diff --git a/CMakeLists.txt b/CMakeLists.txt index 9c1d417..64ebbd7 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -46,9 +46,6 @@ elseif (ANDROID) find_library(ndk_zlib z) find_library(ndk_log log) else() - include(TestBigEndian) - TEST_BIG_ENDIAN(WORDS_BIGENDIAN) - if (NOT DEFINED ENABLE_MODULES) set(ENABLE_MODULES 1) endif() diff --git a/config.h.in b/config.h.in index c166b4e..ae067c0 100644 --- a/config.h.in +++ b/config.h.in @@ -3,8 +3,6 @@ #cmakedefine CMAKE_SYSTEM_NAME "@CMAKE_SYSTEM_NAME@" -#cmakedefine WORDS_BIGENDIAN @WORDS_BIGENDIAN@ - #cmakedefine CACHE_TOTALSIZE @CACHE_TOTALSIZE@ #cmakedefine ENABLE_CDROM_ANDROID @ENABLE_CDROM_ANDROID@ diff --git a/src/cmdl.c b/src/cmdl.c index 227a382..ab11133 100644 --- a/src/cmdl.c +++ b/src/cmdl.c @@ -166,11 +166,7 @@ void commandLL() { num = dfile->size / sizeof(WORD); } for (i = 0; i < num; i++) { -#ifdef WORDS_BIGENDIAN - *var = swap16(*data); var++; data++; -#else - *var = *data; var++; data++; -#endif + var[i] = SDL_SwapLE16(data[i]); } break; diff --git a/src/portab.h b/src/portab.h index 45e259a..e1cd82a 100644 --- a/src/portab.h +++ b/src/portab.h @@ -87,12 +87,6 @@ typedef _Bool ___boolean; # define N_(String) (String) #endif -#define swap16(a) ( (((a) & 0xff) << 8) | ((unsigned short)(a) >> 8) ) -#define swap32(a) ( ((a) << 24) | \ - (((a) << 8) & 0x00ff0000) | \ - (((a) >> 8) & 0x0000ff00) | \ - ((unsigned int)(a) >>24) ) - #ifndef __EMSCRIPTEN__ #define EMSCRIPTEN_KEEPALIVE #endif diff --git a/src/savedata.c b/src/savedata.c index 06d8878..f4a2e71 100644 --- a/src/savedata.c +++ b/src/savedata.c @@ -80,9 +80,9 @@ int save_delete_file(int index) { int save_save_var_with_file(char *fname_utf8, int *start, int cnt) { int status = 0, size, i; FILE *fp; - WORD *tmp, *_tmp; + WORD *tmp; - tmp = _tmp = (WORD *)malloc(cnt * sizeof(WORD)); + tmp = (WORD *)malloc(cnt * sizeof(WORD)); if (tmp == NULL) { WARNING("Out of memory\n"); @@ -90,18 +90,14 @@ int save_save_var_with_file(char *fname_utf8, int *start, int cnt) { } for (i = 0; i < cnt; i++) { -#ifdef WORDS_BIGENDIAN - *tmp = swap16((WORD)*start); start++; tmp++; -#else - *tmp = (WORD)*start; start++; tmp++; -#endif + tmp[i] = SDL_SwapLE16((WORD)start[i]); } if (NULL == (fp = fc_open(fname_utf8, 'w'))) { status = SAVE_SAVEERR; goto errexit; } - size = fwrite(_tmp, sizeof(WORD), cnt, fp); + size = fwrite(tmp, sizeof(WORD), cnt, fp); if (size != cnt) { status = SAVE_OTHERERR; @@ -112,7 +108,7 @@ int save_save_var_with_file(char *fname_utf8, int *start, int cnt) { fclose(fp); scheduleSync(); errexit: - free(_tmp); + free(tmp); return status; } @@ -121,9 +117,9 @@ int save_save_var_with_file(char *fname_utf8, int *start, int cnt) { int save_load_var_with_file(char *fname_utf8, int *start, int cnt) { int status = 0, size, i; FILE *fp; - WORD *tmp, *_tmp; + WORD *tmp; - tmp = _tmp = (WORD *)malloc(cnt * sizeof(WORD)); + tmp = (WORD *)malloc(cnt * sizeof(WORD)); if (tmp == NULL) { WARNING("Out of memory\n"); @@ -143,16 +139,12 @@ int save_load_var_with_file(char *fname_utf8, int *start, int cnt) { } for (i = 0; i < cnt; i++) { -#ifdef WORDS_BIGENDIAN - *start = swap16(*tmp); start++; tmp++; -#else - *start = *tmp; start++; tmp++; -#endif + start[i] = SDL_SwapLE16(tmp[i]); } fclose(fp); errexit: - free(_tmp); + free(tmp); return status; } diff --git a/src/sdl_image.c b/src/sdl_image.c index 4690044..74d4b73 100644 --- a/src/sdl_image.c +++ b/src/sdl_image.c @@ -248,7 +248,7 @@ void sdl_copyAreaSP16_shadow(int sx, int sy, int w, int h, int dx, int dy, int l SDL_LockSurface(s); -#ifndef WORDS_BIGENDIAN +#if SDL_BYTEORDER == SDL_LTL_ENDIAN p_ds = s->pixels + 3; #else p_ds = s->pixels; @@ -347,7 +347,7 @@ void sdl_getPixel(int x, int y, Palette *cell) { } break; case 3: -#ifndef WORDS_BIGENDIAN +#if SDL_BYTEORDER == SDL_LTL_ENDIAN cl = (p[2]<<16)+(p[1]<<8) + p[0]; #else cl = (p[0]<<16)+(p[1]<<8) + p[2];