Welcome to mirror list, hosted at ThFree Co, Russian Federation.

github.com/ClusterM/fceux.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAutomerge Bot <bot@example.com>2022-08-25 03:34:46 +0300
committerAutomerge Bot <bot@example.com>2022-08-25 03:34:46 +0300
commit932ab4c71129c610ae2f3f892a4def9477d8487f (patch)
tree856c94a76f64bdc7a6ed4a6bb30e38689395ea97
parent310c42ed2867b4d1973003c7f413f743cd36c655 (diff)
parent1798fca76a3ffc8d22318e445d10fbb7b63a762b (diff)
Merge branch 'master' of https://github.com/TASVideos/fceux into coolgirl
-rw-r--r--src/drivers/common/vidblit.cpp12
-rw-r--r--src/drivers/common/vidblit.h2
-rw-r--r--src/drivers/win/aviout.cpp11
-rw-r--r--src/utils/memory.cpp26
-rw-r--r--src/utils/memory.h3
5 files changed, 33 insertions, 21 deletions
diff --git a/src/drivers/common/vidblit.cpp b/src/drivers/common/vidblit.cpp
index b2fbda24..6fcdac4e 100644
--- a/src/drivers/common/vidblit.cpp
+++ b/src/drivers/common/vidblit.cpp
@@ -466,7 +466,7 @@ void Blit8To8(uint8 *src, uint8 *dest, int xr, int yr, int pitch, int xscale, in
/* Todo: Make sure 24bpp code works right with big-endian cpus */
//takes a pointer to XBuf and applies fully modern deemph palettizing
-template<int SCALE> static u32 _ModernDeemphColorMap(u8* src, u8* srcbuf)
+template<int SCALE> static u32 _ModernDeemphColorMap(const u8* src, const u8* srcbuf)
{
u8 pixel = *src;
@@ -492,7 +492,7 @@ template<int SCALE> static u32 _ModernDeemphColorMap(u8* src, u8* srcbuf)
return color;
}
-u32 ModernDeemphColorMap(u8* src, u8* srcbuf, int scale)
+u32 ModernDeemphColorMap(const u8* src, const u8* srcbuf, int scale)
{
if(scale == 1) return _ModernDeemphColorMap<1>(src,srcbuf);
else if(scale == 2) return _ModernDeemphColorMap<2>(src,srcbuf);
@@ -503,14 +503,14 @@ u32 ModernDeemphColorMap(u8* src, u8* srcbuf, int scale)
else if(scale == 7) return _ModernDeemphColorMap<7>(src,srcbuf);
else if(scale == 8) return _ModernDeemphColorMap<8>(src,srcbuf);
else if(scale == 9) return _ModernDeemphColorMap<9>(src,srcbuf);
- else { abort(); return 0; }
+ else { FCEU_abort("unhandled ModernDeemphColorMap scale"); return 0; }
}
-typedef u32 (*ModernDeemphColorMapFuncPtr)( u8*, u8* );
+typedef u32 (*ModernDeemphColorMapFuncPtr)( const u8*, const u8* );
static ModernDeemphColorMapFuncPtr getModernDeemphColorMapFunc(int scale)
{
- ModernDeemphColorMapFuncPtr ptr = NULL;
+ ModernDeemphColorMapFuncPtr ptr;
if(scale == 1) ptr = &_ModernDeemphColorMap<1>;
else if(scale == 2) ptr = &_ModernDeemphColorMap<2>;
@@ -521,7 +521,7 @@ static ModernDeemphColorMapFuncPtr getModernDeemphColorMapFunc(int scale)
else if(scale == 7) ptr = &_ModernDeemphColorMap<7>;
else if(scale == 8) ptr = &_ModernDeemphColorMap<8>;
else if(scale == 9) ptr = &_ModernDeemphColorMap<9>;
- else { abort(); ptr = NULL; }
+ else { FCEU_abort("unhandled ModernDeemphColorMap scale"); ptr = nullptr; }
return ptr;
}
diff --git a/src/drivers/common/vidblit.h b/src/drivers/common/vidblit.h
index d9581b0b..ba35b937 100644
--- a/src/drivers/common/vidblit.h
+++ b/src/drivers/common/vidblit.h
@@ -29,4 +29,4 @@ void Blit32to16(uint32 *src, uint16 *dest, int xr, int yr, int dpitch,
int shiftr[3], int shiftl[3]);
-u32 ModernDeemphColorMap(u8* src, u8* srcbuf, int scale); \ No newline at end of file
+u32 ModernDeemphColorMap(const u8* src, const u8* srcbuf, int scale);
diff --git a/src/drivers/win/aviout.cpp b/src/drivers/win/aviout.cpp
index b5ce0333..e0d347be 100644
--- a/src/drivers/win/aviout.cpp
+++ b/src/drivers/win/aviout.cpp
@@ -291,6 +291,8 @@ static void do_video_conversion(const unsigned char* buffer)
{
// memset(avi_file->convert_buffer, 0, VIDEO_WIDTH*(avi_file->end_scanline-avi_file->start_scanline)*3);
+ const unsigned char* mybuffer = buffer;
+
buffer += avi_file->start_scanline * VIDEO_WIDTH;
for(int y=avi_file->start_scanline; y<avi_file->end_scanline; ++y)
@@ -300,10 +302,11 @@ static void do_video_conversion(const unsigned char* buffer)
for(int x=0; x<VIDEO_WIDTH; ++x)
{
- uint8 *cp = (uint8*)(color_palette + *buffer++)+2;
- *pix++ = *cp--;
- *pix++ = *cp--;
- *pix++ = *cp;
+ u32 color = ModernDeemphColorMap(buffer,mybuffer,1);
+ *pix++=(color>>0x00)&0xFF;
+ *pix++=(color>>0x08)&0xFF;
+ *pix++=(color>>0x10)&0xFF;
+ buffer++;
}
buffer = prevbuf + VIDEO_WIDTH;
diff --git a/src/utils/memory.cpp b/src/utils/memory.cpp
index 5ed626ea..93bc3af9 100644
--- a/src/utils/memory.cpp
+++ b/src/utils/memory.cpp
@@ -30,19 +30,19 @@
static void *_FCEU_malloc(uint32 size)
{
+ //do not add an aligned allocation function. if a larger alignment is needed, change this constant to use it for all allocations.
+ static const int alignment = 32;
+
+ size = (size + alignment - 1) & ~(alignment-1);
+
#ifdef _MSC_VER
- void *ret = _aligned_malloc(size,32);
+ void *ret = _aligned_malloc(size,alignment);
#else
- void *ret = aligned_alloc(32,size);
+ void *ret = aligned_alloc(alignment,size);
#endif
if(!ret)
- {
- FCEU_PrintError("Error allocating memory! Doing a hard exit.");
- exit(1);
- }
-
- memset(ret, 0, size);
+ FCEU_abort("Error allocating memory!");
return ret;
}
@@ -74,13 +74,13 @@ void *FCEU_malloc(uint32 size)
return ret;
}
-///frees memory allocated with FCEU_gmalloc
+//frees memory allocated with FCEU_gmalloc
void FCEU_gfree(void *ptr)
{
_FCEU_free(ptr);
}
-///frees memory allocated with FCEU_malloc
+//frees memory allocated with FCEU_malloc
void FCEU_free(void *ptr)
{
_FCEU_free(ptr);
@@ -95,3 +95,9 @@ void FCEU_dfree(void *ptr)
{
return FCEU_free(ptr);
}
+
+void FCEU_abort(const char* message)
+{
+ if(message) FCEU_PrintError(message);
+ abort();
+}
diff --git a/src/utils/memory.h b/src/utils/memory.h
index 174b3d31..b9e6f145 100644
--- a/src/utils/memory.h
+++ b/src/utils/memory.h
@@ -42,3 +42,6 @@ void *FCEU_dmalloc(uint32 size);
//don't use these. change them if you find them.
void FCEU_dfree(void *ptr);
+
+//aborts the process for fatal errors
+void FCEU_abort(const char* message = nullptr);