diff options
Diffstat (limited to 'scumm')
-rw-r--r-- | scumm/charset.cpp | 8 | ||||
-rw-r--r-- | scumm/debugger.cpp | 6 | ||||
-rw-r--r-- | scumm/object.cpp | 18 | ||||
-rw-r--r-- | scumm/resource.cpp | 6 | ||||
-rw-r--r-- | scumm/script.cpp | 10 | ||||
-rw-r--r-- | scumm/script_v2.cpp | 4 | ||||
-rw-r--r-- | scumm/script_v5.cpp | 6 | ||||
-rw-r--r-- | scumm/script_v6.cpp | 10 | ||||
-rw-r--r-- | scumm/script_v8.cpp | 8 | ||||
-rw-r--r-- | scumm/scumm.h | 20 | ||||
-rw-r--r-- | scumm/scummvm.cpp | 19 | ||||
-rw-r--r-- | scumm/sound.cpp | 6 | ||||
-rw-r--r-- | scumm/string.cpp | 2 | ||||
-rw-r--r-- | scumm/verbs.cpp | 8 |
14 files changed, 61 insertions, 70 deletions
diff --git a/scumm/charset.cpp b/scumm/charset.cpp index abf97bc5e0..6b3cae795f 100644 --- a/scumm/charset.cpp +++ b/scumm/charset.cpp @@ -50,7 +50,7 @@ CharsetRenderer::CharsetRenderer(ScummEngine *vm) { } void CharsetRendererCommon::setCurID(byte id) { - checkRange(_vm->_maxCharsets - 1, 0, id, "Printing with bad charset %d"); + checkRange(_vm->_numCharsets - 1, 0, id, "Printing with bad charset %d"); _curId = id; @@ -65,7 +65,7 @@ void CharsetRendererCommon::setCurID(byte id) { } void CharsetRendererV3::setCurID(byte id) { - checkRange(_vm->_maxCharsets - 1, 0, id, "Printing with bad charset %d"); + checkRange(_vm->_numCharsets - 1, 0, id, "Printing with bad charset %d"); _curId = id; @@ -949,7 +949,7 @@ void CharsetRendererV3::printChar(int chr) { int w, h; int drawTop; - checkRange(_vm->_maxCharsets - 1, 0, _curId, "Printing with bad charset %d"); + checkRange(_vm->_numCharsets - 1, 0, _curId, "Printing with bad charset %d"); if ((vs = _vm->findVirtScreen(_top)) == NULL) return; @@ -1005,7 +1005,7 @@ void CharsetRendererClassic::printChar(int chr) { const byte *charPtr; int is2byte = (chr >= 0x80 && _vm->_CJKMode) ? 1 : 0; - checkRange(_vm->_maxCharsets - 1, 1, _curId, "Printing with bad charset %d"); + checkRange(_vm->_numCharsets - 1, 1, _curId, "Printing with bad charset %d"); if ((vs = _vm->findVirtScreen(_top)) == NULL && (vs = _vm->findVirtScreen(_top + getFontHeight())) == NULL) return; diff --git a/scumm/debugger.cpp b/scumm/debugger.cpp index ffa4292974..6e052a9bc4 100644 --- a/scumm/debugger.cpp +++ b/scumm/debugger.cpp @@ -268,8 +268,8 @@ bool ScummDebugger::Cmd_Script(int argc, const char** argv) { scriptnum = atoi(argv[1]); // FIXME: what is the max range on these? - // if (scriptnum >= _vm->_maxScripts) { - // DebugPrintf("Script number %d is out of range (range: 1 - %d)\n", scriptnum, _vm->_maxScripts); + // if (scriptnum >= _vm->_numScripts) { + // DebugPrintf("Script number %d is out of range (range: 1 - %d)\n", scriptnum, _vm->_numScripts); // return true; //} @@ -449,7 +449,7 @@ bool ScummDebugger::Cmd_Object(int argc, const char **argv) { } if (!strcmp(argv[2], "pickup")) { - for (i = 0; i < _vm->_maxInventoryItems; i++) { + for (i = 0; i < _vm->_numInventory; i++) { if (_vm->_inventory[i] == (uint16)obj) { _vm->putOwner(obj, _vm->VAR(_vm->VAR_EGO)); _vm->runInventoryScript(obj); diff --git a/scumm/object.cpp b/scumm/object.cpp index 0d3d610f07..4d2598cb14 100644 --- a/scumm/object.cpp +++ b/scumm/object.cpp @@ -178,7 +178,7 @@ int ScummEngine::whereIsObject(int object) const { return WIO_NOT_FOUND; if (_objectOwnerTable[object] != OF_OWNER_ROOM) { - for (i = 0; i < _maxInventoryItems; i++) + for (i = 0; i < _numInventory; i++) if (_inventory[i] == object) return WIO_INVENTORY; return WIO_NOT_FOUND; @@ -829,7 +829,7 @@ void ScummEngine::clearOwnerOf(int obj) { return; } - for (i = 0; i < _maxInventoryItems; i++) { + for (i = 0; i < _numInventory; i++) { if (_inventory[i] == obj) { j = whereIsObject(obj); if (j == WIO_INVENTORY) { @@ -837,7 +837,7 @@ void ScummEngine::clearOwnerOf(int obj) { _inventory[i] = 0; } a = _inventory; - for (i = 0; i < _maxInventoryItems - 1; i++, a++) { + for (i = 0; i < _numInventory - 1; i++, a++) { if (!a[0] && a[1]) { a[0] = a[1]; a[1] = 0; @@ -941,7 +941,7 @@ byte *ScummEngine::getOBCDFromObject(int obj) { byte *ptr; if (_objectOwnerTable[obj] != OF_OWNER_ROOM) { - for (i = 0; i < _maxInventoryItems; i++) { + for (i = 0; i < _numInventory; i++) { if (_inventory[i] == obj) return getResourceAddress(rtInventory, i); } @@ -1180,11 +1180,11 @@ void ScummEngine::findObjectInRoom(FindObjectInRoom *fo, byte findWhat, uint id, int ScummEngine::getInventorySlot() { int i; - for (i = 0; i < _maxInventoryItems; i++) { + for (i = 0; i < _numInventory; i++) { if (_inventory[i] == 0) return i; } - error("Inventory full, %d max items", _maxInventoryItems); + error("Inventory full, %d max items", _numInventory); return -1; } @@ -1269,7 +1269,7 @@ int ScummEngine::getObjNewDir(int obj) { int ScummEngine::findInventory(int owner, int idx) { int count = 1, i, obj; - for (i = 0; i < _maxInventoryItems; i++) { + for (i = 0; i < _numInventory; i++) { obj = _inventory[i]; if (obj && getOwner(obj) == owner && count++ == idx) return obj; @@ -1280,7 +1280,7 @@ int ScummEngine::findInventory(int owner, int idx) { int ScummEngine::getInventoryCount(int owner) { int i, obj; int count = 0; - for (i = 0; i < _maxInventoryItems; i++) { + for (i = 0; i < _numInventory; i++) { obj = _inventory[i]; if (obj && getOwner(obj) == owner) count++; @@ -1587,7 +1587,7 @@ int ScummEngine::findLocalObjectSlot() { int ScummEngine::findFlObjectSlot() { int i; - for (i = 1; i < _maxFLObject; i++) { + for (i = 1; i < _numFlObject; i++) { if (_baseFLObject[i] == NULL) return i; } diff --git a/scumm/resource.cpp b/scumm/resource.cpp index a36c557e20..33960aedcd 100644 --- a/scumm/resource.cpp +++ b/scumm/resource.cpp @@ -163,7 +163,7 @@ void ScummEngine::deleteRoomOffsets() { if (!(_features & GF_SMALL_HEADER) && !_dynamicRoomOffsets) return; - for (int i = 0; i < _maxRooms; i++) { + for (int i = 0; i < _numRooms; i++) { if (_roomFileOffsets[i] != 0xFFFFFFFF) _roomFileOffsets[i] = 0; } @@ -559,7 +559,7 @@ void ScummEngine::loadCharset(int no) { no = 1; assert(no < (int)sizeof(_charsetData) / 16); - checkRange(_maxCharsets - 1, 1, no, "Loading illegal charset %d"); + checkRange(_numCharsets - 1, 1, no, "Loading illegal charset %d"); // ensureResourceLoaded(rtCharset, no); ptr = getResourceAddress(rtCharset, no); @@ -572,7 +572,7 @@ void ScummEngine::loadCharset(int no) { } void ScummEngine::nukeCharset(int i) { - checkRange(_maxCharsets - 1, 1, i, "Nuking illegal charset %d"); + checkRange(_numCharsets - 1, 1, i, "Nuking illegal charset %d"); nukeResource(rtCharset, i); } diff --git a/scumm/script.cpp b/scumm/script.cpp index 0058b24274..c7252f98be 100644 --- a/scumm/script.cpp +++ b/scumm/script.cpp @@ -345,11 +345,11 @@ void ScummEngine::getScriptBaseAddress() { ss = &vm.slot[_currentScript]; switch (ss->where) { case WIO_INVENTORY: /* inventory script * */ - for (idx = 0; idx < _maxInventoryItems; idx++) + for (idx = 0; idx < _numInventory; idx++) if (_inventory[idx] == ss->number) break; _scriptOrgPointer = getResourceAddress(rtInventory, idx); - assert(idx < _maxInventoryItems); + assert(idx < _numInventory); _lastCodePtr = &_baseInventoryItems[idx]; break; @@ -361,21 +361,21 @@ void ScummEngine::getScriptBaseAddress() { _lastCodePtr = &res.address[rtRoomScripts][_roomResource]; } else { _scriptOrgPointer = getResourceAddress(rtRoom, _roomResource); - assert(_roomResource < _maxRooms); + assert(_roomResource < _numRooms); _lastCodePtr = &_baseRooms[_roomResource]; } break; case WIO_GLOBAL: /* global script */ _scriptOrgPointer = getResourceAddress(rtScript, ss->number); - assert(ss->number < _maxScripts); + assert(ss->number < _numScripts); _lastCodePtr = &_baseScripts[ss->number]; break; case WIO_FLOBJECT: /* flobject script */ idx = getObjectIndex(ss->number); _scriptOrgPointer = getResourceAddress(rtFlObject, _objs[idx].fl_object_index); - assert(idx < _maxFLObject); + assert(idx < _numFlObject); _lastCodePtr = &_baseFLObject[idx]; break; default: diff --git a/scumm/script_v2.cpp b/scumm/script_v2.cpp index 1628106ea6..19a2b558f4 100644 --- a/scumm/script_v2.cpp +++ b/scumm/script_v2.cpp @@ -789,7 +789,7 @@ void ScummEngine_v2::o2_verbOps() { switch (verb) { case 0: // SO_DELETE_VERBS slot = getVarOrDirectByte(PARAM_1) + 1; - assert(0 < slot && slot < _maxVerbs); + assert(0 < slot && slot < _numVerbs); //printf("o2_verbOps delete slot = %d\n", slot); killVerb(slot); @@ -819,7 +819,7 @@ void ScummEngine_v2::o2_verbOps() { // verb, slot, x, y, prep, _scriptPointer); VerbSlot *vs; - assert(0 < slot && slot < _maxVerbs); + assert(0 < slot && slot < _numVerbs); vs = &_verbs[slot]; vs->verbid = verb; diff --git a/scumm/script_v5.cpp b/scumm/script_v5.cpp index 6bec7e0a28..45a16641c2 100644 --- a/scumm/script_v5.cpp +++ b/scumm/script_v5.cpp @@ -2395,7 +2395,7 @@ void ScummEngine_v5::o5_verbOps() { verb = getVarOrDirectByte(PARAM_1); slot = getVerbSlot(verb, 0); - checkRange(_maxVerbs - 1, 0, slot, "Illegal new verb slot %d"); + checkRange(_numVerbs - 1, 0, slot, "Illegal new verb slot %d"); vs = &_verbs[slot]; vs->verbid = verb; @@ -2490,11 +2490,11 @@ void ScummEngine_v5::o5_verbOps() { case 9: // SO_VERB_NEW slot = getVerbSlot(verb, 0); if (slot == 0) { - for (slot = 1; slot < _maxVerbs; slot++) { + for (slot = 1; slot < _numVerbs; slot++) { if (_verbs[slot].verbid == 0) break; } - if (slot == _maxVerbs) + if (slot == _numVerbs) error("Too many verbs"); } vs = &_verbs[slot]; diff --git a/scumm/script_v6.cpp b/scumm/script_v6.cpp index 15eb89e128..1812051054 100644 --- a/scumm/script_v6.cpp +++ b/scumm/script_v6.cpp @@ -38,8 +38,10 @@ #include "sound/mixer.h" #include "scumm/smush/insane.h" +#ifndef INSANE #include "scumm/dialogs.h" // FIXME: This is just for the FT-INSANE warning. // Remove when INSANE is implemented +#endif namespace Scumm { @@ -1134,7 +1136,7 @@ void ScummEngine_v6::o6_pickupObject() { if (room == 0) room = _roomResource; - for (i = 0; i < _maxInventoryItems; i++) { + for (i = 0; i < _numInventory; i++) { if (_inventory[i] == (uint16)obj) { putOwner(obj, VAR(VAR_EGO)); runInventoryScript(obj); @@ -1829,7 +1831,7 @@ void ScummEngine_v6::o6_verbOps() { if (op == 196) { _curVerb = pop(); _curVerbSlot = getVerbSlot(_curVerb, 0); - checkRange(_maxVerbs - 1, 0, _curVerbSlot, "Illegal new verb slot %d"); + checkRange(_numVerbs - 1, 0, _curVerbSlot, "Illegal new verb slot %d"); return; } vs = &_verbs[_curVerbSlot]; @@ -1873,11 +1875,11 @@ void ScummEngine_v6::o6_verbOps() { case 132: // SO_VERB_NEW slot = getVerbSlot(_curVerb, 0); if (slot == 0) { - for (slot = 1; slot < _maxVerbs; slot++) { + for (slot = 1; slot < _numVerbs; slot++) { if (_verbs[slot].verbid == 0) break; } - if (slot == _maxVerbs) + if (slot == _numVerbs) error("Too many verbs"); _curVerbSlot = slot; } diff --git a/scumm/script_v8.cpp b/scumm/script_v8.cpp index 1d26983ddf..9d5822db0a 100644 --- a/scumm/script_v8.cpp +++ b/scumm/script_v8.cpp @@ -1114,12 +1114,12 @@ void ScummEngine_v8::o8_verbOps() { if (subOp == 0x96) { _curVerb = pop(); _curVerbSlot = getVerbSlot(_curVerb, 0); - checkRange(_maxVerbs - 1, 0, _curVerbSlot, "Illegal new verb slot %d"); + checkRange(_numVerbs - 1, 0, _curVerbSlot, "Illegal new verb slot %d"); //printf("Setting current actor to %d\n", _curActor); return; } - assert(0 <= _curVerbSlot && _curVerbSlot < _maxVerbs); + assert(0 <= _curVerbSlot && _curVerbSlot < _numVerbs); vs = &_verbs[_curVerbSlot]; assert(vs); @@ -1129,11 +1129,11 @@ void ScummEngine_v8::o8_verbOps() { break; case 0x97: // SO_VERB_NEW New verb if (_curVerbSlot == 0) { - for (slot = 1; slot < _maxVerbs; slot++) { + for (slot = 1; slot < _numVerbs; slot++) { if (_verbs[slot].verbid == 0) break; } - if (slot >= _maxVerbs) { + if (slot >= _numVerbs) { error("Too many verbs"); } _curVerbSlot = slot; diff --git a/scumm/scumm.h b/scumm/scumm.h index b489b6da41..deeeda0b8a 100644 --- a/scumm/scumm.h +++ b/scumm/scumm.h @@ -195,21 +195,6 @@ enum ScummGameId { GID_MONKEY_SEGA }; -#define _maxRooms res.num[rtRoom] -#define _maxScripts res.num[rtScript] -#define _maxCostumes res.num[rtCostume] -#define _maxInventoryItems res.num[rtInventory] -#define _maxCharsets res.num[rtCharset] -#define _maxStrings res.num[rtString] -#define _maxVerbs res.num[rtVerb] -#define _maxActorNames res.num[rtActorName] -#define _maxBuffer res.num[rtBuffer] -#define _maxScaleTable res.num[rtScaleTable] -#define _maxTemp res.num[rtTemp] -#define _maxFLObject res.num[rtFlObject] -#define _maxMatrixes res.num[rtMatrix] -#define _maxBoxes res.num[rtBox] - #define _baseRooms res.address[rtRoom] #define _baseScripts res.address[rtScript] #define _baseInventoryItems res.address[rtInventory] @@ -286,6 +271,7 @@ public: /** Graphics manager */ Gdi gdi; +protected: /** Central resource data. */ struct { byte mode[rtNumTypes]; @@ -298,7 +284,6 @@ public: uint32 *roomoffs[rtNumTypes]; } res; -protected: VirtualMachineState vm; public: @@ -396,10 +381,11 @@ protected: int _numVariables, _numBitVariables, _numLocalObjects; int _numGlobalObjects, _numArray, _numVerbs, _numFlObject; int _numInventory, _numRooms, _numScripts, _numSounds; - int _numCharsets, _numNewNames, _numGlobalScripts; + int _numNewNames, _numGlobalScripts; int _numActors; public: int _numCostumes; // FIXME - should be protected, used by Actor::remapActorPalette + int _numCharsets; // FIXME - should be protected, used by CharsetRenderer int getNumSounds() const { return _numSounds; } BaseCostumeRenderer* _costumeRenderer; diff --git a/scumm/scummvm.cpp b/scumm/scummvm.cpp index 823053a237..dbdc75c899 100644 --- a/scumm/scummvm.cpp +++ b/scumm/scummvm.cpp @@ -961,6 +961,12 @@ void ScummEngine::launch() { if (_gameId == GID_MONKEY || _gameId == GID_MONKEY_SEGA) _scummVars[74] = 1225; + if (_imuse) { + _imuse->setBase(res.address[rtSound]); + + _imuse->setMasterVolume(ConfMan.getInt("master_volume")); + _imuse->set_music_volume(ConfMan.getInt("music_volume")); + } _sound->setupSound(); // If requested, load a save game instead of running the boot script @@ -1062,7 +1068,7 @@ void ScummEngine::scummInit() { memset(vm.cutScenePtr, 0, sizeof(vm.cutScenePtr)); memset(vm.cutSceneData, 0, sizeof(vm.cutSceneData)); - for (i = 0; i < _maxVerbs; i++) { + for (i = 0; i < _numVerbs; i++) { _verbs[i].verbid = 0; _verbs[i].right = _screenWidth - 1; _verbs[i].old.left = -1; @@ -1448,7 +1454,7 @@ load_game: if (VAR(value) == 2) runScript(restoreScript, 0, 0, &args); } else if (_version > 3) { - for (int i = 0; i < _maxVerbs; i++) + for (int i = 0; i < _numVerbs; i++) drawVerb(i, 0); } else { redrawVerbs(); @@ -2141,7 +2147,7 @@ void ScummEngine::initRoomSubBlocks() { nukeResource(rtMatrix, 1); nukeResource(rtMatrix, 2); - for (i = 1; i < _maxScaleTable; i++) + for (i = 1; i < res.num[rtScaleTable]; i++) nukeResource(rtScaleTable, i); memset(_localScriptList, 0, sizeof(_localScriptList)); @@ -2316,7 +2322,7 @@ void ScummEngine::initRoomSubBlocks() { if (ptr) { int s1, s2, y1, y2; if (_version == 8) { - for (i = 1; i < _maxScaleTable; i++, ptr += 16) { + for (i = 1; i < res.num[rtScaleTable]; i++, ptr += 16) { s1 = READ_LE_UINT32(ptr); y1 = READ_LE_UINT32(ptr + 4); s2 = READ_LE_UINT32(ptr + 8); @@ -2324,7 +2330,7 @@ void ScummEngine::initRoomSubBlocks() { setScaleSlot(i, 0, y1, s1, 0, y2, s2); } } else { - for (i = 1; i < _maxScaleTable; i++, ptr += 8) { + for (i = 1; i < res.num[rtScaleTable]; i++, ptr += 8) { s1 = READ_LE_UINT16(ptr); y1 = READ_LE_UINT16(ptr + 2); s2 = READ_LE_UINT16(ptr + 4); @@ -2521,6 +2527,9 @@ void ScummEngine::restart() { readIndexFile(); // Reread index (reset objectstate etc) createResource(rtTemp, 6, 500); // Create temp buffer initScummVars(); // Reinit scumm variables + if (_imuse) { + _imuse->setBase(res.address[rtSound]); + } _sound->setupSound(); // Reinit sound engine // Re-run bootscript diff --git a/scumm/sound.cpp b/scumm/sound.cpp index b4c601de53..95532761e6 100644 --- a/scumm/sound.cpp +++ b/scumm/sound.cpp @@ -762,12 +762,6 @@ void Sound::talkSound(uint32 a, uint32 b, int mode, int frame) { */ void Sound::setupSound() { - if (_scumm->_imuse) { - _scumm->_imuse->setBase(_scumm->res.address[rtSound]); - - _scumm->_imuse->setMasterVolume(ConfMan.getInt("master_volume")); - _scumm->_imuse->set_music_volume(ConfMan.getInt("music_volume")); - } delete _sfxFile; _sfxFile = openSfxFile(); } diff --git a/scumm/string.cpp b/scumm/string.cpp index 48a6646fad..24d709ec3f 100644 --- a/scumm/string.cpp +++ b/scumm/string.cpp @@ -599,7 +599,7 @@ void ScummEngine::addVerbToStack(int var) { num = readVar(var); if (num) { - for (k = 1; k < _maxVerbs; k++) { + for (k = 1; k < _numVerbs; k++) { if (num == _verbs[k].verbid && !_verbs[k].type && !_verbs[k].saveid) { const byte *ptr = getResourceAddress(rtVerb, k); ptr = translateTextAndPlaySpeech(ptr); diff --git a/scumm/verbs.cpp b/scumm/verbs.cpp index 628df63457..faeac18fd8 100644 --- a/scumm/verbs.cpp +++ b/scumm/verbs.cpp @@ -267,7 +267,7 @@ void ScummEngine::redrawVerbs() { int i; int verb = (_cursor.state > 0 ? checkMouseOver(_mouse.x, _mouse.y) : 0); - for (i = _maxVerbs-1; i >= 0; i--) { + for (i = _numVerbs-1; i >= 0; i--) { if (i == verb && _verbs[verb].hicolor) drawVerb(i, 1); else @@ -286,7 +286,7 @@ void ScummEngine::checkExecVerbs() { if (_mouseButStat < MBS_MAX_KEY) { /* Check keypresses */ vs = &_verbs[1]; - for (i = 1; i < _maxVerbs; i++, vs++) { + for (i = 1; i < _numVerbs; i++, vs++) { if (vs->verbid && vs->saveid == 0 && vs->curmode == 1) { if (_mouseButStat == vs->key) { // Trigger verb as if the user clicked it @@ -340,7 +340,7 @@ void ScummEngine::verbMouseOver(int verb) { int ScummEngine::checkMouseOver(int x, int y) const { VerbSlot *vs; - int i = _maxVerbs - 1; + int i = _numVerbs - 1; vs = &_verbs[i]; do { @@ -503,7 +503,7 @@ void ScummEngine::drawVerbBitmap(int verb, int x, int y) { int ScummEngine::getVerbSlot(int id, int mode) const { int i; - for (i = 1; i < _maxVerbs; i++) { + for (i = 1; i < _numVerbs; i++) { if (_verbs[i].verbid == id && _verbs[i].saveid == mode) { return i; } |