aboutsummaryrefslogtreecommitdiff
path: root/engines/tinsel
diff options
context:
space:
mode:
Diffstat (limited to 'engines/tinsel')
-rw-r--r--engines/tinsel/actors.cpp22
-rw-r--r--engines/tinsel/anim.cpp32
-rw-r--r--engines/tinsel/bg.cpp26
-rw-r--r--engines/tinsel/bmv.cpp18
-rw-r--r--engines/tinsel/cursor.cpp30
-rw-r--r--engines/tinsel/detection.cpp2
-rw-r--r--engines/tinsel/detection_tables.h88
-rw-r--r--engines/tinsel/dialogs.cpp206
-rw-r--r--engines/tinsel/dw.h2
-rw-r--r--engines/tinsel/events.cpp3
-rw-r--r--engines/tinsel/events.h2
-rw-r--r--engines/tinsel/faders.cpp58
-rw-r--r--engines/tinsel/faders.h12
-rw-r--r--engines/tinsel/font.cpp8
-rw-r--r--engines/tinsel/graphics.cpp236
-rw-r--r--engines/tinsel/handle.cpp5
-rw-r--r--engines/tinsel/multiobj.cpp24
-rw-r--r--engines/tinsel/music.cpp209
-rw-r--r--engines/tinsel/object.cpp26
-rw-r--r--engines/tinsel/palette.cpp63
-rw-r--r--engines/tinsel/palette.h12
-rw-r--r--engines/tinsel/pcode.cpp2
-rw-r--r--engines/tinsel/play.cpp104
-rw-r--r--engines/tinsel/polygons.cpp108
-rw-r--r--engines/tinsel/rince.cpp16
-rw-r--r--engines/tinsel/saveload.cpp2
-rw-r--r--engines/tinsel/savescn.cpp3
-rw-r--r--engines/tinsel/scene.cpp58
-rw-r--r--engines/tinsel/sched.cpp12
-rw-r--r--engines/tinsel/sound.cpp140
-rw-r--r--engines/tinsel/sound.h10
-rw-r--r--engines/tinsel/strres.cpp6
-rw-r--r--engines/tinsel/text.cpp46
-rw-r--r--engines/tinsel/timers.cpp2
-rw-r--r--engines/tinsel/tinlib.cpp7
-rw-r--r--engines/tinsel/tinsel.cpp29
-rw-r--r--engines/tinsel/tinsel.h13
37 files changed, 852 insertions, 790 deletions
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..9f1f2c43f4 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];
@@ -153,7 +153,7 @@ static void BGmainProcess(CORO_PARAM, const void *param) {
}
if (g_bDoFadeIn) {
- FadeInFast(NULL);
+ FadeInFast();
g_bDoFadeIn = false;
} else if (TinselV2)
PokeInTagColor();
@@ -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/detection.cpp b/engines/tinsel/detection.cpp
index 2e4be33e53..a7ba8b28cb 100644
--- a/engines/tinsel/detection.cpp
+++ b/engines/tinsel/detection.cpp
@@ -67,7 +67,7 @@ bool TinselEngine::getIsADGFDemo() const {
return (bool)(_gameDescription->desc.flags & ADGF_DEMO);
}
-bool TinselEngine::isCD() const {
+bool TinselEngine::isV1CD() const {
return (bool)(_gameDescription->desc.flags & ADGF_CD);
}
diff --git a/engines/tinsel/detection_tables.h b/engines/tinsel/detection_tables.h
index 631c2dce14..a945672da2 100644
--- a/engines/tinsel/detection_tables.h
+++ b/engines/tinsel/detection_tables.h
@@ -34,6 +34,8 @@ static const TinselGameDescription gameDescriptions[] = {
// TINSEL_V2: The Discworld 2 game used this updated version of the Tinsel 1 engine,
// and as far as we know there aren't any variations of this engine.
+ // ==== Discworld 1 early (TinselV0) entries ==============================
+
{ // Floppy Demo V0 from http://www.adventure-treff.de/specials/dl_demos.php
{
"dw",
@@ -41,7 +43,7 @@ static const TinselGameDescription gameDescriptions[] = {
AD_ENTRY1s("dw.gra", "ce1b57761ba705221bcf70955b827b97", 441192),
//AD_ENTRY1s("dw.scn", "ccd72f02183d0e96b6e7d8df9492cda8", 23308),
Common::EN_ANY,
- Common::kPlatformPC,
+ Common::kPlatformDOS,
ADGF_DEMO,
GUIO3(GUIO_NOSPEECH, GUIO_NOSFX, GUIO_NOMUSIC)
},
@@ -51,6 +53,8 @@ static const TinselGameDescription gameDescriptions[] = {
TINSEL_V0,
},
+ // ==== Discworld 1 entries ===============================================
+
{ // CD Demo V1 version, with *.gra files
{
"dw",
@@ -60,7 +64,7 @@ static const TinselGameDescription gameDescriptions[] = {
{"english.smp", 0, NULL, -1},
},
Common::EN_ANY,
- Common::kPlatformPC,
+ Common::kPlatformDOS,
ADGF_DEMO | ADGF_CD,
GUIO0()
},
@@ -69,7 +73,7 @@ static const TinselGameDescription gameDescriptions[] = {
0,
TINSEL_V1,
},
-#if 0
+
{ // Macintosh CD Demo V1 version, with *.scn files, see tracker #3110936
{
"dw",
@@ -89,7 +93,7 @@ static const TinselGameDescription gameDescriptions[] = {
GF_SCNFILES,
TINSEL_V1,
},
-#endif
+
{ // Multilingual Floppy V1 with *.gra files.
// Note: It contains no english subtitles.
{
@@ -104,7 +108,7 @@ static const TinselGameDescription gameDescriptions[] = {
{NULL, 0, NULL, 0}
},
Common::FR_FRA,
- Common::kPlatformPC,
+ Common::kPlatformDOS,
ADGF_DROPLANGUAGE,
GUIO1(GUIO_NOSPEECH)
},
@@ -127,7 +131,7 @@ static const TinselGameDescription gameDescriptions[] = {
{NULL, 0, NULL, 0}
},
Common::DE_DEU,
- Common::kPlatformPC,
+ Common::kPlatformDOS,
ADGF_DROPLANGUAGE,
GUIO1(GUIO_NOSPEECH)
},
@@ -150,7 +154,7 @@ static const TinselGameDescription gameDescriptions[] = {
{NULL, 0, NULL, 0}
},
Common::IT_ITA,
- Common::kPlatformPC,
+ Common::kPlatformDOS,
ADGF_DROPLANGUAGE,
GUIO1(GUIO_NOSPEECH)
},
@@ -173,7 +177,7 @@ static const TinselGameDescription gameDescriptions[] = {
{NULL, 0, NULL, 0}
},
Common::ES_ESP,
- Common::kPlatformPC,
+ Common::kPlatformDOS,
ADGF_DROPLANGUAGE,
GUIO1(GUIO_NOSPEECH)
},
@@ -189,7 +193,7 @@ static const TinselGameDescription gameDescriptions[] = {
"Floppy",
AD_ENTRY1s("dw.gra", "c8808ccd988d603dd35dff42013ae7fd", 781656),
Common::EN_ANY,
- Common::kPlatformPC,
+ Common::kPlatformDOS,
ADGF_NO_FLAGS,
GUIO1(GUIO_NOSPEECH)
},
@@ -208,7 +212,7 @@ static const TinselGameDescription gameDescriptions[] = {
{"english.smp", 0, NULL, -1},
},
Common::EN_ANY,
- Common::kPlatformPC,
+ Common::kPlatformDOS,
ADGF_CD,
GUIO0()
},
@@ -227,7 +231,7 @@ static const TinselGameDescription gameDescriptions[] = {
{"english.smp", 0, NULL, -1},
},
Common::EN_ANY,
- Common::kPlatformPC,
+ Common::kPlatformDOS,
ADGF_CD,
GUIO_NONE
},
@@ -243,7 +247,7 @@ static const TinselGameDescription gameDescriptions[] = {
"Floppy",
AD_ENTRY1s("dw.gra", "ef05bbd2a754bd11a2e87bcd84ab5ccf", 781864),
Common::EN_ANY,
- Common::kPlatformPC,
+ Common::kPlatformDOS,
ADGF_NO_FLAGS,
GUIO_NOSPEECH
},
@@ -265,7 +269,7 @@ static const TinselGameDescription gameDescriptions[] = {
{NULL, 0, NULL, 0}
},
Common::IT_ITA,
- Common::kPlatformPC,
+ Common::kPlatformDOS,
ADGF_DROPLANGUAGE | ADGF_CD,
GUIO0()
},
@@ -290,7 +294,7 @@ static const TinselGameDescription gameDescriptions[] = {
{NULL, 0, NULL, 0}
},
Common::FR_FRA,
- Common::kPlatformPC,
+ Common::kPlatformDOS,
ADGF_DROPLANGUAGE | ADGF_CD,
GUIO0()
},
@@ -314,7 +318,7 @@ static const TinselGameDescription gameDescriptions[] = {
{NULL, 0, NULL, 0}
},
Common::DE_DEU,
- Common::kPlatformPC,
+ Common::kPlatformDOS,
ADGF_DROPLANGUAGE,
GUIO0()
},
@@ -337,7 +341,7 @@ static const TinselGameDescription gameDescriptions[] = {
{NULL, 0, NULL, 0}
},
Common::IT_ITA,
- Common::kPlatformPC,
+ Common::kPlatformDOS,
ADGF_DROPLANGUAGE | ADGF_CD,
GUIO0()
},
@@ -360,7 +364,7 @@ static const TinselGameDescription gameDescriptions[] = {
{NULL, 0, NULL, 0}
},
Common::ES_ESP,
- Common::kPlatformPC,
+ Common::kPlatformDOS,
ADGF_DROPLANGUAGE | ADGF_CD,
GUIO0()
},
@@ -380,7 +384,7 @@ static const TinselGameDescription gameDescriptions[] = {
{NULL, 0, NULL, 0}
},
Common::EN_ANY,
- Common::kPlatformPC,
+ Common::kPlatformDOS,
ADGF_CD,
GUIO0()
},
@@ -400,7 +404,7 @@ static const TinselGameDescription gameDescriptions[] = {
{NULL, 0, NULL, 0}
},
Common::HE_ISR,
- Common::kPlatformPC,
+ Common::kPlatformDOS,
ADGF_CD,
GUIO0()
},
@@ -463,7 +467,7 @@ static const TinselGameDescription gameDescriptions[] = {
{NULL, 0, NULL, 0}
},
Common::EN_ANY,
- Common::kPlatformPC,
+ Common::kPlatformDOS,
ADGF_CD,
GUIO0()
},
@@ -474,7 +478,6 @@ static const TinselGameDescription gameDescriptions[] = {
},
#endif
-#if 0
{ // Mac multilanguage CD
{
"dw",
@@ -495,8 +498,6 @@ static const TinselGameDescription gameDescriptions[] = {
TINSEL_V1,
},
-#endif
-
{ // German CD re-release "Neon Edition"
// Note: This release has ENGLISH.TXT (with german content) instead of GERMAN.TXT
{
@@ -504,7 +505,7 @@ static const TinselGameDescription gameDescriptions[] = {
"CD",
AD_ENTRY1s("dw.scn", "6182c7986eaec893c62fb6ea13a9f225", 774556),
Common::DE_DEU,
- Common::kPlatformPC,
+ Common::kPlatformDOS,
ADGF_CD,
GUIO0()
},
@@ -525,7 +526,7 @@ static const TinselGameDescription gameDescriptions[] = {
{NULL, 0, NULL, 0}
},
Common::RU_RUS,
- Common::kPlatformPC,
+ Common::kPlatformDOS,
ADGF_CD,
GUIO1(GUIO_NOASPECT)
},
@@ -546,7 +547,7 @@ static const TinselGameDescription gameDescriptions[] = {
{NULL, 0, NULL, 0}
},
Common::PL_POL,
- Common::kPlatformPC,
+ Common::kPlatformDOS,
ADGF_CD,
GUIO_NONE
},
@@ -556,6 +557,9 @@ static const TinselGameDescription gameDescriptions[] = {
TINSEL_V1,
},
+ // ==== Discworld 2 entries ===============================================
+ // Note: All Discworld 2 versions are CD only, therefore we don't add the ADGF_CD flag
+
{ // English Discworld 2 demo
{
"dw2",
@@ -566,8 +570,8 @@ static const TinselGameDescription gameDescriptions[] = {
{NULL, 0, NULL, 0}
},
Common::EN_ANY,
- Common::kPlatformPC,
- ADGF_DEMO | ADGF_CD,
+ Common::kPlatformDOS,
+ ADGF_DEMO,
GUIO1(GUIO_NOASPECT)
},
GID_DW2,
@@ -586,8 +590,8 @@ static const TinselGameDescription gameDescriptions[] = {
{NULL, 0, NULL, 0}
},
Common::EN_GRB,
- Common::kPlatformPC,
- ADGF_CD,
+ Common::kPlatformDOS,
+ ADGF_NO_FLAGS,
GUIO1(GUIO_NOASPECT)
},
GID_DW2,
@@ -606,8 +610,8 @@ static const TinselGameDescription gameDescriptions[] = {
{NULL, 0, NULL, 0}
},
Common::EN_USA,
- Common::kPlatformPC,
- ADGF_CD,
+ Common::kPlatformDOS,
+ ADGF_NO_FLAGS,
GUIO1(GUIO_NOASPECT)
},
GID_DW2,
@@ -626,8 +630,8 @@ static const TinselGameDescription gameDescriptions[] = {
{NULL, 0, NULL, 0}
},
Common::FR_FRA,
- Common::kPlatformPC,
- ADGF_CD,
+ Common::kPlatformDOS,
+ ADGF_NO_FLAGS,
GUIO1(GUIO_NOASPECT)
},
GID_DW2,
@@ -646,8 +650,8 @@ static const TinselGameDescription gameDescriptions[] = {
{NULL, 0, NULL, 0}
},
Common::DE_DEU,
- Common::kPlatformPC,
- ADGF_CD,
+ Common::kPlatformDOS,
+ ADGF_NO_FLAGS,
GUIO1(GUIO_NOASPECT)
},
GID_DW2,
@@ -667,8 +671,8 @@ static const TinselGameDescription gameDescriptions[] = {
{NULL, 0, NULL, 0}
},
Common::IT_ITA,
- Common::kPlatformPC,
- ADGF_CD,
+ Common::kPlatformDOS,
+ ADGF_NO_FLAGS,
GUIO1(GUIO_NOASPECT)
},
GID_DW2,
@@ -687,8 +691,8 @@ static const TinselGameDescription gameDescriptions[] = {
{NULL, 0, NULL, 0}
},
Common::ES_ESP,
- Common::kPlatformPC,
- ADGF_CD,
+ Common::kPlatformDOS,
+ ADGF_NO_FLAGS,
GUIO1(GUIO_NOASPECT)
},
GID_DW2,
@@ -708,8 +712,8 @@ static const TinselGameDescription gameDescriptions[] = {
{NULL, 0, NULL, 0}
},
Common::RU_RUS,
- Common::kPlatformPC,
- ADGF_CD,
+ Common::kPlatformDOS,
+ ADGF_NO_FLAGS,
GUIO1(GUIO_NOASPECT)
},
GID_DW2,
diff --git a/engines/tinsel/dialogs.cpp b/engines/tinsel/dialogs.cpp
index 56ee2ea752..e6229ff3a0 100644
--- a/engines/tinsel/dialogs.cpp
+++ b/engines/tinsel/dialogs.cpp
@@ -234,8 +234,8 @@ enum PARTS_INDEX {
#define NM_RS_R_INSET 4
#define NM_RS_THICKNESS 5
#define NM_MOVE_AREA_B_Y 30
-#define NM_SLIDE_INSET (TinselV2 ? 18 : 15) // X offset (from right) of left of scroll region
-#define NM_SLIDE_THICKNESS (TinselV2 ? 13 : 4) // thickness of scroll region
+#define NM_SLIDE_INSET (TinselV2 ? 18 : 9) // X offset (from right) of left of scroll region
+#define NM_SLIDE_THICKNESS (TinselV2 ? 13 : 7) // thickness of scroll region
#define NM_UP_ARROW_TOP 34 // Y offset of top of up arrow
#define NM_UP_ARROW_BOTTOM 49 // Y offset of bottom of up arrow
#define NM_DN_ARROW_TOP 22 // Y offset (from bottom) of top of down arrow
@@ -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
@@ -2723,7 +2723,7 @@ static OBJECT *AddObject(const FREEL *pfreel, int num) {
static void AddSlider(OBJECT **slide, const FILM *pfilm) {
g_SlideObject = *slide = AddObject(&pfilm->reels[IX_SLIDE], -1);
- MultiSetAniXY(*slide, MultiRightmost(g_RectObject) + (TinselV2 ? NM_SLX : -M_SXOFF + 2) - 1,
+ MultiSetAniXY(*slide, MultiRightmost(g_RectObject) + (TinselV2 ? NM_SLX : -M_SXOFF + 2),
g_InvD[g_ino].inventoryY + g_sliderYpos);
MultiSetZPosition(*slide, Z_INV_MFRAME);
}
@@ -3318,7 +3318,7 @@ static void ConstructInventory(InventoryType filling) {
}
}
} else if (g_InvD[g_ino].NoofItems > g_InvD[g_ino].NoofHicons*g_InvD[g_ino].NoofVicons) {
- g_sliderYmin = g_TLheight - (TinselV2 ? 2 : 1);
+ g_sliderYmin = g_TLheight - (TinselV2 ? 1 : 2);
g_sliderYmax = g_TLheight + eV + (TinselV2 ? 12 : 10);
AddSlider(&retObj[n++], pfilm);
}
@@ -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};
@@ -3655,10 +3655,10 @@ extern void HideConversation(bool bHide) {
if (g_InventoryState == ACTIVE_INV && g_ino == INV_CONV) {
if (bHide) {
// Move all the window and icons off-screen
- for (i = 0; g_objArray[i] && i < MAX_WCOMP; i++) {
+ for (i = 0; i < MAX_WCOMP && g_objArray[i]; i++) {
MultiAdjustXY(g_objArray[i], 2 * SCREEN_WIDTH, 0);
}
- for (i = 0; g_iconArray[i] && i < MAX_ICONS; i++) {
+ for (i = 0; i < MAX_ICONS && g_iconArray[i]; i++) {
MultiAdjustXY(g_iconArray[i], 2 * SCREEN_WIDTH, 0);
}
@@ -4861,50 +4861,101 @@ static void InvDragEnd() {
g_Xchange = g_Ychange = 0; // Probably no need, but does no harm!
}
-static void MenuPageDown() {
+static bool MenuDown(int lines) {
if (cd.box == loadBox || cd.box == saveBox) {
- if (cd.extraBase < MAX_SAVED_FILES-NUM_RGROUP_BOXES) {
- FirstFile(cd.extraBase+(NUM_RGROUP_BOXES - 1));
+ if (cd.extraBase < MAX_SAVED_FILES - NUM_RGROUP_BOXES) {
+ FirstFile(cd.extraBase + lines);
AddBoxes(true);
- cd.selBox = NUM_RGROUP_BOXES - 1;
- Select(cd.selBox, true);
+ return true;
}
} else if (cd.box == hopperBox1) {
if (cd.extraBase < g_numScenes - NUM_RGROUP_BOXES) {
- FirstScene(cd.extraBase + (NUM_RGROUP_BOXES - 1));
+ FirstScene(cd.extraBase + lines);
AddBoxes(true);
- if (cd.selBox)
- cd.selBox = NUM_RGROUP_BOXES - 1;
- Select(cd.selBox, true);
+ return true;
}
} else if (cd.box == hopperBox2) {
if (cd.extraBase < g_numEntries - NUM_RGROUP_BOXES) {
- FirstEntry(cd.extraBase+(NUM_RGROUP_BOXES - 1));
+ FirstEntry(cd.extraBase + lines);
AddBoxes(true);
- if (cd.selBox)
- cd.selBox = NUM_RGROUP_BOXES - 1;
- Select(cd.selBox, true);
+ return true;
}
}
+ return false;
}
-static void MenuPageUp() {
+static bool MenuUp(int lines) {
if (cd.extraBase > 0) {
if (cd.box == loadBox || cd.box == saveBox)
- FirstFile(cd.extraBase-(NUM_RGROUP_BOXES - 1));
+ FirstFile(cd.extraBase - lines);
else if (cd.box == hopperBox1)
- FirstScene(cd.extraBase-(NUM_RGROUP_BOXES - 1));
+ FirstScene(cd.extraBase - lines);
else if (cd.box == hopperBox2)
- FirstEntry(cd.extraBase-(NUM_RGROUP_BOXES - 1));
+ FirstEntry(cd.extraBase - lines);
else
- return;
+ return false;
AddBoxes(true);
+ return true;
+ }
+ return false;
+}
+
+static void MenuRollDown() {
+ if (MenuDown(1)) {
+ if (cd.selBox > 0)
+ cd.selBox--;
+ Select(cd.selBox, true);
+ }
+}
+
+static void MenuRollUp() {
+ if (MenuUp(1)) {
+ if (cd.selBox < NUM_RGROUP_BOXES - 1)
+ cd.selBox++;
+ Select(cd.selBox, true);
+ }
+}
+
+static void MenuPageDown() {
+ if (MenuDown(NUM_RGROUP_BOXES - 1)) {
+ cd.selBox = NUM_RGROUP_BOXES - 1;
+ Select(cd.selBox, true);
+ }
+}
+
+static void MenuPageUp() {
+ if (MenuUp(NUM_RGROUP_BOXES - 1)) {
cd.selBox = 0;
Select(cd.selBox, true);
}
}
+static void InventoryDown() {
+ // This code is a copy of the IB_SLIDE_DOWN case in InvWalkTo
+ // TODO: So share this duplicate code
+ if (g_InvD[g_ino].NoofVicons == 1)
+ if (g_InvD[g_ino].FirstDisp + g_InvD[g_ino].NoofHicons*g_InvD[g_ino].NoofVicons < g_InvD[g_ino].NoofItems)
+ g_InvD[g_ino].FirstDisp += g_InvD[g_ino].NoofHicons;
+ for (int i = 1; i < g_InvD[g_ino].NoofVicons; i++) {
+ if (g_InvD[g_ino].FirstDisp + g_InvD[g_ino].NoofHicons*g_InvD[g_ino].NoofVicons < g_InvD[g_ino].NoofItems)
+ g_InvD[g_ino].FirstDisp += g_InvD[g_ino].NoofHicons;
+ }
+ g_ItemsChanged = true;
+}
+
+static void InventoryUp() {
+ // This code is a copy of the I_SLIDE_UP case in InvWalkTo
+ // TODO: So share this duplicate code
+ if (g_InvD[g_ino].NoofVicons == 1)
+ g_InvD[g_ino].FirstDisp -= g_InvD[g_ino].NoofHicons;
+ for (int i = 1; i < g_InvD[g_ino].NoofVicons; i++)
+ g_InvD[g_ino].FirstDisp -= g_InvD[g_ino].NoofHicons;
+ if (g_InvD[g_ino].FirstDisp < 0)
+ g_InvD[g_ino].FirstDisp = 0;
+ g_ItemsChanged = true;
+}
+
/**************************************************************************/
/************** Incoming events - further processing **********************/
/**************************************************************************/
@@ -5399,42 +5450,47 @@ extern void EventToInventory(PLR_EVENT pEvent, const Common::Point &coOrds) {
case PLR_PGDN:
if (g_ino == INV_MENU) {
- // Only act if load or save screen
+ // Load or Save screen
MenuPageDown();
} else {
- // This code is a copy of the IB_SLIDE_DOWN case in InvWalkTo
- // TODO: So share this duplicate code
- if (g_InvD[g_ino].NoofVicons == 1)
- if (g_InvD[g_ino].FirstDisp + g_InvD[g_ino].NoofHicons*g_InvD[g_ino].NoofVicons < g_InvD[g_ino].NoofItems)
- g_InvD[g_ino].FirstDisp += g_InvD[g_ino].NoofHicons;
- for (int i = 1; i < g_InvD[g_ino].NoofVicons; i++) {
- if (g_InvD[g_ino].FirstDisp + g_InvD[g_ino].NoofHicons*g_InvD[g_ino].NoofVicons < g_InvD[g_ino].NoofItems)
- g_InvD[g_ino].FirstDisp += g_InvD[g_ino].NoofHicons;
- }
- g_ItemsChanged = true;
+ // Inventory window
+ InventoryDown();
}
break;
case PLR_PGUP:
if (g_ino == INV_MENU) {
- // Only act if load or save screen
+ // Load or Save screen
MenuPageUp();
} else {
- // This code is a copy of the I_SLIDE_UP case in InvWalkTo
- // TODO: So share this duplicate code
- if (g_InvD[g_ino].NoofVicons == 1)
- g_InvD[g_ino].FirstDisp -= g_InvD[g_ino].NoofHicons;
- for (int i = 1; i < g_InvD[g_ino].NoofVicons; i++)
- g_InvD[g_ino].FirstDisp -= g_InvD[g_ino].NoofHicons;
- if (g_InvD[g_ino].FirstDisp < 0)
- g_InvD[g_ino].FirstDisp = 0;
- g_ItemsChanged = true;
+ // Inventory window
+ InventoryUp();
+ }
+ break;
+
+ case PLR_WHEEL_DOWN:
+ if (g_ino == INV_MENU) {
+ // Load or Save screen
+ MenuRollDown();
+ } else {
+ // Inventory window
+ InventoryDown();
+ }
+ break;
+
+ case PLR_WHEEL_UP:
+ if (g_ino == INV_MENU) {
+ // Load or Save screen
+ MenuRollUp();
+ } else {
+ // Inventory window
+ InventoryUp();
}
break;
case PLR_HOME:
if (g_ino == INV_MENU) {
- // Only act if load or save screen
+ // Load or Save screen
if (cd.box == loadBox || cd.box == saveBox)
FirstFile(0);
else if (cd.box == hopperBox1)
@@ -5448,6 +5504,7 @@ extern void EventToInventory(PLR_EVENT pEvent, const Common::Point &coOrds) {
cd.selBox = 0;
Select(cd.selBox, true);
} else {
+ // Inventory window
g_InvD[g_ino].FirstDisp = 0;
g_ItemsChanged = true;
}
@@ -5455,6 +5512,7 @@ extern void EventToInventory(PLR_EVENT pEvent, const Common::Point &coOrds) {
case PLR_END:
if (g_ino == INV_MENU) {
+ // Load or Save screen
if (cd.box == loadBox || cd.box == saveBox)
FirstFile(MAX_SAVED_FILES); // Will get reduced to appropriate value
else if (cd.box == hopperBox1)
@@ -5468,6 +5526,7 @@ extern void EventToInventory(PLR_EVENT pEvent, const Common::Point &coOrds) {
cd.selBox = 0;
Select(cd.selBox, true);
} else {
+ // Inventory window
g_InvD[g_ino].FirstDisp = g_InvD[g_ino].NoofItems - g_InvD[g_ino].NoofHicons*g_InvD[g_ino].NoofVicons;
if (g_InvD[g_ino].FirstDisp < 0)
g_InvD[g_ino].FirstDisp = 0;
@@ -5560,21 +5619,6 @@ extern void RegisterIcons(void *cptr, int num) {
memmove(destP, srcP, 12);
destP->attribute = 0;
}
- } else if (TinselV1Mac) {
- // Macintosh version has BE encoded resources, so the values need to be byte swapped
- MEM_NODE *node = MemoryAllocFixed(g_numObjects * sizeof(INV_OBJECT));
- assert(node);
- g_invObjects = (INV_OBJECT *)MemoryDeref(node);
- assert(g_invObjects);
- INV_OBJECT *srcP = (INV_OBJECT *)cptr;
- INV_OBJECT *destP = (INV_OBJECT *)g_invObjects;
-
- for (int i = 0; i < num; ++i, ++destP, ++srcP) {
- destP->id = FROM_BE_32(srcP->id);
- destP->hIconFilm = FROM_BE_32(srcP->hIconFilm);
- destP->hScript = FROM_BE_32(srcP->hScript);
- destP->attribute = FROM_BE_32(srcP->attribute);
- }
} else if (TinselV2) {
if (g_invFilms == NULL) {
// First time - allocate memory
@@ -5613,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
}
@@ -5630,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/dw.h b/engines/tinsel/dw.h
index 21f6db946e..34f05ab8c2 100644
--- a/engines/tinsel/dw.h
+++ b/engines/tinsel/dw.h
@@ -91,7 +91,7 @@ typedef int HPOLYGON;
#define MAX_SAVED_ALIVES 512 // Saves actors'lives
#define MAX_SAVED_ACTOR_Z 512 // Saves actors' Z-ness
-// Legal non-existant entrance number for LoadScene()
+// Legal non-existent entrance number for LoadScene()
#define NO_ENTRY_NUM (-3458) // Magic unlikely number
diff --git a/engines/tinsel/events.cpp b/engines/tinsel/events.cpp
index 1aa4d34227..61d3903f1a 100644
--- a/engines/tinsel/events.cpp
+++ b/engines/tinsel/events.cpp
@@ -389,7 +389,8 @@ void PlayerEvent(PLR_EVENT pEvent, const Common::Point &coOrds) {
"PLR_PROV_WALKTO", "PLR_WALKTO", "PLR_LOOK", "PLR_ACTION", "PLR_ESCAPE",
"PLR_MENU", "PLR_QUIT", "PLR_PGUP", "PLR_PGDN", "PLR_HOME", "PLR_END",
"PLR_DRAG1_START", "PLR_DRAG1_END", "PLR_DRAG2_START", "PLR_DRAG2_END",
- "PLR_JUMP", "PLR_NOEVENT"};
+ "PLR_JUMP", "PLR_NOEVENT", "PLR_SAVE", "PLR_LOAD", "PLR_WHEEL_UP",
+ "PLR_WHEEL_DOWN"};
debugC(DEBUG_BASIC, kTinselDebugActions, "%s - (%d,%d)",
actionList[pEvent], coOrds.x, coOrds.y);
static uint32 lastRealAction = 0; // FIXME: Avoid non-const global vars
diff --git a/engines/tinsel/events.h b/engines/tinsel/events.h
index cdf5ae2ae4..51669e4680 100644
--- a/engines/tinsel/events.h
+++ b/engines/tinsel/events.h
@@ -65,6 +65,8 @@ enum PLR_EVENT {
PLR_NOEVENT = 16,
PLR_SAVE = 17,
PLR_LOAD = 18,
+ PLR_WHEEL_UP = 19,
+ PLR_WHEEL_DOWN = 20,
// Aliases used for DW1 actions
PLR_SLEFT = PLR_WALKTO,
diff --git a/engines/tinsel/faders.cpp b/engines/tinsel/faders.cpp
index c1574ff963..b51b1d6d4f 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);
@@ -137,9 +137,8 @@ static void FadeProcess(CORO_PARAM, const void *param) {
* Generic palette fader/unfader. Creates a 'FadeProcess' process
* for each palette that is to fade.
* @param multTable Fixed point color multiplier table
- * @param noFadeTable List of palettes not to fade
*/
-static void Fader(const long multTable[], SCNHANDLE noFadeTable[]) {
+static void Fader(const long multTable[]) {
PALQ *pPal; // palette manager iterator
if (TinselV2) {
@@ -151,84 +150,61 @@ static void Fader(const long multTable[], SCNHANDLE noFadeTable[]) {
// create a process for each palette in the palette queue
for (pPal = GetNextPalette(NULL); pPal != NULL; pPal = GetNextPalette(pPal)) {
- bool bFade = true;
- // assume we want to fade this palette
-
- // is palette in the list of palettes not to fade
- if (noFadeTable != NULL) {
- // there is a list of palettes not to fade
- for (int i = 0; noFadeTable[i] != 0; i++) {
- if (pPal->hPal == noFadeTable[i]) {
- // palette is in the list - dont fade it
- bFade = false;
-
- // leave loop prematurely
- break;
- }
- }
- }
-
- if (bFade) {
- FADE fade;
+ FADE fade;
- // fill in FADE struct
- fade.pColorMultTable = multTable;
- fade.pPalQ = pPal;
+ // fill in FADE struct
+ fade.pColorMultTable = multTable;
+ fade.pPalQ = pPal;
- // create a fader process for this palette
- CoroScheduler.createProcess(PID_FADER, FadeProcess, (void *)&fade, sizeof(FADE));
- }
+ // create a fader process for this palette
+ CoroScheduler.createProcess(PID_FADER, FadeProcess, (void *)&fade, sizeof(FADE));
}
}
/**
* Fades a list of palettes down to black.
- * 'noFadeTable' is a NULL terminated list of palettes not to fade.
*/
-void FadeOutMedium(SCNHANDLE noFadeTable[]) {
+void FadeOutMedium() {
// Fixed point fade multiplier table
static const long fadeout[] = {0xea00, 0xd000, 0xb600, 0x9c00,
0x8200, 0x6800, 0x4e00, 0x3400, 0x1a00, 0, -1};
// call generic fader
- Fader(fadeout, noFadeTable);
+ Fader(fadeout);
}
/**
* Fades a list of palettes down to black.
- * @param noFadeTable A NULL terminated list of palettes not to fade.
*/
-void FadeOutFast(SCNHANDLE noFadeTable[]) {
+void FadeOutFast() {
// Fixed point fade multiplier table
static const long fadeout[] = {0xd000, 0xa000, 0x7000, 0x4000, 0x1000, 0, -1};
// call generic fader
- Fader(fadeout, noFadeTable);
+ Fader(fadeout);
}
/**
* Fades a list of palettes from black to their current colors.
- * 'noFadeTable' is a NULL terminated list of palettes not to fade.
*/
-void FadeInMedium(SCNHANDLE noFadeTable[]) {
+void FadeInMedium() {
// Fade multiplier table
static const long fadein[] = {0, 0x1a00, 0x3400, 0x4e00, 0x6800,
0x8200, 0x9c00, 0xb600, 0xd000, 0xea00, 0x10000L, -1};
// call generic fader
- Fader(fadein, noFadeTable);
+ Fader(fadein);
}
/**
* Fades a list of palettes from black to their current colors.
- * @param noFadeTable A NULL terminated list of palettes not to fade.
*/
-void FadeInFast(SCNHANDLE noFadeTable[]) {
+void FadeInFast() {
// Fade multiplier table
static const long fadein[] = {0, 0x1000, 0x4000, 0x7000, 0xa000, 0xd000, 0x10000L, -1};
// call generic fader
- Fader(fadein, noFadeTable);
+ Fader(fadein);
}
void PokeInTagColor() {
diff --git a/engines/tinsel/faders.h b/engines/tinsel/faders.h
index dc0b903d7e..f7db902fe5 100644
--- a/engines/tinsel/faders.h
+++ b/engines/tinsel/faders.h
@@ -39,14 +39,10 @@ namespace Tinsel {
|* Fader Function Prototypes *|
\*----------------------------------------------------------------------*/
-// usefull palette faders - they all need a list of palettes that
-// should not be faded. This parameter can be
-// NULL - fade all palettes.
-
-void FadeOutMedium(SCNHANDLE noFadeTable[]);
-void FadeOutFast(SCNHANDLE noFadeTable[]);
-void FadeInMedium(SCNHANDLE noFadeTable[]);
-void FadeInFast(SCNHANDLE noFadeTable[]);
+void FadeOutMedium();
+void FadeOutFast();
+void FadeInMedium();
+void FadeInFast();
void PokeInTagColor();
} // End of namespace Tinsel
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..5dae984def 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--;
@@ -212,6 +212,82 @@ static void t0WrtNonZero(DRAWOBJECT *pObj, uint8 *srcP, uint8 *destP, bool apply
}
/**
+ * Straight rendering with transparency support, Mac variant
+ */
+static void MacDrawTiles(DRAWOBJECT *pObj, uint8 *srcP, uint8 *destP, bool applyClipping) {
+ int yClip = 0;
+
+ if (applyClipping) {
+ // Adjust the height down to skip any bottom clipping
+ pObj->height -= pObj->botClip;
+ yClip = pObj->topClip;
+ }
+
+ // Simple RLE-like scheme: the two first bytes of each data chunk determine
+ // if bytes should be repeated or copied.
+ // Example: 10 00 00 20 will repeat byte 0x0 0x10 times, and will copy 0x20
+ // bytes from the input stream afterwards
+
+ // Vertical loop
+ for (int y = 0; y < pObj->height; ++y) {
+ // Get the start of the next line output
+ uint8 *tempDest = destP;
+
+ int leftClip = applyClipping ? pObj->leftClip : 0;
+ int rightClip = applyClipping ? pObj->rightClip : 0;
+
+ // Horizontal loop
+ for (int x = 0; x < pObj->width; ) {
+ byte repeatBytes = *srcP++;
+
+ if (repeatBytes) {
+ uint clipAmount = MIN<int>(repeatBytes, leftClip);
+ leftClip -= clipAmount;
+ x += clipAmount;
+
+ // Repeat of a given color
+ byte color = *srcP++;
+ int runLength = repeatBytes - clipAmount;
+ int rptLength = MAX(MIN(runLength, pObj->width - rightClip - x), 0);
+ if (yClip == 0) {
+ if (color != 0)
+ memset(tempDest, color, rptLength);
+ tempDest += rptLength;
+ }
+
+ x += runLength;
+ } else {
+ // Copy a specified sequence length of pixels
+ byte copyBytes = *srcP++;
+
+ uint clipAmount = MIN<int>(copyBytes, leftClip);
+ leftClip -= clipAmount;
+ x += clipAmount;
+ srcP += clipAmount;
+
+ int runLength = copyBytes - clipAmount;
+ int rptLength = MAX(MIN(runLength, pObj->width - rightClip - x), 0);
+ if (yClip == 0) {
+ memmove(tempDest, srcP, rptLength);
+ tempDest += rptLength;
+ }
+
+ int overflow = (copyBytes & 1);
+ x += runLength;
+ srcP += runLength + overflow;
+ }
+ } // horizontal loop
+
+ // Move to next line
+ if (yClip > 0)
+ --yClip;
+ else
+ destP += SCREEN_WIDTH;
+ } // vertical loop
+}
+
+
+/**
* Straight rendering with transparency support, PSX variant supporting also 4-BIT clut data
*/
static void PsxDrawTiles(DRAWOBJECT *pObj, uint8 *srcP, uint8 *destP, bool applyClipping, bool fourBitClut, uint32 psxSkipBytes, byte *psxMapperTable, bool transparency) {
@@ -721,9 +797,10 @@ static void PackedWrtNonZero(DRAWOBJECT *pObj, uint8 *srcP, uint8 *destP,
* Clears both the screen surface buffer and screen to the specified value
*/
void ClearScreen() {
+ byte blackColorIndex = (!TinselV1Mac) ? 0 : 255;
void *pDest = _vm->screen().getBasePtr(0, 0);
- memset(pDest, 0, SCREEN_WIDTH * SCREEN_HEIGHT);
- g_system->fillScreen(0);
+ memset(pDest, blackColorIndex, SCREEN_WIDTH * SCREEN_HEIGHT);
+ g_system->fillScreen(blackColorIndex);
g_system->updateScreen();
}
@@ -822,120 +899,59 @@ void DrawObject(DRAWOBJECT *pObj) {
// Handle various draw types
uint8 typeId = pObj->flags & 0xff;
+ int packType = pObj->flags >> 14; // TinselV2
- if (TinselV2) {
- // Tinsel v2 decoders
- // Initial switch statement for the different bit packing types
- int packType = pObj->flags >> 14;
-
- if (packType == 0) {
- // No color packing
- switch (typeId) {
- case 0x01:
- case 0x11:
- case 0x41:
- case 0x51:
- case 0x81:
- case 0xC1:
- t2WrtNonZero(pObj, srcPtr, destPtr, typeId >= 0x40, (typeId & 0x10) != 0);
- break;
- case 0x02:
- case 0x42:
- // This renderer called 'RlWrtAll', but is the same as t2WrtNonZero
- t2WrtNonZero(pObj, srcPtr, destPtr, typeId >= 0x40, false);
- break;
- case 0x04:
- case 0x44:
- // WrtConst with/without clipping
- WrtConst(pObj, destPtr, typeId == 0x44);
- break;
- case 0x08:
- case 0x48:
- WrtAll(pObj, srcPtr, destPtr, typeId >= 0x40);
- break;
- case 0x84:
- case 0xC4:
- // WrtTrans with/without clipping
- WrtTrans(pObj, destPtr, typeId == 0xC4);
- break;
- default:
- error("Unknown drawing type %d", typeId);
- }
- } else {
- // 1 = 16 from 240
- // 2 = 16 from 224
- // 3 = variable color
- if (packType == 1) pObj->baseCol = 0xF0;
- else if (packType == 2) pObj->baseCol = 0xE0;
-
- PackedWrtNonZero(pObj, srcPtr, destPtr, (pObj->flags & DMA_CLIP) != 0,
- (pObj->flags & DMA_FLIPH), packType);
- }
+ if (TinselV2 && packType != 0) {
+ // Color packing for TinselV2
+
+ if (packType == 1)
+ pObj->baseCol = 0xF0; // 16 from 240
+ else if (packType == 2)
+ pObj->baseCol = 0xE0; // 16 from 224
+ // 3 = variable color
- } else if (TinselV1PSX) {
- // Tinsel v1 decoders, PSX specific variants
+ PackedWrtNonZero(pObj, srcPtr, destPtr, (pObj->flags & DMA_CLIP) != 0,
+ (pObj->flags & DMA_FLIPH), packType);
+ } else {
switch (typeId) {
- case 0x01:
- case 0x41:
- PsxDrawTiles(pObj, srcPtr, destPtr, typeId >= 0x40, psxFourBitClut, psxSkipBytes, psxMapperTable, true);
- break;
- case 0x08:
- case 0x48:
- PsxDrawTiles(pObj, srcPtr, destPtr, typeId >= 0x40, psxFourBitClut, psxSkipBytes, psxMapperTable, false);
- break;
- case 0x84:
- case 0xC4:
- // WrtTrans with/without clipping
- WrtTrans(pObj, destPtr, typeId == 0xC4);
- break;
- case 0x04:
- case 0x44:
- // WrtConst with/without clipping
- WrtConst(pObj, destPtr, typeId == 0x44);
+ case 0x01: // all versions, draw sprite without clipping
+ case 0x41: // all versions, draw sprite with clipping
+ case 0x02: // TinselV2, draw sprite without clipping
+ case 0x11: // TinselV2, draw sprite without clipping, flipped horizontally
+ case 0x42: // TinselV2, draw sprite with clipping
+ case 0x51: // TinselV2, draw sprite with clipping, flipped horizontally
+ case 0x81: // TinselV2, draw sprite with clipping
+ case 0xC1: // TinselV2, draw sprite with clipping
+ assert(TinselV2 || (typeId == 0x01 || typeId == 0x41));
+
+ if (TinselV2)
+ t2WrtNonZero(pObj, srcPtr, destPtr, typeId >= 0x40, (typeId & 0x10) != 0);
+ else if (TinselV1PSX)
+ PsxDrawTiles(pObj, srcPtr, destPtr, typeId == 0x41, psxFourBitClut, psxSkipBytes, psxMapperTable, true);
+ else if (TinselV1Mac)
+ MacDrawTiles(pObj, srcPtr, destPtr, typeId == 0x41);
+ else if (TinselV1)
+ WrtNonZero(pObj, srcPtr, destPtr, typeId == 0x41);
+ else if (TinselV0)
+ t0WrtNonZero(pObj, srcPtr, destPtr, typeId == 0x41);
break;
- default:
- error("Unknown drawing type %d", typeId);
- }
- } else if (TinselV1) {
- // Tinsel v1 decoders
- switch (typeId) {
- case 0x01:
- case 0x08:
- case 0x41:
- case 0x48:
- WrtNonZero(pObj, srcPtr, destPtr, typeId >= 0x40);
+ case 0x08: // draw background without clipping
+ case 0x48: // draw background with clipping
+ if (TinselV2 || TinselV1Mac || TinselV0)
+ WrtAll(pObj, srcPtr, destPtr, typeId == 0x48);
+ else if (TinselV1PSX)
+ PsxDrawTiles(pObj, srcPtr, destPtr, typeId == 0x48, psxFourBitClut, psxSkipBytes, psxMapperTable, false);
+ else if (TinselV1)
+ WrtNonZero(pObj, srcPtr, destPtr, typeId == 0x48);
break;
-
- case 0x04:
- case 0x44:
- // WrtConst with/without clipping
+ case 0x04: // fill with constant color without clipping
+ case 0x44: // fill with constant color with clipping
WrtConst(pObj, destPtr, typeId == 0x44);
break;
-
- case 0x84:
- case 0xC4:
- // WrtTrans with/without clipping
+ case 0x84: // draw transparent surface without clipping
+ case 0xC4: // draw transparent surface with clipping
WrtTrans(pObj, destPtr, typeId == 0xC4);
break;
-
- default:
- error("Unknown drawing type %d", typeId);
- }
- } else {
- // Tinsel v0 decoders
- switch (typeId) {
- case 0x01:
- case 0x41:
- t0WrtNonZero(pObj, srcPtr, destPtr, typeId >= 0x40);
- break;
- case 0x08:
- case 0x48:
- WrtAll(pObj, srcPtr, destPtr, typeId >= 0x40);
- break;
- case 0x84:
- case 0xC4:
- WrtTrans(pObj, destPtr, (typeId & 0x40) != 0);
- break;
default:
error("Unknown drawing type %d", typeId);
}
diff --git a/engines/tinsel/handle.cpp b/engines/tinsel/handle.cpp
index 14d588dcec..3921414b01 100644
--- a/engines/tinsel/handle.cpp
+++ b/engines/tinsel/handle.cpp
@@ -30,6 +30,7 @@
#include "tinsel/dw.h"
#include "tinsel/handle.h"
#include "tinsel/heapmem.h" // heap memory manager
+#include "tinsel/scn.h" // for the DW1 Mac resource handler
#include "tinsel/timers.h" // for DwGetCurrentTime()
#include "tinsel/tinsel.h"
#include "tinsel/scene.h"
@@ -85,7 +86,6 @@ static char g_szCdPlayFile[100];
static void LoadFile(MEMHANDLE *pH); // load a memory block as a file
-
/**
* Loads the graphics handle table index file and preloads all the
* permanent graphics etc.
@@ -300,7 +300,7 @@ void LoadFile(MEMHANDLE *pH) {
// discardable - unlock the memory
MemoryUnlock(pH->_node);
-
+
// set the loaded flag
pH->filesize |= fLoaded;
@@ -322,6 +322,7 @@ void LoadFile(MEMHANDLE *pH) {
*/
byte *LockMem(SCNHANDLE offset) {
uint32 handle = offset >> SCNHANDLE_SHIFT; // calc memory handle to use
+ //debug("Locking offset of type %d (%x), offset %d, handle %d", (offset & HANDLEMASK) >> SCNHANDLE_SHIFT, (offset & HANDLEMASK) >> SCNHANDLE_SHIFT, offset & OFFSETMASK, handle);
MEMHANDLE *pH; // points to table entry
// range check the memory handle
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 b3bfbcc5dc..3144ea7f94 100644
--- a/engines/tinsel/music.cpp
+++ b/engines/tinsel/music.cpp
@@ -187,43 +187,48 @@ bool PlayMidiSequence(uint32 dwFileOffset, bool bLoop) {
// move to correct position in the file
midiStream.seek(dwFileOffset, SEEK_SET);
- // read the length of the sequence
- dwSeqLen = midiStream.readUint32LE();
-
- // make sure buffer is large enough for this sequence
- assert(dwSeqLen > 0 && dwSeqLen <= g_midiBuffer.size);
-
- // stop any currently playing tune
- _vm->_midiMusic->stop();
-
- // read the sequence. This needs to be read again before playSEQ() is
- // called even if the music is restarting, as playSEQ() reads the file
- // name off the buffer itself. However, that function adds SMF headers
- // to the buffer, thus if it's read again, the SMF headers will be read
- // and the filename will always be 'MThd'.
- if (midiStream.read(g_midiBuffer.pDat, dwSeqLen) != dwSeqLen)
- error(FILE_IS_CORRUPT, MIDI_FILE);
-
- midiStream.close();
+ if (TinselV1Mac) {
+ // The Macintosh version of DW1 uses raw PCM for music
+ dwSeqLen = midiStream.readUint32BE();
+ _vm->_sound->playDW1MacMusic(midiStream, dwSeqLen);
+ } else {
+ dwSeqLen = midiStream.readUint32LE();
+
+ // make sure buffer is large enough for this sequence
+ assert(dwSeqLen > 0 && dwSeqLen <= g_midiBuffer.size);
+
+ // stop any currently playing tune
+ _vm->_midiMusic->stop();
+
+ // read the sequence. This needs to be read again before playSEQ() is
+ // called even if the music is restarting, as playSEQ() reads the file
+ // name off the buffer itself. However, that function adds SMF headers
+ // to the buffer, thus if it's read again, the SMF headers will be read
+ // and the filename will always be 'MThd'.
+ if (midiStream.read(g_midiBuffer.pDat, dwSeqLen) != dwSeqLen)
+ error(FILE_IS_CORRUPT, MIDI_FILE);
+
+ // WORKAROUND for bug #2820054 "DW1: No intro music at first start on Wii",
+ // which actually affects all ports, since it's specific to the GRA version.
+ //
+ // The GRA version does not seem to set the channel volume at all for the first
+ // intro track, thus we need to do that here. We only initialize the channels
+ // used in that sequence. And we are using 127 as default channel volume.
+ //
+ // Only in the GRA version dwFileOffset can be "38888", just to be sure, we
+ // check for the SCN files feature flag not being set though.
+ if (_vm->getGameID() == GID_DW1 && dwFileOffset == 38888 && !(_vm->getFeatures() & GF_SCNFILES)) {
+ _vm->_midiMusic->send(0x7F07B0 | 3);
+ _vm->_midiMusic->send(0x7F07B0 | 5);
+ _vm->_midiMusic->send(0x7F07B0 | 8);
+ _vm->_midiMusic->send(0x7F07B0 | 10);
+ _vm->_midiMusic->send(0x7F07B0 | 13);
+ }
- // WORKAROUND for bug #2820054 "DW1: No intro music at first start on Wii",
- // which actually affects all ports, since it's specific to the GRA version.
- //
- // The GRA version does not seem to set the channel volume at all for the first
- // intro track, thus we need to do that here. We only initialize the channels
- // used in that sequence. And we are using 127 as default channel volume.
- //
- // Only in the GRA version dwFileOffset can be "38888", just to be sure, we
- // check for the SCN files feature flag not being set though.
- if (_vm->getGameID() == GID_DW1 && dwFileOffset == 38888 && !(_vm->getFeatures() & GF_SCNFILES)) {
- _vm->_midiMusic->send(0x7F07B0 | 3);
- _vm->_midiMusic->send(0x7F07B0 | 5);
- _vm->_midiMusic->send(0x7F07B0 | 8);
- _vm->_midiMusic->send(0x7F07B0 | 10);
- _vm->_midiMusic->send(0x7F07B0 | 13);
+ _vm->_midiMusic->playMIDI(dwSeqLen, bLoop);
}
- _vm->_midiMusic->playMIDI(dwSeqLen, bLoop);
+ midiStream.close();
return true;
}
@@ -277,63 +282,89 @@ void SetMidiVolume(int vol) {
void OpenMidiFiles() {
Common::File midiStream;
- // Demo version has no midi file
- if (TinselV0 || TinselV2)
- return;
+ if (TinselV0) {
+ // The early demo version of DW1 doesn't have MIDI
+ } else if (TinselV2) {
+ // DW2 uses a different music mechanism
+ } else if (TinselV1Mac) {
+ // open MIDI sequence file in binary mode
+ if (!midiStream.open(MIDI_FILE))
+ error(CANNOT_FIND_FILE, MIDI_FILE);
- if (g_midiBuffer.pDat)
- // already allocated
- return;
+ uint32 curTrack = 1;
+ uint32 songLength = 0;
+ int32 fileSize = midiStream.size();
- // open MIDI sequence file in binary mode
- if (!midiStream.open(MIDI_FILE))
- error(CANNOT_FIND_FILE, MIDI_FILE);
+ // Init
+ for (int i = 0; i < ARRAYSIZE(g_midiOffsets); i++)
+ g_midiOffsets[i] = 0;
- // gen length of the largest sequence
- g_midiBuffer.size = midiStream.readUint32LE();
- if (midiStream.eos() || midiStream.err())
- error(FILE_IS_CORRUPT, MIDI_FILE);
-
- if (g_midiBuffer.size) {
- // allocate a buffer big enough for the largest MIDI sequence
- if ((g_midiBuffer.pDat = (uint8 *)malloc(g_midiBuffer.size)) != NULL) {
- // clear out the buffer
- memset(g_midiBuffer.pDat, 0, g_midiBuffer.size);
-// VMM_lock(midiBuffer.pDat, midiBuffer.size);
- } else {
- //mSeqHandle = NULL;
+ midiStream.skip(4); // skip file header
+
+ while (!midiStream.eos() && !midiStream.err() && midiStream.pos() != fileSize) {
+ assert(curTrack < ARRAYSIZE(g_midiOffsets));
+ g_midiOffsets[curTrack] = midiStream.pos();
+ //debug("%d: %d", curTrack, g_midiOffsets[curTrack]);
+
+ songLength = midiStream.readUint32BE();
+ midiStream.skip(songLength);
+
+ curTrack++;
}
- }
- // Now scan through the contents of the MIDI file to find the offset
- // of each individual track, in order to create a mapping from MIDI
- // offset to track number, for the enhanced MIDI soundtrack.
- // The first song is always at position 4. The subsequent ones are
- // calculated dynamically.
- uint32 curOffset = 4;
- uint32 curTrack = 0;
- uint32 songLength = 0;
+ midiStream.close();
+ } else {
+ if (g_midiBuffer.pDat)
+ // already allocated
+ return;
+
+ // open MIDI sequence file in binary mode
+ if (!midiStream.open(MIDI_FILE))
+ error(CANNOT_FIND_FILE, MIDI_FILE);
+
+ // get length of the largest sequence
+ g_midiBuffer.size = midiStream.readUint32LE();
+ if (midiStream.eos() || midiStream.err())
+ error(FILE_IS_CORRUPT, MIDI_FILE);
+
+ if (g_midiBuffer.size) {
+ // allocate a buffer big enough for the largest MIDI sequence
+ if ((g_midiBuffer.pDat = (uint8 *)malloc(g_midiBuffer.size)) != NULL) {
+ // clear out the buffer
+ memset(g_midiBuffer.pDat, 0, g_midiBuffer.size);
+ }
+ }
- // Init
- for (int i = 0; i < ARRAYSIZE(g_midiOffsets); i++)
- g_midiOffsets[i] = 0;
+ // Now scan through the contents of the MIDI file to find the offset
+ // of each individual track, in order to create a mapping from MIDI
+ // offset to track number, for the enhanced MIDI soundtrack.
+ // The first song is always at position 4. The subsequent ones are
+ // calculated dynamically.
+ uint32 curOffset = 4;
+ uint32 curTrack = 0;
+ uint32 songLength = 0;
+
+ // Init
+ for (int i = 0; i < ARRAYSIZE(g_midiOffsets); i++)
+ g_midiOffsets[i] = 0;
+
+ while (!midiStream.eos() && !midiStream.err()) {
+ if (curOffset + (4 * curTrack) >= (uint32)midiStream.size())
+ break;
- while (!midiStream.eos() && !midiStream.err()) {
- if (curOffset + (4 * curTrack) >= (uint32)midiStream.size())
- break;
+ assert(curTrack < ARRAYSIZE(g_midiOffsets));
+ g_midiOffsets[curTrack] = curOffset + (4 * curTrack);
+ //debug("%d: %d", curTrack, midiOffsets[curTrack]);
- assert(curTrack < ARRAYSIZE(g_midiOffsets));
- g_midiOffsets[curTrack] = curOffset + (4 * curTrack);
- //debug("%d: %d", curTrack, midiOffsets[curTrack]);
+ songLength = midiStream.readUint32LE();
+ curOffset += songLength;
+ midiStream.skip(songLength);
- songLength = midiStream.readUint32LE();
- curOffset += songLength;
- midiStream.skip(songLength);
+ curTrack++;
+ }
- curTrack++;
+ midiStream.close();
}
-
- midiStream.close();
}
void DeleteMidiBuffer() {
@@ -784,8 +815,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!
@@ -797,11 +828,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))
@@ -839,14 +870,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..b70b581bbe 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
@@ -375,7 +375,7 @@ OBJECT *InitObject(const OBJ_INIT *pInitTbl) {
if (pImg->hImgPal) {
// allocate a palette for this object
- pPalQ = AllocPalette(FROM_LE_32(pImg->hImgPal));
+ pPalQ = AllocPalette(FROM_32(pImg->hImgPal));
// make sure palette allocated
assert(pPalQ != NULL);
@@ -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..b72d52cc8d 100644
--- a/engines/tinsel/palette.cpp
+++ b/engines/tinsel/palette.cpp
@@ -72,8 +72,6 @@ static VIDEO_DAC_Q *g_pDAChead;
/** the translucent palette lookup table */
uint8 g_transPalette[MAX_COLORS]; // used in graphics.cpp
-uint8 g_ghostPalette[MAX_COLORS];
-
static int g_translucentIndex = 228;
static int g_talkIndex = 233;
@@ -102,7 +100,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 +108,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);
@@ -170,6 +168,16 @@ void PalettesToVideoDAC() {
pal[i * 3 + 2] = TINSEL_GetBValue(pColors[i]);
}
+ // Swap black/white colors in the Mac version.
+ // We need to swap the current black/white values so that screen fade
+ // in/out is done correctly.
+ if (TinselV1Mac) {
+ byte macWhite = pal[ 0 * 3 + 0];
+ byte macBlack = pal[254 * 3 + 0];
+ pal[254 * 3 + 0] = pal[254 * 3 + 1] = pal[254 * 3 + 2] = macWhite;
+ pal[ 0 * 3 + 0] = pal[ 0 * 3 + 1] = pal[ 0 * 3 + 2] = macBlack;
+ }
+
// update the system palette
g_system->getPaletteManager()->setPalette(pal, pDACtail->destDACindex, pDACtail->numColors);
@@ -318,7 +326,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 +438,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 +554,8 @@ void CreateTranslucentPalette(SCNHANDLE hPalette) {
// leave background color alone
g_transPalette[0] = 0;
- for (uint i = 0; i < FROM_LE_32(pPal->numColors); i++) {
+ int32 numColors = FROM_32(pPal->numColors);
+ for (int32 i = 0; i < numColors; i++) {
// get the RGB color model values
uint8 red = TINSEL_GetRValue(pPal->palRGB[i]);
uint8 green = TINSEL_GetGValue(pPal->palRGB[i]);
@@ -558,41 +567,13 @@ void CreateTranslucentPalette(SCNHANDLE hPalette) {
// map the Value field to one of the 4 colors reserved for the translucent palette
val /= 63;
- g_transPalette[i + 1] = (uint8)((val == 0) ? 0 : val +
+ byte blackColorIndex = (!TinselV1Mac) ? 0 : 255;
+ g_transPalette[i + 1] = (uint8)((val == 0) ? blackColorIndex : val +
(TinselV2 ? TranslucentColor() : COL_HILIGHT) - 1);
}
}
/**
- * Creates the ghost palette
- */
-void CreateGhostPalette(SCNHANDLE hPalette) {
- // get a pointer to the palette
- PALETTE *pPal = (PALETTE *)LockMem(hPalette);
- int i;
-
- // leave background color alone
- g_ghostPalette[0] = 0;
-
- for (i = 0; i < (int)FROM_LE_32(pPal->numColors); i++) {
- // get the RGB color model values
- uint8 red = TINSEL_GetRValue(pPal->palRGB[i]);
- uint8 green = TINSEL_GetGValue(pPal->palRGB[i]);
- uint8 blue = TINSEL_GetBValue(pPal->palRGB[i]);
-
- // calculate the Value field of the HSV color model
- unsigned val = (red > green) ? red : green;
- val = (val > blue) ? val : blue;
-
- // map the Value field to one of the 4 colors reserved for the translucent palette
- val /= 64;
- assert(/*val >= 0 &&*/ val <= 3);
- g_ghostPalette[i + 1] = (uint8)(val + SysVar(ISV_GHOST_BASE));
- }
-}
-
-
-/**
* Returns an adjusted color RGB
* @param color Color to scale
*/
diff --git a/engines/tinsel/palette.h b/engines/tinsel/palette.h
index af58a7ffbd..c57b8df2ba 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)))
@@ -107,7 +107,7 @@ void PaletteStats(); // Shows the maximum number of palettes used at once
void psxPaletteMapper(PALQ *originalPal, uint8 *psxClut, byte *mapperTable); // Maps PSX CLUTs to original palette in resource file
-void PalettesToVideoDAC(); // Update the video DAC with palettes currently the the DAC queue
+void PalettesToVideoDAC(); // Update the video DAC with palettes currently in the DAC queue
void UpdateDACqueueHandle(
int posInDAC, // position in video DAC
@@ -146,8 +146,6 @@ void FadingPalette(PALQ *pPalQ, bool bFading);
void CreateTranslucentPalette(SCNHANDLE BackPal);
-void CreateGhostPalette(SCNHANDLE hPalette);
-
void NoFadingPalettes(); // All fading processes have just been killed
void DimPartPalette(
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/saveload.cpp b/engines/tinsel/saveload.cpp
index 2ef92d853f..acff196916 100644
--- a/engines/tinsel/saveload.cpp
+++ b/engines/tinsel/saveload.cpp
@@ -540,8 +540,8 @@ static void SaveFailure(Common::OutSaveFile *f) {
if (f) {
delete f;
_vm->getSaveFileMan()->removeSavefile(g_SaveSceneName);
- g_SaveSceneName = NULL; // Invalidate save name
}
+ g_SaveSceneName = NULL; // Invalidate save name
GUI::MessageDialog dialog(_("Failed to save game state to file."));
dialog.runModal();
}
diff --git a/engines/tinsel/savescn.cpp b/engines/tinsel/savescn.cpp
index 0c0cc5c81e..d2537169f7 100644
--- a/engines/tinsel/savescn.cpp
+++ b/engines/tinsel/savescn.cpp
@@ -303,7 +303,7 @@ static int DoRestoreSceneFrame(SAVED_DATA *sd, int n) {
switch (n) {
case RS_COUNT + COUNTOUT_COUNT:
// Trigger pre-load and fade and start countdown
- FadeOutFast(NULL);
+ FadeOutFast();
break;
case RS_COUNT:
@@ -360,7 +360,6 @@ static int DoRestoreSceneFrame(SAVED_DATA *sd, int n) {
RestoreActorZ(sd->savedActorZ);
RestoreZpositions(sd->zPositions);
RestoreSysVars(sd->SavedSystemVars);
- CreateGhostPalette(BgPal());
RestoreActors(sd->NumSavedActors, sd->SavedActorInfo);
RestoreSoundReels(sd->SavedSoundReels);
return 1;
diff --git a/engines/tinsel/scene.cpp b/engines/tinsel/scene.cpp
index c5444517f1..17cb23b98f 100644
--- a/engines/tinsel/scene.cpp
+++ b/engines/tinsel/scene.cpp
@@ -86,8 +86,8 @@ struct SCENE_STRUC {
SCNHANDLE hTaggedActor; // handle to table of tagged actors
int32 numProcess; // number of processes in this scene
SCNHANDLE hProcess; // handle to table of processes
- SCNHANDLE hMusicScript; // handle to music script data
- SCNHANDLE hMusicSegment;// handle to music segments
+ SCNHANDLE hMusicScript; // handle to music script data - Tinsel 2 only
+ SCNHANDLE hMusicSegment;// handle to music segments - Tinsel 2 only
} PACKED_STRUCT;
/** entrance structure - one per entrance */
@@ -130,15 +130,15 @@ const SCENE_STRUC *GetSceneStruc(const byte *pStruc) {
const byte *p = pStruc;
memset(&g_tempStruc, 0, sizeof(SCENE_STRUC));
- g_tempStruc.numEntrance = READ_UINT32(p); p += sizeof(uint32);
- g_tempStruc.numPoly = READ_UINT32(p); p += sizeof(uint32);
- g_tempStruc.numTaggedActor = READ_UINT32(p); p += sizeof(uint32);
- g_tempStruc.defRefer = READ_UINT32(p); p += sizeof(uint32);
- g_tempStruc.hSceneScript = READ_UINT32(p); p += sizeof(uint32);
- g_tempStruc.hEntrance = READ_UINT32(p); p += sizeof(uint32);
- g_tempStruc.hPoly = READ_UINT32(p); p += sizeof(uint32);
- g_tempStruc.hTaggedActor = READ_UINT32(p); p += sizeof(uint32);
-
+ g_tempStruc.numEntrance = READ_32(p); p += sizeof(uint32);
+ g_tempStruc.numPoly = READ_32(p); p += sizeof(uint32);
+ g_tempStruc.numTaggedActor = READ_32(p); p += sizeof(uint32);
+ g_tempStruc.defRefer = READ_32(p); p += sizeof(uint32);
+ g_tempStruc.hSceneScript = READ_32(p); p += sizeof(uint32);
+ g_tempStruc.hEntrance = READ_32(p); p += sizeof(uint32);
+ g_tempStruc.hPoly = READ_32(p); p += sizeof(uint32);
+ g_tempStruc.hTaggedActor = READ_32(p); p += sizeof(uint32);
+
return &g_tempStruc;
}
@@ -159,7 +159,8 @@ static void SceneTinselProcess(CORO_PARAM, const void *param) {
// The following myEscape value setting is used for enabling title screen skipping in DW1
if (TinselV1 && (g_sceneCtr == 1)) g_initialMyEscape = GetEscEvents();
// DW1 PSX has its own scene skipping script code for scenes 2 and 3 (bug #3541542).
- _ctx->myEscape = (TinselV1 && (g_sceneCtr < (TinselV1PSX ? 2 : 4))) ? g_initialMyEscape : 0;
+ // Same goes for DW1 Mac.
+ _ctx->myEscape = (TinselV1 && (g_sceneCtr < ((TinselV1PSX || TinselV1Mac) ? 2 : 4))) ? g_initialMyEscape : 0;
// get the stuff copied to process when it was created
_ctx->pInit = (const TP_INIT *)param;
@@ -167,7 +168,7 @@ static void SceneTinselProcess(CORO_PARAM, const void *param) {
assert(_ctx->pInit->hTinselCode); // Must have some code to run
_ctx->pic = InitInterpretContext(GS_SCENE,
- READ_LE_UINT32(&_ctx->pInit->hTinselCode),
+ _ctx->pInit->hTinselCode,
TinselV2 ? _ctx->pInit->event : NOEVENT,
NOPOLY, // No polygon
0, // No actor
@@ -209,7 +210,7 @@ void SendSceneTinselProcess(TINSEL_EVENT event) {
*/
static void LoadScene(SCNHANDLE scene, int entry) {
- uint i;
+ int32 i;
TP_INIT init;
const SCENE_STRUC *ss;
const ENTRANCE_STRUC *es;
@@ -223,7 +224,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);
@@ -238,18 +239,17 @@ static void LoadScene(SCNHANDLE scene, int entry) {
// Music stuff
char *cptr = (char *)FindChunk(scene, CHUNK_MUSIC_FILENAME);
assert(cptr);
- _vm->_pcmMusic->setMusicSceneDetails(FROM_LE_32(ss->hMusicScript),
- FROM_LE_32(ss->hMusicSegment), cptr);
+ _vm->_pcmMusic->setMusicSceneDetails(ss->hMusicScript, ss->hMusicSegment, cptr);
}
if (entry == NO_ENTRY_NUM) {
// Restoring scene
// Initialize all the polygons for this scene
- InitPolygons(FROM_LE_32(ss->hPoly), FROM_LE_32(ss->numPoly), true);
+ InitPolygons(ss->hPoly, ss->numPoly, true);
// Initialize the actors for this scene
- StartTaggedActors(FROM_LE_32(ss->hTaggedActor), FROM_LE_32(ss->numTaggedActor), false);
+ StartTaggedActors(ss->hTaggedActor, ss->numTaggedActor, false);
if (TinselV2)
// Returning from cutscene
@@ -259,18 +259,18 @@ static void LoadScene(SCNHANDLE scene, int entry) {
// Genuine new scene
// Initialize all the polygons for this scene
- InitPolygons(FROM_LE_32(ss->hPoly), FROM_LE_32(ss->numPoly), false);
+ InitPolygons(ss->hPoly, ss->numPoly, false);
// Initialize the actors for this scene
- StartTaggedActors(FROM_LE_32(ss->hTaggedActor), FROM_LE_32(ss->numTaggedActor), true);
+ StartTaggedActors(ss->hTaggedActor, ss->numTaggedActor, true);
// Run the appropriate entrance code (if any)
- es = (const ENTRANCE_STRUC *)LockMem(FROM_LE_32(ss->hEntrance));
- for (i = 0; i < FROM_LE_32(ss->numEntrance); i++) {
- if (FROM_LE_32(es->eNumber) == (uint)entry) {
+ es = (const ENTRANCE_STRUC *)LockMem(ss->hEntrance);
+ for (i = 0; i < ss->numEntrance; i++) {
+ if (FROM_32(es->eNumber) == (uint)entry) {
if (es->hScript) {
init.event = STARTUP;
- init.hTinselCode = es->hScript;
+ init.hTinselCode = FROM_32(es->hScript);
CoroScheduler.createProcess(PID_TCODE, SceneTinselProcess, &init, sizeof(init));
}
@@ -285,8 +285,8 @@ static void LoadScene(SCNHANDLE scene, int entry) {
}
- if (i == FROM_LE_32(ss->numEntrance))
- error("Non-existant scene entry number");
+ if (i == ss->numEntrance)
+ error("Non-existent scene entry number");
if (ss->hSceneScript) {
init.event = STARTUP;
@@ -297,10 +297,10 @@ static void LoadScene(SCNHANDLE scene, int entry) {
}
// Default refer type
- SetDefaultRefer(FROM_LE_32(ss->defRefer));
+ SetDefaultRefer(ss->defRefer);
// Scene's processes
- SceneProcesses(FROM_LE_32(ss->numProcess), FROM_LE_32(ss->hProcess));
+ SceneProcesses(ss->numProcess, ss->hProcess);
}
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/sound.cpp b/engines/tinsel/sound.cpp
index e052302cfd..416ee74127 100644
--- a/engines/tinsel/sound.cpp
+++ b/engines/tinsel/sound.cpp
@@ -74,8 +74,8 @@ SoundManager::~SoundManager() {
*/
// playSample for DiscWorld 1
bool SoundManager::playSample(int id, Audio::Mixer::SoundType type, Audio::SoundHandle *handle) {
- // Floppy version has no sample file
- if (!_vm->isCD())
+ // Floppy version has no sample file.
+ if (!_vm->isV1CD())
return false;
// no sample driver?
@@ -102,7 +102,7 @@ bool SoundManager::playSample(int id, Audio::Mixer::SoundType type, Audio::Sound
error(FILE_IS_CORRUPT, _vm->getSampleFile(g_sampleLanguage));
// read the length of the sample
- uint32 sampleLen = _sampleStream.readUint32();
+ uint32 sampleLen = _sampleStream.readUint32LE();
if (_sampleStream.eos() || _sampleStream.err())
error(FILE_IS_CORRUPT, _vm->getSampleFile(g_sampleLanguage));
@@ -177,14 +177,36 @@ bool SoundManager::playSample(int id, Audio::Mixer::SoundType type, Audio::Sound
return true;
}
+void SoundManager::playDW1MacMusic(Common::File &s, uint32 length) {
+ // TODO: It's a bad idea to load the music track in a buffer.
+ // We should use a SubReadStream instead, and keep midi.dat open.
+ // However, the track lengths aren't that big (about 1-4MB),
+ // so this shouldn't be a major issue.
+ byte *soundData = (byte *)malloc(length);
+ assert(soundData);
+
+ // read all of the sample
+ if (s.read(soundData, length) != length)
+ error(FILE_IS_CORRUPT, MIDI_FILE);
+
+ Common::SeekableReadStream *memStream = new Common::MemoryReadStream(soundData, length);
+
+ Audio::SoundHandle *handle = &_channels[kChannelDW1MacMusic].handle;
+
+ // Stop any previously playing music track
+ _vm->_mixer->stopHandle(*handle);
+
+ // TODO: Compression support (MP3/OGG/FLAC) for midi.dat in DW1 Mac
+ Audio::RewindableAudioStream *musicStream = Audio::makeRawStream(memStream, 22050, Audio::FLAG_UNSIGNED, DisposeAfterUse::YES);
+
+ if (musicStream)
+ _vm->_mixer->playStream(Audio::Mixer::kMusicSoundType, handle, Audio::makeLoopingAudioStream(musicStream, 0));
+}
+
// playSample for DiscWorld 2
bool SoundManager::playSample(int id, int sub, bool bLooped, int x, int y, int priority,
Audio::Mixer::SoundType type, Audio::SoundHandle *handle) {
- // Floppy version has no sample file
- if (!_vm->isCD())
- return false;
-
// no sample driver?
if (!_vm->_mixer->isReady())
return false;
@@ -247,7 +269,7 @@ bool SoundManager::playSample(int id, int sub, bool bLooped, int x, int y, int p
uint32 dwSampleIndex = _sampleIndex[id];
if (dwSampleIndex == 0) {
- warning("Tinsel2 playSample, non-existant sample %d", id);
+ warning("Tinsel2 playSample, non-existent sample %d", id);
return false;
}
@@ -257,7 +279,7 @@ bool SoundManager::playSample(int id, int sub, bool bLooped, int x, int y, int p
error(FILE_IS_CORRUPT, _vm->getSampleFile(g_sampleLanguage));
// read the length of the sample
- uint32 sampleLen = _sampleStream.readUint32();
+ uint32 sampleLen = _sampleStream.readUint32LE();
if (_sampleStream.eos() || _sampleStream.err())
error(FILE_IS_CORRUPT, _vm->getSampleFile(g_sampleLanguage));
@@ -270,12 +292,12 @@ bool SoundManager::playSample(int id, int sub, bool bLooped, int x, int y, int p
// Skipping
for (int32 i = 0; i < sub; i++) {
- sampleLen = _sampleStream.readUint32();
+ sampleLen = _sampleStream.readUint32LE();
_sampleStream.skip(sampleLen);
if (_sampleStream.eos() || _sampleStream.err())
error(FILE_IS_CORRUPT, _vm->getSampleFile(g_sampleLanguage));
}
- sampleLen = _sampleStream.readUint32();
+ sampleLen = _sampleStream.readUint32LE();
if (_sampleStream.eos() || _sampleStream.err())
error(FILE_IS_CORRUPT, _vm->getSampleFile(g_sampleLanguage));
}
@@ -369,7 +391,6 @@ bool SoundManager::offscreenChecks(int x, int &y) {
}
int8 SoundManager::getPan(int x) {
-
if (x == -1)
return 0;
@@ -416,14 +437,13 @@ bool SoundManager::sampleExists(int id) {
/**
* Returns true if a sample is currently playing.
*/
-bool SoundManager::sampleIsPlaying(int id) {
+bool SoundManager::sampleIsPlaying() {
if (!TinselV2)
return _vm->_mixer->isSoundHandleActive(_channels[kChannelTinsel1].handle);
for (int i = 0; i < kNumChannels; i++)
- if (_channels[i].sampleNum == id)
- if (_vm->_mixer->isSoundHandleActive(_channels[i].handle))
- return true;
+ if (_vm->_mixer->isSoundHandleActive(_channels[i].handle))
+ return true;
return false;
}
@@ -432,8 +452,6 @@ bool SoundManager::sampleIsPlaying(int id) {
* Stops any currently playing sample.
*/
void SoundManager::stopAllSamples() {
- // stop currently playing sample
-
if (!TinselV2) {
_vm->_mixer->stopHandle(_channels[kChannelTinsel1].handle);
return;
@@ -466,12 +484,21 @@ void SoundManager::setSFXVolumes(uint8 volume) {
_vm->_mixer->setChannelVolume(_channels[i].handle, volume);
}
+void SoundManager::showSoundError(const char *errorMsg, const char *soundFile) {
+ Common::String msg;
+ msg = Common::String::format(errorMsg, soundFile);
+ GUI::MessageDialog dialog(msg, "OK");
+ dialog.runModal();
+
+ error("%s", msg.c_str());
+}
+
/**
* Opens and inits all sound sample files.
*/
void SoundManager::openSampleFiles() {
- // Floppy and demo versions have no sample files, except for the Discworld 2 demo
- if (!_vm->isCD() || TinselV0)
+ // V1 Floppy and V0 demo versions have no sample files
+ if (TinselV0 || (TinselV1 && !_vm->isV1CD()))
return;
TinselFile f;
@@ -480,42 +507,26 @@ void SoundManager::openSampleFiles() {
// already allocated
return;
- // open sample index file in binary mode
+ // Open sample index (*.idx) in binary mode
if (f.open(_vm->getSampleIndex(g_sampleLanguage))) {
- // get length of index file
- f.seek(0, SEEK_END); // move to end of file
- _sampleIndexLen = f.pos(); // get file pointer
- f.seek(0, SEEK_SET); // back to beginning
-
+ uint32 fileSize = f.size();
+ _sampleIndex = (uint32 *)malloc(fileSize);
if (_sampleIndex == NULL) {
- // allocate a buffer for the indices
- _sampleIndex = (uint32 *)malloc(_sampleIndexLen);
-
- // make sure memory allocated
- if (_sampleIndex == NULL) {
- // disable samples if cannot alloc buffer for indices
- // TODO: Disabled sound if we can't load the sample index?
- return;
- }
+ showSoundError(NO_MEM, _vm->getSampleIndex(g_sampleLanguage));
+ return;
}
- // load data
- if (f.read(_sampleIndex, _sampleIndexLen) != (uint32)_sampleIndexLen)
- // file must be corrupt if we get to here
- error(FILE_IS_CORRUPT, _vm->getSampleFile(g_sampleLanguage));
-
- // close the file
- f.close();
-
- // convert file size to size in DWORDs
- _sampleIndexLen /= sizeof(uint32);
+ _sampleIndexLen = fileSize / 4; // total sample of indices (DWORDs)
-#ifdef SCUMM_BIG_ENDIAN
- // Convert all ids from LE to native format
+ // Load data
for (int i = 0; i < _sampleIndexLen; ++i) {
- _sampleIndex[i] = SWAP_BYTES_32(_sampleIndex[i]);
+ _sampleIndex[i] = f.readUint32LE();
+ if (f.err()) {
+ showSoundError(FILE_READ_ERROR, _vm->getSampleIndex(g_sampleLanguage));
+ }
}
-#endif
+
+ f.close();
// Detect format of soundfile by looking at 1st sample-index
switch (TO_BE_32(_sampleIndex[0])) {
@@ -523,48 +534,31 @@ void SoundManager::openSampleFiles() {
debugC(DEBUG_DETAILED, kTinselDebugSound, "Detected MP3 sound-data");
_soundMode = kMP3Mode;
break;
-
case MKTAG('O','G','G',' '):
debugC(DEBUG_DETAILED, kTinselDebugSound, "Detected OGG sound-data");
_soundMode = kVorbisMode;
break;
-
case MKTAG('F','L','A','C'):
debugC(DEBUG_DETAILED, kTinselDebugSound, "Detected FLAC sound-data");
_soundMode = kFLACMode;
break;
-
default:
debugC(DEBUG_DETAILED, kTinselDebugSound, "Detected original sound-data");
break;
}
- // Normally the 1st sample-index points to nothing at all
+
+ // Normally the 1st sample index points to nothing at all. We use it to
+ // determine if the game's sample files have been compressed, thus restore
+ // it here
_sampleIndex[0] = 0;
} else {
- char buf[50];
- sprintf(buf, CANNOT_FIND_FILE, _vm->getSampleIndex(g_sampleLanguage));
- GUI::MessageDialog dialog(buf, "OK");
- dialog.runModal();
-
- error(CANNOT_FIND_FILE, _vm->getSampleIndex(g_sampleLanguage));
+ showSoundError(FILE_READ_ERROR, _vm->getSampleIndex(g_sampleLanguage));
}
- // open sample file in binary mode
+ // Open sample file (*.smp) in binary mode
if (!_sampleStream.open(_vm->getSampleFile(g_sampleLanguage))) {
- char buf[50];
- sprintf(buf, CANNOT_FIND_FILE, _vm->getSampleFile(g_sampleLanguage));
- GUI::MessageDialog dialog(buf, "OK");
- dialog.runModal();
-
- error(CANNOT_FIND_FILE, _vm->getSampleFile(g_sampleLanguage));
+ showSoundError(FILE_READ_ERROR, _vm->getSampleFile(g_sampleLanguage));
}
-
-/*
- // gen length of the largest sample
- sampleBuffer.size = _sampleStream.readUint32LE();
- if (_sampleStream.eos() || _sampleStream.err())
- error(FILE_IS_CORRUPT, _vm->getSampleFile(g_sampleLanguage));
-*/
}
void SoundManager::closeSampleStream() {
diff --git a/engines/tinsel/sound.h b/engines/tinsel/sound.h
index d7083b3b21..c68d9cb71e 100644
--- a/engines/tinsel/sound.h
+++ b/engines/tinsel/sound.h
@@ -51,7 +51,8 @@ protected:
enum {
kChannelTalk = 0,
kChannelTinsel1 = 0, // Always using this channel for DW1
- kChannelSFX = 1
+ kChannelSFX = 1,
+ kChannelDW1MacMusic = 2
};
static const int kNumChannels = kChannelSFX + kNumSFX;
@@ -108,6 +109,7 @@ public:
bool playSample(int id, Audio::Mixer::SoundType type, Audio::SoundHandle *handle = 0);
bool playSample(int id, int sub, bool bLooped, int x, int y, int priority,
Audio::Mixer::SoundType type, Audio::SoundHandle *handle = 0);
+ void playDW1MacMusic(Common::File &s, uint32 length);
void stopAllSamples(); // Stops any currently playing sample
void stopSpecSample(int id, int sub = 0); // Stops a specific sample
@@ -115,11 +117,13 @@ public:
void setSFXVolumes(uint8 volume);
bool sampleExists(int id);
- bool sampleIsPlaying(int id = -1);
+ bool sampleIsPlaying();
- // TODO: Internal method, make this protected?
void openSampleFiles();
void closeSampleStream();
+
+private:
+ void showSoundError(const char *errorMsg, const char *soundFile);
};
} // End of namespace Tinsel
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/timers.cpp b/engines/tinsel/timers.cpp
index d3a7446565..36986ccb47 100644
--- a/engines/tinsel/timers.cpp
+++ b/engines/tinsel/timers.cpp
@@ -106,7 +106,7 @@ static TIMER *findTimer(int num) {
*/
static TIMER *allocateTimer(int num) {
assert(num); // zero is not allowed as a timer number
- assert(!findTimer(num)); // Allocating already existant timer
+ assert(!findTimer(num)); // Allocating already existent timer
for (int i = 0; i < MAX_TIMERS; i++) {
if (!g_timers[i].tno) {
diff --git a/engines/tinsel/tinlib.cpp b/engines/tinsel/tinlib.cpp
index 058f8eb6fd..34aa64a609 100644
--- a/engines/tinsel/tinlib.cpp
+++ b/engines/tinsel/tinlib.cpp
@@ -1151,14 +1151,14 @@ static void FaceTag(int actor, HPOLYGON hp) {
* FadeIn
*/
static void FadeIn() {
- FadeInMedium(NULL);
+ FadeInMedium();
}
/**
* FadeOut
*/
static void FadeOut() {
- FadeOutMedium(NULL);
+ FadeOutMedium();
}
/**
@@ -1198,7 +1198,6 @@ static void Ghost(int actor, int tColor, int tPalOffset) {
SetSysVar(ISV_GHOST_ACTOR, actor);
SetSysVar(ISV_GHOST_COLOR, tColor);
SetSysVar(ISV_GHOST_BASE, tPalOffset);
- CreateGhostPalette(BgPal());
}
/**
@@ -3684,7 +3683,7 @@ static void TranslucentIndex(unsigned index) {
}
/**
- * Play a sample.
+ * Play a sample (DW1 only).
*/
static void TryPlaySample(CORO_PARAM, int sample, bool bComplete, bool escOn, int myEscape) {
CORO_BEGIN_CONTEXT;
diff --git a/engines/tinsel/tinsel.cpp b/engines/tinsel/tinsel.cpp
index e09e2c1dcf..9075e1adb1 100644
--- a/engines/tinsel/tinsel.cpp
+++ b/engines/tinsel/tinsel.cpp
@@ -430,6 +430,14 @@ static void MouseProcess(CORO_PARAM, const void *) {
ProcessButEvent(PLR_DRAG2_END);
break;
+ case Common::EVENT_WHEELUP:
+ PlayerEvent(PLR_WHEEL_UP, mousePos);
+ break;
+
+ case Common::EVENT_WHEELDOWN:
+ PlayerEvent(PLR_WHEEL_DOWN, mousePos);
+ break;
+
default:
break;
}
@@ -658,7 +666,7 @@ bool ChangeScene(bool bReset) {
default:
// Trigger pre-load and fade and start countdown
CountOut = COUNTOUT_COUNT;
- FadeOutFast(NULL);
+ FadeOutFast();
if (TinselV2)
_vm->_pcmMusic->startFadeOut(COUNTOUT_COUNT);
break;
@@ -722,21 +730,20 @@ void LoadBasicChunks() {
cptr = FindChunk(INV_OBJ_SCNHANDLE, CHUNK_OBJECTS);
-#ifdef SCUMM_BIG_ENDIAN
- //convert to native endianness
+ // 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
RegisterIcons(cptr, numObjects);
cptr = FindChunk(MASTER_SCNHANDLE, CHUNK_TOTAL_POLY);
- if (cptr != NULL)
+ // Max polygons are 0 in DW1 Mac (both in the demo and the full version)
+ if (cptr != NULL && *cptr != 0)
MaxPolygons(*cptr);
if (TinselV2) {
@@ -1046,6 +1053,8 @@ bool TinselEngine::pollEvent() {
case Common::EVENT_LBUTTONUP:
case Common::EVENT_RBUTTONDOWN:
case Common::EVENT_RBUTTONUP:
+ case Common::EVENT_WHEELUP:
+ case Common::EVENT_WHEELDOWN:
// Add button to queue for the mouse process
_mouseButtons.push_back(event.type);
break;
@@ -1053,7 +1062,7 @@ bool TinselEngine::pollEvent() {
case Common::EVENT_MOUSEMOVE:
{
// This fragment takes care of Tinsel 2 when it's been compiled with
- // blank areas at the top and bottom of thes creen
+ // blank areas at the top and bottom of the screen
int ySkip = TinselV2 ? (g_system->getHeight() - _vm->screen().h) / 2 : 0;
if ((event.mouse.y >= ySkip) && (event.mouse.y < (g_system->getHeight() - ySkip)))
_mousePos = Common::Point(event.mouse.x, event.mouse.y - ySkip);
diff --git a/engines/tinsel/tinsel.h b/engines/tinsel/tinsel.h
index 123249125e..5eb3b7d7b8 100644
--- a/engines/tinsel/tinsel.h
+++ b/engines/tinsel/tinsel.h
@@ -78,7 +78,7 @@ enum TinselGameFeatures {
/**
* The following is the ScummVM definitions of the various Tinsel versions:
* TINSEL_V0 - This was an early engine version that was only used in the Discworld 1
- * demo. It is not currently supported.
+ * demo.
* TINSEL_V1 - This was the engine version used by Discworld 1. Note that there were two
* major releases: an earlier version that used *.gra files, and a later one that
* used *.scn files, and contained certain script and engine bugfixes. In ScummVM,
@@ -135,6 +135,9 @@ typedef bool (*KEYFPTR)(const Common::KeyState &);
#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;
@@ -181,7 +184,7 @@ public:
uint32 getFlags() const;
Common::Platform getPlatform() const;
bool getIsADGFDemo() const;
- bool isCD() const;
+ bool isV1CD() const;
const char *getSampleIndex(LANGUAGE lang);
const char *getSampleFile(LANGUAGE lang);
@@ -223,7 +226,11 @@ public:
Graphics::Surface &screen() { return _screenSurface; }
Common::Point getMousePosition() const { return _mousePos; }
- void setMousePosition(const Common::Point &pt) {
+ void setMousePosition(Common::Point pt) {
+ // Clip mouse position to be within the screen coordinates
+ pt.x = CLIP<int16>(pt.x, 0, SCREEN_WIDTH - 1);
+ pt.y = CLIP<int16>(pt.y, 0, SCREEN_HEIGHT - 1);
+
int yOffset = TinselV2 ? (g_system->getHeight() - _screenSurface.h) / 2 : 0;
g_system->warpMouse(pt.x, pt.y + yOffset);
_mousePos = pt;