From 2ee774cae28211aeb55a565003e7e62d43351fc0 Mon Sep 17 00:00:00 2001 From: Florian Schulze Date: Fri, 19 Apr 2002 12:12:27 +0000 Subject: [PATCH] More endian fixes. --- globals.h | 2 +- sdl/gfx.c | 32 ++++++++++++++++++++------------ sdl/sound.c | 14 ++++++++++++++ 3 files changed, 35 insertions(+), 13 deletions(-) diff --git a/globals.h b/globals.h index ebb33ae..3027903 100644 --- a/globals.h +++ b/globals.h @@ -149,7 +149,7 @@ extern int bytes_per_pixel; #define DATA_PATH "data/jumpbump.dat" #elif _WIN32 #define DATA_PATH "data/jumpbump.dat" -#elif +#else #define DATA_PATH "/usr/share/jumpnbump/jumpbump.dat" #endif #endif diff --git a/sdl/gfx.c b/sdl/gfx.c index 5392976..094e518 100644 --- a/sdl/gfx.c +++ b/sdl/gfx.c @@ -28,6 +28,14 @@ */ #include "globals.h" +#include "SDL_endian.h" +#if SDL_BYTEORDER == SDL_LIL_ENDIAN +#define SWAP16(X) (X) +#define SWAP32(X) (X) +#else +#define SWAP16(X) SDL_Swap16(X) +#define SWAP32(X) SDL_Swap32(X) +#endif int screen_width=400; int screen_height=256; @@ -278,21 +286,21 @@ int Init_2xSaI (unsigned int BitFormat) { if (BitFormat == 565) { - colorMask = 0xF7DEF7DE; - lowPixelMask = 0x08210821; - qcolorMask = 0xE79CE79C; - qlowpixelMask = 0x18631863; - redblueMask = 0xF81F; - greenMask = 0x7E0; + colorMask = SWAP32(0xF7DEF7DE); + lowPixelMask = SWAP32(0x08210821); + qcolorMask = SWAP32(0xE79CE79C); + qlowpixelMask = SWAP32(0x18631863); + redblueMask = SWAP16(0xF81F); + greenMask = SWAP16(0x7E0); } else if (BitFormat == 555) { - colorMask = 0x7BDE7BDE; - lowPixelMask = 0x04210421; - qcolorMask = 0x739C739C; - qlowpixelMask = 0x0C630C63; - redblueMask = 0x7C1F; - greenMask = 0x3E0; + colorMask = SWAP32(0x7BDE7BDE); + lowPixelMask = SWAP32(0x04210421); + qcolorMask = SWAP32(0x739C739C); + qlowpixelMask = SWAP32(0x0C630C63); + redblueMask = SWAP16(0x7C1F); + greenMask = SWAP16(0x3E0); } else { diff --git a/sdl/sound.c b/sdl/sound.c index 89fc1f7..4461273 100644 --- a/sdl/sound.c +++ b/sdl/sound.c @@ -411,12 +411,26 @@ void dj_stop_sfx_channel(char channel_num) char dj_load_sfx(FILE * file_handle, char *filename, int file_length, char sfx_type, unsigned char sfx_num) { + int i; + unsigned char *src; + unsigned short *dest; + if (main_info.no_sound) return 0; sounds[sfx_num].buf = malloc(file_length); fread(sounds[sfx_num].buf, 1, file_length, file_handle); sounds[sfx_num].length = file_length / 2; + src = sounds[sfx_num].buf; + dest = sounds[sfx_num].buf; + for (i=0; i