[Scummvm-cvs-logs] scummvm master -> b532a81b42bce16838347aa560138da1b15418e5
bluegr
bluegr at gmail.com
Mon Dec 10 16:39:27 CET 2012
This automated email contains information about 3 new commits which have been
pushed to the 'scummvm' repo located at https://github.com/scummvm/scummvm .
Summary:
c6cf4827d7 TINSEL: Revert most of the engine BE resource handling code
c90d56355f TINSEL: Simplify the scene entrance handling code
b532a81b42 TINSEL: Add a WIP BE To LE SCN file conversion code (unfinished)
Commit: c6cf4827d719c1833ce4d7e108410db81f00c358
https://github.com/scummvm/scummvm/commit/c6cf4827d719c1833ce4d7e108410db81f00c358
Author: Filippos Karapetis (bluegr at gmail.com)
Date: 2012-12-10T07:38:22-08:00
Commit Message:
TINSEL: Revert most of the engine BE resource handling code
This was added in commit 3fdddd53b2b970aae3e967bebc0bff6e642a5111.
However, having handling for both BE and LE resource complicates
the engine code unnecessarily. Thus, a different approach will be
done.
Changed paths:
engines/tinsel/anim.cpp
engines/tinsel/bg.cpp
engines/tinsel/cursor.cpp
engines/tinsel/font.cpp
engines/tinsel/multiobj.cpp
engines/tinsel/palette.cpp
engines/tinsel/play.cpp
engines/tinsel/scn.cpp
engines/tinsel/tinsel.cpp
diff --git a/engines/tinsel/anim.cpp b/engines/tinsel/anim.cpp
index cfc2612..034296c 100644
--- a/engines/tinsel/anim.cpp
+++ b/engines/tinsel/anim.cpp
@@ -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_32(pAni[pAnim->scriptIndex].hFrame);
+ pAnim->pObject->hShape = FROM_LE_32(pAni[pAnim->scriptIndex].hFrame);
// re-shape the object
MultiReshape(pAnim->pObject);
diff --git a/engines/tinsel/bg.cpp b/engines/tinsel/bg.cpp
index 0c0db12..a3e21a8 100644
--- a/engines/tinsel/bg.cpp
+++ b/engines/tinsel/bg.cpp
@@ -124,7 +124,7 @@ static void BGmainProcess(CORO_PARAM, const void *param) {
pReel = (const FREEL *)param;
// Get the MULTI_INIT structure
- pmi = (const MULTI_INIT *)LockMem(FROM_32(pReel->mobj));
+ pmi = (const MULTI_INIT *)LockMem(FROM_LE_32(pReel->mobj));
// Initialize and insert the object, and initialize its script.
g_pBG[0] = MultiInitObject(pmi);
@@ -249,10 +249,10 @@ void StartupBackground(CORO_PARAM, SCNHANDLE hFilm) {
pim = GetImageFromFilm(hFilm, 0, NULL, NULL, &pfilm);
- SetBackPal(FROM_32(pim->hImgPal));
+ SetBackPal(FROM_LE_32(pim->hImgPal));
// Extract the film speed
- g_BGspeed = ONE_SECOND / FROM_32(pfilm->frate);
+ g_BGspeed = ONE_SECOND / FROM_LE_32(pfilm->frate);
// Start display process for each reel in the film
CoroScheduler.createProcess(PID_REEL, BGmainProcess, &pfilm->reels[0], sizeof(FREEL));
diff --git a/engines/tinsel/cursor.cpp b/engines/tinsel/cursor.cpp
index 5b365fc..bf901c0 100644
--- a/engines/tinsel/cursor.cpp
+++ b/engines/tinsel/cursor.cpp
@@ -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_32(pfr->mobj));
+ pmi = (const MULTI_INIT *)LockMem(FROM_LE_32(pfr->mobj));
if (ppmi)
*ppmi = pmi;
- pFrame = (const FRAME *)LockMem(FROM_32(pmi->hMulFrame));
+ pFrame = (const FRAME *)LockMem(FROM_LE_32(pmi->hMulFrame));
// get pointer to image
- return (IMAGE *)LockMem(READ_32(pFrame));
+ return (IMAGE *)LockMem(READ_LE_UINT32(pFrame));
}
/**
@@ -620,7 +620,7 @@ void DwInitCursor(SCNHANDLE bfilm) {
g_hCursorFilm = bfilm;
pfilm = (const FILM *)LockMem(g_hCursorFilm);
- g_numTrails = FROM_32(pfilm->numreels) - 1;
+ g_numTrails = FROM_LE_32(pfilm->numreels) - 1;
assert(g_numTrails <= MAX_TRAILERS);
}
diff --git a/engines/tinsel/font.cpp b/engines/tinsel/font.cpp
index 6f7c391..54aa7cc 100644
--- a/engines/tinsel/font.cpp
+++ b/engines/tinsel/font.cpp
@@ -102,14 +102,14 @@ void FettleFontPal(SCNHANDLE fontPal) {
assert(g_hTalkFont); // Talk font not declared
pFont = (const FONT *)LockMem(g_hTagFont);
- pImg = (IMAGE *)LockMem(FROM_32(pFont->fontInit.hObjImg)); // get image for char 0
+ pImg = (IMAGE *)LockMem(FROM_LE_32(pFont->fontInit.hObjImg)); // get image for char 0
if (!TinselV2)
pImg->hImgPal = TO_LE_32(fontPal);
else
pImg->hImgPal = 0;
pFont = (const FONT *)LockMem(g_hTalkFont);
- pImg = (IMAGE *)LockMem(FROM_32(pFont->fontInit.hObjImg)); // get image for char 0
+ pImg = (IMAGE *)LockMem(FROM_LE_32(pFont->fontInit.hObjImg)); // get image for char 0
if (!TinselV2)
pImg->hImgPal = TO_LE_32(fontPal);
else
diff --git a/engines/tinsel/multiobj.cpp b/engines/tinsel/multiobj.cpp
index 37769a7..c48fefd 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_32(pInitTbl->hMulFrame)) {
+ if (FROM_LE_32(pInitTbl->hMulFrame)) {
// we have a frame handle
- pFrame = (FRAME *)LockMem(FROM_32(pInitTbl->hMulFrame));
+ pFrame = (FRAME *)LockMem(FROM_LE_32(pInitTbl->hMulFrame));
- obj_init.hObjImg = READ_32(pFrame); // first objects shape
+ obj_init.hObjImg = READ_LE_UINT32(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_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
+ 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
// create and init the first object
pObj = pFirst = InitObject(&obj_init);
@@ -65,9 +65,9 @@ OBJECT *MultiInitObject(const MULTI_INIT *pInitTbl) {
pFrame++;
- while (READ_32(pFrame) != 0) {
+ while (READ_LE_UINT32(pFrame) != 0) {
// set next objects shape
- obj_init.hObjImg = READ_32(pFrame);
+ obj_init.hObjImg = READ_LE_UINT32(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_32(pFrame) != 0 && pMultiObj != NULL) {
+ while (READ_LE_UINT32(pFrame) != 0 && pMultiObj != NULL) {
// a normal image - update the current object with this image
- AnimateObject(pMultiObj, READ_32(pFrame));
+ AnimateObject(pMultiObj, READ_LE_UINT32(pFrame));
// move to next image for this frame
pFrame++;
diff --git a/engines/tinsel/palette.cpp b/engines/tinsel/palette.cpp
index 544dc03..e6c9467 100644
--- a/engines/tinsel/palette.cpp
+++ b/engines/tinsel/palette.cpp
@@ -546,7 +546,7 @@ void CreateTranslucentPalette(SCNHANDLE hPalette) {
// leave background color alone
g_transPalette[0] = 0;
- for (uint i = 0; i < FROM_32(pPal->numColors); i++) {
+ for (uint i = 0; i < 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]);
diff --git a/engines/tinsel/play.cpp b/engines/tinsel/play.cpp
index 718ee7f..9e0baa7 100644
--- a/engines/tinsel/play.cpp
+++ b/engines/tinsel/play.cpp
@@ -81,7 +81,7 @@ static void PokeInPalette(SCNHANDLE hMulFrame) {
pFrame = (const FRAME *)LockMem(hMulFrame);
// get pointer to image
- pim = (IMAGE *)LockMem(READ_32(pFrame)); // handle to image
+ pim = (IMAGE *)LockMem(READ_LE_UINT32(pFrame)); // handle to image
pim->hImgPal = TO_LE_32(BgPal());
}
@@ -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_32(_ctx->pfreel->mobj));
+ pmi = (const MULTI_INIT *)LockMem(FROM_LE_32(_ctx->pfreel->mobj));
// Save actor's ID
- _ctx->reelActor = (int32)FROM_32(pmi->mulID);
+ _ctx->reelActor = (int32)FROM_LE_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_32(pmi->hMulFrame));
+ PokeInPalette(FROM_LE_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_32(_ctx->pfreel->script), ppi->speed);
+ InitStepAnimScript(&_ctx->thisAnim, _ctx->pPlayObj, FROM_LE_32(_ctx->pfreel->script), ppi->speed);
// If first column, set Z position as per
// Otherwise, column 0's + column number
@@ -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_32(reel->mobj));
+ pmi = (const MULTI_INIT *)LockMem(FROM_LE_32(reel->mobj));
- if (!TinselV2 || ((int32)FROM_32(pmi->mulID) != -2))
- SetActorLatestFilm((int32)FROM_32(pmi->mulID), film);
+ if (!TinselV2 || ((int32)FROM_LE_32(pmi->mulID) != -2))
+ SetActorLatestFilm((int32)FROM_LE_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_32(pFilm->frate));
+ ppi.speed = (ONE_SECOND / FROM_LE_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_32(pFilm->numreels) - 1; i >= 0; i--) {
+ for (int i = FROM_LE_32(pFilm->numreels) - 1; i >= 0; i--) {
NewestFilm(hFilm, &pFilm->reels[i]);
ppi.column = i;
diff --git a/engines/tinsel/scn.cpp b/engines/tinsel/scn.cpp
index 7009344..168dcf4 100644
--- a/engines/tinsel/scn.cpp
+++ b/engines/tinsel/scn.cpp
@@ -54,11 +54,11 @@ byte *FindChunk(SCNHANDLE handle, uint32 chunk) {
chunk -= 0x2L;
while (1) {
- if (READ_32(lptr) == chunk)
+ if (READ_LE_UINT32(lptr) == chunk)
return (byte *)(lptr + 2);
++lptr;
- add = READ_32(lptr);
+ add = READ_LE_UINT32(lptr);
if (!add)
// End of file reached
diff --git a/engines/tinsel/tinsel.cpp b/engines/tinsel/tinsel.cpp
index a60eb2b..83812ca 100644
--- a/engines/tinsel/tinsel.cpp
+++ b/engines/tinsel/tinsel.cpp
@@ -718,15 +718,15 @@ void LoadBasicChunks() {
// CHUNK_TOTAL_ACTORS seems to be missing in the released version, hard coding a value
// TODO: Would be nice to just change 511 to MAX_SAVED_ALIVES
cptr = FindChunk(MASTER_SCNHANDLE, CHUNK_TOTAL_ACTORS);
- RegisterActors((cptr != NULL) ? READ_32(cptr) : 511);
+ RegisterActors((cptr != NULL) ? READ_LE_UINT32(cptr) : 511);
// CHUNK_TOTAL_GLOBALS seems to be missing in some versions.
// So if it is missing, set a reasonably high value for the number of globals.
cptr = FindChunk(MASTER_SCNHANDLE, CHUNK_TOTAL_GLOBALS);
- RegisterGlobals((cptr != NULL) ? READ_32(cptr) : 512);
+ RegisterGlobals((cptr != NULL) ? READ_LE_UINT32(cptr) : 512);
cptr = FindChunk(INV_OBJ_SCNHANDLE, CHUNK_TOTAL_OBJECTS);
- numObjects = (cptr != NULL) ? READ_32(cptr) : 0;
+ numObjects = (cptr != NULL) ? READ_LE_UINT32(cptr) : 0;
cptr = FindChunk(INV_OBJ_SCNHANDLE, CHUNK_OBJECTS);
@@ -759,7 +759,7 @@ void LoadBasicChunks() {
// CdPlay() stuff
cptr = FindChunk(MASTER_SCNHANDLE, CHUNK_CDPLAY_HANDLE);
assert(cptr);
- uint32 playHandle = READ_32(cptr);
+ uint32 playHandle = READ_LE_UINT32(cptr);
assert(playHandle < 512);
SetCdPlayHandle(playHandle);
}
Commit: c90d56355fa0bbcdd3122f3e376e5609422338b3
https://github.com/scummvm/scummvm/commit/c90d56355fa0bbcdd3122f3e376e5609422338b3
Author: Filippos Karapetis (bluegr at gmail.com)
Date: 2012-12-10T07:38:23-08:00
Commit Message:
TINSEL: Simplify the scene entrance handling code
This also reverts the rest of the BE resource handling code
Changed paths:
engines/tinsel/scene.cpp
engines/tinsel/tinsel.h
diff --git a/engines/tinsel/scene.cpp b/engines/tinsel/scene.cpp
index 37088fd..2fda517 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 = FROM_LE_32(READ_LE_UINT32(p)); p += sizeof(uint32);
+ g_tempStruc.numPoly = FROM_LE_32(READ_LE_UINT32(p)); p += sizeof(uint32);
+ g_tempStruc.numTaggedActor = FROM_LE_32(READ_LE_UINT32(p)); p += sizeof(uint32);
+ g_tempStruc.defRefer = FROM_LE_32(READ_LE_UINT32(p)); p += sizeof(uint32);
+ g_tempStruc.hSceneScript = FROM_LE_32(READ_LE_UINT32(p)); p += sizeof(uint32);
+ g_tempStruc.hEntrance = FROM_LE_32(READ_LE_UINT32(p)); p += sizeof(uint32);
+ g_tempStruc.hPoly = FROM_LE_32(READ_LE_UINT32(p)); p += sizeof(uint32);
+ g_tempStruc.hTaggedActor = FROM_LE_32(READ_LE_UINT32(p)); p += sizeof(uint32);
+
return &g_tempStruc;
}
@@ -167,7 +167,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_32(&_ctx->pInit->hTinselCode),
+ _ctx->pInit->hTinselCode,
TinselV2 ? _ctx->pInit->event : NOEVENT,
NOPOLY, // No polygon
0, // No actor
@@ -209,7 +209,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;
@@ -238,18 +238,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 +258,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_32(ss->hEntrance));
- for (i = 0; i < FROM_32(ss->numEntrance); i++) {
+ es = (const ENTRANCE_STRUC *)LockMem(ss->hEntrance);
+ for (i = 0; i < ss->numEntrance; i++) {
if (FROM_LE_32(es->eNumber) == (uint)entry) {
if (es->hScript) {
init.event = STARTUP;
- init.hTinselCode = es->hScript;
+ init.hTinselCode = FROM_LE_32(es->hScript);
CoroScheduler.createProcess(PID_TCODE, SceneTinselProcess, &init, sizeof(init));
}
@@ -285,7 +284,7 @@ static void LoadScene(SCNHANDLE scene, int entry) {
}
- if (i == FROM_LE_32(ss->numEntrance))
+ if (i == ss->numEntrance)
error("Non-existant scene entry number");
if (ss->hSceneScript) {
@@ -297,10 +296,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/tinsel.h b/engines/tinsel/tinsel.h
index 02a0d0f..7fb50da 100644
--- a/engines/tinsel/tinsel.h
+++ b/engines/tinsel/tinsel.h
@@ -133,11 +133,6 @@ typedef bool (*KEYFPTR)(const Common::KeyState &);
#define TinselV1PSX (TinselVersion == TINSEL_V1 && _vm->getPlatform() == Common::kPlatformPSX)
#define TinselV1Mac (TinselVersion == TINSEL_V1 && _vm->getPlatform() == Common::kPlatformMacintosh)
-#define READ_16(v) (TinselV1Mac ? READ_BE_UINT16(v) : READ_LE_UINT16(v))
-#define READ_32(v) (TinselV1Mac ? READ_BE_UINT32(v) : READ_LE_UINT32(v))
-#define FROM_16(v) (TinselV1Mac ? FROM_BE_16(v) : FROM_LE_16(v))
-#define FROM_32(v) (TinselV1Mac ? FROM_BE_32(v) : FROM_LE_32(v))
-
// Global reference to the TinselEngine object
extern TinselEngine *_vm;
Commit: b532a81b42bce16838347aa560138da1b15418e5
https://github.com/scummvm/scummvm/commit/b532a81b42bce16838347aa560138da1b15418e5
Author: Filippos Karapetis (bluegr at gmail.com)
Date: 2012-12-10T07:38:24-08:00
Commit Message:
TINSEL: Add a WIP BE To LE SCN file conversion code (unfinished)
This is a cleaner approach to handle the Mac version of DW1 (demo
and full versions - refer to bug #3110936). This way, we can keep
the game engine as LE even with the Mac BE resource files.
Both the demo and the full version progress up to drawing the scene
graphics now and crash because of the currently unhandled bitmap
chunk.
Changed paths:
engines/tinsel/dialogs.cpp
engines/tinsel/handle.cpp
diff --git a/engines/tinsel/dialogs.cpp b/engines/tinsel/dialogs.cpp
index 1199066..8006bc1 100644
--- a/engines/tinsel/dialogs.cpp
+++ b/engines/tinsel/dialogs.cpp
@@ -5619,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
diff --git a/engines/tinsel/handle.cpp b/engines/tinsel/handle.cpp
index 14d588d..4f38f00 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"
@@ -84,7 +85,7 @@ static char g_szCdPlayFile[100];
//----------------- FORWARD REFERENCES --------------------
static void LoadFile(MEMHANDLE *pH); // load a memory block as a file
-
+static void convertFileToLE(MEMHANDLE *pH);
/**
* Loads the graphics handle table index file and preloads all the
@@ -301,6 +302,9 @@ void LoadFile(MEMHANDLE *pH) {
// discardable - unlock the memory
MemoryUnlock(pH->_node);
+ if (TinselV1Mac)
+ convertFileToLE(pH);
+
// set the loaded flag
pH->filesize |= fLoaded;
@@ -322,6 +326,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
@@ -375,6 +380,136 @@ byte *LockMem(SCNHANDLE offset) {
return MemoryDeref(pH->_node) + (offset & OFFSETMASK);
}
+void convertFileToLE(MEMHANDLE *pH) {
+ assert(TinselV1Mac);
+
+ char szFilename[sizeof(pH->szName) + 1];
+ // extract and zero terminate the filename
+ memcpy(szFilename, pH->szName, sizeof(pH->szName));
+ szFilename[sizeof(pH->szName)] = 0;
+
+ debug("Converting file: %s", szFilename);
+
+ byte *data = MemoryDeref(pH->_node);
+ byte *ptr = data;
+
+ // Process each chunk
+
+ while (true) {
+ uint32 pos = ptr - data;
+
+ uint32 chunkId = READ_BE_UINT32(ptr);
+ WRITE_LE_UINT32(ptr, chunkId); ptr += 4;
+
+ uint32 nextChunkOffset = READ_BE_UINT32(ptr);
+ WRITE_LE_UINT32(ptr, nextChunkOffset); ptr += 4;
+
+ uint32 chunkSize = (nextChunkOffset > 0 ? nextChunkOffset : pH->filesize & FSIZE_MASK) - pos;
+ uint32 chunkDataSize = chunkSize - 4 - 4; // chunk ID, chunk length
+ uint32 tmp = 0; // for temp data
+
+ debug("Chunk ID: %x, size %d, next chunk: %d", chunkId, chunkSize, nextChunkOffset);
+
+ switch (chunkId) {
+ case CHUNK_SCENE - 1:
+ assert(chunkDataSize == 8 * 4);
+ for (uint32 i = 0; i < 8; i++) {
+ // numEntrance, numPoly, numTaggedActor, defRefer, hSceneScript,
+ // hEntrance, hPoly, hTaggedActor
+ WRITE_LE_UINT32(ptr, READ_BE_UINT32(ptr)); ptr += 4;
+ }
+ break;
+ case CHUNK_TOTAL_ACTORS - 1:
+ case CHUNK_TOTAL_GLOBALS - 1:
+ case CHUNK_TOTAL_OBJECTS - 1:
+ case CHUNK_TOTAL_POLY - 1:
+ assert(chunkDataSize == 4);
+ WRITE_LE_UINT32(ptr, READ_BE_UINT32(ptr)); ptr += 4;
+ break;
+ case CHUNK_OBJECTS - 1:
+ // INV_OBJECT structure
+ assert(chunkDataSize % 16 == 0);
+ for (uint32 i = 0; i < chunkDataSize / 16; i++) {
+ WRITE_LE_UINT32(ptr, READ_BE_UINT32(ptr)); ptr += 4; // id
+ WRITE_LE_UINT32(ptr, READ_BE_UINT32(ptr)); ptr += 4; // hIconFilm
+ WRITE_LE_UINT32(ptr, READ_BE_UINT32(ptr)); ptr += 4; // hScript
+ WRITE_LE_UINT32(ptr, READ_BE_UINT32(ptr)); ptr += 4; // attribute
+ }
+ break;
+ case CHUNK_FONT:
+ assert(chunkDataSize == 4 * 11 + 4 * 300 + 4 * 223);
+ // FONT structure: xSpacing, ySpacing, xShadow, yShadow, spaceSize
+ // OBJ_INIT: hObjImg, objFlags, objID, objX, objY, objZ
+ for (uint32 i = 0; i < 11; i++) {
+ WRITE_LE_UINT32(ptr, READ_BE_UINT32(ptr)); ptr += 4;
+ }
+ // SCNHANDLE fontDef[300]
+ for (uint32 i = 0; i < 300; i++) {
+ WRITE_LE_UINT32(ptr, READ_BE_UINT32(ptr)); ptr += 4;
+ }
+ // TODO: the font chunk in dw.scn is 2136 bytes, we've only processed the
+ // first 44 + 300 * 4 = 1244 ones, so we're left with 892 more...
+ // Since all resources are BE in the Mac version, I assume that these are
+ // 32-bit integers that should be byte swapped as well.
+ for (uint32 i = 0; i < 223; i++) {
+ WRITE_LE_UINT32(ptr, READ_BE_UINT32(ptr)); ptr += 4;
+ }
+ break;
+ case CHUNK_BITMAP:
+ // TODO
+ break;
+ case CHUNK_PALETTE:
+ // Palette entries: 32-bit integers, each one with [R, G, B, unused] bytes
+ assert(chunkDataSize % 256 == 0);
+ for (uint32 i = 0; i < 256; i++) {
+ WRITE_LE_UINT32(ptr, READ_BE_UINT32(ptr)); ptr += 4;
+ }
+ break;
+ case CHUNK_IMAGE:
+ assert(chunkDataSize % 16 == 0);
+ for (uint32 i = 0; i < chunkDataSize / 16; i++) {
+ WRITE_LE_UINT16(ptr, READ_BE_UINT16(ptr)); ptr += 2; // width
+ WRITE_LE_UINT16(ptr, READ_BE_UINT16(ptr)); ptr += 2; // height
+ WRITE_LE_UINT32(ptr, READ_BE_UINT32(ptr)); ptr += 4;
+ WRITE_LE_UINT32(ptr, READ_BE_UINT32(ptr)); ptr += 4;
+ WRITE_LE_UINT32(ptr, READ_BE_UINT32(ptr)); ptr += 4;
+ }
+ break;
+ case CHUNK_ANI_FRAME:
+ assert(chunkDataSize % 8 == 0);
+ for (uint32 i = 0; i < chunkDataSize / 8; i++) {
+ WRITE_LE_UINT32(ptr, READ_BE_UINT32(ptr)); ptr += 4; // SCNHANDLE
+ WRITE_LE_UINT32(ptr, READ_BE_UINT32(ptr)); ptr += 4;
+ }
+ break;
+ case CHUNK_FILM:
+ // Filled with 32-bit integers
+ assert(chunkDataSize % 4 == 0);
+ for (uint32 i = 0; i < chunkDataSize / 4; i++) {
+ WRITE_LE_UINT32(ptr, READ_BE_UINT32(ptr)); ptr += 4;
+ }
+ break;
+ case CHUNK_PCODE:
+ // Too complicated to handle here - handled by the script parser
+ break;
+ case CHUNK_ENTRANCE:
+ // Entrance structure (ENTRANCE_STRUC)
+ assert(chunkDataSize == 8);
+ WRITE_LE_UINT32(ptr, READ_BE_UINT32(ptr)); ptr += 4; // eNumber - entrance number
+ WRITE_LE_UINT32(ptr, READ_BE_UINT32(ptr)); ptr += 4; // hScript - handle to entrance script
+ break;
+ default:
+ error("Unknown chunk ID: %x", chunkId);
+ }
+
+ // Jump to the next chunk
+ if (!nextChunkOffset)
+ break;
+
+ ptr = data + nextChunkOffset;
+ }
+}
+
/**
* Called to lock the current scene and make it non-discardable.
* @param offset Handle and offset to data
More information about the Scummvm-git-logs
mailing list