diff options
author | Filippos Karapetis | 2012-12-11 02:41:51 +0200 |
---|---|---|
committer | Filippos Karapetis | 2012-12-11 02:41:51 +0200 |
commit | ce87175bede46c1bb938b73484e1db05212defbd (patch) | |
tree | 92fb21975a13b845a27cdbd6bbdf226857e30ebf | |
parent | 4914bea358c249aa10206bb6fda3fa4b4fbb6631 (diff) | |
download | scummvm-rg350-ce87175bede46c1bb938b73484e1db05212defbd.tar.gz scummvm-rg350-ce87175bede46c1bb938b73484e1db05212defbd.tar.bz2 scummvm-rg350-ce87175bede46c1bb938b73484e1db05212defbd.zip |
TINSEL: Revert the BE -> LE resource conversion for DW1 Mac
This was a bad idea, as we ended up with another place where the
resource files were processed. Thus, I'm moving back to handling the
BE resources of the Mac version in the engine itself
-rw-r--r-- | engines/tinsel/handle.cpp | 135 |
1 files changed, 1 insertions, 134 deletions
diff --git a/engines/tinsel/handle.cpp b/engines/tinsel/handle.cpp index c839cb39e3..3921414b01 100644 --- a/engines/tinsel/handle.cpp +++ b/engines/tinsel/handle.cpp @@ -85,7 +85,6 @@ 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,10 +300,7 @@ void LoadFile(MEMHANDLE *pH) { // discardable - unlock the memory MemoryUnlock(pH->_node); - - if (TinselV1Mac) - convertFileToLE(pH); - + // set the loaded flag pH->filesize |= fLoaded; @@ -380,135 +376,6 @@ 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 - - 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 |