diff options
author | Max Horn | 2005-04-09 20:22:31 +0000 |
---|---|---|
committer | Max Horn | 2005-04-09 20:22:31 +0000 |
commit | 81e34e9110f88cd92227d451d153bd336a3902c1 (patch) | |
tree | c4e95bef98dc7ede51e466c7f87f35b9e0342fdf | |
parent | d271b58aa78875983143c07facac596cd393f9f0 (diff) | |
download | scummvm-rg350-81e34e9110f88cd92227d451d153bd336a3902c1.tar.gz scummvm-rg350-81e34e9110f88cd92227d451d153bd336a3902c1.tar.bz2 scummvm-rg350-81e34e9110f88cd92227d451d153bd336a3902c1.zip |
Overload getStringAddress in subclasses; moved V6-V8 specific res stuff to resource.cpp
svn-id: r17489
-rw-r--r-- | scumm/intern.h | 12 | ||||
-rw-r--r-- | scumm/resource.cpp | 151 | ||||
-rw-r--r-- | scumm/resource_v4.cpp | 137 | ||||
-rw-r--r-- | scumm/resource_v7he.cpp | 7 | ||||
-rw-r--r-- | scumm/scumm.h | 2 |
5 files changed, 159 insertions, 150 deletions
diff --git a/scumm/intern.h b/scumm/intern.h index bb64222bd0..2bf3110fd5 100644 --- a/scumm/intern.h +++ b/scumm/intern.h @@ -412,6 +412,7 @@ protected: virtual void decodeParseString(int a, int b); virtual void readArrayFromIndexFile(); + virtual byte *getStringAddress(int i); virtual void readMAXS(int blockSize); virtual void palManipulateInit(int resID, int start, int end, int time); @@ -754,15 +755,16 @@ public: ScummEngine_v72he(GameDetector *detector, OSystem *syst, const ScummGameSettings &gs, uint8 md5sum[16]) : ScummEngine_v70he(detector, syst, gs, md5sum) {} protected: - virtual void readMAXS(int blockSize); - virtual void setupOpcodes(); virtual void executeOpcode(byte i); virtual const char *getOpcodeDesc(byte i); virtual void setupScummVars(); virtual void readArrayFromIndexFile(); - + + virtual byte *getStringAddress(int i); + virtual void readMAXS(int blockSize); + virtual void redrawBGAreas(); ArrayHeader *defineArray(int array, int type, int dim2start, int dim2end, int dim1start, int dim1end); @@ -924,13 +926,13 @@ public: virtual void scummInit(); protected: - virtual void readMAXS(int blockSize); - virtual void allocateArrays(); virtual void setupOpcodes(); virtual void executeOpcode(byte i); virtual const char *getOpcodeDesc(byte i); + virtual void readMAXS(int blockSize); + void createWizEmptyImage(const WizParameters *params); void fillWizRect(const WizParameters *params); void processWizImage(const WizParameters *params); diff --git a/scumm/resource.cpp b/scumm/resource.cpp index 4a054319e1..5c3be0c0d6 100644 --- a/scumm/resource.cpp +++ b/scumm/resource.cpp @@ -25,6 +25,7 @@ #include "scumm/dialogs.h" #include "scumm/imuse.h" #include "scumm/imuse_digi/dimuse.h" +#include "scumm/intern.h" #include "scumm/object.h" #include "scumm/resource.h" #include "scumm/scumm.h" @@ -706,15 +707,14 @@ byte *ScummEngine::getResourceAddress(int type, int idx) { byte *ScummEngine::getStringAddress(int i) { byte *addr = getResourceAddress(rtString, i); + return addr; +} + +byte *ScummEngine_v6::getStringAddress(int i) { + byte *addr = getResourceAddress(rtString, i); if (addr == NULL) return NULL; - - if (_heversion >= 72) - return (addr + 0x14); // ArrayHeader->data - - if (_version >= 6) - return (addr + 0x6); // ArrayHeader->data - return addr; + return ((ScummEngine_v6::ArrayHeader *)addr)->data; } byte *ScummEngine::getStringAddressVar(int i) { @@ -994,6 +994,107 @@ void ScummEngine::readMAXS(int blockSize) { _dynamicRoomOffsets = true; } +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(); + _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); + + _numVariables = _fileHandle->readUint16LE(); + _fileHandle->readUint16LE(); + _numBitVariables = _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(); + _numNewNames = 50; + + _objectRoomTable = NULL; + _numGlobalScripts = 200; + + if (_heversion >= 70) { + _objectRoomTable = (byte *)calloc(_numGlobalObjects, 1); + } + + _shadowPaletteSize = 256; + _shadowPalette = (byte *)calloc(_shadowPaletteSize, 1); + + allocateArrays(); + _dynamicRoomOffsets = true; +} + void ScummEngine::readGlobalObjects() { int i; int num = _fileHandle->readUint16LE(); @@ -1014,6 +1115,42 @@ void ScummEngine::readGlobalObjects() { #endif } +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 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 (int 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_v4.cpp b/scumm/resource_v4.cpp index 579820e467..f7cc007d2a 100644 --- a/scumm/resource_v4.cpp +++ b/scumm/resource_v4.cpp @@ -184,141 +184,4 @@ 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 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 (int 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(); - _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); - - _numVariables = _fileHandle->readUint16LE(); - _fileHandle->readUint16LE(); - _numBitVariables = _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(); - _numNewNames = 50; - - _objectRoomTable = NULL; - _numGlobalScripts = 200; - - if (_heversion >= 70) { - _objectRoomTable = (byte *)calloc(_numGlobalObjects, 1); - } - - _shadowPaletteSize = 256; - _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 8580920dba..ced6b0758a 100644 --- a/scumm/resource_v7he.cpp +++ b/scumm/resource_v7he.cpp @@ -1753,4 +1753,11 @@ void ScummEngine_v72he::readMAXS(int blockSize) { _dynamicRoomOffsets = true; } +byte *ScummEngine_v72he::getStringAddress(int i) { + byte *addr = getResourceAddress(rtString, i); + if (addr == NULL) + return NULL; + return ((ScummEngine_v72he::ArrayHeader *)addr)->data; +} + } // End of namespace Scumm diff --git a/scumm/scumm.h b/scumm/scumm.h index c8fb44477b..3bd6fd9412 100644 --- a/scumm/scumm.h +++ b/scumm/scumm.h @@ -709,7 +709,7 @@ protected: public: byte *getResourceAddress(int type, int i); - byte *getStringAddress(int i); + virtual byte *getStringAddress(int i); byte *getStringAddressVar(int i); void ensureResourceLoaded(int type, int i); int getResourceRoomNr(int type, int index); |