--- egoboo/code/egobootypedef.h.orig 2004-02-15 15:19:03.000000000 +0100 +++ egoboo/code/egobootypedef.h 2004-02-15 15:23:58.000000000 +0100 @@ -71,13 +71,49 @@ typedef Sint32 LONG; typedef Uint32 DWORD; typedef struct lin_RECT { LONG left; LONG right; LONG top; LONG bottom; } RECT; + +#ifdef __powerpc__ +#define _BIG_ENDIAN + +/* + * __lwbrx - Load Word Byte-Reverse Indexed + * + * int __lwbrx(void *, int); + */ +#define __lwbrx(base, index) \ + ({ unsigned long lwbrxResult; \ + __asm__ volatile ("lwbrx %0, %1, %2" : "=r" (lwbrxResult) : "b%" (index), "r" (base) : "memory"); \ + /*return*/ lwbrxResult; }) + +static float LoadFloatByteswapped( float *ptr ); +static inline float LoadFloatByteswapped( float *ptr ) +{ + union { + float f; + long l; + } data; + + /*Load byteswapped and store to the stack*/ + data.l = __lwbrx( ptr, 0 ); + + /*Return the result*/ + return data.f; +} +#elif __i386__ #define _LITTLE_ENDIAN +#else +#define _BIG_ENDIAN +#error You have to implement LoadFloatByteswapped on your architecture! +#endif + #define LE32bitToHost( pData, pNumByte ) pData #define BE32bitToHost( pData, pNumByte ) pData #define LE16bitToHost( pData, pNumByte ) pData #define BE16bitToHost( pData, pNumByte ) pData #define EndianChange32bit( pData, pNumByte ) pData #define EndianChange16bit( pData, pNumByte ) pData + + #endif --- egoboo/code/game.c.orig 2004-02-15 15:19:07.000000000 +0100 +++ egoboo/code/game.c 2004-02-15 15:19:19.000000000 +0100 @@ -10,6 +10,7 @@ #define TITLE "Boo" #define RELEASE(x) if (x) {x->Release(); x=NULL;} +#include //--------------------------------------------------------------------------------------------- char *os_cvrt_filename(char *name, char ch) @@ -2203,7 +2204,7 @@ #ifdef _LITTLE_ENDIAN iTmp = ipIntPointer[0]; #else - iTmp = EndianS32_LtoB( ipIntPointer[0] ); + iTmp = SDL_SwapLE32( ipIntPointer[0] ); #endif if(iTmp != MD2START ) return FALSE; @@ -2284,14 +2285,14 @@ #ifdef _LITTLE_ENDIAN int iNumCommands = ipIntPointer[9]; #else - int iNumCommands = EndianS32_LtoB( ipIntPointer[9] ); + int iNumCommands = SDL_SwapLE32( ipIntPointer[9] ); #endif // Offset (in DWORDS) from the start of the file to the gl command list. #ifdef _LITTLE_ENDIAN int iCommandOffset = ipIntPointer[15]>>2; #else - int iCommandOffset = EndianS32_LtoB( ipIntPointer[15] )>>2; + int iCommandOffset = SDL_SwapLE32( ipIntPointer[15] )>>2; #endif // Read in each command @@ -2306,7 +2307,7 @@ #ifdef _LITTLE_ENDIAN iNumVertices = ipIntPointer[iCommandOffset]; iCommandOffset++; cnt++; #else - iNumVertices = EndianS32_LtoB( ipIntPointer[iCommandOffset] ); iCommandOffset++; cnt++; + iNumVertices = SDL_SwapLE32( ipIntPointer[iCommandOffset] ); iCommandOffset++; cnt++; #endif if(iNumVertices != 0) { @@ -2337,7 +2338,7 @@ #else fTmpu = LoadFloatByteswapped( &fpFloatPointer[iCommandOffset] ); iCommandOffset++; cnt++; fTmpv = LoadFloatByteswapped( &fpFloatPointer[iCommandOffset] ); iCommandOffset++; cnt++; - iTmp = EndianS32_LtoB( ipIntPointer[iCommandOffset] ); iCommandOffset++; cnt++; + iTmp = SDL_SwapLE32( ipIntPointer[iCommandOffset] ); iCommandOffset++; cnt++; #endif madcommandu[modelindex][entry] = fTmpu-(.5/64); // GL doesn't align correctly madcommandv[modelindex][entry] = fTmpv-(.5/64); // with D3D @@ -2373,9 +2374,9 @@ iNumFrames = ipIntPointer[10]; iFrameOffset = ipIntPointer[14]>>2; #else - iNumVertices = EndianS32_LtoB( ipIntPointer[6] ); - iNumFrames = EndianS32_LtoB( ipIntPointer[10] ); - iFrameOffset = EndianS32_LtoB( ipIntPointer[14] )>>2; + iNumVertices = SDL_SwapLE32( ipIntPointer[6] ); + iNumFrames = SDL_SwapLE32( ipIntPointer[10] ); + iFrameOffset = SDL_SwapLE32( ipIntPointer[14] )>>2; #endif @@ -2433,9 +2434,9 @@ iNumFrames = ipIntPointer[10]; iFrameOffset = ipIntPointer[14]>>2; #else - iNumVertices = EndianS32_LtoB( ipIntPointer[6] ); - iNumFrames = EndianS32_LtoB( ipIntPointer[10] ); - iFrameOffset = EndianS32_LtoB( ipIntPointer[14] )>>2; + iNumVertices = SDL_SwapLE32( ipIntPointer[6] ); + iNumFrames = SDL_SwapLE32( ipIntPointer[10] ); + iFrameOffset = SDL_SwapLE32( ipIntPointer[14] )>>2; #endif @@ -3270,10 +3271,10 @@ fread(&itmp, 4, 1, fileread); meshsizex = itmp; fread(&itmp, 4, 1, fileread); meshsizey = itmp; #else - fread(&itmp, 4, 1, fileread); if( ( int )EndianS32_LtoB( itmp ) != MAPID) return FALSE; - fread(&itmp, 4, 1, fileread); numvert = ( int )EndianS32_LtoB( itmp ); - fread(&itmp, 4, 1, fileread); meshsizex = ( int )EndianS32_LtoB( itmp ); - fread(&itmp, 4, 1, fileread); meshsizey = ( int )EndianS32_LtoB( itmp ); + fread(&itmp, 4, 1, fileread); if( ( int )SDL_SwapLE32( itmp ) != MAPID) return FALSE; + fread(&itmp, 4, 1, fileread); numvert = ( int )SDL_SwapLE32( itmp ); + fread(&itmp, 4, 1, fileread); meshsizex = ( int )SDL_SwapLE32( itmp ); + fread(&itmp, 4, 1, fileread); meshsizey = ( int )SDL_SwapLE32( itmp ); #endif numfan = meshsizex*meshsizey; @@ -3299,9 +3300,9 @@ meshfx[fan] = itmp>>16; meshtile[fan] = itmp; #else - meshtype[fan] = EndianS32_LtoB( itmp )>>24; - meshfx[fan] = EndianS32_LtoB( itmp )>>16; - meshtile[fan] = EndianS32_LtoB( itmp ); + meshtype[fan] = SDL_SwapLE32( itmp )>>24; + meshfx[fan] = SDL_SwapLE32( itmp )>>16; + meshtile[fan] = SDL_SwapLE32( itmp ); #endif fan++; @@ -3315,7 +3316,7 @@ #ifdef _LITTLE_ENDIAN meshtwist[fan] = itmp; #else - meshtwist[fan] = EndianS32_LtoB( itmp ); + meshtwist[fan] = SDL_SwapLE32( itmp ); #endif fan++; @@ -3387,7 +3388,7 @@ #ifdef _LITTLE_ENDIAN meshvrta[cnt] = itmp; #else - meshvrta[cnt] = EndianS32_LtoB( itmp ); + meshvrta[cnt] = SDL_SwapLE32( itmp ); #endif meshvrtl[cnt] = 0;