Don't rely on LSB_FIRST
This commit is contained in:
@@ -66,10 +66,10 @@ int read32le(uint32 *Bufo, FILE *fp)
|
||||
uint32 buf;
|
||||
if (fread(&buf, 1, 4, fp) < 4)
|
||||
return 0;
|
||||
#ifdef LSB_FIRST
|
||||
*(uint32*)Bufo = buf;
|
||||
#else
|
||||
#ifdef MSB_FIRST
|
||||
*(uint32*)Bufo = ((buf & 0xFF) << 24) | ((buf & 0xFF00) << 8) | ((buf & 0xFF0000) >> 8) | ((buf & 0xFF000000) >> 24);
|
||||
#else
|
||||
*(uint32*)Bufo = buf;
|
||||
#endif
|
||||
return 1;
|
||||
}
|
||||
@@ -89,23 +89,23 @@ int read32le_mem(uint32 *Bufo, memstream_t *mem)
|
||||
uint32 buf;
|
||||
if(memstream_read(mem, &buf, 4)<4)
|
||||
return 0;
|
||||
#ifdef LSB_FIRST
|
||||
*(uint32*)Bufo=buf;
|
||||
#else
|
||||
#ifdef MSB_FIRST
|
||||
*(uint32*)Bufo=((buf&0xFF)<<24)|((buf&0xFF00)<<8)|((buf&0xFF0000)>>8)|((buf&0xFF000000)>>24);
|
||||
#else
|
||||
*(uint32*)Bufo=buf;
|
||||
#endif
|
||||
return 1;
|
||||
}
|
||||
|
||||
int read16le(char *d, FILE *fp)
|
||||
{
|
||||
#ifdef LSB_FIRST
|
||||
return((fread(d, 1, 2, fp) < 2) ? 0 : 2);
|
||||
#else
|
||||
#ifdef MSB_FIRST
|
||||
int ret;
|
||||
ret = fread(d + 1, 1, 1, fp);
|
||||
ret += fread(d, 1, 1, fp);
|
||||
return ret < 2 ? 0 : 2;
|
||||
#else
|
||||
return((fread(d, 1, 2, fp) < 2) ? 0 : 2);
|
||||
#endif
|
||||
}
|
||||
|
||||
|
||||
@@ -106,14 +106,14 @@ static int SubWrite(memstream_t *mem, SFORMAT *sf)
|
||||
memstream_write(mem, sf->desc, 4);
|
||||
write32le_mem(sf->s&(~RLSB), mem);
|
||||
|
||||
#ifndef LSB_FIRST
|
||||
#ifdef MSB_FIRST
|
||||
if(sf->s&RLSB)
|
||||
FlipByteOrder(sf->v,sf->s&(~RLSB));
|
||||
#endif
|
||||
|
||||
memstream_write(mem, (uint8 *)sf->v, sf->s&(~RLSB));
|
||||
/* Now restore the original byte order. */
|
||||
#ifndef LSB_FIRST
|
||||
#ifdef MSB_FIRST
|
||||
if(sf->s&RLSB)
|
||||
FlipByteOrder(sf->v,sf->s&(~RLSB));
|
||||
#endif
|
||||
@@ -180,7 +180,7 @@ static int ReadStateChunk(memstream_t *mem, SFORMAT *sf, int size)
|
||||
{
|
||||
memstream_read(mem, (uint8 *)tmp->v, tmp->s&(~RLSB));
|
||||
|
||||
#ifndef LSB_FIRST
|
||||
#ifdef MSB_FIRST
|
||||
if(tmp->s&RLSB)
|
||||
FlipByteOrder(tmp->v,tmp->s&(~RLSB));
|
||||
#endif
|
||||
|
||||
@@ -23,7 +23,7 @@ include ../../../../Makefile.common
|
||||
|
||||
LOCAL_SRC_FILES = $(SOURCES_C)
|
||||
|
||||
LOCAL_CFLAGS += -DWANT_GRIFFIN -DINLINE=inline -DSOUND_QUALITY=0 -DPSS_STYLE=1 -DLSB_FIRST -D__LIBRETRO__ -DHAVE_ASPRINTF -DFCEU_VERSION_NUMERIC=9813 -DFRONTEND_SUPPORTS_RGB565
|
||||
LOCAL_CFLAGS += -DWANT_GRIFFIN -DINLINE=inline -DSOUND_QUALITY=0 -DPSS_STYLE=1 -D__LIBRETRO__ -DHAVE_ASPRINTF -DFCEU_VERSION_NUMERIC=9813 -DFRONTEND_SUPPORTS_RGB565
|
||||
LOCAL_C_INCLUDES = $(LOCAL_PATH)/$(CORE_DIR)
|
||||
|
||||
include $(BUILD_SHARED_LIBRARY)
|
||||
|
||||
@@ -22,7 +22,7 @@
|
||||
Optimization="0"
|
||||
OptimizeForProcessor="2"
|
||||
AdditionalIncludeDirectories=""$(SolutionDir)\msvc-2003-xbox1";"$(SolutionDir)\..\";"$(SolutionDir)\..\..\..\""
|
||||
PreprocessorDefinitions="_DEBUG;_XBOX;_LIB;__LIBRETRO__;LSB_FIRST;LOCAL_LE;INLINE=_inline;SOUND_QUALITY=0;PSS_STYLE=2;ZLIB;PATH_MAX=1024;_XBOX1;FCEU_VERSION_NUMERIC=9813;FRONTEND_SUPPORTS_RGB565;WANT_GRIFFIN;HAVE_EXTERNAL_ZLIB"
|
||||
PreprocessorDefinitions="_DEBUG;_XBOX;_LIB;__LIBRETRO__;LOCAL_LE;INLINE=_inline;SOUND_QUALITY=0;PSS_STYLE=2;ZLIB;PATH_MAX=1024;_XBOX1;FCEU_VERSION_NUMERIC=9813;FRONTEND_SUPPORTS_RGB565;WANT_GRIFFIN;HAVE_EXTERNAL_ZLIB"
|
||||
MinimalRebuild="TRUE"
|
||||
BasicRuntimeChecks="3"
|
||||
RuntimeLibrary="1"
|
||||
@@ -56,7 +56,7 @@
|
||||
OmitFramePointers="TRUE"
|
||||
OptimizeForProcessor="2"
|
||||
AdditionalIncludeDirectories=""$(SolutionDir)\msvc-2003-xbox1";"$(SolutionDir)\..\";"$(SolutionDir)\..\..\..\""
|
||||
PreprocessorDefinitions="NDEBUG;_XBOX;PROFILE;_LIB;__LIBRETRO__;LSB_FIRST;LOCAL_LE;INLINE=_inline;SOUND_QUALITY=0;PSS_STYLE=2;ZLIB;PATH_MAX=1024;_XBOX1;FCEU_VERSION_NUMERIC=9813;FRONTEND_SUPPORTS_RGB565;WANT_GRIFFIN;HAVE_EXTERNAL_ZLIB"
|
||||
PreprocessorDefinitions="NDEBUG;_XBOX;PROFILE;_LIB;__LIBRETRO__;LOCAL_LE;INLINE=_inline;SOUND_QUALITY=0;PSS_STYLE=2;ZLIB;PATH_MAX=1024;_XBOX1;FCEU_VERSION_NUMERIC=9813;FRONTEND_SUPPORTS_RGB565;WANT_GRIFFIN;HAVE_EXTERNAL_ZLIB"
|
||||
StringPooling="TRUE"
|
||||
RuntimeLibrary="0"
|
||||
BufferSecurityCheck="TRUE"
|
||||
@@ -91,7 +91,7 @@
|
||||
OmitFramePointers="TRUE"
|
||||
OptimizeForProcessor="2"
|
||||
AdditionalIncludeDirectories=""$(SolutionDir)\msvc-2003-xbox1";"$(SolutionDir)\..\";"$(SolutionDir)\..\..\..\""
|
||||
PreprocessorDefinitions="NDEBUG;_XBOX;PROFILE;FASTCAP;_LIB;__LIBRETRO__;LSB_FIRST;LOCAL_LE;INLINE=_inline;SOUND_QUALITY=0;PSS_STYLE=2;ZLIB;PATH_MAX=1024;_XBOX1;FCEU_VERSION_NUMERIC=9813;FRONTEND_SUPPORTS_RGB565;WANT_GRIFFIN;HAVE_EXTERNAL_ZLIB"
|
||||
PreprocessorDefinitions="NDEBUG;_XBOX;PROFILE;FASTCAP;_LIB;__LIBRETRO__;LOCAL_LE;INLINE=_inline;SOUND_QUALITY=0;PSS_STYLE=2;ZLIB;PATH_MAX=1024;_XBOX1;FCEU_VERSION_NUMERIC=9813;FRONTEND_SUPPORTS_RGB565;WANT_GRIFFIN;HAVE_EXTERNAL_ZLIB"
|
||||
StringPooling="TRUE"
|
||||
RuntimeLibrary="0"
|
||||
BufferSecurityCheck="TRUE"
|
||||
@@ -127,7 +127,7 @@
|
||||
OmitFramePointers="TRUE"
|
||||
OptimizeForProcessor="2"
|
||||
AdditionalIncludeDirectories=""$(SolutionDir)\msvc-2003-xbox1";"$(SolutionDir)\..\";"$(SolutionDir)\..\..\..\""
|
||||
PreprocessorDefinitions="NDEBUG;_XBOX;_LIB;__LIBRETRO__;LSB_FIRST;LOCAL_LE;INLINE=_inline;SOUND_QUALITY=0;PSS_STYLE=2;ZLIB;PATH_MAX=1024;_XBOX1;FCEU_VERSION_NUMERIC=9813;FRONTEND_SUPPORTS_RGB565;WANT_GRIFFIN;HAVE_EXTERNAL_ZLIB"
|
||||
PreprocessorDefinitions="NDEBUG;_XBOX;_LIB;__LIBRETRO__;LOCAL_LE;INLINE=_inline;SOUND_QUALITY=0;PSS_STYLE=2;ZLIB;PATH_MAX=1024;_XBOX1;FCEU_VERSION_NUMERIC=9813;FRONTEND_SUPPORTS_RGB565;WANT_GRIFFIN;HAVE_EXTERNAL_ZLIB"
|
||||
StringPooling="TRUE"
|
||||
RuntimeLibrary="0"
|
||||
BufferSecurityCheck="TRUE"
|
||||
@@ -163,7 +163,7 @@
|
||||
OmitFramePointers="TRUE"
|
||||
OptimizeForProcessor="2"
|
||||
AdditionalIncludeDirectories=""$(SolutionDir)\msvc-2003-xbox1";"$(SolutionDir)\..\";"$(SolutionDir)\..\..\..\""
|
||||
PreprocessorDefinitions="NDEBUG;_XBOX;LTCG;_LIB;__LIBRETRO__;LSB_FIRST;LOCAL_LE;INLINE=_inline;SOUND_QUALITY=0;PSS_STYLE=2;ZLIB;PATH_MAX=1024;_XBOX1;FCEU_VERSION_NUMERIC=9813;FRONTEND_SUPPORTS_RGB565;WANT_GRIFFIN;HAVE_EXTERNAL_ZLIB"
|
||||
PreprocessorDefinitions="NDEBUG;_XBOX;LTCG;_LIB;__LIBRETRO__;LOCAL_LE;INLINE=_inline;SOUND_QUALITY=0;PSS_STYLE=2;ZLIB;PATH_MAX=1024;_XBOX1;FCEU_VERSION_NUMERIC=9813;FRONTEND_SUPPORTS_RGB565;WANT_GRIFFIN;HAVE_EXTERNAL_ZLIB"
|
||||
StringPooling="TRUE"
|
||||
RuntimeLibrary="0"
|
||||
BufferSecurityCheck="TRUE"
|
||||
|
||||
@@ -63,22 +63,22 @@ int read32le(uint32 *Bufo, FILE *fp) {
|
||||
uint32 buf;
|
||||
if (fread(&buf, 1, 4, fp) < 4)
|
||||
return 0;
|
||||
#ifdef LSB_FIRST
|
||||
*(uint32*)Bufo = buf;
|
||||
#else
|
||||
#ifdef MSB_FIRST
|
||||
*(uint32*)Bufo = ((buf & 0xFF) << 24) | ((buf & 0xFF00) << 8) | ((buf & 0xFF0000) >> 8) | ((buf & 0xFF000000) >> 24);
|
||||
#else
|
||||
*(uint32*)Bufo = buf;
|
||||
#endif
|
||||
return 1;
|
||||
}
|
||||
|
||||
int read16le(char *d, FILE *fp) {
|
||||
#ifdef LSB_FIRST
|
||||
return((fread(d, 1, 2, fp) < 2) ? 0 : 2);
|
||||
#else
|
||||
#ifdef MSB_FIRST
|
||||
int ret;
|
||||
ret = fread(d + 1, 1, 1, fp);
|
||||
ret += fread(d, 1, 1, fp);
|
||||
return ret < 2 ? 0 : 2;
|
||||
#else
|
||||
return((fread(d, 1, 2, fp) < 2) ? 0 : 2);
|
||||
#endif
|
||||
}
|
||||
|
||||
|
||||
@@ -413,10 +413,11 @@ int FCEU_read16le(uint16 *val, FCEUFILE *fp) {
|
||||
return(1);
|
||||
}
|
||||
|
||||
int FCEU_read32le(uint32 *Bufo, FCEUFILE *fp) {
|
||||
int FCEU_read32le(uint32 *Bufo, FCEUFILE *fp)
|
||||
{
|
||||
if (fp->type >= 1) {
|
||||
uint8 t[4];
|
||||
#ifndef LSB_FIRST
|
||||
#ifdef MSB_FIRST
|
||||
uint8 x[4];
|
||||
#endif
|
||||
if (fp->type >= 2) {
|
||||
@@ -429,7 +430,7 @@ int FCEU_read32le(uint32 *Bufo, FCEUFILE *fp) {
|
||||
wz->location += 4;
|
||||
} else if (fp->type == 1)
|
||||
gzread(fp->fp, &t, 4);
|
||||
#ifndef LSB_FIRST
|
||||
#ifdef MSB_FIRST
|
||||
x[0] = t[3];
|
||||
x[1] = t[2];
|
||||
x[2] = t[1];
|
||||
|
||||
43
src/ppu.c
43
src/ppu.c
@@ -1002,27 +1002,7 @@ static void CopySprites(uint8 *target) {
|
||||
uint32 t = *(uint32*)(sprlinebuf + n);
|
||||
|
||||
if (t != 0x80808080) {
|
||||
#ifdef LSB_FIRST
|
||||
if (!(t & 0x80)) {
|
||||
if (!(t & 0x40) || (P[n] & 0x40)) // Normal sprite || behind bg sprite
|
||||
P[n] = sprlinebuf[n];
|
||||
}
|
||||
|
||||
if (!(t & 0x8000)) {
|
||||
if (!(t & 0x4000) || (P[n + 1] & 0x40)) // Normal sprite || behind bg sprite
|
||||
P[n + 1] = (sprlinebuf + 1)[n];
|
||||
}
|
||||
|
||||
if (!(t & 0x800000)) {
|
||||
if (!(t & 0x400000) || (P[n + 2] & 0x40)) // Normal sprite || behind bg sprite
|
||||
P[n + 2] = (sprlinebuf + 2)[n];
|
||||
}
|
||||
|
||||
if (!(t & 0x80000000)) {
|
||||
if (!(t & 0x40000000) || (P[n + 3] & 0x40)) // Normal sprite || behind bg sprite
|
||||
P[n + 3] = (sprlinebuf + 3)[n];
|
||||
}
|
||||
#else
|
||||
#ifdef MSB_FIRST
|
||||
if (!(t & 0x80000000)) {
|
||||
if (!(t & 0x40000000) || (P[n] & 64)) // Normal sprite || behind bg sprite
|
||||
P[n] = sprlinebuf[n];
|
||||
@@ -1042,6 +1022,27 @@ static void CopySprites(uint8 *target) {
|
||||
if (!(t & 0x40) || (P[n + 3] & 64)) // Normal sprite || behind bg sprite
|
||||
P[n + 3] = (sprlinebuf + 3)[n];
|
||||
}
|
||||
#else
|
||||
|
||||
if (!(t & 0x80)) {
|
||||
if (!(t & 0x40) || (P[n] & 0x40)) // Normal sprite || behind bg sprite
|
||||
P[n] = sprlinebuf[n];
|
||||
}
|
||||
|
||||
if (!(t & 0x8000)) {
|
||||
if (!(t & 0x4000) || (P[n + 1] & 0x40)) // Normal sprite || behind bg sprite
|
||||
P[n + 1] = (sprlinebuf + 1)[n];
|
||||
}
|
||||
|
||||
if (!(t & 0x800000)) {
|
||||
if (!(t & 0x400000) || (P[n + 2] & 0x40)) // Normal sprite || behind bg sprite
|
||||
P[n + 2] = (sprlinebuf + 2)[n];
|
||||
}
|
||||
|
||||
if (!(t & 0x80000000)) {
|
||||
if (!(t & 0x40000000) || (P[n + 3] & 0x40)) // Normal sprite || behind bg sprite
|
||||
P[n + 3] = (sprlinebuf + 3)[n];
|
||||
}
|
||||
#endif
|
||||
}
|
||||
n += 4;
|
||||
|
||||
@@ -108,14 +108,14 @@ static int SubWrite(MEM_TYPE *st, SFORMAT *sf) {
|
||||
fwrite(sf->desc, 1, 4, st);
|
||||
write32le(sf->s & (~RLSB), st);
|
||||
|
||||
#ifndef LSB_FIRST
|
||||
#ifdef MSB_FIRST
|
||||
if (sf->s & RLSB)
|
||||
FlipByteOrder(sf->v, sf->s & (~RLSB));
|
||||
#endif
|
||||
|
||||
fwrite((uint8*)sf->v, 1, sf->s & (~RLSB), st);
|
||||
/* Now restore the original byte order. */
|
||||
#ifndef LSB_FIRST
|
||||
#ifdef MSB_FIRST
|
||||
if (sf->s & RLSB)
|
||||
FlipByteOrder(sf->v, sf->s & (~RLSB));
|
||||
#endif
|
||||
@@ -173,7 +173,7 @@ static int ReadStateChunk(MEM_TYPE *st, SFORMAT *sf, int size) {
|
||||
if ((tmp = CheckS(sf, tsize, toa))) {
|
||||
fread((uint8*)tmp->v, 1, tmp->s & (~RLSB), st);
|
||||
|
||||
#ifndef LSB_FIRST
|
||||
#ifdef MSB_FIRST
|
||||
if (tmp->s & RLSB)
|
||||
FlipByteOrder(tmp->v, tmp->s & (~RLSB));
|
||||
#endif
|
||||
|
||||
Reference in New Issue
Block a user