diff --git a/Makefile.libretro b/Makefile.libretro index 96cc5b5..d3741c3 100644 --- a/Makefile.libretro +++ b/Makefile.libretro @@ -41,13 +41,13 @@ ifeq ($(platform), unix) TARGET := $(TARGET_NAME)_libretro.so fpic := -fPIC SHARED := -shared -Wl,--version-script=src/drivers/libretro/link.T -Wl,-no-undefined - ENDIANNESS_DEFINES = -DLSB_FIRST -DLOCAL_LE=1 + ENDIANNESS_DEFINES = -DLOCAL_LE=1 else ifeq ($(platform), linux-portable) TARGET := $(TARGET_NAME)_libretro.so fpic := -fPIC -nostdlib SHARED := -shared -Wl,--version-script=src/drivers/libretro/link.T - ENDIANNESS_DEFINES = -DLSB_FIRST -DLOCAL_LE=1 + ENDIANNESS_DEFINES = -DLOCAL_LE=1 LIBM := # OS X else ifeq ($(platform), osx) @@ -55,7 +55,7 @@ else ifeq ($(platform), osx) fpic := -fPIC SHARED := -dynamiclib ifneq ($(arch),ppc) - ENDIANNESS_DEFINES = -DLSB_FIRST -DLOCAL_LE=1 + ENDIANNESS_DEFINES = -DLOCAL_LE=1 endif CFLAGS += -DHAVE_ASPRINTF OSXVER = `sw_vers -productVersion | cut -d. -f 2` @@ -73,7 +73,7 @@ else ifeq ($(platform), ios) TARGET := $(TARGET_NAME)_libretro_ios.dylib fpic := -fPIC SHARED := -dynamiclib - ENDIANNESS_DEFINES = -DLSB_FIRST -DLOCAL_LE=1 + ENDIANNESS_DEFINES = -DLOCAL_LE=1 CFLAGS += -DHAVE_ASPRINTF -DIOS ifeq ($(IOSSDK),) IOSSDK := $(shell xcodebuild -version -sdk iphoneos Path) @@ -103,7 +103,7 @@ else ifeq ($(platform), qnx) TARGET := $(TARGET_NAME)_libretro_qnx.so fpic := -fPIC SHARED := -shared -Wl,--version-script=src/drivers/libretro/link.T -Wl,-no-undefined - ENDIANNESS_DEFINES = -DLSB_FIRST -DLOCAL_LE=1 + ENDIANNESS_DEFINES = -DLOCAL_LE=1 CC = qcc -Vgcc_ntoarmv7le AR = qcc -Vgcc_ntoarmv7le PLATFORM_DEFINES := -D__BLACKBERRY_QNX__ -marm -mcpu=cortex-a9 -mfpu=neon -mfloat-abi=softfp @@ -132,7 +132,7 @@ else ifeq ($(platform), psp1) CC = psp-gcc$(EXE_EXT) CXX = psp-g++$(EXE_EXT) AR = psp-ar$(EXE_EXT) - PLATFORM_DEFINES := -DPSP -G0 -DLSB_FIRST -DHAVE_ASPRINTF + PLATFORM_DEFINES := -DPSP -G0 -DHAVE_ASPRINTF PLATFORM_DEFINES += -march=allegrex -mfp32 -mgp32 -mlong32 -mabi=eabi PLATFORM_DEFINES += -fomit-frame-pointer -fstrict-aliasing PLATFORM_DEFINES += -falign-functions=32 -falign-loops -falign-labels -falign-jumps @@ -145,7 +145,7 @@ else ifeq ($(platform), ctr) CC = $(DEVKITARM)/bin/arm-none-eabi-gcc$(EXE_EXT) CXX = $(DEVKITARM)/bin/arm-none-eabi-g++$(EXE_EXT) AR = $(DEVKITARM)/bin/arm-none-eabi-ar$(EXE_EXT) - PLATFORM_DEFINES := -DARM11 -D_3DS -DLSB_FIRST -DHAVE_ASPRINTF + PLATFORM_DEFINES := -DARM11 -D_3DS -DHAVE_ASPRINTF CFLAGS += -march=armv6k -mtune=mpcore -mfloat-abi=hard CFLAGS += -Wall -mword-relocations CFLAGS += -fomit-frame-pointer -fstrict-aliasing -ffast-math @@ -195,7 +195,7 @@ else ifeq ($(platform), wii) else ifneq (,$(findstring armv,$(platform))) TARGET := $(TARGET_NAME)_libretro.so SHARED := -shared -Wl,--version-script=src/drivers/libretro/link.T -Wl,-no-undefined - ENDIANNESS_DEFINES = -DLSB_FIRST -DLOCAL_LE=1 + ENDIANNESS_DEFINES = -DLOCAL_LE=1 fpic := -fPIC ifneq (,$(findstring cortexa5,$(platform))) PLATFORM_DEFINES += -marm -mcpu=cortex-a5 @@ -220,7 +220,7 @@ else TARGET := $(TARGET_NAME)_libretro.dll CC = gcc SHARED := -shared -static-libgcc -static-libstdc++ -s -Wl,--version-script=src/drivers/libretro/link.T - ENDIANNESS_DEFINES = -DLSB_FIRST -DLOCAL_LE=1 + ENDIANNESS_DEFINES = -DLOCAL_LE=1 endif diff --git a/src/drivers/libretro/fceu/fceu-endian.c b/src/drivers/libretro/fceu/fceu-endian.c index c1a14c6..754489f 100644 --- a/src/drivers/libretro/fceu/fceu-endian.c +++ b/src/drivers/libretro/fceu/fceu-endian.c @@ -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 } diff --git a/src/drivers/libretro/fceu/state.c b/src/drivers/libretro/fceu/state.c index 240176b..5958970 100644 --- a/src/drivers/libretro/fceu/state.c +++ b/src/drivers/libretro/fceu/state.c @@ -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 diff --git a/src/drivers/libretro/jni/Android.mk b/src/drivers/libretro/jni/Android.mk index 62c2bc9..081390f 100644 --- a/src/drivers/libretro/jni/Android.mk +++ b/src/drivers/libretro/jni/Android.mk @@ -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) diff --git a/src/drivers/libretro/msvc/msvc-2003-xbox1/msvc-2003-xbox1.vcproj b/src/drivers/libretro/msvc/msvc-2003-xbox1/msvc-2003-xbox1.vcproj index 3d7c708..53ef4a2 100644 --- a/src/drivers/libretro/msvc/msvc-2003-xbox1/msvc-2003-xbox1.vcproj +++ b/src/drivers/libretro/msvc/msvc-2003-xbox1/msvc-2003-xbox1.vcproj @@ -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" diff --git a/src/fceu-endian.c b/src/fceu-endian.c index bb4e3ee..fcdd64c 100644 --- a/src/fceu-endian.c +++ b/src/fceu-endian.c @@ -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 } diff --git a/src/file.c b/src/file.c index 288961c..784dd49 100644 --- a/src/file.c +++ b/src/file.c @@ -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]; diff --git a/src/ppu.c b/src/ppu.c index cc59523..ce0fda3 100644 --- a/src/ppu.c +++ b/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; diff --git a/src/state.c b/src/state.c index bb631f3..7089353 100644 --- a/src/state.c +++ b/src/state.c @@ -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