More endian fixes.
authorFlorian Schulze <crow@icculus.org>
Fri, 19 Apr 2002 12:12:27 +0000 (12:12 +0000)
committerFlorian Schulze <crow@icculus.org>
Fri, 19 Apr 2002 12:12:27 +0000 (12:12 +0000)
globals.h
sdl/gfx.c
sdl/sound.c

index ebb33ae..3027903 100644 (file)
--- 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"
 #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
 #define        DATA_PATH "/usr/share/jumpnbump/jumpbump.dat"
 #endif
 #endif
index 5392976..094e518 100644 (file)
--- a/sdl/gfx.c
+++ b/sdl/gfx.c
  */
 
 #include "globals.h"
  */
 
 #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;
 
 int screen_width=400;
 int screen_height=256;
@@ -278,21 +286,21 @@ int Init_2xSaI (unsigned int BitFormat)
 {
     if (BitFormat == 565)
     {
 {
     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)
     {
     }
     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
     {
     }
     else
     {
index 89fc1f7..4461273 100644 (file)
@@ -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)
 {
 
 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;
        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<sounds[sfx_num].length; i++)
+       {
+               unsigned short temp;
+               temp = src[0] + (src[1] << 8);
+               dest = temp;
+               src += 2;
+               dest++;
+       }
        return 0;
 }
 
        return 0;
 }