From b05fa7f20414d6a7571a9ba52f542e527f598c62 Mon Sep 17 00:00:00 2001 From: Filippos Karapetis Date: Tue, 11 Dec 2012 02:56:48 +0200 Subject: TINSEL: Add resource handling of the BE resources in DW1 Mac This is the second attempt. All the BE resources of DW1 Mac are handled correctly now. Added READ_16, READ_32, FROM_16, FROM_32 and TO_32 to handle all of the different cases where endianess is already handled. Note that the game scripts are LE, so these haven't been changed --- engines/tinsel/actors.cpp | 22 ++++----- engines/tinsel/anim.cpp | 32 ++++++------- engines/tinsel/bg.cpp | 24 +++++----- engines/tinsel/bmv.cpp | 18 ++++---- engines/tinsel/cursor.cpp | 30 ++++++------ engines/tinsel/dialogs.cpp | 40 ++++++++-------- engines/tinsel/faders.cpp | 4 +- engines/tinsel/font.cpp | 8 ++-- engines/tinsel/graphics.cpp | 19 ++++---- engines/tinsel/multiobj.cpp | 24 +++++----- engines/tinsel/music.cpp | 18 ++++---- engines/tinsel/object.cpp | 24 +++++----- engines/tinsel/palette.cpp | 22 ++++----- engines/tinsel/palette.h | 8 ++-- engines/tinsel/pcode.cpp | 2 +- engines/tinsel/play.cpp | 104 +++++++++++++++++++++--------------------- engines/tinsel/polygons.cpp | 108 ++++++++++++++++++++++---------------------- engines/tinsel/rince.cpp | 16 +++---- engines/tinsel/scene.cpp | 22 ++++----- engines/tinsel/sched.cpp | 12 ++--- engines/tinsel/scn.cpp | 4 +- engines/tinsel/strres.cpp | 6 +-- engines/tinsel/text.cpp | 46 +++++++++---------- engines/tinsel/tinsel.cpp | 16 +++---- engines/tinsel/tinsel.h | 6 +++ 25 files changed, 319 insertions(+), 316 deletions(-) (limited to 'engines') diff --git a/engines/tinsel/actors.cpp b/engines/tinsel/actors.cpp index 0ba8b7cdba..531a8e3d12 100644 --- a/engines/tinsel/actors.cpp +++ b/engines/tinsel/actors.cpp @@ -406,7 +406,7 @@ void ActorEvent(CORO_PARAM, int ano, TINSEL_EVENT tEvent, bool bWait, int myEsca * @param bRunScript Flag for whether to run actor's script for the scene */ void StartActor(const T1_ACTOR_STRUC *as, bool bRunScript) { - SCNHANDLE hActorId = FROM_LE_32(as->hActorId); + SCNHANDLE hActorId = FROM_32(as->hActorId); // Zero-out many things actorInfo[hActorId - 1].bHidden = false; @@ -418,15 +418,15 @@ void StartActor(const T1_ACTOR_STRUC *as, bool bRunScript) { actorInfo[hActorId - 1].presObj = NULL; // Store current scene's parameters for this actor - actorInfo[hActorId - 1].mtype = FROM_LE_32(as->masking); - actorInfo[hActorId - 1].actorCode = FROM_LE_32(as->hActorCode); + actorInfo[hActorId - 1].mtype = FROM_32(as->masking); + actorInfo[hActorId - 1].actorCode = FROM_32(as->hActorCode); // Run actor's script for this scene if (bRunScript) { if (bActorsOn) actorInfo[hActorId - 1].bAlive = true; - if (actorInfo[hActorId - 1].bAlive && FROM_LE_32(as->hActorCode)) + if (actorInfo[hActorId - 1].bAlive && FROM_32(as->hActorCode)) ActorEvent(hActorId, STARTUP, PLR_NOEVENT); } } @@ -465,11 +465,11 @@ void StartTaggedActors(SCNHANDLE ah, int numActors, bool bRunScript) { assert(as->hActorCode); // Store current scene's parameters for this tagged actor - taggedActors[i].id = FROM_LE_32(as->hActorId); - taggedActors[i].hTagText = FROM_LE_32(as->hTagText); - taggedActors[i].tagPortionV = FROM_LE_32(as->tagPortionV); - taggedActors[i].tagPortionH = FROM_LE_32(as->tagPortionH); - taggedActors[i].hActorCode = FROM_LE_32(as->hActorCode); + taggedActors[i].id = FROM_32(as->hActorId); + taggedActors[i].hTagText = FROM_32(as->hTagText); + taggedActors[i].tagPortionV = FROM_32(as->tagPortionV); + taggedActors[i].tagPortionH = FROM_32(as->tagPortionH); + taggedActors[i].hActorCode = FROM_32(as->hActorCode); // Run actor's script for this scene if (bRunScript) { @@ -1310,9 +1310,9 @@ void SetActorRGB(int ano, COLORREF color) { assert(ano >= 0 && ano <= NumActors); if (ano) - actorInfo[ano - 1].textColor = TO_LE_32(color); + actorInfo[ano - 1].textColor = TO_32(color); else - defaultColor = TO_LE_32(color); + defaultColor = TO_32(color); } /** diff --git a/engines/tinsel/anim.cpp b/engines/tinsel/anim.cpp index 034296ccc7..a1ec02186c 100644 --- a/engines/tinsel/anim.cpp +++ b/engines/tinsel/anim.cpp @@ -44,9 +44,9 @@ SCRIPTSTATE DoNextFrame(ANIM *pAnim) { while (1) { // repeat until a real image debugC(DEBUG_DETAILED, kTinselDebugAnimations, "DoNextFrame %ph index=%d, op=%xh", (byte *)pAnim, pAnim->scriptIndex, - FROM_LE_32(pAni[pAnim->scriptIndex].op)); + FROM_32(pAni[pAnim->scriptIndex].op)); - switch ((int32)FROM_LE_32(pAni[pAnim->scriptIndex].op)) { + switch ((int32)FROM_32(pAni[pAnim->scriptIndex].op)) { case ANI_END: // end of animation script // move to next opcode @@ -61,7 +61,7 @@ SCRIPTSTATE DoNextFrame(ANIM *pAnim) { pAnim->scriptIndex++; // jump to new frame position - pAnim->scriptIndex += (int32)FROM_LE_32(pAni[pAnim->scriptIndex].op); + pAnim->scriptIndex += (int32)FROM_32(pAni[pAnim->scriptIndex].op); // go fetch a real image break; @@ -101,7 +101,7 @@ SCRIPTSTATE DoNextFrame(ANIM *pAnim) { // move to x adjustment operand pAnim->scriptIndex++; - MultiAdjustXY(pAnim->pObject, (int32)FROM_LE_32(pAni[pAnim->scriptIndex].op), 0); + MultiAdjustXY(pAnim->pObject, (int32)FROM_32(pAni[pAnim->scriptIndex].op), 0); // next opcode pAnim->scriptIndex++; @@ -114,7 +114,7 @@ SCRIPTSTATE DoNextFrame(ANIM *pAnim) { // move to y adjustment operand pAnim->scriptIndex++; - MultiAdjustXY(pAnim->pObject, 0, (int32)FROM_LE_32(pAni[pAnim->scriptIndex].op)); + MultiAdjustXY(pAnim->pObject, 0, (int32)FROM_32(pAni[pAnim->scriptIndex].op)); // next opcode pAnim->scriptIndex++; @@ -128,11 +128,11 @@ SCRIPTSTATE DoNextFrame(ANIM *pAnim) { // move to x adjustment operand pAnim->scriptIndex++; - x = (int32)FROM_LE_32(pAni[pAnim->scriptIndex].op); + x = (int32)FROM_32(pAni[pAnim->scriptIndex].op); // move to y adjustment operand pAnim->scriptIndex++; - y = (int32)FROM_LE_32(pAni[pAnim->scriptIndex].op); + y = (int32)FROM_32(pAni[pAnim->scriptIndex].op); MultiAdjustXY(pAnim->pObject, x, y); @@ -189,7 +189,7 @@ SCRIPTSTATE DoNextFrame(ANIM *pAnim) { default: // must be an actual animation frame handle // set objects new animation frame - pAnim->pObject->hShape = FROM_LE_32(pAni[pAnim->scriptIndex].hFrame); + pAnim->pObject->hShape = FROM_32(pAni[pAnim->scriptIndex].hFrame); // re-shape the object MultiReshape(pAnim->pObject); @@ -273,7 +273,7 @@ void SkipFrames(ANIM *pAnim, int numFrames) { while (1) { // repeat until a real image - switch ((int32)FROM_LE_32(pAni[pAnim->scriptIndex].op)) { + switch ((int32)FROM_32(pAni[pAnim->scriptIndex].op)) { case ANI_END: // end of animation script // going off the end is probably a error, but only in Tinsel 1 if (!TinselV2) @@ -286,7 +286,7 @@ void SkipFrames(ANIM *pAnim, int numFrames) { pAnim->scriptIndex++; // jump to new frame position - pAnim->scriptIndex += (int32)FROM_LE_32(pAni[pAnim->scriptIndex].op); + pAnim->scriptIndex += (int32)FROM_32(pAni[pAnim->scriptIndex].op); if (TinselV2) // Done if skip to jump @@ -323,7 +323,7 @@ void SkipFrames(ANIM *pAnim, int numFrames) { // move to x adjustment operand pAnim->scriptIndex++; - MultiAdjustXY(pAnim->pObject, (int32)FROM_LE_32(pAni[pAnim->scriptIndex].op), 0); + MultiAdjustXY(pAnim->pObject, (int32)FROM_32(pAni[pAnim->scriptIndex].op), 0); // next opcode pAnim->scriptIndex++; @@ -334,7 +334,7 @@ void SkipFrames(ANIM *pAnim, int numFrames) { // move to y adjustment operand pAnim->scriptIndex++; - MultiAdjustXY(pAnim->pObject, 0, (int32)FROM_LE_32(pAni[pAnim->scriptIndex].op)); + MultiAdjustXY(pAnim->pObject, 0, (int32)FROM_32(pAni[pAnim->scriptIndex].op)); // next opcode pAnim->scriptIndex++; @@ -346,11 +346,11 @@ void SkipFrames(ANIM *pAnim, int numFrames) { // move to x adjustment operand pAnim->scriptIndex++; - x = (int32)FROM_LE_32(pAni[pAnim->scriptIndex].op); + x = (int32)FROM_32(pAni[pAnim->scriptIndex].op); // move to y adjustment operand pAnim->scriptIndex++; - y = (int32)FROM_LE_32(pAni[pAnim->scriptIndex].op); + y = (int32)FROM_32(pAni[pAnim->scriptIndex].op); MultiAdjustXY(pAnim->pObject, x, y); @@ -389,7 +389,7 @@ void SkipFrames(ANIM *pAnim, int numFrames) { pAnim->scriptIndex++; } else { // set objects new animation frame - pAnim->pObject->hShape = FROM_LE_32(pAni[pAnim->scriptIndex].hFrame); + pAnim->pObject->hShape = FROM_32(pAni[pAnim->scriptIndex].hFrame); // re-shape the object MultiReshape(pAnim->pObject); @@ -414,7 +414,7 @@ bool AboutToJumpOrEnd(PANIM pAnim) { for (;;) { // repeat until a real image - switch (FROM_LE_32(pAni[zzz].op)) { + switch (FROM_32(pAni[zzz].op)) { case ANI_END: // end of animation script case ANI_JUMP: // do animation jump return true; diff --git a/engines/tinsel/bg.cpp b/engines/tinsel/bg.cpp index a3e21a8227..ed15bfef2a 100644 --- a/engines/tinsel/bg.cpp +++ b/engines/tinsel/bg.cpp @@ -124,28 +124,28 @@ static void BGmainProcess(CORO_PARAM, const void *param) { pReel = (const FREEL *)param; // Get the MULTI_INIT structure - pmi = (const MULTI_INIT *)LockMem(FROM_LE_32(pReel->mobj)); + pmi = (const MULTI_INIT *)LockMem(FROM_32(pReel->mobj)); // Initialize and insert the object, and initialize its script. g_pBG[0] = MultiInitObject(pmi); MultiInsertObject(GetPlayfieldList(FIELD_WORLD), g_pBG[0]); - InitStepAnimScript(&g_thisAnim[0], g_pBG[0], FROM_LE_32(pReel->script), g_BGspeed); + InitStepAnimScript(&g_thisAnim[0], g_pBG[0], FROM_32(pReel->script), g_BGspeed); g_bgReels = 1; } else { /*** At start of scene ***/ pFilm = (const FILM *)LockMem(g_hBackground); - g_bgReels = FROM_LE_32(pFilm->numreels); + g_bgReels = FROM_32(pFilm->numreels); int i; for (i = 0; i < g_bgReels; i++) { // Get the MULTI_INIT structure - pmi = (PMULTI_INIT) LockMem(FROM_LE_32(pFilm->reels[i].mobj)); + pmi = (PMULTI_INIT) LockMem(FROM_32(pFilm->reels[i].mobj)); // Initialize and insert the object, and initialize its script. g_pBG[i] = MultiInitObject(pmi); MultiInsertObject(GetPlayfieldList(FIELD_WORLD), g_pBG[i]); MultiSetZPosition(g_pBG[i], 0); - InitStepAnimScript(&g_thisAnim[i], g_pBG[i], FROM_LE_32(pFilm->reels[i].script), g_BGspeed); + InitStepAnimScript(&g_thisAnim[i], g_pBG[i], FROM_32(pFilm->reels[i].script), g_BGspeed); if (i > 0) g_pBG[i-1]->pSlave = g_pBG[i]; @@ -170,11 +170,11 @@ static void BGmainProcess(CORO_PARAM, const void *param) { // New background during scene if (!TinselV2) { pReel = (const FREEL *)param; - InitStepAnimScript(&g_thisAnim[0], g_pBG[0], FROM_LE_32(pReel->script), g_BGspeed); + InitStepAnimScript(&g_thisAnim[0], g_pBG[0], FROM_32(pReel->script), g_BGspeed); StepAnimScript(&g_thisAnim[0]); } else { pFilm = (const FILM *)LockMem(g_hBackground); - assert(g_bgReels == (int32)FROM_LE_32(pFilm->numreels)); + assert(g_bgReels == (int32)FROM_32(pFilm->numreels)); // Just re-initialize the scripts. for (int i = 0; i < g_bgReels; i++) { @@ -198,7 +198,7 @@ static void BGotherProcess(CORO_PARAM, const void *param) { CORO_END_CONTEXT(_ctx); const FREEL *pReel = (const FREEL *)param; - const MULTI_INIT *pmi = (const MULTI_INIT *)LockMem(FROM_LE_32(pReel->mobj)); + const MULTI_INIT *pmi = (const MULTI_INIT *)LockMem(FROM_32(pReel->mobj)); CORO_BEGIN_CODE(_ctx); @@ -206,7 +206,7 @@ static void BGotherProcess(CORO_PARAM, const void *param) { _ctx->pObj = MultiInitObject(pmi); MultiInsertObject(GetPlayfieldList(FIELD_WORLD), _ctx->pObj); - InitStepAnimScript(&_ctx->anim, g_pBG[0], FROM_LE_32(pReel->script), g_BGspeed); + InitStepAnimScript(&_ctx->anim, g_pBG[0], FROM_32(pReel->script), g_BGspeed); while (StepAnimScript(&_ctx->anim) != ScriptFinished) CORO_SLEEP(1); @@ -249,16 +249,16 @@ void StartupBackground(CORO_PARAM, SCNHANDLE hFilm) { pim = GetImageFromFilm(hFilm, 0, NULL, NULL, &pfilm); - SetBackPal(FROM_LE_32(pim->hImgPal)); + SetBackPal(FROM_32(pim->hImgPal)); // Extract the film speed - g_BGspeed = ONE_SECOND / FROM_LE_32(pfilm->frate); + g_BGspeed = ONE_SECOND / FROM_32(pfilm->frate); // Start display process for each reel in the film CoroScheduler.createProcess(PID_REEL, BGmainProcess, &pfilm->reels[0], sizeof(FREEL)); if (TinselV0) { - for (uint i = 1; i < FROM_LE_32(pfilm->numreels); ++i) + for (uint i = 1; i < FROM_32(pfilm->numreels); ++i) CoroScheduler.createProcess(PID_REEL, BGotherProcess, &pfilm->reels[i], sizeof(FREEL)); } diff --git a/engines/tinsel/bmv.cpp b/engines/tinsel/bmv.cpp index 438fd52a81..106e1542d5 100644 --- a/engines/tinsel/bmv.cpp +++ b/engines/tinsel/bmv.cpp @@ -529,9 +529,9 @@ int BMVPlayer::MovieCommand(char cmd, int commandOffset) { if (cmd & CD_PRINT) { PRINT_CMD *pCmd = (PRINT_CMD *)(bigBuffer + commandOffset); - MovieText(Common::nullContext, (int16)READ_LE_UINT16(&pCmd->stringId), - (int16)READ_LE_UINT16(&pCmd->x), - (int16)READ_LE_UINT16(&pCmd->y), + MovieText(Common::nullContext, (int16)READ_16(&pCmd->stringId), + (int16)READ_16(&pCmd->x), + (int16)READ_16(&pCmd->y), pCmd->fontId, NULL, pCmd->duration); @@ -542,9 +542,9 @@ int BMVPlayer::MovieCommand(char cmd, int commandOffset) { TALK_CMD *pCmd = (TALK_CMD *)(bigBuffer + commandOffset); talkColor = TINSEL_RGB(pCmd->r, pCmd->g, pCmd->b); - MovieText(Common::nullContext, (int16)READ_LE_UINT16(&pCmd->stringId), - (int16)READ_LE_UINT16(&pCmd->x), - (int16)READ_LE_UINT16(&pCmd->y), + MovieText(Common::nullContext, (int16)READ_16(&pCmd->stringId), + (int16)READ_16(&pCmd->x), + (int16)READ_16(&pCmd->y), 0, &talkColor, pCmd->duration); @@ -622,7 +622,7 @@ int BMVPlayer::FollowingPacket(int thisPacket, bool bReallyImportant) { if (nextReadSlot*SLOT_SIZE >= thisPacket && thisPacket+3 >= nextReadSlot*SLOT_SIZE) return thisPacket + 3; } - length = (int32)READ_LE_UINT32(bigBuffer + thisPacket + 1); + length = (int32)READ_32(bigBuffer + thisPacket + 1); length &= 0x00ffffff; return thisPacket + length + 4; } @@ -886,7 +886,7 @@ bool BMVPlayer::DoBMVFrame() { return true; default: - length = (int32)READ_LE_UINT32(data + 1); + length = (int32)READ_32(data + 1); length &= 0x00ffffff; graphOffset = nextUseOffset + 4; // Skip command byte and length @@ -922,7 +922,7 @@ bool BMVPlayer::DoBMVFrame() { } if (*data & CD_XSCR) { - xscr = (int16)READ_LE_UINT16(bigBuffer + graphOffset); + xscr = (int16)READ_16(bigBuffer + graphOffset); graphOffset += sz_XSCR_pkt; // Skip scroll offset length -= sz_XSCR_pkt; } else if (*data & BIT0) diff --git a/engines/tinsel/cursor.cpp b/engines/tinsel/cursor.cpp index bf901c03b6..a83e7cd9ca 100644 --- a/engines/tinsel/cursor.cpp +++ b/engines/tinsel/cursor.cpp @@ -125,7 +125,7 @@ static void InitCurTrailObj(int i, int x, int y) { pim = GetImageFromFilm(g_hCursorFilm, i+1, &pfr, &pmi, &pfilm);// Get pointer to image assert(BgPal()); // No background palette - pim->hImgPal = TO_LE_32(BgPal()); + pim->hImgPal = TO_32(BgPal()); // Initialize and insert the object, set its Z-pos, and hide it g_ntrailData[i].trailObj = MultiInitObject(pmi); @@ -134,7 +134,7 @@ static void InitCurTrailObj(int i, int x, int y) { MultiSetAniXY(g_ntrailData[i].trailObj, x, y); // Initialize the animation script - InitStepAnimScript(&g_ntrailData[i].trailAnim, g_ntrailData[i].trailObj, FROM_LE_32(pfr->script), ONE_SECOND / FROM_LE_32(pfilm->frate)); + InitStepAnimScript(&g_ntrailData[i].trailAnim, g_ntrailData[i].trailObj, FROM_32(pfr->script), ONE_SECOND / FROM_32(pfilm->frate)); StepAnimScript(&g_ntrailData[i].trailAnim); } @@ -237,7 +237,7 @@ void RestoreMainCursor() { if (g_McurObj != NULL) { pfilm = (const FILM *)LockMem(g_hCursorFilm); - InitStepAnimScript(&g_McurAnim, g_McurObj, FROM_LE_32(pfilm->reels->script), ONE_SECOND / FROM_LE_32(pfilm->frate)); + InitStepAnimScript(&g_McurAnim, g_McurObj, FROM_32(pfilm->reels->script), ONE_SECOND / FROM_32(pfilm->frate)); StepAnimScript(&g_McurAnim); } g_bHiddenCursor = false; @@ -324,14 +324,14 @@ IMAGE *GetImageFromReel(const FREEL *pfr, const MULTI_INIT **ppmi) { const MULTI_INIT *pmi; const FRAME *pFrame; - pmi = (const MULTI_INIT *)LockMem(FROM_LE_32(pfr->mobj)); + pmi = (const MULTI_INIT *)LockMem(FROM_32(pfr->mobj)); if (ppmi) *ppmi = pmi; - pFrame = (const FRAME *)LockMem(FROM_LE_32(pmi->hMulFrame)); + pFrame = (const FRAME *)LockMem(FROM_32(pmi->hMulFrame)); // get pointer to image - return (IMAGE *)LockMem(READ_LE_UINT32(pFrame)); + return (IMAGE *)LockMem(READ_32(pFrame)); } /** @@ -379,18 +379,18 @@ void SetAuxCursor(SCNHANDLE hFilm) { pim = GetImageFromFilm(hFilm, 0, &pfr, &pmi, &pfilm);// Get pointer to image assert(BgPal()); // no background palette - pim->hImgPal = TO_LE_32(BgPal()); // Poke in the background palette + pim->hImgPal = TO_32(BgPal()); // Poke in the background palette - g_ACoX = (short)(FROM_LE_16(pim->imgWidth)/2 - ((int16) FROM_LE_16(pim->anioffX))); - g_ACoY = (short)((FROM_LE_16(pim->imgHeight) & ~C16_FLAG_MASK)/2 - - ((int16) FROM_LE_16(pim->anioffY))); + g_ACoX = (short)(FROM_16(pim->imgWidth)/2 - ((int16) FROM_16(pim->anioffX))); + g_ACoY = (short)((FROM_16(pim->imgHeight) & ~C16_FLAG_MASK)/2 - + ((int16) FROM_16(pim->anioffY))); // Initialize and insert the auxillary cursor object g_AcurObj = MultiInitObject(pmi); MultiInsertObject(GetPlayfieldList(FIELD_STATUS), g_AcurObj); // Initialize the animation and set its position - InitStepAnimScript(&g_AcurAnim, g_AcurObj, FROM_LE_32(pfr->script), ONE_SECOND / FROM_LE_32(pfilm->frate)); + InitStepAnimScript(&g_AcurAnim, g_AcurObj, FROM_32(pfr->script), ONE_SECOND / FROM_32(pfilm->frate)); MultiSetAniXY(g_AcurObj, x - g_ACoX, y - g_ACoY); MultiSetZPosition(g_AcurObj, Z_ACURSOR); @@ -481,14 +481,14 @@ static void InitCurObj() { if (TinselV2) { pFilm = (const FILM *)LockMem(g_hCursorFilm); pfr = (const FREEL *)&pFilm->reels[0]; - pmi = (MULTI_INIT *)LockMem(FROM_LE_32(pfr->mobj)); + pmi = (MULTI_INIT *)LockMem(FROM_32(pfr->mobj)); PokeInPalette(pmi); } else { assert(BgPal()); // no background palette pim = GetImageFromFilm(g_hCursorFilm, 0, &pfr, &pmi, &pFilm);// Get pointer to image - pim->hImgPal = TO_LE_32(BgPal()); + pim->hImgPal = TO_32(BgPal()); g_AcurObj = NULL; // No auxillary cursor } @@ -496,7 +496,7 @@ static void InitCurObj() { g_McurObj = MultiInitObject(pmi); MultiInsertObject(GetPlayfieldList(FIELD_STATUS), g_McurObj); - InitStepAnimScript(&g_McurAnim, g_McurObj, FROM_LE_32(pfr->script), ONE_SECOND / FROM_LE_32(pFilm->frate)); + InitStepAnimScript(&g_McurAnim, g_McurObj, FROM_32(pfr->script), ONE_SECOND / FROM_32(pFilm->frate)); } /** @@ -620,7 +620,7 @@ void DwInitCursor(SCNHANDLE bfilm) { g_hCursorFilm = bfilm; pfilm = (const FILM *)LockMem(g_hCursorFilm); - g_numTrails = FROM_LE_32(pfilm->numreels) - 1; + g_numTrails = FROM_32(pfilm->numreels) - 1; assert(g_numTrails <= MAX_TRAILERS); } diff --git a/engines/tinsel/dialogs.cpp b/engines/tinsel/dialogs.cpp index 8006bc137f..d0c99f7830 100644 --- a/engines/tinsel/dialogs.cpp +++ b/engines/tinsel/dialogs.cpp @@ -1143,7 +1143,7 @@ static void FirstScene(int first) { // Fill in the rest for (i = 0; i < NUM_RGROUP_BOXES && i + first < g_numScenes; i++) { cd.box[i].textMethod = TM_STRINGNUM; - cd.box[i].ixText = FROM_LE_32(g_pHopper[i + first].hSceneDesc); + cd.box[i].ixText = FROM_32(g_pHopper[i + first].hSceneDesc); } // Blank out the spare ones (if any) while (i < NUM_RGROUP_BOXES) { @@ -1166,10 +1166,10 @@ static void SetChosenScene() { static void FirstEntry(int first) { int i; - g_InvD[INV_MENU].hInvTitle = FROM_LE_32(g_pChosenScene->hSceneDesc); + g_InvD[INV_MENU].hInvTitle = FROM_32(g_pChosenScene->hSceneDesc); // get number of entrances - g_numEntries = FROM_LE_32(g_pChosenScene->numEntries); + g_numEntries = FROM_32(g_pChosenScene->numEntries); // Force first to a sensible value if (first > g_numEntries-NUM_RGROUP_BOXES) @@ -1179,7 +1179,7 @@ static void FirstEntry(int first) { for (i = 0; i < NUM_RGROUP_BOXES && i < g_numEntries; i++) { cd.box[i].textMethod = TM_STRINGNUM; - cd.box[i].ixText = FROM_LE_32(g_pEntries[FROM_LE_32(g_pChosenScene->entryIndex) + i + first].hDesc); + cd.box[i].ixText = FROM_32(g_pEntries[FROM_32(g_pChosenScene->entryIndex) + i + first].hDesc); } // Blank out the spare ones (if any) while (i < NUM_RGROUP_BOXES) { @@ -1191,17 +1191,17 @@ static void FirstEntry(int first) { } static void HopAction() { - PHOPENTRY pEntry = g_pEntries + FROM_LE_32(g_pChosenScene->entryIndex) + cd.selBox + cd.extraBase; + PHOPENTRY pEntry = g_pEntries + FROM_32(g_pChosenScene->entryIndex) + cd.selBox + cd.extraBase; - uint32 hScene = FROM_LE_32(g_pChosenScene->hScene); - uint32 eNumber = FROM_LE_32(pEntry->eNumber); + uint32 hScene = FROM_32(g_pChosenScene->hScene); + uint32 eNumber = FROM_32(pEntry->eNumber); debugC(DEBUG_BASIC, kTinselDebugAnimations, "Scene hopper chose scene %xh,%d\n", hScene, eNumber); - if (FROM_LE_32(pEntry->flags) & fCall) { + if (FROM_32(pEntry->flags) & fCall) { SaveScene(Common::nullContext); NewScene(Common::nullContext, g_pChosenScene->hScene, pEntry->eNumber, TRANS_FADE); } - else if (FROM_LE_32(pEntry->flags) & fHook) + else if (FROM_32(pEntry->flags) & fHook) HookScene(hScene, eNumber, TRANS_FADE); else NewScene(Common::nullContext, hScene, eNumber, TRANS_CUT); @@ -2568,7 +2568,7 @@ static OBJECT *AddInvObject(int num, const FREEL **pfreel, const FILM **pfilm) { pim = GetImageFromFilm(invObj->hIconFilm, 0, pfreel, &pmi, pfilm); // Poke in the background palette - pim->hImgPal = TO_LE_32(BgPal()); + pim->hImgPal = TO_32(BgPal()); // Set up the multi-object pPlayObj = MultiInitObject(pmi); @@ -2609,7 +2609,7 @@ static void FillInInventory() { MultiSetAniXY(g_iconArray[n], g_InvD[g_ino].inventoryX + xpos , g_InvD[g_ino].inventoryY + ypos); MultiSetZPosition(g_iconArray[n], Z_INV_ICONS); - InitStepAnimScript(&g_iconAnims[n], g_iconArray[n], FROM_LE_32(pfr->script), ONE_SECOND / FROM_LE_32(pfilm->frate)); + InitStepAnimScript(&g_iconAnims[n], g_iconArray[n], FROM_32(pfr->script), ONE_SECOND / FROM_32(pfilm->frate)); n++; } @@ -2697,17 +2697,17 @@ static OBJECT *AddObject(const FREEL *pfreel, int num) { pim = GetImageFromReel(pfreel, &pmi); // Poke in the background palette - pim->hImgPal = TO_LE_32(BgPal()); + pim->hImgPal = TO_32(BgPal()); // Horrible bodge involving global variables to save // width and/or height of some window frame components if (num == g_TL) { - g_TLwidth = FROM_LE_16(pim->imgWidth); - g_TLheight = FROM_LE_16(pim->imgHeight) & ~C16_FLAG_MASK; + g_TLwidth = FROM_16(pim->imgWidth); + g_TLheight = FROM_16(pim->imgHeight) & ~C16_FLAG_MASK; } else if (num == g_TR) { - g_TRwidth = FROM_LE_16(pim->imgWidth); + g_TRwidth = FROM_16(pim->imgWidth); } else if (num == g_BL) { - g_BLheight = FROM_LE_16(pim->imgHeight) & ~C16_FLAG_MASK; + g_BLheight = FROM_16(pim->imgHeight) & ~C16_FLAG_MASK; } // Set up and insert the multi-object @@ -3406,9 +3406,9 @@ static void AlterCursor(int num) { pim = GetImageFromFilm(g_hWinParts, num, &pfreel); // Poke in the background palette - pim->hImgPal = TO_LE_32(BgPal()); + pim->hImgPal = TO_32(BgPal()); - SetTempCursor(FROM_LE_32(pfreel->script)); + SetTempCursor(FROM_32(pfreel->script)); } enum InvCursorFN {IC_AREA, IC_DROP}; @@ -5657,7 +5657,7 @@ extern void setInvWinParts(SCNHANDLE hf) { #ifdef DEBUG pfilm = (const FILM *)LockMem(hf); - assert(FROM_LE_32(pfilm->numreels) >= (uint32)(TinselV2 ? T2_HOPEDFORREELS : T1_HOPEDFORREELS)); // not as many reels as expected + assert(FROM_32(pfilm->numreels) >= (uint32)(TinselV2 ? T2_HOPEDFORREELS : T1_HOPEDFORREELS)); // not as many reels as expected #endif } @@ -5674,7 +5674,7 @@ extern void setFlagFilms(SCNHANDLE hf) { #ifdef DEBUG pfilm = (const FILM *)LockMem(hf); - assert(FROM_LE_32(pfilm->numreels) >= HOPEDFORFREELS); // not as many reels as expected + assert(FROM_32(pfilm->numreels) >= HOPEDFORFREELS); // not as many reels as expected #endif } diff --git a/engines/tinsel/faders.cpp b/engines/tinsel/faders.cpp index c1574ff963..a03dc4f369 100644 --- a/engines/tinsel/faders.cpp +++ b/engines/tinsel/faders.cpp @@ -117,10 +117,10 @@ static void FadeProcess(CORO_PARAM, const void *param) { pFade->pPalQ->numColors, (uint32) *_ctx->pColMult); else FadePalette(_ctx->fadeRGB, _ctx->pPalette->palRGB, - FROM_LE_32(_ctx->pPalette->numColors), (uint32) *_ctx->pColMult); + FROM_32(_ctx->pPalette->numColors), (uint32) *_ctx->pColMult); // send new palette to video DAC - UpdateDACqueue(pFade->pPalQ->posInDAC, FROM_LE_32(_ctx->pPalette->numColors), _ctx->fadeRGB); + UpdateDACqueue(pFade->pPalQ->posInDAC, FROM_32(_ctx->pPalette->numColors), _ctx->fadeRGB); // allow time for video DAC to be updated CORO_SLEEP(1); diff --git a/engines/tinsel/font.cpp b/engines/tinsel/font.cpp index 54aa7cc15f..3dba56468b 100644 --- a/engines/tinsel/font.cpp +++ b/engines/tinsel/font.cpp @@ -102,16 +102,16 @@ void FettleFontPal(SCNHANDLE fontPal) { assert(g_hTalkFont); // Talk font not declared pFont = (const FONT *)LockMem(g_hTagFont); - pImg = (IMAGE *)LockMem(FROM_LE_32(pFont->fontInit.hObjImg)); // get image for char 0 + pImg = (IMAGE *)LockMem(FROM_32(pFont->fontInit.hObjImg)); // get image for char 0 if (!TinselV2) - pImg->hImgPal = TO_LE_32(fontPal); + pImg->hImgPal = TO_32(fontPal); else pImg->hImgPal = 0; pFont = (const FONT *)LockMem(g_hTalkFont); - pImg = (IMAGE *)LockMem(FROM_LE_32(pFont->fontInit.hObjImg)); // get image for char 0 + pImg = (IMAGE *)LockMem(FROM_32(pFont->fontInit.hObjImg)); // get image for char 0 if (!TinselV2) - pImg->hImgPal = TO_LE_32(fontPal); + pImg->hImgPal = TO_32(fontPal); else pImg->hImgPal = 0; diff --git a/engines/tinsel/graphics.cpp b/engines/tinsel/graphics.cpp index 9b06b1a501..4487a94df8 100644 --- a/engines/tinsel/graphics.cpp +++ b/engines/tinsel/graphics.cpp @@ -73,7 +73,7 @@ uint8* psxPJCRLEUnwinder(uint16 imageWidth, uint16 imageHeight, uint8 *srcIdx) { while (remainingBlocks) { // Repeat until all blocks are decompressed if (!controlBits) { - controlData = READ_LE_UINT16(srcIdx); + controlData = READ_16(srcIdx); srcIdx += 2; // If bit 15 of controlData is enabled, compression data is type 1. @@ -92,7 +92,7 @@ uint8* psxPJCRLEUnwinder(uint16 imageWidth, uint16 imageHeight, uint8 *srcIdx) { // If there is compression, we need to fetch an index // to be treated as "base" for compression. if (compressionType != 0) { - controlData = READ_LE_UINT16(srcIdx); + controlData = READ_16(srcIdx); srcIdx += 2; baseIndex = controlData; } @@ -114,7 +114,7 @@ uint8* psxPJCRLEUnwinder(uint16 imageWidth, uint16 imageHeight, uint8 *srcIdx) { switch (compressionType) { case 0: // No compression, plain copy of indexes while (decremTiles) { - WRITE_LE_UINT16(dstIdx, READ_LE_UINT16(srcIdx)); + WRITE_LE_UINT16(dstIdx, READ_16(srcIdx)); srcIdx += 2; dstIdx += 2; decremTiles--; @@ -272,7 +272,7 @@ static void PsxDrawTiles(DRAWOBJECT *pObj, uint8 *srcP, uint8 *destP, bool apply assert(boxBounds.bottom >= boxBounds.top); assert(boxBounds.right >= boxBounds.left); - int16 indexVal = READ_LE_UINT16(srcP); + int16 indexVal = READ_16(srcP); srcP += sizeof(uint16); // Draw a 4x4 block based on the opcode as in index into the block list @@ -381,7 +381,7 @@ static void WrtNonZero(DRAWOBJECT *pObj, uint8 *srcP, uint8 *destP, bool applyCl assert(boxBounds.bottom >= boxBounds.top); assert(boxBounds.right >= boxBounds.left); - int16 indexVal = READ_LE_UINT16(srcP); + int16 indexVal = READ_16(srcP); srcP += sizeof(uint16); if (indexVal >= 0) { @@ -763,8 +763,8 @@ void DrawObject(DRAWOBJECT *pObj) { byte *p = (byte *)LockMem(pObj->hBits & HANDLEMASK); srcPtr = p + (pObj->hBits & OFFSETMASK); - pObj->charBase = (char *)p + READ_LE_UINT32(p + 0x10); - pObj->transOffset = READ_LE_UINT32(p + 0x14); + pObj->charBase = (char *)p + READ_32(p + 0x10); + pObj->transOffset = READ_32(p + 0x14); // Decompress block indexes for Discworld PSX if (TinselV1PSX) { @@ -793,7 +793,7 @@ void DrawObject(DRAWOBJECT *pObj) { psxPaletteMapper(pObj->pPal, srcPtr + sizeof(uint16), psxMapperTable); psxFourBitClut = true; - psxSkipBytes = READ_LE_UINT32(p + sizeof(uint32) * 5) << 4; // Fetch number of bytes we have to skip + psxSkipBytes = READ_32(p + sizeof(uint32) * 5) << 4; // Fetch number of bytes we have to skip switch (indexType) { case 0xDD: // Normal uncompressed indexes psxRLEindex = false; @@ -905,19 +905,16 @@ void DrawObject(DRAWOBJECT *pObj) { case 0x48: WrtNonZero(pObj, srcPtr, destPtr, typeId >= 0x40); break; - case 0x04: case 0x44: // WrtConst with/without clipping WrtConst(pObj, destPtr, typeId == 0x44); break; - case 0x84: case 0xC4: // WrtTrans with/without clipping WrtTrans(pObj, destPtr, typeId == 0xC4); break; - default: error("Unknown drawing type %d", typeId); } diff --git a/engines/tinsel/multiobj.cpp b/engines/tinsel/multiobj.cpp index c48fefdd22..37769a7819 100644 --- a/engines/tinsel/multiobj.cpp +++ b/engines/tinsel/multiobj.cpp @@ -40,22 +40,22 @@ OBJECT *MultiInitObject(const MULTI_INIT *pInitTbl) { OBJECT *pFirst, *pObj; // object pointers FRAME *pFrame; // list of images for the multi-part object - if (FROM_LE_32(pInitTbl->hMulFrame)) { + if (FROM_32(pInitTbl->hMulFrame)) { // we have a frame handle - pFrame = (FRAME *)LockMem(FROM_LE_32(pInitTbl->hMulFrame)); + pFrame = (FRAME *)LockMem(FROM_32(pInitTbl->hMulFrame)); - obj_init.hObjImg = READ_LE_UINT32(pFrame); // first objects shape + obj_init.hObjImg = READ_32(pFrame); // first objects shape } else { // this must be a animation list for a NULL object pFrame = NULL; obj_init.hObjImg = 0; // first objects shape } // init the object init table - obj_init.objFlags = (int)FROM_LE_32(pInitTbl->mulFlags); // all objects have same flags - obj_init.objID = (int)FROM_LE_32(pInitTbl->mulID); // all objects have same ID - obj_init.objX = (int)FROM_LE_32(pInitTbl->mulX); // all objects have same X ani pos - obj_init.objY = (int)FROM_LE_32(pInitTbl->mulY); // all objects have same Y ani pos - obj_init.objZ = (int)FROM_LE_32(pInitTbl->mulZ); // all objects have same Z pos + obj_init.objFlags = (int)FROM_32(pInitTbl->mulFlags); // all objects have same flags + obj_init.objID = (int)FROM_32(pInitTbl->mulID); // all objects have same ID + obj_init.objX = (int)FROM_32(pInitTbl->mulX); // all objects have same X ani pos + obj_init.objY = (int)FROM_32(pInitTbl->mulY); // all objects have same Y ani pos + obj_init.objZ = (int)FROM_32(pInitTbl->mulZ); // all objects have same Z pos // create and init the first object pObj = pFirst = InitObject(&obj_init); @@ -65,9 +65,9 @@ OBJECT *MultiInitObject(const MULTI_INIT *pInitTbl) { pFrame++; - while (READ_LE_UINT32(pFrame) != 0) { + while (READ_32(pFrame) != 0) { // set next objects shape - obj_init.hObjImg = READ_LE_UINT32(pFrame); + obj_init.hObjImg = READ_32(pFrame); // create next object and link to previous pObj = pObj->pSlave = InitObject(&obj_init); @@ -378,9 +378,9 @@ void MultiReshape(OBJECT *pMultiObj) { // update previous pMultiObj->hMirror = hFrame; - while (READ_LE_UINT32(pFrame) != 0 && pMultiObj != NULL) { + while (READ_32(pFrame) != 0 && pMultiObj != NULL) { // a normal image - update the current object with this image - AnimateObject(pMultiObj, READ_LE_UINT32(pFrame)); + AnimateObject(pMultiObj, READ_32(pFrame)); // move to next image for this frame pFrame++; diff --git a/engines/tinsel/music.cpp b/engines/tinsel/music.cpp index 15406c5d43..952b629f08 100644 --- a/engines/tinsel/music.cpp +++ b/engines/tinsel/music.cpp @@ -788,8 +788,8 @@ bool PCMMusicPlayer::getNextChunk() { // Set parameters for this chunk of music id = _scriptNum; while (id--) - script = scriptBuffer + READ_LE_UINT32(script); - snum = FROM_LE_32(script[_scriptIndex++]); + script = scriptBuffer + READ_32(script); + snum = FROM_32(script[_scriptIndex++]); if (snum == MUSIC_JUMP || snum == MUSIC_END) { // Let usual code sort it out! @@ -801,11 +801,11 @@ bool PCMMusicPlayer::getNextChunk() { musicSegments = (MusicSegment *) LockMem(_hSegment); - assert(FROM_LE_32(musicSegments[snum].numChannels) == 1); - assert(FROM_LE_32(musicSegments[snum].bitsPerSample) == 16); + assert(FROM_32(musicSegments[snum].numChannels) == 1); + assert(FROM_32(musicSegments[snum].bitsPerSample) == 16); - sampleOffset = FROM_LE_32(musicSegments[snum].sampleOffset); - sampleLength = FROM_LE_32(musicSegments[snum].sampleLength); + sampleOffset = FROM_32(musicSegments[snum].sampleOffset); + sampleLength = FROM_32(musicSegments[snum].sampleLength); sampleCLength = (((sampleLength + 63) & ~63)*33)/64; if (!file.open(_filename)) @@ -843,14 +843,14 @@ bool PCMMusicPlayer::getNextChunk() { id = _scriptNum; while (id--) - script = scriptBuffer + READ_LE_UINT32(script); - snum = FROM_LE_32(script[_scriptIndex]); + script = scriptBuffer + READ_32(script); + snum = FROM_32(script[_scriptIndex]); if (snum == MUSIC_END) { _state = S_END2; } else { if (snum == MUSIC_JUMP) - _scriptIndex = FROM_LE_32(script[_scriptIndex+1]); + _scriptIndex = FROM_32(script[_scriptIndex+1]); _state = _forcePlay ? S_NEW : S_NEXT; _forcePlay = false; diff --git a/engines/tinsel/object.cpp b/engines/tinsel/object.cpp index cbe5b0a88f..c9a392f192 100644 --- a/engines/tinsel/object.cpp +++ b/engines/tinsel/object.cpp @@ -302,23 +302,23 @@ void GetAniOffset(SCNHANDLE hImg, int flags, int *pAniX, int *pAniY) { const IMAGE *pImg = (const IMAGE *)LockMem(hImg); // set ani X - *pAniX = (int16) FROM_LE_16(pImg->anioffX); + *pAniX = (int16) FROM_16(pImg->anioffX); // set ani Y - *pAniY = (int16) FROM_LE_16(pImg->anioffY); + *pAniY = (int16) FROM_16(pImg->anioffY); if (flags & DMA_FLIPH) { // we are flipped horizontally // set ani X = -ani X + width - 1 - *pAniX = -*pAniX + FROM_LE_16(pImg->imgWidth) - 1; + *pAniX = -*pAniX + FROM_16(pImg->imgWidth) - 1; } if (flags & DMA_FLIPV) { // we are flipped vertically // set ani Y = -ani Y + height - 1 - *pAniY = -*pAniY + (FROM_LE_16(pImg->imgHeight) & ~C16_FLAG_MASK) - 1; + *pAniY = -*pAniY + (FROM_16(pImg->imgHeight) & ~C16_FLAG_MASK) - 1; } } else // null image @@ -385,13 +385,13 @@ OBJECT *InitObject(const OBJ_INIT *pInitTbl) { pObj->pPal = pPalQ; // set objects size - pObj->width = FROM_LE_16(pImg->imgWidth); - pObj->height = FROM_LE_16(pImg->imgHeight) & ~C16_FLAG_MASK; + pObj->width = FROM_16(pImg->imgWidth); + pObj->height = FROM_16(pImg->imgHeight) & ~C16_FLAG_MASK; pObj->flags &= ~C16_FLAG_MASK; - pObj->flags |= FROM_LE_16(pImg->imgHeight) & C16_FLAG_MASK; + pObj->flags |= FROM_16(pImg->imgHeight) & C16_FLAG_MASK; // set objects bitmap definition - pObj->hBits = FROM_LE_32(pImg->hImgBits); + pObj->hBits = FROM_32(pImg->hImgBits); // get animation offset of object GetAniOffset(pObj->hImg, pInitTbl->objFlags, &aniX, &aniY); @@ -442,13 +442,13 @@ void AnimateObjectFlags(OBJECT *pAniObj, int newflags, SCNHANDLE hNewImg) { const IMAGE *pNewImg = (IMAGE *)LockMem(hNewImg); // setup new shape - pAniObj->width = FROM_LE_16(pNewImg->imgWidth); - pAniObj->height = FROM_LE_16(pNewImg->imgHeight) & ~C16_FLAG_MASK; + pAniObj->width = FROM_16(pNewImg->imgWidth); + pAniObj->height = FROM_16(pNewImg->imgHeight) & ~C16_FLAG_MASK; newflags &= ~C16_FLAG_MASK; - newflags |= FROM_LE_16(pNewImg->imgHeight) & C16_FLAG_MASK; + newflags |= FROM_16(pNewImg->imgHeight) & C16_FLAG_MASK; // set objects bitmap definition - pAniObj->hBits = FROM_LE_32(pNewImg->hImgBits); + pAniObj->hBits = FROM_32(pNewImg->hImgBits); } else { // null image pAniObj->width = 0; pAniObj->height = 0; diff --git a/engines/tinsel/palette.cpp b/engines/tinsel/palette.cpp index e6c9467fab..9155386bbc 100644 --- a/engines/tinsel/palette.cpp +++ b/engines/tinsel/palette.cpp @@ -102,7 +102,7 @@ void psxPaletteMapper(PALQ *originalPal, uint8 *psxClut, byte *mapperTable) { memset(mapperTable, 0, 16); for (int j = 1; j < 16; j++) { - clutEntry = READ_LE_UINT16(psxClut + (sizeof(uint16) * j)); + clutEntry = READ_16(psxClut + (sizeof(uint16) * j)); if (clutEntry) { if (clutEntry == 0x7EC0) { // This is an already known value, used by the in-game text mapperTable[j] = 232; @@ -110,7 +110,7 @@ void psxPaletteMapper(PALQ *originalPal, uint8 *psxClut, byte *mapperTable) { } // Check for correspondent color - for (uint i = 0; (i < FROM_LE_32(pal->numColors)) && !colorFound; i++) { + for (uint i = 0; (i < FROM_32(pal->numColors)) && !colorFound; i++) { // get R G B values in the same way as psx format converters uint16 psxEquivalent = TINSEL_PSX_RGB(TINSEL_GetRValue(pal->palRGB[i]) >> 3, TINSEL_GetGValue(pal->palRGB[i]) >> 3, TINSEL_GetBValue(pal->palRGB[i]) >> 3); @@ -152,7 +152,7 @@ void PalettesToVideoDAC() { // we are using a palette handle // get hardware palette pointer - pPalette = (const PALETTE *)LockMem(pDACtail->pal.hRGBarray); + pPalette = (const PALETTE *)LockMem(FROM_32(pDACtail->pal.hRGBarray)); // get RGB pointer pColors = pPalette->palRGB; @@ -318,7 +318,7 @@ PALQ *AllocPalette(SCNHANDLE hNewPal) { p->objCount = 1; // init number of objects using palette p->posInDAC = iDAC; // set palettes start pos in video DAC p->hPal = hNewPal; // set hardware palette data - p->numColors = FROM_LE_32(pNewPal->numColors); // set number of colors in palette + p->numColors = FROM_32(pNewPal->numColors); // set number of colors in palette if (TinselV2) // Copy all the colors @@ -430,24 +430,24 @@ void SwapPalette(PALQ *pPalQ, SCNHANDLE hNewPal) { // validate palette Q pointer assert(pPalQ >= g_palAllocData && pPalQ <= g_palAllocData + NUM_PALETTES - 1); - if (pPalQ->numColors >= (int)FROM_LE_32(pNewPal->numColors)) { + if (pPalQ->numColors >= (int)FROM_32(pNewPal->numColors)) { // new palette will fit the slot // install new palette pPalQ->hPal = hNewPal; if (TinselV2) { - pPalQ->numColors = FROM_LE_32(pNewPal->numColors); + pPalQ->numColors = FROM_32(pNewPal->numColors); // Copy all the colors - memcpy(pPalQ->palRGB, pNewPal->palRGB, FROM_LE_32(pNewPal->numColors) * sizeof(COLORREF)); + memcpy(pPalQ->palRGB, pNewPal->palRGB, FROM_32(pNewPal->numColors) * sizeof(COLORREF)); if (!pPalQ->bFading) // Q the change to the video DAC - UpdateDACqueue(pPalQ->posInDAC, FROM_LE_32(pNewPal->numColors), pPalQ->palRGB); + UpdateDACqueue(pPalQ->posInDAC, FROM_32(pNewPal->numColors), pPalQ->palRGB); } else { // Q the change to the video DAC - UpdateDACqueueHandle(pPalQ->posInDAC, FROM_LE_32(pNewPal->numColors), hNewPal); + UpdateDACqueueHandle(pPalQ->posInDAC, FROM_32(pNewPal->numColors), hNewPal); } } else { // # colors are different - will have to update all following palette entries @@ -546,7 +546,7 @@ void CreateTranslucentPalette(SCNHANDLE hPalette) { // leave background color alone g_transPalette[0] = 0; - for (uint i = 0; i < FROM_LE_32(pPal->numColors); i++) { + for (uint i = 0; i < FROM_32(pPal->numColors); i++) { // get the RGB color model values uint8 red = TINSEL_GetRValue(pPal->palRGB[i]); uint8 green = TINSEL_GetGValue(pPal->palRGB[i]); @@ -574,7 +574,7 @@ void CreateGhostPalette(SCNHANDLE hPalette) { // leave background color alone g_ghostPalette[0] = 0; - for (i = 0; i < (int)FROM_LE_32(pPal->numColors); i++) { + for (i = 0; i < (int)FROM_32(pPal->numColors); i++) { // get the RGB color model values uint8 red = TINSEL_GetRValue(pPal->palRGB[i]); uint8 green = TINSEL_GetGValue(pPal->palRGB[i]); diff --git a/engines/tinsel/palette.h b/engines/tinsel/palette.h index af58a7ffbd..49a78ae236 100644 --- a/engines/tinsel/palette.h +++ b/engines/tinsel/palette.h @@ -30,11 +30,11 @@ namespace Tinsel { typedef uint32 COLORREF; -#define TINSEL_RGB(r,g,b) ((COLORREF)TO_LE_32(((uint8)(r)|((uint16)(g)<<8))|(((uint32)(uint8)(b))<<16))) +#define TINSEL_RGB(r,g,b) ((COLORREF)TO_32(((uint8)(r)|((uint16)(g)<<8))|(((uint32)(uint8)(b))<<16))) -#define TINSEL_GetRValue(rgb) ((uint8)(FROM_LE_32(rgb))) -#define TINSEL_GetGValue(rgb) ((uint8)(((uint16)(FROM_LE_32(rgb)))>>8)) -#define TINSEL_GetBValue(rgb) ((uint8)((FROM_LE_32(rgb))>>16)) +#define TINSEL_GetRValue(rgb) ((uint8)(FROM_32(rgb))) +#define TINSEL_GetGValue(rgb) ((uint8)(((uint16)(FROM_32(rgb)))>>8)) +#define TINSEL_GetBValue(rgb) ((uint8)((FROM_32(rgb))>>16)) #define TINSEL_PSX_RGB(r,g,b) ((uint16)(((uint8)(r))|((uint16)(g)<<5)|(((uint16)(b))<<10))) diff --git a/engines/tinsel/pcode.cpp b/engines/tinsel/pcode.cpp index 04bc2856ca..7e439e83a9 100644 --- a/engines/tinsel/pcode.cpp +++ b/engines/tinsel/pcode.cpp @@ -420,7 +420,7 @@ void RegisterGlobals(int num) { g_numGlobals = num; g_hMasterScript = !TinselV2 ? 0 : - READ_LE_UINT32(FindChunk(MASTER_SCNHANDLE, CHUNK_MASTER_SCRIPT)); + READ_32(FindChunk(MASTER_SCNHANDLE, CHUNK_MASTER_SCRIPT)); // Allocate RAM for pGlobals and make sure it's allocated g_pGlobals = (int32 *)calloc(g_numGlobals, sizeof(int32)); diff --git a/engines/tinsel/play.cpp b/engines/tinsel/play.cpp index 9e0baa749e..e202278953 100644 --- a/engines/tinsel/play.cpp +++ b/engines/tinsel/play.cpp @@ -81,9 +81,9 @@ static void PokeInPalette(SCNHANDLE hMulFrame) { pFrame = (const FRAME *)LockMem(hMulFrame); // get pointer to image - pim = (IMAGE *)LockMem(READ_LE_UINT32(pFrame)); // handle to image + pim = (IMAGE *)LockMem(READ_32(pFrame)); // handle to image - pim->hImgPal = TO_LE_32(BgPal()); + pim->hImgPal = TO_32(BgPal()); } } @@ -96,12 +96,12 @@ void PokeInPalette(const MULTI_INIT *pmi) { // Could be an empty column if (pmi->hMulFrame) { - pFrame = (FRAME *)LockMem(FROM_LE_32(pmi->hMulFrame)); + pFrame = (FRAME *)LockMem(FROM_32(pmi->hMulFrame)); // get pointer to image - pim = (IMAGE *)LockMem(READ_LE_UINT32(pFrame)); // handle to image + pim = (IMAGE *)LockMem(READ_32(pFrame)); // handle to image - pim->hImgPal = TO_LE_32(BgPal()); + pim->hImgPal = TO_32(BgPal()); } } @@ -234,8 +234,8 @@ static void SoundReel(CORO_PARAM, SCNHANDLE hFilm, int column, int speed, PMULTI_INIT pmi; // MULTI_INIT structure pReel = GetReel(hFilm, actorCol - 1); - pmi = (PMULTI_INIT) LockMem(FROM_LE_32(pReel->mobj)); - _ctx->reelActor = (int32)FROM_LE_32(pmi->mulID); + pmi = (PMULTI_INIT) LockMem(FROM_32(pReel->mobj)); + _ctx->reelActor = (int32)FROM_32(pmi->mulID); } else _ctx->reelActor = 0; @@ -251,27 +251,27 @@ static void SoundReel(CORO_PARAM, SCNHANDLE hFilm, int column, int speed, pFilm = (FILM *)LockMem(hFilm); pReel = &pFilm->reels[column]; - pAni = (ANI_SCRIPT *)LockMem(FROM_LE_32(pReel->script)); + pAni = (ANI_SCRIPT *)LockMem(FROM_32(pReel->script)); if (_ctx->speed == -1) { - _ctx->speed = (ONE_SECOND/FROM_LE_32(pFilm->frate)); + _ctx->speed = (ONE_SECOND/FROM_32(pFilm->frate)); // Restored reel for (;;) { - if (FROM_LE_32(pAni[_ctx->frameNumber].op) == ANI_END) + if (FROM_32(pAni[_ctx->frameNumber].op) == ANI_END) break; - else if (FROM_LE_32(pAni[_ctx->frameNumber].op) == ANI_JUMP) { + else if (FROM_32(pAni[_ctx->frameNumber].op) == ANI_JUMP) { _ctx->frameNumber++; - _ctx->frameNumber += FROM_LE_32(pAni[_ctx->frameNumber].op); + _ctx->frameNumber += FROM_32(pAni[_ctx->frameNumber].op); break; } // Could check for the other stuff here // but they really dont happen // OH YES THEY DO - else if (FROM_LE_32(pAni[_ctx->frameNumber].op) == ANI_ADJUSTX - || FROM_LE_32(pAni[_ctx->frameNumber].op) == ANI_ADJUSTY) { + else if (FROM_32(pAni[_ctx->frameNumber].op) == ANI_ADJUSTX + || FROM_32(pAni[_ctx->frameNumber].op) == ANI_ADJUSTY) { _ctx->frameNumber += 2; - } else if (FROM_LE_32(pAni[_ctx->frameNumber].op) == ANI_ADJUSTXY) { + } else if (FROM_32(pAni[_ctx->frameNumber].op) == ANI_ADJUSTXY) { _ctx->frameNumber += 3; } else { // ANI_STOP, ANI_HIDE, ANI_HFLIP, @@ -281,7 +281,7 @@ static void SoundReel(CORO_PARAM, SCNHANDLE hFilm, int column, int speed, } } - switch (FROM_LE_32(pAni[_ctx->frameNumber].op)) { + switch (FROM_32(pAni[_ctx->frameNumber].op)) { case ANI_END: // Stop this sample if repeating if (_ctx->sampleNumber && _ctx->bLooped) @@ -292,9 +292,9 @@ static void SoundReel(CORO_PARAM, SCNHANDLE hFilm, int column, int speed, case ANI_JUMP: _ctx->frameNumber++; - assert((int32)FROM_LE_32(pAni[_ctx->frameNumber].op) < 0); + assert((int32)FROM_32(pAni[_ctx->frameNumber].op) < 0); - _ctx->frameNumber += FROM_LE_32(pAni[_ctx->frameNumber].op); + _ctx->frameNumber += FROM_32(pAni[_ctx->frameNumber].op); assert(_ctx->frameNumber >= 0); continue; @@ -329,15 +329,15 @@ static void SoundReel(CORO_PARAM, SCNHANDLE hFilm, int column, int speed, if (_ctx->sampleNumber) _vm->_sound->stopSpecSample(_ctx->sampleNumber, 0); - _ctx->sampleNumber = FROM_LE_32(pAni[_ctx->frameNumber++].op); + _ctx->sampleNumber = FROM_32(pAni[_ctx->frameNumber++].op); if (_ctx->sampleNumber > 0) _ctx->bLooped = false; else { _ctx->sampleNumber = ~_ctx->sampleNumber; _ctx->bLooped = true; } - x = (short)(FROM_LE_32(pAni[_ctx->frameNumber].op) >> 16); - y = (short)(FROM_LE_32(pAni[_ctx->frameNumber].op) & 0xffff); + x = (short)(FROM_32(pAni[_ctx->frameNumber].op) >> 16); + y = (short)(FROM_32(pAni[_ctx->frameNumber].op) & 0xffff); if (x == 0) x = -1; @@ -451,10 +451,10 @@ static void t1PlayReel(CORO_PARAM, const PPINIT *ppi) { _ctx->pfreel = &pfilm->reels[ppi->column]; // Get the MULTI_INIT structure - pmi = (const MULTI_INIT *)LockMem(FROM_LE_32(_ctx->pfreel->mobj)); + pmi = (const MULTI_INIT *)LockMem(FROM_32(_ctx->pfreel->mobj)); // Save actor's ID - _ctx->reelActor = (int32)FROM_LE_32(pmi->mulID); + _ctx->reelActor = (int32)FROM_32(pmi->mulID); /**** New (experimental? bit 5/1/95 ****/ if (!TinselV0 && !actorAlive(_ctx->reelActor)) @@ -488,7 +488,7 @@ static void t1PlayReel(CORO_PARAM, const PPINIT *ppi) { return; // Poke in the background palette - PokeInPalette(FROM_LE_32(pmi->hMulFrame)); + PokeInPalette(FROM_32(pmi->hMulFrame)); // Set up and insert the multi-object _ctx->pPlayObj = MultiInitObject(pmi); @@ -534,7 +534,7 @@ static void t1PlayReel(CORO_PARAM, const PPINIT *ppi) { if (ppi->actorid == 0 && !actorAlive(_ctx->reelActor)) _ctx->lifeNoMatter = true; - InitStepAnimScript(&_ctx->thisAnim, _ctx->pPlayObj, FROM_LE_32(_ctx->pfreel->script), ppi->speed); + InitStepAnimScript(&_ctx->thisAnim, _ctx->pPlayObj, FROM_32(_ctx->pfreel->script), ppi->speed); // If first column, set Z position as per // Otherwise, column 0's + column number @@ -706,16 +706,16 @@ static void t2PlayReel(CORO_PARAM, int x, int y, bool bRestore, int speed, SCNHA // Get the reel and MULTI_INIT structure _ctx->pFreel = GetReel(hFilm, column); - _ctx->pmi = (MULTI_INIT *)LockMem(FROM_LE_32(_ctx->pFreel->mobj)); + _ctx->pmi = (MULTI_INIT *)LockMem(FROM_32(_ctx->pFreel->mobj)); - if ((int32)FROM_LE_32(_ctx->pmi->mulID) == -2) { + if ((int32)FROM_32(_ctx->pmi->mulID) == -2) { CORO_INVOKE_ARGS(SoundReel, (CORO_SUBCTX, hFilm, column, speed, myescEvent, - FROM_LE_32(_ctx->pmi->otherFlags) & OTH_RELATEDACTOR)); + FROM_32(_ctx->pmi->otherFlags) & OTH_RELATEDACTOR)); return; } // Save actor's ID - _ctx->reelActor = FROM_LE_32(_ctx->pmi->mulID); + _ctx->reelActor = FROM_32(_ctx->pmi->mulID); UpdateActorEsc(_ctx->reelActor, myescEvent); @@ -759,8 +759,8 @@ static void t2PlayReel(CORO_PARAM, int x, int y, bool bRestore, int speed, SCNHA // Set ghost bit if wanted if (ActorIsGhost(_ctx->reelActor)) { - assert(FROM_LE_32(_ctx->pmi->mulFlags) == DMA_WNZ || FROM_LE_32(_ctx->pmi->mulFlags) == (DMA_WNZ | DMA_GHOST)); - _ctx->pmi->mulFlags = TO_LE_32(FROM_LE_32(_ctx->pmi->mulFlags) | DMA_GHOST); + assert(FROM_32(_ctx->pmi->mulFlags) == DMA_WNZ || FROM_32(_ctx->pmi->mulFlags) == (DMA_WNZ | DMA_GHOST)); + _ctx->pmi->mulFlags = TO_32(FROM_32(_ctx->pmi->mulFlags) | DMA_GHOST); } // Set up and insert the multi-object @@ -793,10 +793,10 @@ static void t2PlayReel(CORO_PARAM, int x, int y, bool bRestore, int speed, SCNHA /* * Sort out x and y */ - assert( ((FROM_LE_32(_ctx->pmi->otherFlags) & OTH_RELATIVE) && !(FROM_LE_32(_ctx->pmi->otherFlags) & OTH_ABSOLUTE)) - || ((FROM_LE_32(_ctx->pmi->otherFlags) & OTH_ABSOLUTE) && !(FROM_LE_32(_ctx->pmi->otherFlags) & OTH_RELATIVE)) ); + assert( ((FROM_32(_ctx->pmi->otherFlags) & OTH_RELATIVE) && !(FROM_32(_ctx->pmi->otherFlags) & OTH_ABSOLUTE)) + || ((FROM_32(_ctx->pmi->otherFlags) & OTH_ABSOLUTE) && !(FROM_32(_ctx->pmi->otherFlags) & OTH_RELATIVE)) ); - _ctx->bRelative = FROM_LE_32(_ctx->pmi->otherFlags) & OTH_RELATIVE; + _ctx->bRelative = FROM_32(_ctx->pmi->otherFlags) & OTH_RELATIVE; if (_ctx->bRelative) { // Use actor's position. If (x, y) specified, move the actor. @@ -808,7 +808,7 @@ static void t2PlayReel(CORO_PARAM, int x, int y, bool bRestore, int speed, SCNHA x = y = 0; // Use (0,0) if no specified // Add embedded co-ords - MultiSetAniXY(_ctx->pPlayObj, x + FROM_LE_32(_ctx->pmi->mulX), y + FROM_LE_32(_ctx->pmi->mulY)); + MultiSetAniXY(_ctx->pPlayObj, x + FROM_32(_ctx->pmi->mulX), y + FROM_32(_ctx->pmi->mulY)); /* * Sort out z @@ -824,10 +824,10 @@ static void t2PlayReel(CORO_PARAM, int x, int y, bool bRestore, int speed, SCNHA // N.B. It HAS been ensured that the first column gets here first - if ((int32)FROM_LE_32(_ctx->pmi->mulZ) != -1) { + if ((int32)FROM_32(_ctx->pmi->mulZ) != -1) { // Z override in script - baseZfact = FROM_LE_32(_ctx->pmi->mulZ); + baseZfact = FROM_32(_ctx->pmi->mulZ); baseZposn = (baseZfact << ZSHIFT) + MultiLowest(_ctx->pPlayObj); if (bTop) baseZposn += Z_TOPPLAY; @@ -850,7 +850,7 @@ static void t2PlayReel(CORO_PARAM, int x, int y, bool bRestore, int speed, SCNHA * another reel starts up for this actor, * or the actor gets killed. */ - InitStepAnimScript(&_ctx->thisAnim, _ctx->pPlayObj, FROM_LE_32(_ctx->pFreel->script), speed); + InitStepAnimScript(&_ctx->thisAnim, _ctx->pPlayObj, FROM_32(_ctx->pFreel->script), speed); if (bRestore || (ActorEsc(_ctx->reelActor) == true && ActorEev(_ctx->reelActor) != GetEscEvents())) { @@ -952,10 +952,10 @@ void NewestFilm(SCNHANDLE film, const FREEL *reel) { const MULTI_INIT *pmi; // MULTI_INIT structure // Get the MULTI_INIT structure - pmi = (const MULTI_INIT *)LockMem(FROM_LE_32(reel->mobj)); + pmi = (const MULTI_INIT *)LockMem(FROM_32(reel->mobj)); - if (!TinselV2 || ((int32)FROM_LE_32(pmi->mulID) != -2)) - SetActorLatestFilm((int32)FROM_LE_32(pmi->mulID), film); + if (!TinselV2 || ((int32)FROM_32(pmi->mulID) != -2)) + SetActorLatestFilm((int32)FROM_32(pmi->mulID), film); } // ******************************************************* @@ -988,7 +988,7 @@ void PlayFilm(CORO_PARAM, SCNHANDLE hFilm, int x, int y, int actorid, bool splay ppi.y = y; ppi.z = 0; ppi.bRestore = false; - ppi.speed = (ONE_SECOND / FROM_LE_32(pFilm->frate)); + ppi.speed = (ONE_SECOND / FROM_32(pFilm->frate)); ppi.actorid = actorid; ppi.splay = splay; ppi.bTop = bTop; @@ -997,7 +997,7 @@ void PlayFilm(CORO_PARAM, SCNHANDLE hFilm, int x, int y, int actorid, bool splay ppi.myescEvent = myescEvent; // Start display process for each reel in the film - for (int i = FROM_LE_32(pFilm->numreels) - 1; i >= 0; i--) { + for (int i = FROM_32(pFilm->numreels) - 1; i >= 0; i--) { NewestFilm(hFilm, &pFilm->reels[i]); ppi.column = i; @@ -1049,7 +1049,7 @@ void PlayFilmc(CORO_PARAM, SCNHANDLE hFilm, int x, int y, int actorid, bool spla _ctx->ppi.y = y; _ctx->ppi.z = 0; _ctx->ppi.bRestore = false; - _ctx->ppi.speed = (ONE_SECOND / FROM_LE_32(pFilm->frate)); + _ctx->ppi.speed = (ONE_SECOND / FROM_32(pFilm->frate)); _ctx->ppi.actorid = actorid; _ctx->ppi.splay = splay; _ctx->ppi.bTop = bTop; @@ -1059,7 +1059,7 @@ void PlayFilmc(CORO_PARAM, SCNHANDLE hFilm, int x, int y, int actorid, bool spla // Start display process for each secondary reel in the film in Tinsel 1, // or all of them in Tinsel 2 - for (int i = FROM_LE_32(pFilm->numreels) - 1; i >= (TinselV2 ? 0 : 1); i--) { + for (int i = FROM_32(pFilm->numreels) - 1; i >= (TinselV2 ? 0 : 1); i--) { NewestFilm(hFilm, &pFilm->reels[i]); _ctx->ppi.column = i; @@ -1109,7 +1109,7 @@ void RestoreActorReels(SCNHANDLE hFilm, short reelnum, short z, int x, int y) { ppi.x = x; ppi.y = y; ppi.z = z; - ppi.speed = (ONE_SECOND / FROM_LE_32(pfilm->frate)); + ppi.speed = (ONE_SECOND / FROM_32(pfilm->frate)); ppi.actorid = 0; ppi.splay = false; ppi.bTop = false; @@ -1147,15 +1147,15 @@ void RestoreActorReels(SCNHANDLE hFilm, int actor, int x, int y) { ppi.x = (short)x; ppi.y = (short)y; ppi.bRestore = true; - ppi.speed = (short)(ONE_SECOND/FROM_LE_32(pFilm->frate)); + ppi.speed = (short)(ONE_SECOND/FROM_32(pFilm->frate)); ppi.bTop = false; ppi.myescEvent = 0; // Search backwards for now as later column will be the one - for (i = (int)FROM_LE_32(pFilm->numreels) - 1; i >= 0; i--) { + for (i = (int)FROM_32(pFilm->numreels) - 1; i >= 0; i--) { pFreel = &pFilm->reels[i]; - pmi = (PMULTI_INIT) LockMem(FROM_LE_32(pFreel->mobj)); - if ((int32)FROM_LE_32(pmi->mulID) == actor) { + pmi = (PMULTI_INIT) LockMem(FROM_32(pFreel->mobj)); + if ((int32)FROM_32(pmi->mulID) == actor) { ppi.column = (short)i; NewestFilm(hFilm, &pFilm->reels[i]); @@ -1173,8 +1173,8 @@ void RestoreActorReels(SCNHANDLE hFilm, int actor, int x, int y) { int ExtractActor(SCNHANDLE hFilm) { const FILM *pFilm = (const FILM *)LockMem(hFilm); const FREEL *pReel = &pFilm->reels[0]; - const MULTI_INIT *pmi = (const MULTI_INIT *)LockMem(FROM_LE_32(pReel->mobj)); - return (int)FROM_LE_32(pmi->mulID); + const MULTI_INIT *pmi = (const MULTI_INIT *)LockMem(FROM_32(pReel->mobj)); + return (int)FROM_32(pmi->mulID); } } // End of namespace Tinsel diff --git a/engines/tinsel/polygons.cpp b/engines/tinsel/polygons.cpp index d8c1cef0b6..8a984c78f9 100644 --- a/engines/tinsel/polygons.cpp +++ b/engines/tinsel/polygons.cpp @@ -154,13 +154,13 @@ public: void setIndex(int index); - POLY_TYPE getType() const { return (POLY_TYPE)FROM_LE_32(type); } - int getNodecount() const { return (int)FROM_LE_32(nodecount); } - int getNodeX(int i) const { return (int)FROM_LE_32(nlistx[i]); } - int getNodeY(int i) const { return (int)FROM_LE_32(nlisty[i]); } + POLY_TYPE getType() const { return (POLY_TYPE)FROM_32(type); } + int getNodecount() const { return (int)FROM_32(nodecount); } + int getNodeX(int i) const { return (int)FROM_32(nlistx[i]); } + int getNodeY(int i) const { return (int)FROM_32(nlisty[i]); } // get Inter-node line structure - const LINEINFO *getLineinfo(int i) const { return ((const LINEINFO *)(_pStart + (int)FROM_LE_32(plinelist))) + i; } + const LINEINFO *getLineinfo(int i) const { return ((const LINEINFO *)(_pStart + (int)FROM_32(plinelist))) + i; } protected: POLY_TYPE type; ///< type of polygon @@ -230,8 +230,8 @@ void Poly::nextPoly() { const byte *pRecord = _pData; int typeVal = nextLong(_pData); - if ((FROM_LE_32(typeVal) == 5) && TinselV2) - typeVal = TO_LE_32(6); + if ((FROM_32(typeVal) == 5) && TinselV2) + typeVal = TO_32(6); type = (POLY_TYPE)typeVal; for (int i = 0; i < 4; ++i) @@ -275,8 +275,8 @@ void Poly::nextPoly() { pnodelisty = nextLong(_pData); plinelist = nextLong(_pData); - nlistx = (const int32 *)(_pStart + (int)FROM_LE_32(pnodelistx)); - nlisty = (const int32 *)(_pStart + (int)FROM_LE_32(pnodelisty)); + nlistx = (const int32 *)(_pStart + (int)FROM_32(pnodelistx)); + nlisty = (const int32 *)(_pStart + (int)FROM_32(pnodelisty)); if (TinselV0) // Skip to the last 4 bytes of the record for the hScript value @@ -591,16 +591,16 @@ void FindBestPoint(HPOLYGON hp, int *x, int *y, int *pline) { for (int i = 0; i < ptp.getNodecount() - 1; i++) { const LINEINFO *line = ptp.getLineinfo(i); - const int32 a = (int)FROM_LE_32(line->a); - const int32 b = (int)FROM_LE_32(line->b); - const int32 c = (int)FROM_LE_32(line->c); + const int32 a = (int)FROM_32(line->a); + const int32 b = (int)FROM_32(line->b); + const int32 c = (int)FROM_32(line->c); #if 1 // TODO: If the comments of the LINEINFO struct are correct, then it contains mostly // duplicate data, probably in an effort to safe CPU cycles. Even on the slowest devices // we support, calculating a product of two ints is not an issue. // So we can just load & endian convert a,b,c, then replace stuff like - // (int)FROM_LE_32(line->ab) + // (int)FROM_32(line->ab) // by simply a*b, which makes it easier to understand what the code does, too. // Just in case there is some bugged data, I leave this code here for verifying it. // Let's leave it in for some time. @@ -608,14 +608,14 @@ void FindBestPoint(HPOLYGON hp, int *x, int *y, int *pline) { // One bad thing: We use sqrt to compute a square root. Might not be a good idea, // speed wise. Maybe we should take Vicent's fp_sqroot. But that's a problem for later. - int32 a2 = (int)FROM_LE_32(line->a2); ///< a squared - int32 b2 = (int)FROM_LE_32(line->b2); ///< b squared - int32 a2pb2 = (int)FROM_LE_32(line->a2pb2); ///< a squared + b squared - int32 ra2pb2 = (int)FROM_LE_32(line->ra2pb2); ///< root(a squared + b squared) + int32 a2 = (int)FROM_32(line->a2); ///< a squared + int32 b2 = (int)FROM_32(line->b2); ///< b squared + int32 a2pb2 = (int)FROM_32(line->a2pb2); ///< a squared + b squared + int32 ra2pb2 = (int)FROM_32(line->ra2pb2); ///< root(a squared + b squared) - int32 ab = (int)FROM_LE_32(line->ab); - int32 ac = (int)FROM_LE_32(line->ac); - int32 bc = (int)FROM_LE_32(line->bc); + int32 ab = (int)FROM_32(line->ab); + int32 ac = (int)FROM_32(line->ac); + int32 bc = (int)FROM_32(line->bc); assert(a*a == a2); assert(b*b == b2); @@ -676,9 +676,9 @@ void FindBestPoint(HPOLYGON hp, int *x, int *y, int *pline) { // A point on a line is nearest const LINEINFO *line = ptp.getLineinfo(nearestL); - const int32 a = (int)FROM_LE_32(line->a); - const int32 b = (int)FROM_LE_32(line->b); - const int32 c = (int)FROM_LE_32(line->c); + const int32 a = (int)FROM_32(line->a); + const int32 b = (int)FROM_32(line->b); + const int32 c = (int)FROM_32(line->c); dropX = ((b*b * h) - (a*b * k) - a*c) / (a*a + b*b); dropY = ((a*a * k) - (a*b * h) - b*c) / (a*a + b*b); *x = dropX; @@ -994,15 +994,15 @@ int GetScale(HPOLYGON hPath, int y) { Poly ptp(LockMem(pHandle), Polys[hPath]->pIndex); // Path is of a constant scale? - if (FROM_LE_32(ptp.scale2) == 0) - return FROM_LE_32(ptp.scale1); + if (FROM_32(ptp.scale2) == 0) + return FROM_32(ptp.scale1); - assert(FROM_LE_32(ptp.scale1) >= FROM_LE_32(ptp.scale2)); + assert(FROM_32(ptp.scale1) >= FROM_32(ptp.scale2)); - zones = FROM_LE_32(ptp.scale1) - FROM_LE_32(ptp.scale2) + 1; + zones = FROM_32(ptp.scale1) - FROM_32(ptp.scale2) + 1; zlen = (Polys[hPath]->pbottom - Polys[hPath]->ptop) / zones; - scale = FROM_LE_32(ptp.scale1); + scale = FROM_32(ptp.scale1); top = Polys[hPath]->ptop; do { @@ -1011,7 +1011,7 @@ int GetScale(HPOLYGON hPath, int y) { return scale; } while (--scale); - return FROM_LE_32(ptp.scale2); + return FROM_32(ptp.scale2); } /** @@ -1033,15 +1033,15 @@ int GetBrightness(HPOLYGON hPath, int y) { Poly ptp(LockMem(pHandle), Polys[hPath]->pIndex); // Path is of a constant brightness? - if (FROM_LE_32(ptp.bright1) == FROM_LE_32(ptp.bright2)) - return FROM_LE_32(ptp.bright1); + if (FROM_32(ptp.bright1) == FROM_32(ptp.bright2)) + return FROM_32(ptp.bright1); - assert(FROM_LE_32(ptp.bright1) >= FROM_LE_32(ptp.bright2)); + assert(FROM_32(ptp.bright1) >= FROM_32(ptp.bright2)); - zones = FROM_LE_32(ptp.bright1) - FROM_LE_32(ptp.bright2) + 1; + zones = FROM_32(ptp.bright1) - FROM_32(ptp.bright2) + 1; zlen = (Polys[hPath]->pbottom - Polys[hPath]->ptop) / zones; - brightness = FROM_LE_32(ptp.bright1); + brightness = FROM_32(ptp.bright1); top = Polys[hPath]->ptop; do { @@ -1050,7 +1050,7 @@ int GetBrightness(HPOLYGON hPath, int y) { return brightness; } while (--brightness); - return FROM_LE_32(ptp.bright2); + return FROM_32(ptp.bright2); } @@ -1079,9 +1079,9 @@ void GetTagTag(HPOLYGON hp, SCNHANDLE *hTagText, int *tagx, int *tagy) { Poly ptp(LockMem(pHandle), Polys[hp]->pIndex); - *tagx = (int)FROM_LE_32(ptp.tagx) + (TinselV2 ? volatileStuff[hp].xoff : 0); - *tagy = (int)FROM_LE_32(ptp.tagy) + (TinselV2 ? volatileStuff[hp].yoff : 0); - *hTagText = FROM_LE_32(ptp.hTagtext); + *tagx = (int)FROM_32(ptp.tagx) + (TinselV2 ? volatileStuff[hp].xoff : 0); + *tagy = (int)FROM_32(ptp.tagy) + (TinselV2 ? volatileStuff[hp].yoff : 0); + *hTagText = FROM_32(ptp.hTagtext); } /** @@ -1092,7 +1092,7 @@ SCNHANDLE GetPolyFilm(HPOLYGON hp) { Poly ptp(LockMem(pHandle), Polys[hp]->pIndex); - return FROM_LE_32(ptp.hFilm); + return FROM_32(ptp.hFilm); } /** @@ -1103,7 +1103,7 @@ SCNHANDLE GetPolyScript(HPOLYGON hp) { Poly ptp(LockMem(pHandle), Polys[hp]->pIndex); - return FROM_LE_32(ptp.hScript); + return FROM_32(ptp.hScript); } REEL GetPolyReelType(HPOLYGON hp) { @@ -1115,7 +1115,7 @@ REEL GetPolyReelType(HPOLYGON hp) { Poly ptp(LockMem(pHandle), Polys[hp]->pIndex); - return (REEL)FROM_LE_32(ptp.reel); + return (REEL)FROM_32(ptp.reel); } int32 GetPolyZfactor(HPOLYGON hp) { @@ -1124,7 +1124,7 @@ int32 GetPolyZfactor(HPOLYGON hp) { Poly ptp(LockMem(pHandle), Polys[hp]->pIndex); - return (int)FROM_LE_32(ptp.zFactor); + return (int)FROM_32(ptp.zFactor); } int numNodes(HPOLYGON hp) { @@ -1319,11 +1319,11 @@ static bool MatchingLevels(PPOLYGON p1, PPOLYGON p2) { Poly pp1(pps, p1->pIndex); // This polygon 1 Poly pp2(pps, p2->pIndex); // This polygon 2 - assert((int32)FROM_LE_32(pp1.level1) <= (int32)FROM_LE_32(pp1.level2)); - assert((int32)FROM_LE_32(pp2.level1) <= (int32)FROM_LE_32(pp2.level2)); + assert((int32)FROM_32(pp1.level1) <= (int32)FROM_32(pp1.level2)); + assert((int32)FROM_32(pp2.level1) <= (int32)FROM_32(pp2.level2)); - for (int pl = (int32)FROM_LE_32(pp1.level1); pl <= (int32)FROM_LE_32(pp1.level2); pl++) { - if (pl >= (int32)FROM_LE_32(pp2.level1) && pl <= (int32)FROM_LE_32(pp2.level2)) + for (int pl = (int32)FROM_32(pp1.level1); pl <= (int32)FROM_32(pp1.level2); pl++) { + if (pl >= (int32)FROM_32(pp2.level1) && pl <= (int32)FROM_32(pp2.level2)) return true; } @@ -1604,17 +1604,17 @@ static PPOLYGON CommonInits(PTYPE polyType, int pno, const Poly &ptp, bool bRest p->pIndex = pno; for (i = 0; i < 4; i++) { // Polygon definition - p->cx[i] = (short)FROM_LE_32(ptp.x[i]); - p->cy[i] = (short)FROM_LE_32(ptp.y[i]); + p->cx[i] = (short)FROM_32(ptp.x[i]); + p->cy[i] = (short)FROM_32(ptp.y[i]); } if (!bRestart) { hp = PolygonIndex(p); - volatileStuff[hp].xoff = (short)FROM_LE_32(ptp.xoff); - volatileStuff[hp].yoff = (short)FROM_LE_32(ptp.yoff); + volatileStuff[hp].xoff = (short)FROM_32(ptp.xoff); + volatileStuff[hp].yoff = (short)FROM_32(ptp.yoff); } - p->polyID = FROM_LE_32(ptp.id); // Identifier + p->polyID = FROM_32(ptp.id); // Identifier FiddlyBit(p); @@ -1731,7 +1731,7 @@ static void InitEffect(const Poly &ptp, int pno, bool bRestart) { static void InitRefer(const Poly &ptp, int pno, bool bRestart) { PPOLYGON p = CommonInits(REFER, pno, ptp, bRestart); - p->subtype = FROM_LE_32(ptp.reftype); // Refer type + p->subtype = FROM_32(ptp.reftype); // Refer type } @@ -1990,8 +1990,8 @@ void GetPolyNode(HPOLYGON hp, int *pNodeX, int *pNodeY) { *pNodeX = 480; *pNodeY = 408; } else { - *pNodeX = FROM_LE_32(ptp.nodex); - *pNodeY = FROM_LE_32(ptp.nodey); + *pNodeX = FROM_32(ptp.nodex); + *pNodeY = FROM_32(ptp.nodey); } if (TinselV2) { diff --git a/engines/tinsel/rince.cpp b/engines/tinsel/rince.cpp index ba8f47f9cf..3e6334f583 100644 --- a/engines/tinsel/rince.cpp +++ b/engines/tinsel/rince.cpp @@ -550,7 +550,7 @@ void AlterMover(PMOVER pMover, SCNHANDLE film, AR_FUNCTION fn) { pfilm = (const FILM *)LockMem(film); assert(pfilm != NULL); - InitStepAnimScript(&pMover->actorAnim, pMover->actorObj, FROM_LE_32(pfilm->reels[0].script), ONE_SECOND / FROM_LE_32(pfilm->frate)); + InitStepAnimScript(&pMover->actorAnim, pMover->actorObj, FROM_32(pfilm->reels[0].script), ONE_SECOND / FROM_32(pfilm->frate)); if (!TinselV2) pMover->stepCount = 0; @@ -643,7 +643,7 @@ void SetMoverWalkReel(PMOVER pMover, DIRECTION reel, int scale, bool force) { pfilm = (const FILM *)LockMem(whichReel); assert(pfilm != NULL); // no film - InitStepAnimScript(&pMover->actorAnim, pMover->actorObj, FROM_LE_32(pfilm->reels[0].script), 1); + InitStepAnimScript(&pMover->actorAnim, pMover->actorObj, FROM_32(pfilm->reels[0].script), 1); // Synchronised walking reels assert(pMover->stepCount >= 0); @@ -704,14 +704,14 @@ static void MoverProcessHelper(int X, int Y, int id, PMOVER pMover) { InitialPathChecks(pMover, X, Y); pfilm = (const FILM *)LockMem(pMover->walkReels[0][FORWARD]); - pmi = (const MULTI_INIT *)LockMem(FROM_LE_32(pfilm->reels[0].mobj)); + pmi = (const MULTI_INIT *)LockMem(FROM_32(pfilm->reels[0].mobj)); //--- - pFrame = (const FRAME *)LockMem(FROM_LE_32(pmi->hMulFrame)); + pFrame = (const FRAME *)LockMem(FROM_32(pmi->hMulFrame)); // get pointer to image - pim = (IMAGE *)LockMem(READ_LE_UINT32(pFrame)); // handle to image - pim->hImgPal = TO_LE_32(BgPal()); + pim = (IMAGE *)LockMem(READ_32(pFrame)); // handle to image + pim->hImgPal = TO_32(BgPal()); //--- pMover->actorObj = MultiInitObject(pmi); @@ -722,7 +722,7 @@ static void MoverProcessHelper(int X, int Y, int id, PMOVER pMover) { MultiInsertObject(GetPlayfieldList(FIELD_WORLD), pMover->actorObj); storeActorReel(id, NULL, 0, pMover->actorObj, 0, 0, 0); - InitStepAnimScript(&pMover->actorAnim, pMover->actorObj, FROM_LE_32(pfilm->reels[0].script), ONE_SECOND / FROM_LE_32(pfilm->frate)); + InitStepAnimScript(&pMover->actorAnim, pMover->actorObj, FROM_32(pfilm->reels[0].script), ONE_SECOND / FROM_32(pfilm->frate)); pMover->stepCount = 0; MultiSetAniXY(pMover->actorObj, pMover->objX, pMover->objY); @@ -802,7 +802,7 @@ void T2MoverProcess(CORO_PARAM, const void *param) { InitialPathChecks(pMover, rpos->X, rpos->Y); pFilm = (FILM *)LockMem(pMover->walkReels[i][FORWARD]); // Any old reel - pmi = (PMULTI_INIT)LockMem(FROM_LE_32(pFilm->reels[0].mobj)); + pmi = (PMULTI_INIT)LockMem(FROM_32(pFilm->reels[0].mobj)); // Poke in the background palette PokeInPalette(pmi); diff --git a/engines/tinsel/scene.cpp b/engines/tinsel/scene.cpp index 2fda5176fb..986d54f59f 100644 --- a/engines/tinsel/scene.cpp +++ b/engines/tinsel/scene.cpp @@ -130,14 +130,14 @@ const SCENE_STRUC *GetSceneStruc(const byte *pStruc) { const byte *p = pStruc; memset(&g_tempStruc, 0, sizeof(SCENE_STRUC)); - g_tempStruc.numEntrance = FROM_LE_32(READ_LE_UINT32(p)); p += sizeof(uint32); - g_tempStruc.numPoly = FROM_LE_32(READ_LE_UINT32(p)); p += sizeof(uint32); - g_tempStruc.numTaggedActor = FROM_LE_32(READ_LE_UINT32(p)); p += sizeof(uint32); - g_tempStruc.defRefer = FROM_LE_32(READ_LE_UINT32(p)); p += sizeof(uint32); - g_tempStruc.hSceneScript = FROM_LE_32(READ_LE_UINT32(p)); p += sizeof(uint32); - g_tempStruc.hEntrance = FROM_LE_32(READ_LE_UINT32(p)); p += sizeof(uint32); - g_tempStruc.hPoly = FROM_LE_32(READ_LE_UINT32(p)); p += sizeof(uint32); - g_tempStruc.hTaggedActor = FROM_LE_32(READ_LE_UINT32(p)); p += sizeof(uint32); + g_tempStruc.numEntrance = FROM_LE_32(READ_32(p)); p += sizeof(uint32); + g_tempStruc.numPoly = FROM_LE_32(READ_32(p)); p += sizeof(uint32); + g_tempStruc.numTaggedActor = FROM_LE_32(READ_32(p)); p += sizeof(uint32); + g_tempStruc.defRefer = FROM_LE_32(READ_32(p)); p += sizeof(uint32); + g_tempStruc.hSceneScript = FROM_LE_32(READ_32(p)); p += sizeof(uint32); + g_tempStruc.hEntrance = FROM_LE_32(READ_32(p)); p += sizeof(uint32); + g_tempStruc.hPoly = FROM_LE_32(READ_32(p)); p += sizeof(uint32); + g_tempStruc.hTaggedActor = FROM_LE_32(READ_32(p)); p += sizeof(uint32); return &g_tempStruc; } @@ -223,7 +223,7 @@ static void LoadScene(SCNHANDLE scene, int entry) { // CdPlay() stuff byte *cptr = FindChunk(scene, CHUNK_CDPLAY_FILENUM); assert(cptr); - i = READ_LE_UINT32(cptr); + i = READ_32(cptr); assert(i < 512); cptr = FindChunk(scene, CHUNK_CDPLAY_FILENAME); assert(cptr); @@ -266,10 +266,10 @@ static void LoadScene(SCNHANDLE scene, int entry) { // Run the appropriate entrance code (if any) es = (const ENTRANCE_STRUC *)LockMem(ss->hEntrance); for (i = 0; i < ss->numEntrance; i++) { - if (FROM_LE_32(es->eNumber) == (uint)entry) { + if (FROM_32(es->eNumber) == (uint)entry) { if (es->hScript) { init.event = STARTUP; - init.hTinselCode = FROM_LE_32(es->hScript); + init.hTinselCode = FROM_32(es->hScript); CoroScheduler.createProcess(PID_TCODE, SceneTinselProcess, &init, sizeof(init)); } diff --git a/engines/tinsel/sched.cpp b/engines/tinsel/sched.cpp index 4bf356ba36..a73b4b9b97 100644 --- a/engines/tinsel/sched.cpp +++ b/engines/tinsel/sched.cpp @@ -109,7 +109,7 @@ void RestoreSceneProcess(INT_CONTEXT *pic) { pStruc = (PROCESS_STRUC *)LockMem(g_hSceneProcess); for (i = 0; i < g_numSceneProcess; i++) { - if (FROM_LE_32(pStruc[i].hProcessCode) == pic->hCode) { + if (FROM_32(pStruc[i].hProcessCode) == pic->hCode) { CoroScheduler.createProcess(PID_PROCESS + i, RestoredProcessProcess, &pic, sizeof(pic)); break; @@ -137,11 +137,11 @@ void SceneProcessEvent(CORO_PARAM, uint32 procID, TINSEL_EVENT event, bool bWait _ctx->pStruc = (PROCESS_STRUC *)LockMem(g_hSceneProcess); for (i = 0; i < g_numSceneProcess; i++) { - if (FROM_LE_32(_ctx->pStruc[i].processId) == procID) { + if (FROM_32(_ctx->pStruc[i].processId) == procID) { assert(_ctx->pStruc[i].hProcessCode); // Must have some code to run _ctx->pic = InitInterpretContext(GS_PROCESS, - FROM_LE_32(_ctx->pStruc[i].hProcessCode), + FROM_32(_ctx->pStruc[i].hProcessCode), event, NOPOLY, // No polygon 0, // No actor @@ -176,7 +176,7 @@ void KillSceneProcess(uint32 procID) { pStruc = (PROCESS_STRUC *) LockMem(g_hSceneProcess); for (i = 0; i < g_numSceneProcess; i++) { - if (FROM_LE_32(pStruc[i].processId) == procID) { + if (FROM_32(pStruc[i].processId) == procID) { CoroScheduler.killMatchingProcess(PID_PROCESS + i, -1); break; } @@ -293,8 +293,8 @@ void GlobalProcesses(uint32 numProcess, byte *pProcess) { byte *p = pProcess; for (uint i = 0; i < numProcess; ++i, p += 8) { - g_pGlobalProcess[i].processId = READ_LE_UINT32(p); - g_pGlobalProcess[i].hProcessCode = READ_LE_UINT32(p + 4); + g_pGlobalProcess[i].processId = READ_32(p); + g_pGlobalProcess[i].hProcessCode = READ_32(p + 4); } } diff --git a/engines/tinsel/scn.cpp b/engines/tinsel/scn.cpp index 168dcf464f..70093447ff 100644 --- a/engines/tinsel/scn.cpp +++ b/engines/tinsel/scn.cpp @@ -54,11 +54,11 @@ byte *FindChunk(SCNHANDLE handle, uint32 chunk) { chunk -= 0x2L; while (1) { - if (READ_LE_UINT32(lptr) == chunk) + if (READ_32(lptr) == chunk) return (byte *)(lptr + 2); ++lptr; - add = READ_LE_UINT32(lptr); + add = READ_32(lptr); if (!add) // End of file reached diff --git a/engines/tinsel/strres.cpp b/engines/tinsel/strres.cpp index 5a29a4d2cd..19a1ee94d6 100644 --- a/engines/tinsel/strres.cpp +++ b/engines/tinsel/strres.cpp @@ -165,15 +165,15 @@ static byte *FindStringBase(int id) { // skip to the correct chunk while (chunkSkip-- != 0) { // make sure chunk id is correct - assert(READ_LE_UINT32(pText + index) == CHUNK_STRING || READ_LE_UINT32(pText + index) == CHUNK_MBSTRING); + assert(READ_32(pText + index) == CHUNK_STRING || READ_32(pText + index) == CHUNK_MBSTRING); - if (READ_LE_UINT32(pText + index + sizeof(uint32)) == 0) { + if (READ_32(pText + index + sizeof(uint32)) == 0) { // string does not exist return NULL; } // get index to next chunk - index = READ_LE_UINT32(pText + index + sizeof(uint32)); + index = READ_32(pText + index + sizeof(uint32)); } // skip over chunk id and offset diff --git a/engines/tinsel/text.cpp b/engines/tinsel/text.cpp index 5eb092d00d..150eb2bdde 100644 --- a/engines/tinsel/text.cpp +++ b/engines/tinsel/text.cpp @@ -46,24 +46,24 @@ int StringLengthPix(char *szStr, const FONT *pFont) { if (c & 0x80) c = ((c & ~0x80) << 8) + *++szStr; } - hImg = FROM_LE_32(pFont->fontDef[c]); + hImg = FROM_32(pFont->fontDef[c]); if (hImg) { // there is a IMAGE for this character const IMAGE *pChar = (const IMAGE *)LockMem(hImg); // add width of font bitmap - strLen += FROM_LE_16(pChar->imgWidth); + strLen += FROM_16(pChar->imgWidth); } else // use width of space character - strLen += FROM_LE_32(pFont->spaceSize); + strLen += FROM_32(pFont->spaceSize); // finally add the inter-character spacing - strLen += FROM_LE_32(pFont->xSpacing); + strLen += FROM_32(pFont->xSpacing); } // return length of line in pixels - minus inter-char spacing for last character - strLen -= FROM_LE_32(pFont->xSpacing); + strLen -= FROM_32(pFont->xSpacing); return (strLen > 0) ? strLen : 0; } @@ -125,10 +125,10 @@ OBJECT *ObjectTextOut(OBJECT **pList, char *szStr, int color, // get image for capital W assert(pFont->fontDef[(int)'W']); - pImg = (const IMAGE *)LockMem(FROM_LE_32(pFont->fontDef[(int)'W'])); + pImg = (const IMAGE *)LockMem(FROM_32(pFont->fontDef[(int)'W'])); // get height of capital W for offset to next line - yOffset = FROM_LE_16(pImg->imgHeight) & ~C16_FLAG_MASK; + yOffset = FROM_16(pImg->imgHeight) & ~C16_FLAG_MASK; while (*szStr) { // x justify the text according to the mode flags @@ -140,24 +140,24 @@ OBJECT *ObjectTextOut(OBJECT **pList, char *szStr, int color, if (c & 0x80) c = ((c & ~0x80) << 8) + *++szStr; } - hImg = FROM_LE_32(pFont->fontDef[c]); + hImg = FROM_32(pFont->fontDef[c]); if (hImg == 0) { // no image for this character // add font spacing for a space character - xJustify += FROM_LE_32(pFont->spaceSize); + xJustify += FROM_32(pFont->spaceSize); } else { // printable character int aniX, aniY; // char image animation offsets OBJ_INIT oi; - oi.hObjImg = FROM_LE_32(pFont->fontInit.hObjImg); - oi.objFlags = FROM_LE_32(pFont->fontInit.objFlags); - oi.objID = FROM_LE_32(pFont->fontInit.objID); - oi.objX = FROM_LE_32(pFont->fontInit.objX); - oi.objY = FROM_LE_32(pFont->fontInit.objY); - oi.objZ = FROM_LE_32(pFont->fontInit.objZ); + oi.hObjImg = FROM_32(pFont->fontInit.hObjImg); + oi.objFlags = FROM_32(pFont->fontInit.objFlags); + oi.objID = FROM_32(pFont->fontInit.objID); + oi.objX = FROM_32(pFont->fontInit.objX); + oi.objY = FROM_32(pFont->fontInit.objY); + oi.objZ = FROM_32(pFont->fontInit.objZ); // allocate and init a character object if (pFirst == NULL) @@ -172,9 +172,9 @@ OBJECT *ObjectTextOut(OBJECT **pList, char *szStr, int color, // fill in character object pChar->hImg = hImg; // image def - pChar->width = FROM_LE_16(pImg->imgWidth); // width of chars bitmap - pChar->height = FROM_LE_16(pImg->imgHeight) & ~C16_FLAG_MASK; // height of chars bitmap - pChar->hBits = FROM_LE_32(pImg->hImgBits); // bitmap + pChar->width = FROM_16(pImg->imgWidth); // width of chars bitmap + pChar->height = FROM_16(pImg->imgHeight) & ~C16_FLAG_MASK; // height of chars bitmap + pChar->hBits = FROM_32(pImg->hImgBits); // bitmap // check for absolute positioning if (mode & TXT_ABSOLUTE) @@ -203,8 +203,8 @@ OBJECT *ObjectTextOut(OBJECT **pList, char *szStr, int color, CopyObject(pShad, pChar); // add shadow offsets to characters position - pShad->xPos += intToFrac(FROM_LE_32(pFont->xShadow)); - pShad->yPos += intToFrac(FROM_LE_32(pFont->yShadow)); + pShad->xPos += intToFrac(FROM_32(pFont->xShadow)); + pShad->yPos += intToFrac(FROM_32(pFont->yShadow)); // shadow is behind the character pShad->zPos--; @@ -232,18 +232,18 @@ OBJECT *ObjectTextOut(OBJECT **pList, char *szStr, int color, pChar = pChar->pSlave; // add character spacing - xJustify += FROM_LE_16(pImg->imgWidth); + xJustify += FROM_16(pImg->imgWidth); } // finally add the inter-character spacing - xJustify += FROM_LE_32(pFont->xSpacing); + xJustify += FROM_32(pFont->xSpacing); // next character in string ++szStr; } // adjust the text y position and add the inter-line spacing - yPos += yOffset + FROM_LE_32(pFont->ySpacing); + yPos += yOffset + FROM_32(pFont->ySpacing); // check for newline if (c == LF_CHAR) diff --git a/engines/tinsel/tinsel.cpp b/engines/tinsel/tinsel.cpp index 83812caf96..721e76dbac 100644 --- a/engines/tinsel/tinsel.cpp +++ b/engines/tinsel/tinsel.cpp @@ -718,15 +718,15 @@ void LoadBasicChunks() { // CHUNK_TOTAL_ACTORS seems to be missing in the released version, hard coding a value // TODO: Would be nice to just change 511 to MAX_SAVED_ALIVES cptr = FindChunk(MASTER_SCNHANDLE, CHUNK_TOTAL_ACTORS); - RegisterActors((cptr != NULL) ? READ_LE_UINT32(cptr) : 511); + RegisterActors((cptr != NULL) ? READ_32(cptr) : 511); // CHUNK_TOTAL_GLOBALS seems to be missing in some versions. // So if it is missing, set a reasonably high value for the number of globals. cptr = FindChunk(MASTER_SCNHANDLE, CHUNK_TOTAL_GLOBALS); - RegisterGlobals((cptr != NULL) ? READ_LE_UINT32(cptr) : 512); + RegisterGlobals((cptr != NULL) ? READ_32(cptr) : 512); cptr = FindChunk(INV_OBJ_SCNHANDLE, CHUNK_TOTAL_OBJECTS); - numObjects = (cptr != NULL) ? READ_LE_UINT32(cptr) : 0; + numObjects = (cptr != NULL) ? READ_32(cptr) : 0; cptr = FindChunk(INV_OBJ_SCNHANDLE, CHUNK_OBJECTS); @@ -734,10 +734,10 @@ void LoadBasicChunks() { //convert to native endianness INV_OBJECT *io = (INV_OBJECT *)cptr; for (int i = 0; i < numObjects; i++, io++) { - io->id = FROM_LE_32(io->id); - io->hIconFilm = FROM_LE_32(io->hIconFilm); - io->hScript = FROM_LE_32(io->hScript); - io->attribute = FROM_LE_32(io->attribute); + io->id = FROM_32(io->id); + io->hIconFilm = FROM_32(io->hIconFilm); + io->hScript = FROM_32(io->hScript); + io->attribute = FROM_32(io->attribute); } #endif @@ -759,7 +759,7 @@ void LoadBasicChunks() { // CdPlay() stuff cptr = FindChunk(MASTER_SCNHANDLE, CHUNK_CDPLAY_HANDLE); assert(cptr); - uint32 playHandle = READ_LE_UINT32(cptr); + uint32 playHandle = READ_32(cptr); assert(playHandle < 512); SetCdPlayHandle(playHandle); } diff --git a/engines/tinsel/tinsel.h b/engines/tinsel/tinsel.h index 7fb50da791..32e21842a1 100644 --- a/engines/tinsel/tinsel.h +++ b/engines/tinsel/tinsel.h @@ -133,6 +133,12 @@ typedef bool (*KEYFPTR)(const Common::KeyState &); #define TinselV1PSX (TinselVersion == TINSEL_V1 && _vm->getPlatform() == Common::kPlatformPSX) #define TinselV1Mac (TinselVersion == TINSEL_V1 && _vm->getPlatform() == Common::kPlatformMacintosh) +#define READ_16(v) (TinselV1Mac ? READ_BE_UINT16(v) : READ_LE_UINT16(v)) +#define READ_32(v) (TinselV1Mac ? READ_BE_UINT32(v) : READ_LE_UINT32(v)) +#define FROM_16(v) (TinselV1Mac ? FROM_BE_16(v) : FROM_LE_16(v)) +#define FROM_32(v) (TinselV1Mac ? FROM_BE_32(v) : FROM_LE_32(v)) +#define TO_32(v) (TinselV1Mac ? TO_BE_32(v) : TO_LE_32(v)) + // Global reference to the TinselEngine object extern TinselEngine *_vm; -- cgit v1.2.3