diff options
-rw-r--r-- | scumm/intern.h | 54 | ||||
-rw-r--r-- | scumm/resource.cpp | 268 | ||||
-rw-r--r-- | scumm/resource_v2.cpp | 25 | ||||
-rw-r--r-- | scumm/resource_v3.cpp | 2 | ||||
-rw-r--r-- | scumm/resource_v4.cpp | 238 | ||||
-rw-r--r-- | scumm/resource_v7he.cpp | 18 | ||||
-rw-r--r-- | scumm/scumm.h | 1 |
7 files changed, 328 insertions, 278 deletions
diff --git a/scumm/intern.h b/scumm/intern.h index df813bb47c..c876e57443 100644 --- a/scumm/intern.h +++ b/scumm/intern.h @@ -195,14 +195,13 @@ public: ScummEngine_v4(GameDetector *detector, OSystem *syst, const ScummGameSettings &gs, uint8 md5sum[16]); protected: - void readIndexFile(); - void loadCharset(int no); - void loadRoomObjects(); - void readMAXS(); - - void readGlobalObjects(); + virtual void readIndexFile(); + virtual void loadCharset(int no); + virtual void loadRoomObjects(); + virtual void readMAXS(int blockSize); + virtual void readGlobalObjects(); - void setupRoomObject(ObjectData *od, const byte *room, const byte *searchptr = NULL); + virtual void setupRoomObject(ObjectData *od, const byte *room, const byte *searchptr = NULL); }; /** @@ -213,8 +212,8 @@ public: ScummEngine_v3(GameDetector *detector, OSystem *syst, const ScummGameSettings &gs, uint8 md5sum[16]); protected: - void readRoomsOffsets(); - void loadCharset(int no); + virtual void readRoomsOffsets(); + virtual void loadCharset(int no); }; /** @@ -225,10 +224,10 @@ public: ScummEngine_v3old(GameDetector *detector, OSystem *syst, const ScummGameSettings &gs, uint8 md5sum[16]); protected: - void readResTypeList(int id, uint32 tag, const char *name); - void readIndexFile(); - void initRoomSubBlocks(); - void loadRoomObjects(); + virtual void readResTypeList(int id, uint32 tag, const char *name); + virtual void readIndexFile(); + virtual void initRoomSubBlocks(); + virtual void loadRoomObjects(); }; /** @@ -236,12 +235,6 @@ protected: */ class ScummEngine_v2 : public ScummEngine_v3old { protected: - void readIndexFile(); - void readClassicIndexFile(); // V1 - void readEnhancedIndexFile(); // V2 - void loadCharset(int no); - void readMAXS(); - typedef void (ScummEngine_v2::*OpcodeProcV2)(); struct OpcodeEntryV2 { OpcodeProcV2 proc; @@ -263,6 +256,12 @@ protected: virtual void setupScummVars(); virtual void decodeParseString(); + virtual void readIndexFile(); + void readClassicIndexFile(); // V1 + void readEnhancedIndexFile(); // V2 + virtual void loadCharset(int no); + + virtual int getVar(); void getResultPosIndirect(); @@ -413,6 +412,8 @@ protected: virtual void decodeParseString(int a, int b); virtual void readArrayFromIndexFile(); + virtual void readMAXS(int blockSize); + virtual void palManipulateInit(int resID, int start, int end, int time); int getStackList(int *args, uint maxnum); @@ -687,7 +688,8 @@ protected: virtual void executeOpcode(byte i); virtual const char *getOpcodeDesc(byte i); - void readRoomsOffsets(); + virtual void readRoomsOffsets(); + virtual void readGlobalObjects(); virtual void redrawBGAreas(); @@ -752,12 +754,12 @@ public: ScummEngine_v72he(GameDetector *detector, OSystem *syst, const ScummGameSettings &gs, uint8 md5sum[16]) : ScummEngine_v70he(detector, syst, gs, md5sum) {} protected: - virtual void setupScummVars(); - virtual void readArrayFromIndexFile(); - virtual void setupOpcodes(); virtual void executeOpcode(byte i); virtual const char *getOpcodeDesc(byte i); + + virtual void setupScummVars(); + virtual void readArrayFromIndexFile(); virtual void redrawBGAreas(); @@ -1149,6 +1151,9 @@ public: protected: virtual void setupScummVars(); + virtual void readMAXS(int blockSize); + virtual void readGlobalObjects(); + virtual void setCameraAt(int pos_x, int pos_y); virtual void setCameraFollows(Actor *a); virtual void moveCamera(); @@ -1177,6 +1182,9 @@ protected: virtual void decodeParseString(int m, int n); virtual void readArrayFromIndexFile(); + virtual void readMAXS(int blockSize); + virtual void readGlobalObjects(); + virtual uint fetchScriptWord(); virtual int fetchScriptWordSigned(); diff --git a/scumm/resource.cpp b/scumm/resource.cpp index c7d26ebf30..80390d50e1 100644 --- a/scumm/resource.cpp +++ b/scumm/resource.cpp @@ -288,7 +288,7 @@ void ScummEngine::askForDisk(const char *filename, int disknum) { void ScummEngine::readIndexFile() { uint32 blocktype, itemsize; int numblock = 0; - int num, i; + int i; bool stop = false; debugC(DEBUG_GENERAL, "readIndexFile()"); @@ -351,50 +351,7 @@ void ScummEngine::readIndexFile() { case MKID('DOBJ'): debug(9, "found DOBJ block, reading object table"); - if (_version == 8) - num = _fileHandle->readUint32LE(); - else - num = _fileHandle->readUint16LE(); - assert(num == _numGlobalObjects); - - if (_version == 8) { /* FIXME: Not sure.. */ - char buffer[40]; - for (i = 0; i < num; i++) { - _fileHandle->read(buffer, 40); - if (buffer[0]) { - // Add to object name-to-id map - _objectIDMap[buffer] = i; - } - _objectStateTable[i] = _fileHandle->readByte(); - _objectRoomTable[i] = _fileHandle->readByte(); - _classData[i] = _fileHandle->readUint32LE(); - } - memset(_objectOwnerTable, 0xFF, num); - } else if (_version == 7) { - _fileHandle->read(_objectStateTable, num); - _fileHandle->read(_objectRoomTable, num); - memset(_objectOwnerTable, 0xFF, num); - } else if (_heversion >= 70) { // HE Windows titles - _fileHandle->read(_objectStateTable, num); - _fileHandle->read(_objectOwnerTable, num); - _fileHandle->read(_objectRoomTable, num); - } else { - _fileHandle->read(_objectOwnerTable, num); - for (i = 0; i < num; i++) { - _objectStateTable[i] = _objectOwnerTable[i] >> OF_STATE_SHL; - _objectOwnerTable[i] &= OF_OWNER_MASK; - } - } - - if (_version != 8) { - _fileHandle->read(_classData, num * sizeof(uint32)); - - // Swap flag endian where applicable -#if defined(SCUMM_BIG_ENDIAN) - for (i = 0; i != num; i++) - _classData[i] = FROM_LE_32(_classData[i]); -#endif - } + readGlobalObjects(); break; case MKID('RNAM'): @@ -1017,188 +974,27 @@ void ScummEngine::resourceStats() { void ScummEngine::readMAXS(int blockSize) { debug(9, "readMAXS: MAXS has blocksize %d", blockSize); - if (_version == 8) { // CMI - _fileHandle->seek(50 + 50, SEEK_CUR); // 176 - 8 - _numVariables = _fileHandle->readUint32LE(); // 1500 - _numBitVariables = _fileHandle->readUint32LE(); // 2048 - _fileHandle->readUint32LE(); // 40 - _numScripts = _fileHandle->readUint32LE(); // 458 - _numSounds = _fileHandle->readUint32LE(); // 789 - _numCharsets = _fileHandle->readUint32LE(); // 1 - _numCostumes = _fileHandle->readUint32LE(); // 446 - _numRooms = _fileHandle->readUint32LE(); // 95 - _fileHandle->readUint32LE(); // 80 - _numGlobalObjects = _fileHandle->readUint32LE(); // 1401 - _fileHandle->readUint32LE(); // 60 - _numLocalObjects = _fileHandle->readUint32LE(); // 200 - _numNewNames = _fileHandle->readUint32LE(); // 100 - _numFlObject = _fileHandle->readUint32LE(); // 128 - _numInventory = _fileHandle->readUint32LE(); // 80 - _numArray = _fileHandle->readUint32LE(); // 200 - _numVerbs = _fileHandle->readUint32LE(); // 50 - - _objectRoomTable = (byte *)calloc(_numGlobalObjects, 1); - _numGlobalScripts = 2000; - - _shadowPaletteSize = NUM_SHADOW_PALETTE * 256; - } else if (_version == 7) { - _fileHandle->seek(50 + 50, SEEK_CUR); - _numVariables = _fileHandle->readUint16LE(); - _numBitVariables = _fileHandle->readUint16LE(); - _fileHandle->readUint16LE(); // 40 in FT; 16 in Dig - _numGlobalObjects = _fileHandle->readUint16LE(); - _numLocalObjects = _fileHandle->readUint16LE(); - _numNewNames = _fileHandle->readUint16LE(); - _numVerbs = _fileHandle->readUint16LE(); - _numFlObject = _fileHandle->readUint16LE(); - _numInventory = _fileHandle->readUint16LE(); - _numArray = _fileHandle->readUint16LE(); - _numRooms = _fileHandle->readUint16LE(); - _numScripts = _fileHandle->readUint16LE(); - _numSounds = _fileHandle->readUint16LE(); - _numCharsets = _fileHandle->readUint16LE(); - _numCostumes = _fileHandle->readUint16LE(); - - _objectRoomTable = (byte *)calloc(_numGlobalObjects, 1); - - if ((_gameId == GID_FT) && (_features & GF_DEMO) && - (_features & GF_PC)) - _numGlobalScripts = 300; - else - _numGlobalScripts = 2000; - - _shadowPaletteSize = NUM_SHADOW_PALETTE * 256; - } else if (_heversion >= 70 && (blockSize == 44 + 8)) { // C++ based engine - _numVariables = _fileHandle->readUint16LE(); - _fileHandle->readUint16LE(); - _numRoomVariables = _fileHandle->readUint16LE(); - _numLocalObjects = _fileHandle->readUint16LE(); - _numArray = _fileHandle->readUint16LE(); - _fileHandle->readUint16LE(); // unknown - _fileHandle->readUint16LE(); // unknown - _numFlObject = _fileHandle->readUint16LE(); - _numInventory = _fileHandle->readUint16LE(); - _numRooms = _fileHandle->readUint16LE(); - _numScripts = _fileHandle->readUint16LE(); - _numSounds = _fileHandle->readUint16LE(); - _numCharsets = _fileHandle->readUint16LE(); - _numCostumes = _fileHandle->readUint16LE(); - _numGlobalObjects = _fileHandle->readUint16LE(); - _numImages = _fileHandle->readUint16LE(); - _numSprites = _fileHandle->readUint16LE(); - _numLocalScripts = _fileHandle->readUint16LE(); - _fileHandle->readUint16LE(); // heap related - _numPalettes = _fileHandle->readUint16LE(); - _numUnk = _fileHandle->readUint16LE(); - _numTalkies = _fileHandle->readUint16LE(); - _numNewNames = 10; - - _objectRoomTable = (byte *)calloc(_numGlobalObjects, 1); - _numGlobalScripts = 2048; - - } else if (_heversion >= 70 && (blockSize == 38 + 8)) { // Scummsys.9x - _numVariables = _fileHandle->readUint16LE(); - _fileHandle->readUint16LE(); - _numRoomVariables = _fileHandle->readUint16LE(); - _numLocalObjects = _fileHandle->readUint16LE(); - _numArray = _fileHandle->readUint16LE(); - _fileHandle->readUint16LE(); // unknown - _fileHandle->readUint16LE(); // unknown - _numFlObject = _fileHandle->readUint16LE(); - _numInventory = _fileHandle->readUint16LE(); - _numRooms = _fileHandle->readUint16LE(); - _numScripts = _fileHandle->readUint16LE(); - _numSounds = _fileHandle->readUint16LE(); - _numCharsets = _fileHandle->readUint16LE(); - _numCostumes = _fileHandle->readUint16LE(); - _numGlobalObjects = _fileHandle->readUint16LE(); - _numImages = _fileHandle->readUint16LE(); - _numSprites = _fileHandle->readUint16LE(); - _numLocalScripts = _fileHandle->readUint16LE(); - _fileHandle->readUint16LE(); // heap releated - _numNewNames = 10; - - _objectRoomTable = (byte *)calloc(_numGlobalObjects, 1); - if (_gameId == GID_FREDDI4) - _numGlobalScripts = 2048; - else - _numGlobalScripts = 200; - - } else if (_heversion >= 70 && blockSize > 38) { // sputm7.2 - if (blockSize != 32 + 8) - error("MAXS block of size %d not supported, please report", blockSize); - _numVariables = _fileHandle->readUint16LE(); - _fileHandle->readUint16LE(); - _numBitVariables = _numRoomVariables = _fileHandle->readUint16LE(); - _numLocalObjects = _fileHandle->readUint16LE(); - _numArray = _fileHandle->readUint16LE(); - _fileHandle->readUint16LE(); - _numVerbs = _fileHandle->readUint16LE(); - _numFlObject = _fileHandle->readUint16LE(); - _numInventory = _fileHandle->readUint16LE(); - _numRooms = _fileHandle->readUint16LE(); - _numScripts = _fileHandle->readUint16LE(); - _numSounds = _fileHandle->readUint16LE(); - _numCharsets = _fileHandle->readUint16LE(); - _numCostumes = _fileHandle->readUint16LE(); - _numGlobalObjects = _fileHandle->readUint16LE(); - _numImages = _fileHandle->readUint16LE(); - _numNewNames = 10; - - _objectRoomTable = (byte *)calloc(_numGlobalObjects, 1); - _numGlobalScripts = 200; - - } else if (_version == 6) { - if (blockSize != 30 + 8) - error("MAXS block of size %d not supported", blockSize); - _numVariables = _fileHandle->readUint16LE(); - _fileHandle->readUint16LE(); // 16 in Sam/DOTT - _numBitVariables = _fileHandle->readUint16LE(); - _numLocalObjects = _fileHandle->readUint16LE(); - _numArray = _fileHandle->readUint16LE(); - _fileHandle->readUint16LE(); // 0 in Sam/DOTT - _numVerbs = _fileHandle->readUint16LE(); - _numFlObject = _fileHandle->readUint16LE(); - _numInventory = _fileHandle->readUint16LE(); - _numRooms = _fileHandle->readUint16LE(); - _numScripts = _fileHandle->readUint16LE(); - _numSounds = _fileHandle->readUint16LE(); - _numCharsets = _fileHandle->readUint16LE(); - _numCostumes = _fileHandle->readUint16LE(); - _numGlobalObjects = _fileHandle->readUint16LE(); - _numNewNames = 50; - - _objectRoomTable = NULL; - _numGlobalScripts = 200; - - _shadowPaletteSize = 256; + _numVariables = _fileHandle->readUint16LE(); // 800 + _fileHandle->readUint16LE(); // 16 + _numBitVariables = _fileHandle->readUint16LE(); // 2048 + _numLocalObjects = _fileHandle->readUint16LE(); // 200 + _numArray = 50; + _numVerbs = 100; + // Used to be 50, which wasn't enough for MI2 and FOA. See bugs + // #933610, #936323 and #941275. + _numNewNames = 150; + _objectRoomTable = NULL; - if (_heversion >= 70) { - _objectRoomTable = (byte *)calloc(_numGlobalObjects, 1); - } - } else { - _numVariables = _fileHandle->readUint16LE(); // 800 - _fileHandle->readUint16LE(); // 16 - _numBitVariables = _fileHandle->readUint16LE(); // 2048 - _numLocalObjects = _fileHandle->readUint16LE(); // 200 - _numArray = 50; - _numVerbs = 100; - // Used to be 50, which wasn't enough for MI2 and FOA. See bugs - // #933610, #936323 and #941275. - _numNewNames = 150; - _objectRoomTable = NULL; - - _fileHandle->readUint16LE(); // 50 - _numCharsets = _fileHandle->readUint16LE(); // 9 - _fileHandle->readUint16LE(); // 100 - _fileHandle->readUint16LE(); // 50 - _numInventory = _fileHandle->readUint16LE(); // 80 - _numGlobalScripts = 200; - - _shadowPaletteSize = 256; - - _numFlObject = 50; - } + _fileHandle->readUint16LE(); // 50 + _numCharsets = _fileHandle->readUint16LE(); // 9 + _fileHandle->readUint16LE(); // 100 + _fileHandle->readUint16LE(); // 50 + _numInventory = _fileHandle->readUint16LE(); // 80 + _numGlobalScripts = 200; + + _shadowPaletteSize = 256; + + _numFlObject = 50; if (_shadowPaletteSize) _shadowPalette = (byte *)calloc(_shadowPaletteSize, 1); @@ -1207,6 +1003,26 @@ void ScummEngine::readMAXS(int blockSize) { _dynamicRoomOffsets = true; } +void ScummEngine::readGlobalObjects() { + int i; + int num = _fileHandle->readUint16LE(); + assert(num == _numGlobalObjects); + + _fileHandle->read(_objectOwnerTable, num); + for (i = 0; i < num; i++) { + _objectStateTable[i] = _objectOwnerTable[i] >> OF_STATE_SHL; + _objectOwnerTable[i] &= OF_OWNER_MASK; + } + + _fileHandle->read(_classData, num * sizeof(uint32)); + +#if defined(SCUMM_BIG_ENDIAN) + // Correct the endianess if necessary + for (i = 0; i != num; i++) + _classData[i] = FROM_LE_32(_classData[i]); +#endif +} + void ScummEngine::allocateArrays() { // Note: Buffers are now allocated in scummMain to allow for // early GUI init. diff --git a/scumm/resource_v2.cpp b/scumm/resource_v2.cpp index 0147d33ee3..b2c512224d 100644 --- a/scumm/resource_v2.cpp +++ b/scumm/resource_v2.cpp @@ -64,7 +64,7 @@ void ScummEngine_v2::readClassicIndexFile() { _fileHandle->seek(0, SEEK_SET); - readMAXS(); + readMAXS(0); // Jamieson630: palManipulate variable initialization _palManipCounter = 0; @@ -134,7 +134,7 @@ void ScummEngine_v2::readEnhancedIndexFile() { _fileHandle->clearIOFailed(); _fileHandle->seek(0, SEEK_SET); - readMAXS(); + readMAXS(0); // Jamieson630: palManipulate variable initialization _palManipCounter = 0; @@ -189,27 +189,6 @@ void ScummEngine_v2::readIndexFile() { closeRoom(); } -void ScummEngine_v2::readMAXS() { - // FIXME - I'm not sure for those values yet, they will have to be rechecked - - _numVariables = 800; // 800 - _numBitVariables = 4096; // 2048 - _numLocalObjects = 200; // 200 - _numArray = 50; - _numVerbs = 100; - _numNewNames = 50; - _objectRoomTable = NULL; - _numCharsets = 9; // 9 - _numInventory = 80; // 80 - _numGlobalScripts = 200; - _numFlObject = 50; - - _shadowPaletteSize = 256; - - _shadowPalette = (byte *) calloc(_shadowPaletteSize, 1); // FIXME - needs to be removed later - allocateArrays(); -} - void ScummEngine_v2::loadCharset(int num) { // Stub, V2 font resources are hardcoded into the engine. } diff --git a/scumm/resource_v3.cpp b/scumm/resource_v3.cpp index 4211274a55..7c6855197a 100644 --- a/scumm/resource_v3.cpp +++ b/scumm/resource_v3.cpp @@ -80,7 +80,7 @@ void ScummEngine_v3old::readIndexFile() { _fileHandle->clearIOFailed(); _fileHandle->seek(0, SEEK_SET); - readMAXS(); + readMAXS(0); // Jamieson630: palManipulate variable initialization _palManipCounter = 0; diff --git a/scumm/resource_v4.cpp b/scumm/resource_v4.cpp index a5f39e4358..a1a6f5322f 100644 --- a/scumm/resource_v4.cpp +++ b/scumm/resource_v4.cpp @@ -69,7 +69,7 @@ void ScummEngine_v4::readIndexFile() { _fileHandle->clearIOFailed(); _fileHandle->seek(0, SEEK_SET); - readMAXS(); + readMAXS(0); // Jamieson630: palManipulate variable initialization _palManipCounter = 0; @@ -138,7 +138,7 @@ void ScummEngine_v4::loadCharset(int no) { closeRoom(); } -void ScummEngine_v4::readMAXS() { +void ScummEngine_v4::readMAXS(int blockSize) { // FIXME - I'm not sure for those values yet, they will have to be rechecked _numVariables = 800; // 800 @@ -160,11 +160,14 @@ void ScummEngine_v4::readMAXS() { } void ScummEngine_v4::readGlobalObjects() { + int i; int num = _fileHandle->readUint16LE(); assert(num == _numGlobalObjects); - for (int i = 0; i != num; i++) { - uint32 bits = _fileHandle->readByte(); - byte tmp; + + uint32 bits; + byte tmp; + for (i = 0; i != num; i++) { + bits = _fileHandle->readByte(); bits |= _fileHandle->readByte() << 8; bits |= _fileHandle->readByte() << 16; _classData[i] = bits; @@ -174,4 +177,229 @@ void ScummEngine_v4::readGlobalObjects() { } } + +void ScummEngine_v8::readGlobalObjects() { + int i; + int num = _fileHandle->readUint32LE(); + assert(num == _numGlobalObjects); + + char buffer[40]; + for (i = 0; i < num; i++) { + _fileHandle->read(buffer, 40); + if (buffer[0]) { + // Add to object name-to-id map + _objectIDMap[buffer] = i; + } + _objectStateTable[i] = _fileHandle->readByte(); + _objectRoomTable[i] = _fileHandle->readByte(); + _classData[i] = _fileHandle->readUint32LE(); + } + memset(_objectOwnerTable, 0xFF, num); +} + +void ScummEngine_v7::readGlobalObjects() { + int i; + int num = _fileHandle->readUint16LE(); + assert(num == _numGlobalObjects); + + _fileHandle->read(_objectStateTable, num); + _fileHandle->read(_objectRoomTable, num); + memset(_objectOwnerTable, 0xFF, num); + + _fileHandle->read(_classData, num * sizeof(uint32)); + +#if defined(SCUMM_BIG_ENDIAN) + // Correct the endianess if necessary + for (i = 0; i != num; i++) + _classData[i] = FROM_LE_32(_classData[i]); +#endif +} + +void ScummEngine_v8::readMAXS(int blockSize) { + debug(9, "readMAXS: MAXS has blocksize %d", blockSize); + + _fileHandle->seek(50 + 50, SEEK_CUR); // 176 - 8 + _numVariables = _fileHandle->readUint32LE(); // 1500 + _numBitVariables = _fileHandle->readUint32LE(); // 2048 + _fileHandle->readUint32LE(); // 40 + _numScripts = _fileHandle->readUint32LE(); // 458 + _numSounds = _fileHandle->readUint32LE(); // 789 + _numCharsets = _fileHandle->readUint32LE(); // 1 + _numCostumes = _fileHandle->readUint32LE(); // 446 + _numRooms = _fileHandle->readUint32LE(); // 95 + _fileHandle->readUint32LE(); // 80 + _numGlobalObjects = _fileHandle->readUint32LE(); // 1401 + _fileHandle->readUint32LE(); // 60 + _numLocalObjects = _fileHandle->readUint32LE(); // 200 + _numNewNames = _fileHandle->readUint32LE(); // 100 + _numFlObject = _fileHandle->readUint32LE(); // 128 + _numInventory = _fileHandle->readUint32LE(); // 80 + _numArray = _fileHandle->readUint32LE(); // 200 + _numVerbs = _fileHandle->readUint32LE(); // 50 + + _objectRoomTable = (byte *)calloc(_numGlobalObjects, 1); + _numGlobalScripts = 2000; + + _shadowPaletteSize = NUM_SHADOW_PALETTE * 256; + _shadowPalette = (byte *)calloc(_shadowPaletteSize, 1); + + allocateArrays(); + _dynamicRoomOffsets = true; +} + +void ScummEngine_v7::readMAXS(int blockSize) { + debug(9, "readMAXS: MAXS has blocksize %d", blockSize); + + _fileHandle->seek(50 + 50, SEEK_CUR); + _numVariables = _fileHandle->readUint16LE(); + _numBitVariables = _fileHandle->readUint16LE(); + _fileHandle->readUint16LE(); // 40 in FT; 16 in Dig + _numGlobalObjects = _fileHandle->readUint16LE(); + _numLocalObjects = _fileHandle->readUint16LE(); + _numNewNames = _fileHandle->readUint16LE(); + _numVerbs = _fileHandle->readUint16LE(); + _numFlObject = _fileHandle->readUint16LE(); + _numInventory = _fileHandle->readUint16LE(); + _numArray = _fileHandle->readUint16LE(); + _numRooms = _fileHandle->readUint16LE(); + _numScripts = _fileHandle->readUint16LE(); + _numSounds = _fileHandle->readUint16LE(); + _numCharsets = _fileHandle->readUint16LE(); + _numCostumes = _fileHandle->readUint16LE(); + + _objectRoomTable = (byte *)calloc(_numGlobalObjects, 1); + + if ((_gameId == GID_FT) && (_features & GF_DEMO) && + (_features & GF_PC)) + _numGlobalScripts = 300; + else + _numGlobalScripts = 2000; + + _shadowPaletteSize = NUM_SHADOW_PALETTE * 256; + _shadowPalette = (byte *)calloc(_shadowPaletteSize, 1); + + allocateArrays(); + _dynamicRoomOffsets = true; +} + +void ScummEngine_v6::readMAXS(int blockSize) { + debug(9, "readMAXS: MAXS has blocksize %d", blockSize); + + if (_heversion >= 70 && (blockSize == 44 + 8)) { // C++ based engine + _numVariables = _fileHandle->readUint16LE(); + _fileHandle->readUint16LE(); + _numRoomVariables = _fileHandle->readUint16LE(); + _numLocalObjects = _fileHandle->readUint16LE(); + _numArray = _fileHandle->readUint16LE(); + _fileHandle->readUint16LE(); // unknown + _fileHandle->readUint16LE(); // unknown + _numFlObject = _fileHandle->readUint16LE(); + _numInventory = _fileHandle->readUint16LE(); + _numRooms = _fileHandle->readUint16LE(); + _numScripts = _fileHandle->readUint16LE(); + _numSounds = _fileHandle->readUint16LE(); + _numCharsets = _fileHandle->readUint16LE(); + _numCostumes = _fileHandle->readUint16LE(); + _numGlobalObjects = _fileHandle->readUint16LE(); + _numImages = _fileHandle->readUint16LE(); + _numSprites = _fileHandle->readUint16LE(); + _numLocalScripts = _fileHandle->readUint16LE(); + _fileHandle->readUint16LE(); // heap related + _numPalettes = _fileHandle->readUint16LE(); + _numUnk = _fileHandle->readUint16LE(); + _numTalkies = _fileHandle->readUint16LE(); + _numNewNames = 10; + + _objectRoomTable = (byte *)calloc(_numGlobalObjects, 1); + _numGlobalScripts = 2048; + + } else if (_heversion >= 70 && (blockSize == 38 + 8)) { // Scummsys.9x + _numVariables = _fileHandle->readUint16LE(); + _fileHandle->readUint16LE(); + _numRoomVariables = _fileHandle->readUint16LE(); + _numLocalObjects = _fileHandle->readUint16LE(); + _numArray = _fileHandle->readUint16LE(); + _fileHandle->readUint16LE(); // unknown + _fileHandle->readUint16LE(); // unknown + _numFlObject = _fileHandle->readUint16LE(); + _numInventory = _fileHandle->readUint16LE(); + _numRooms = _fileHandle->readUint16LE(); + _numScripts = _fileHandle->readUint16LE(); + _numSounds = _fileHandle->readUint16LE(); + _numCharsets = _fileHandle->readUint16LE(); + _numCostumes = _fileHandle->readUint16LE(); + _numGlobalObjects = _fileHandle->readUint16LE(); + _numImages = _fileHandle->readUint16LE(); + _numSprites = _fileHandle->readUint16LE(); + _numLocalScripts = _fileHandle->readUint16LE(); + _fileHandle->readUint16LE(); // heap releated + _numNewNames = 10; + + _objectRoomTable = (byte *)calloc(_numGlobalObjects, 1); + if (_gameId == GID_FREDDI4) + _numGlobalScripts = 2048; + else + _numGlobalScripts = 200; + + } else if (_heversion >= 70 && blockSize > 38) { // sputm7.2 + if (blockSize != 32 + 8) + error("MAXS block of size %d not supported, please report", blockSize); + _numVariables = _fileHandle->readUint16LE(); + _fileHandle->readUint16LE(); + _numBitVariables = _numRoomVariables = _fileHandle->readUint16LE(); + _numLocalObjects = _fileHandle->readUint16LE(); + _numArray = _fileHandle->readUint16LE(); + _fileHandle->readUint16LE(); + _numVerbs = _fileHandle->readUint16LE(); + _numFlObject = _fileHandle->readUint16LE(); + _numInventory = _fileHandle->readUint16LE(); + _numRooms = _fileHandle->readUint16LE(); + _numScripts = _fileHandle->readUint16LE(); + _numSounds = _fileHandle->readUint16LE(); + _numCharsets = _fileHandle->readUint16LE(); + _numCostumes = _fileHandle->readUint16LE(); + _numGlobalObjects = _fileHandle->readUint16LE(); + _numImages = _fileHandle->readUint16LE(); + _numNewNames = 10; + + _objectRoomTable = (byte *)calloc(_numGlobalObjects, 1); + _numGlobalScripts = 200; + + } else if (_version == 6) { + if (blockSize != 30 + 8) + error("MAXS block of size %d not supported", blockSize); + _numVariables = _fileHandle->readUint16LE(); + _fileHandle->readUint16LE(); // 16 in Sam/DOTT + _numBitVariables = _fileHandle->readUint16LE(); + _numLocalObjects = _fileHandle->readUint16LE(); + _numArray = _fileHandle->readUint16LE(); + _fileHandle->readUint16LE(); // 0 in Sam/DOTT + _numVerbs = _fileHandle->readUint16LE(); + _numFlObject = _fileHandle->readUint16LE(); + _numInventory = _fileHandle->readUint16LE(); + _numRooms = _fileHandle->readUint16LE(); + _numScripts = _fileHandle->readUint16LE(); + _numSounds = _fileHandle->readUint16LE(); + _numCharsets = _fileHandle->readUint16LE(); + _numCostumes = _fileHandle->readUint16LE(); + _numGlobalObjects = _fileHandle->readUint16LE(); + _numNewNames = 50; + + _objectRoomTable = NULL; + _numGlobalScripts = 200; + + _shadowPaletteSize = 256; + + if (_heversion >= 70) { + _objectRoomTable = (byte *)calloc(_numGlobalObjects, 1); + } + } + + if (_shadowPaletteSize) + _shadowPalette = (byte *)calloc(_shadowPaletteSize, 1); + + allocateArrays(); + _dynamicRoomOffsets = true; +} + } // End of namespace Scumm diff --git a/scumm/resource_v7he.cpp b/scumm/resource_v7he.cpp index 7efcd1777f..976c741342 100644 --- a/scumm/resource_v7he.cpp +++ b/scumm/resource_v7he.cpp @@ -1640,4 +1640,22 @@ void ScummEngine_v70he::readRoomsOffsets() { } } +void ScummEngine_v70he::readGlobalObjects() { + int i; + int num = _fileHandle->readUint16LE(); + assert(num == _numGlobalObjects); + + _fileHandle->read(_objectStateTable, num); + _fileHandle->read(_objectOwnerTable, num); + _fileHandle->read(_objectRoomTable, num); + + _fileHandle->read(_classData, num * sizeof(uint32)); + +#if defined(SCUMM_BIG_ENDIAN) + // Correct the endianess if necessary + for (i = 0; i != num; i++) + _classData[i] = FROM_LE_32(_classData[i]); +#endif +} + } // End of namespace Scumm diff --git a/scumm/scumm.h b/scumm/scumm.h index 1d0606b96b..0f2a5497b1 100644 --- a/scumm/scumm.h +++ b/scumm/scumm.h @@ -728,6 +728,7 @@ protected: virtual void readArrayFromIndexFile(); virtual void readMAXS(int blockSize); + virtual void readGlobalObjects(); virtual void readIndexFile(); virtual void loadCharset(int i); void nukeCharset(int i); |