diff --git a/src/animation/AnimManager.cpp b/src/animation/AnimManager.cpp index 3c67e95f..6a5148ab 100644 --- a/src/animation/AnimManager.cpp +++ b/src/animation/AnimManager.cpp @@ -810,17 +810,11 @@ CAnimManager::LoadAnimFile(int fd, bool compress) float *fbuf = (float*)buf; CFileMgr::Read(fd, (char*)&anpk, sizeof(IfpHeader)); -#ifdef BIGENDIAN - anpk.size = BSWAP32(anpk.size); -#endif + memLittle32(&anpk.size); if(!CGeneral::faststrncmp(anpk.ident, "ANLF", 4)) { ROUNDSIZE(anpk.size); CFileMgr::Read(fd, buf, anpk.size); -#ifndef BIGENDIAN - numANPK = *(int*)buf; -#else numANPK = BSWAP32(*(int*)buf); -#endif } else if(!CGeneral::faststrncmp(anpk.ident, "ANPK", 4)) { CFileMgr::Seek(fd, -8, 1); numANPK = 1; @@ -829,23 +823,15 @@ CAnimManager::LoadAnimFile(int fd, bool compress) for(i = 0; i < numANPK; i++){ // block name CFileMgr::Read(fd, (char*)&anpk, sizeof(IfpHeader)); -#ifdef BIGENDIAN - anpk.size = BSWAP32(anpk.size); -#endif + memLittle32(&anpk.size); ROUNDSIZE(anpk.size); CFileMgr::Read(fd, (char*)&info, sizeof(IfpHeader)); -#ifdef BIGENDIAN - info.size = BSWAP32(info.size); -#endif + memLittle32(&info.size); ROUNDSIZE(info.size); CFileMgr::Read(fd, buf, info.size); CAnimBlock *animBlock = &ms_aAnimBlocks[ms_numAnimBlocks++]; strncpy(animBlock->name, buf+4, 24); -#ifndef BIGENDIAN - animBlock->numAnims = *(int*)buf; -#else animBlock->numAnims = BSWAP32(*(int*)buf); -#endif animBlock->firstIndex = ms_numAnimations; @@ -854,59 +840,37 @@ CAnimManager::LoadAnimFile(int fd, bool compress) // animation name CFileMgr::Read(fd, (char*)&name, sizeof(IfpHeader)); -#ifdef BIGENDIAN - name.size = BSWAP32(name.size); -#endif + memLittle32(&name.size); ROUNDSIZE(name.size); CFileMgr::Read(fd, buf, name.size); hier->SetName(buf); // DG info has number of nodes/sequences CFileMgr::Read(fd, (char*)&dgan, sizeof(IfpHeader)); -#ifdef BIGENDIAN - dgan.size = BSWAP32(dgan.size); -#endif + memLittle32(&dgan.size); ROUNDSIZE(dgan.size); CFileMgr::Read(fd, (char*)&info, sizeof(IfpHeader)); -#ifdef BIGENDIAN - info.size = BSWAP32(info.size); -#endif + memLittle32(&info.size); ROUNDSIZE(info.size); CFileMgr::Read(fd, buf, info.size); -#ifndef BIGENDIAN - hier->numSequences = *(int*)buf; -#else hier->numSequences = BSWAP32(*(int*)buf); -#endif hier->sequences = new CAnimBlendSequence[hier->numSequences]; CAnimBlendSequence *seq = hier->sequences; for(k = 0; k < hier->numSequences; k++, seq++){ // Each node has a name and key frames CFileMgr::Read(fd, (char*)&cpan, sizeof(IfpHeader)); -#ifdef BIGENDIAN - cpan.size = BSWAP32(cpan.size); -#endif + memLittle32(&cpan.size); ROUNDSIZE(dgan.size); CFileMgr::Read(fd, (char*)&anim, sizeof(IfpHeader)); -#ifdef BIGENDIAN - anim.size = BSWAP32(anim.size); -#endif + memLittle32(&anim.size); ROUNDSIZE(anim.size); CFileMgr::Read(fd, buf, anim.size); -#ifndef BIGENDIAN - int numFrames = *(int*)(buf+28); -#else int numFrames = BSWAP32(*(int*)(buf+28)); -#endif seq->SetName(buf); #ifdef PED_SKIN if(anim.size == 44) -#ifndef BIGENDIAN - seq->SetBoneTag(*(int*)(buf+40)); -#else seq->SetBoneTag(BSWAP32(*(int*)(buf+40))); -#endif #endif if(numFrames == 0) continue; diff --git a/src/audio/oal/oal_utils.cpp b/src/audio/oal/oal_utils.cpp index eabd5f14..582882bb 100644 --- a/src/audio/oal/oal_utils.cpp +++ b/src/audio/oal/oal_utils.cpp @@ -53,7 +53,6 @@ using namespace re3_openal; void EFXInit() { /* Define a macro to help load the function pointers. */ - /* Prefix all the function pointers with re* to avoid linking issue with the library functions */ #define LOAD_PROC(T, x) ((x) = (T)alGetProcAddress(#x)) LOAD_PROC(LPALGENEFFECTS, alGenEffects); LOAD_PROC(LPALDELETEEFFECTS, alDeleteEffects); diff --git a/src/audio/sampman_oal.cpp b/src/audio/sampman_oal.cpp index c241dfeb..404c9062 100644 --- a/src/audio/sampman_oal.cpp +++ b/src/audio/sampman_oal.cpp @@ -46,16 +46,7 @@ //TODO: max channels //TODO: loop count -#ifdef _WIN32 -#pragma comment( lib, "OpenAL32.lib" ) -#endif - -// for user MP3s -#ifdef _WIN32 -#include -#include -#include -#elif defined __WIIU__ +#ifdef __WIIU__ extern "C" char *_getcwd (char *__buf, size_t __size); #else #define _getcwd getcwd @@ -267,10 +258,9 @@ release_existing() alcSuspendContext(ALContext); alcDestroyContext(ALContext); } - if ( ALDevice ) alcCloseDevice(ALDevice); - + ALDevice = NULL; ALContext = NULL; @@ -2021,11 +2011,11 @@ cSampleManager::InitialiseSampleBanks(void) // fix endianess for (int i = 0; i < TOTAL_AUDIO_SAMPLES; i++) { - m_aSamples[i].nOffset = BSWAP32(m_aSamples[i].nOffset); - m_aSamples[i].nSize = BSWAP32(m_aSamples[i].nSize); - m_aSamples[i].nFrequency = BSWAP32(m_aSamples[i].nFrequency); - m_aSamples[i].nLoopStart = BSWAP32(m_aSamples[i].nLoopStart); - m_aSamples[i].nLoopEnd = BSWAP32(m_aSamples[i].nLoopEnd); + memLittle32(&m_aSamples[i].nOffset); + memLittle32(&m_aSamples[i].nSize); + memLittle32(&m_aSamples[i].nFrequency); + memLittle32(&m_aSamples[i].nLoopStart); + memLittle32(&m_aSamples[i].nLoopEnd); } #endif #ifdef OPUS_SFX diff --git a/src/control/OnscreenTimer.cpp b/src/control/OnscreenTimer.cpp index ce23e43e..b3243799 100644 --- a/src/control/OnscreenTimer.cpp +++ b/src/control/OnscreenTimer.cpp @@ -107,11 +107,7 @@ void COnscreenTimerEntry::Process() { } int32* timerPtr = CTheScripts::GetPointerToScriptVariable(m_nTimerOffset); -#ifndef BIGENDIAN - int32 oldTime = *timerPtr; -#else int32 oldTime = BSWAP32(*timerPtr); -#endif int32 newTime = oldTime - int32(CTimer::GetTimeStepInSeconds() * 1000); if(newTime < 0) { *timerPtr = 0; @@ -119,11 +115,7 @@ void COnscreenTimerEntry::Process() { m_nTimerOffset = 0; m_aTimerText[0] = 0; } else { -#ifndef BIGENDIAN - *timerPtr = newTime; -#else *timerPtr = BSWAP32(newTime); -#endif int32 oldTimeSeconds = oldTime / 1000; if(oldTimeSeconds < 12 && newTime / 1000 != oldTimeSeconds) { DMAudio.PlayFrontEndSound(SOUND_CLOCK_TICK, newTime / 1000); @@ -152,20 +144,12 @@ bool COnscreenTimerEntry::ProcessForDisplay() { } void COnscreenTimerEntry::ProcessForDisplayClock() { -#ifndef BIGENDIAN - uint32 time = *CTheScripts::GetPointerToScriptVariable(m_nTimerOffset); -#else uint32 time = BSWAP32(*CTheScripts::GetPointerToScriptVariable(m_nTimerOffset)); -#endif sprintf(m_bTimerBuffer, "%02d:%02d", time / 1000 / 60, time / 1000 % 60); } void COnscreenTimerEntry::ProcessForDisplayCounter() { -#ifndef BIGENDIAN - uint32 counter = *CTheScripts::GetPointerToScriptVariable(m_nCounterOffset); -#else uint32 counter = BSWAP32(*CTheScripts::GetPointerToScriptVariable(m_nCounterOffset)); -#endif sprintf(m_bCounterBuffer, "%d", counter); } diff --git a/src/control/Record.cpp b/src/control/Record.cpp index dfa6277e..68daf305 100644 --- a/src/control/Record.cpp +++ b/src/control/Record.cpp @@ -67,12 +67,6 @@ void CRecordDataForGame::SaveOrRetrieveDataForThisFrame(void) uint8* pEndPtr = pController2; if ((pDataBufferForFrame.m_nSizeOfPads[0] + pDataBufferForFrame.m_nSizeOfPads[1]) & 1) pEndPtr += 2; -#ifdef BIGENDIAN - // save as LE - pDataBufferForFrame.m_fTimeStep = FLOATSWAP32(pDataBufferForFrame.m_fTimeStep); - pDataBufferForFrame.m_nTimeInMilliseconds = BSWAP32(pDataBufferForFrame.m_nTimeInMilliseconds); - pDataBufferForFrame.m_nChecksum = BSWAP32(pDataBufferForFrame.m_nChecksum); -#endif CFileMgr::Write(FId, (char*)&pDataBufferForFrame, pEndPtr - (uint8*)&pDataBufferForFrame); break; } @@ -81,11 +75,6 @@ void CRecordDataForGame::SaveOrRetrieveDataForThisFrame(void) CPad::GetPad(0)->NewState.Clear(); else { tGameBuffer* pData = (tGameBuffer*)pDataBufferPointer; -#ifdef BIGENDIAN - pData->m_fTimeStep = FLOATSWAP32(pData->m_fTimeStep); - pData->m_nTimeInMilliseconds = BSWAP32(pData->m_nTimeInMilliseconds); - pData->m_nChecksum = BSWAP32(pData->m_nChecksum); -#endif CTimer::SetTimeInMilliseconds(pData->m_nTimeInMilliseconds); CTimer::SetTimeStep(pData->m_fTimeStep); uint8 size1 = pData->m_nSizeOfPads[0]; diff --git a/src/control/Script.cpp b/src/control/Script.cpp index 1e770817..00afdadc 100644 --- a/src/control/Script.cpp +++ b/src/control/Script.cpp @@ -1602,11 +1602,7 @@ void CRunningScript::CollectParameters(uint32* pIp, int16 total) case ARGUMENT_GLOBALVAR: varIndex = CTheScripts::Read2BytesFromScript(pIp); script_assert(varIndex >= 8 && varIndex < CTheScripts::GetSizeOfVariableSpace()); -#ifndef BIGENDIAN - ScriptParams[i] = *((int32*)&CTheScripts::ScriptSpace[varIndex]); -#else ScriptParams[i] = BSWAP32(*((int32*)&CTheScripts::ScriptSpace[varIndex])); -#endif break; case ARGUMENT_LOCALVAR: varIndex = CTheScripts::Read2BytesFromScript(pIp); @@ -1647,11 +1643,7 @@ int CRunningScript::CollectParameterForDebug(char* buf, bool& var) var = true; sprintf(tmpstr, " $%d", varIndex / 4); strcat(buf, tmpstr); -#ifndef BIGENDIAN - return *((int32*)&CTheScripts::ScriptSpace[varIndex]); -#else return BSWAP32(*((int32*)&CTheScripts::ScriptSpace[varIndex])); -#endif case ARGUMENT_LOCALVAR: varIndex = CTheScripts::Read2BytesFromScript(&m_nIp); script_assert(varIndex >= 0 && varIndex < ARRAY_SIZE(m_anLocalVariables)); @@ -1705,11 +1697,7 @@ int32 CRunningScript::CollectNextParameterWithoutIncreasingPC(uint32 ip) case ARGUMENT_INT32: return CTheScripts::Read4BytesFromScript(pIp); case ARGUMENT_GLOBALVAR: -#ifndef BIGENDIAN - return *((int32*)&CTheScripts::ScriptSpace[(uint16)CTheScripts::Read2BytesFromScript(pIp)]); -#else return BSWAP32(*((int32*)&CTheScripts::ScriptSpace[(uint16)CTheScripts::Read2BytesFromScript(pIp)])); -#endif case ARGUMENT_LOCALVAR: return m_anLocalVariables[CTheScripts::Read2BytesFromScript(pIp)]; case ARGUMENT_INT8: @@ -1730,12 +1718,7 @@ void CRunningScript::StoreParameters(uint32* pIp, int16 number) for (int16 i = 0; i < number; i++){ switch (CTheScripts::Read1ByteFromScript(pIp)) { case ARGUMENT_GLOBALVAR: -#ifndef BIGENDIAN - *(int32*)&CTheScripts::ScriptSpace[(uint16)CTheScripts::Read2BytesFromScript(pIp)] = ScriptParams[i]; -#else - // store as LE *(int32*)&CTheScripts::ScriptSpace[(uint16)CTheScripts::Read2BytesFromScript(pIp)] = BSWAP32(ScriptParams[i]); -#endif break; case ARGUMENT_LOCALVAR: m_anLocalVariables[CTheScripts::Read2BytesFromScript(pIp)] = ScriptParams[i]; @@ -2034,11 +2017,7 @@ CRunningScript* CTheScripts::StartTestScript() bool CTheScripts::IsPlayerOnAMission() { -#ifndef BIGENDIAN - return OnAMissionFlag && *(int32*)&ScriptSpace[OnAMissionFlag] == 1; -#else return OnAMissionFlag && BSWAP32(*(int32*)&ScriptSpace[OnAMissionFlag]) == 1; -#endif } void CRunningScript::Process() diff --git a/src/core/CdStreamPosix.cpp b/src/core/CdStreamPosix.cpp index ce2d77f4..8222e3c5 100644 --- a/src/core/CdStreamPosix.cpp +++ b/src/core/CdStreamPosix.cpp @@ -164,6 +164,7 @@ CdStreamInitThread(void) ASSERT(gChannelRequestQ.items != nil ); gCdStreamSema = sem_open("/semaphore_cd_stream", O_CREAT, 0644, 0); + if (gCdStreamSema == SEM_FAILED) { CDTRACE("failed to create stream semaphore"); ASSERT(0); diff --git a/src/core/Directory.cpp b/src/core/Directory.cpp index 90bf1057..b8d2d9d9 100644 --- a/src/core/Directory.cpp +++ b/src/core/Directory.cpp @@ -24,10 +24,8 @@ CDirectory::ReadDirFile(const char *filename) fd = CFileMgr::OpenFile(filename, "rb"); while(CFileMgr::Read(fd, (char*)&dirinfo, sizeof(dirinfo))) { -#ifdef BIGENDIAN - dirinfo.offset = BSWAP32(dirinfo.offset); - dirinfo.size = BSWAP32(dirinfo.size); -#endif + memLittle32(&dirinfo.offset); + memLittle32(&dirinfo.size); AddItem(dirinfo); } CFileMgr::CloseFile(fd); diff --git a/src/core/FileLoader.cpp b/src/core/FileLoader.cpp index ffd7e341..48e4f9c8 100644 --- a/src/core/FileLoader.cpp +++ b/src/core/FileLoader.cpp @@ -218,9 +218,7 @@ CFileLoader::LoadCollisionFile(const char *filename) #else assert(header.ident == 'LLOC'); #endif -#ifdef BIGENDIAN - header.size = BSWAP32(header.size); -#endif + memLittle32(&header.size); CFileMgr::Read(fd, (char*)work_buff, header.size); memcpy(modelname, work_buff, 24); @@ -248,19 +246,6 @@ CFileLoader::LoadCollisionModel(uint8 *buf, CColModel &model, char *modelname) { int i; -#ifndef BIGENDIAN - model.boundingSphere.radius = *(float*)(buf); - model.boundingSphere.center.x = *(float*)(buf+4); - model.boundingSphere.center.y = *(float*)(buf+8); - model.boundingSphere.center.z = *(float*)(buf+12); - model.boundingBox.min.x = *(float*)(buf+16); - model.boundingBox.min.y = *(float*)(buf+20); - model.boundingBox.min.z = *(float*)(buf+24); - model.boundingBox.max.x = *(float*)(buf+28); - model.boundingBox.max.y = *(float*)(buf+32); - model.boundingBox.max.z = *(float*)(buf+36); - model.numSpheres = *(int16*)(buf+40); -#else model.boundingSphere.radius = FLOATSWAP32(*(float*)(buf)); model.boundingSphere.center.x = FLOATSWAP32(*(float*)(buf+4)); model.boundingSphere.center.y = FLOATSWAP32(*(float*)(buf+8)); @@ -272,7 +257,6 @@ CFileLoader::LoadCollisionModel(uint8 *buf, CColModel &model, char *modelname) model.boundingBox.max.y = FLOATSWAP32(*(float*)(buf+32)); model.boundingBox.max.z = FLOATSWAP32(*(float*)(buf+36)); model.numSpheres = (int16) BSWAP16(*(uint16*)(buf+40)); -#endif buf += 44; if(model.numSpheres > 0){ @@ -294,11 +278,7 @@ CFileLoader::LoadCollisionModel(uint8 *buf, CColModel &model, char *modelname) }else model.spheres = nil; -#ifndef BIGENDIAN - model.numLines = *(int16*)buf; -#else model.numLines = (int16) BSWAP16(*(uint16*)buf); -#endif buf += 4; if(model.numLines > 0){ model.lines = (CColLine*)RwMalloc(model.numLines*sizeof(CColLine)); @@ -322,11 +302,7 @@ CFileLoader::LoadCollisionModel(uint8 *buf, CColModel &model, char *modelname) }else model.lines = nil; -#ifndef BIGENDIAN - model.numBoxes = *(int16*)buf; -#else model.numBoxes = (int16) BSWAP16(*(uint16*)buf); -#endif buf += 4; if(model.numBoxes > 0){ model.boxes = (CColBox*)RwMalloc(model.numBoxes*sizeof(CColBox)); @@ -350,11 +326,7 @@ CFileLoader::LoadCollisionModel(uint8 *buf, CColModel &model, char *modelname) }else model.boxes = nil; -#ifndef BIGENDIAN - int32 numVertices = *(int16*)buf; -#else int32 numVertices = (int16) BSWAP16(*(uint16*)buf); -#endif buf += 4; if(numVertices > 0){ model.vertices = (CompressedVector*)RwMalloc(numVertices*sizeof(CompressedVector)); @@ -381,11 +353,7 @@ CFileLoader::LoadCollisionModel(uint8 *buf, CColModel &model, char *modelname) }else model.vertices = nil; -#ifndef BIGENDIAN - model.numTriangles = *(int16*)buf; -#else model.numTriangles = (int16) BSWAP16(*(uint16*)buf); -#endif buf += 4; if(model.numTriangles > 0){ model.triangles = (CColTriangle*)RwMalloc(model.numTriangles*sizeof(CColTriangle)); diff --git a/src/core/Pad.cpp b/src/core/Pad.cpp index faf83b7f..35de6c5f 100644 --- a/src/core/Pad.cpp +++ b/src/core/Pad.cpp @@ -527,7 +527,7 @@ CMouseControllerState CMousePointerStateHelper::GetMouseSetUp() } } #elif __WIIU__ -// TODO: WIIU + // no mouse on the Wii U #else // It seems there is no way to get number of buttons on mouse, so assign all buttons if we have mouse. double xpos = 1.0f, ypos; @@ -588,7 +588,7 @@ void CPad::UpdateMouse() } } #elif __WIIU__ -// TODO: wiiu + // no mouse on the Wii U #else if ( IsForegroundApp() && PSGLOBAL(cursorIsInWindow) ) { diff --git a/src/core/Streaming.cpp b/src/core/Streaming.cpp index 6aa64f94..8b6752c4 100644 --- a/src/core/Streaming.cpp +++ b/src/core/Streaming.cpp @@ -420,10 +420,8 @@ CStreaming::LoadCdDirectory(const char *dirname, int n) imgSelector = n<<24; assert(sizeof(direntry) == 32); while(CFileMgr::Read(fd, (char*)&direntry, sizeof(direntry))){ -#ifdef BIGENDIAN - direntry.offset = BSWAP32(direntry.offset); - direntry.size = BSWAP32(direntry.size); -#endif + memLittle32(&direntry.offset); + memLittle32(&direntry.size); dot = strchr(direntry.name, '.'); assert(dot); if(dot) *dot = '\0'; diff --git a/src/core/common.h b/src/core/common.h index 6fc5c6a0..7b5f3ae1 100644 --- a/src/core/common.h +++ b/src/core/common.h @@ -107,36 +107,33 @@ typedef uint16 bool16; typedef uint32 bool32; #ifdef BIGENDIAN -inline float _floatswap32(float f) -{ - uint32_t _swapval = __builtin_bswap32(*(uint32_t*)&f); - return *(float*)&_swapval; -} - #define BSWAP32(x) __builtin_bswap32(x) #define BSWAP16(x) __builtin_bswap16(x) + +inline float _floatswap32(float f) +{ + uint32 _swapval = BSWAP32(*(uint32*)&f); + return *(float*)&_swapval; +} #define FLOATSWAP32(x) _floatswap32(x) -#define BSWAP_VECTOR(v) \ - do { \ - v.x = FLOATSWAP32(v.x); \ - v.y = FLOATSWAP32(v.y); \ - v.z = FLOATSWAP32(v.z); \ - } while(0) -#define BSWAP_MTX(m) \ - do { \ - BSWAP_VECTOR(m.right); \ - BSWAP_VECTOR(m.up); \ - BSWAP_VECTOR(m.at); \ - BSWAP_VECTOR(m.pos); \ - BSWAP32(m.flags); \ - BSWAP32(m.pad1); \ - BSWAP32(m.pad2); \ - BSWAP32(m.pad3); \ - } while(0) + +inline void _memLittle32(void* val) +{ + *(uint32*)val = BSWAP32(*(uint32*)val); +} +#define memLittle32(val) _memLittle32(val) + +inline void _memLittle16(void* val) +{ + *(uint16*)val = BSWAP16(*(uint16*)val); +} +#define memLittle16(val) _memLittle16(val) #else #define BSWAP32(x) (x) #define BSWAP16(x) (x) #define FLOATSWAP32(x) (x) +#define memLittle32(val) +#define memLittle16(val) #endif #if defined(_MSC_VER) || defined (__MWERKS__) diff --git a/src/render/PlayerSkin.cpp b/src/render/PlayerSkin.cpp index 21d0d5ea..9e6d1678 100644 --- a/src/render/PlayerSkin.cpp +++ b/src/render/PlayerSkin.cpp @@ -32,10 +32,8 @@ FindPlayerDff(uint32 &offset, uint32 &size) do { if (!CFileMgr::Read(file, (char*)&info, sizeof(CDirectory::DirectoryInfo))) return; -#ifdef BIGENDIAN - info.offset = BSWAP32(info.offset); - info.size = BSWAP32(info.size); -#endif + memLittle32(&info.offset); + memLittle32(&info.size); } while (strcasecmp("player.dff", info.name) != 0); offset = info.offset; diff --git a/src/rw/ClumpRead.cpp b/src/rw/ClumpRead.cpp index d85be948..3f6cc675 100644 --- a/src/rw/ClumpRead.cpp +++ b/src/rw/ClumpRead.cpp @@ -35,9 +35,7 @@ GeometryListStreamRead1(RwStream *stream, rpGeometryList *geomlist) if(RwStreamRead(stream, &numGeoms, 4) != 4) return nil; -#ifdef BIGENDIAN - numGeoms = BSWAP32(numGeoms); -#endif + memLittle32(&numGeoms); numberGeometrys = numGeoms/2; geomlist->numGeoms = numGeoms; @@ -106,12 +104,10 @@ ClumpAtomicStreamRead(RwStream *stream, rwFrameList *frmList, rpGeometryList *ge if(RwStreamRead(stream, &a, size) != size) return nil; -#ifdef BIGENDIAN - a.frameIndex = BSWAP32(a.frameIndex); - a.geomIndex = BSWAP32(a.geomIndex); - a.flags = BSWAP32(a.flags); - a.unused = BSWAP32(a.unused); -#endif + memLittle32(&a.frameIndex); + memLittle32(&a.geomIndex); + memLittle32(&a.flags); + memLittle32(&a.unused); atomic = RpAtomicCreate(); if(atomic == nil) @@ -162,11 +158,9 @@ RpClumpGtaStreamRead1(RwStream *stream) return false; } -#ifdef BIGENDIAN - gClumpInfo.numAtomics = BSWAP32(gClumpInfo.numAtomics); - gClumpInfo.numCameras = BSWAP32(gClumpInfo.numCameras); - gClumpInfo.numLights = BSWAP32(gClumpInfo.numLights); -#endif + memLittle32(&gClumpInfo.numAtomics); + memLittle32(&gClumpInfo.numCameras); + memLittle32(&gClumpInfo.numLights); if(!RwStreamFindChunk(stream, rwID_FRAMELIST, nil, &version)) return false; diff --git a/src/rw/TexRead.cpp b/src/rw/TexRead.cpp index 82f1f45e..8d55b059 100644 --- a/src/rw/TexRead.cpp +++ b/src/rw/TexRead.cpp @@ -81,9 +81,7 @@ RwTexDictionaryGtaStreamRead(RwStream *stream) if(RwStreamRead(stream, &numTextures, size) != size) return nil; -#ifdef BIGENDIAN - numTextures = BSWAP32(numTextures); -#endif + memLittle32(&numTextures); texDict = RwTexDictionaryCreate(); if(texDict == nil) @@ -120,9 +118,7 @@ RwTexDictionaryGtaStreamRead1(RwStream *stream) if(RwStreamRead(stream, &numTextures, size) != size) return nil; -#ifdef BIGENDIAN - numTextures = BSWAP32(numTextures); -#endif + memLittle32(&numTextures); texDict = RwTexDictionaryCreate(); if(texDict == nil) diff --git a/src/text/Text.cpp b/src/text/Text.cpp index 46480ed5..656e4ac0 100644 --- a/src/text/Text.cpp +++ b/src/text/Text.cpp @@ -70,7 +70,6 @@ CText::Load(void) type[3] = filedata[offset++]; sectlen = (int)filedata[offset+3]<<24 | (int)filedata[offset+2]<<16 | (int)filedata[offset+1]<<8 | (int)filedata[offset+0]; - offset += 4; if(sectlen != 0){ if(strncmp(type, "TKEY", 4) == 0) @@ -192,7 +191,7 @@ CKeyArray::Load(size_t length, uint8 *data, ssize_t *offset) #ifdef BIGENDIAN for (i = 0; i < numEntries; i++) - entries[i].valueOffset = BSWAP32(entries[i].valueOffset); + memLittle32(&entries[i].valueOffset); #endif } @@ -277,7 +276,7 @@ CData::Load(size_t length, uint8 *data, ssize_t *offset) #ifdef BIGENDIAN for (i = 0; i < numChars; i++) - chars[i] = BSWAP16(chars[i]); + memLittle16(&chars[i]); #endif }