diff options
Diffstat (limited to 'engines')
-rw-r--r-- | engines/mohawk/console.cpp | 28 | ||||
-rw-r--r-- | engines/mohawk/riven.cpp | 82 | ||||
-rw-r--r-- | engines/mohawk/riven.h | 22 | ||||
-rw-r--r-- | engines/mohawk/riven_external.cpp | 6 | ||||
-rw-r--r-- | engines/mohawk/riven_graphics.cpp | 2 | ||||
-rw-r--r-- | engines/mohawk/riven_saveload.cpp | 79 | ||||
-rw-r--r-- | engines/mohawk/riven_scripts.cpp | 4 |
7 files changed, 81 insertions, 142 deletions
diff --git a/engines/mohawk/console.cpp b/engines/mohawk/console.cpp index 2e83eb3328..d95c91e3be 100644 --- a/engines/mohawk/console.cpp +++ b/engines/mohawk/console.cpp @@ -426,13 +426,11 @@ bool RivenConsole::Cmd_CurStack(int argc, const char **argv) { } bool RivenConsole::Cmd_ChangeStack(int argc, const char **argv) { - byte i; - if (argc < 3) { DebugPrintf("Usage: changeStack <stack> <card>\n\n"); DebugPrintf("Stacks:\n=======\n"); - for (i = 0; i <= tspit; i++) + for (uint i = kStackFirst; i <= kStackLast; i++) DebugPrintf(" %s\n", _vm->getStackName(i).c_str()); DebugPrintf("\n"); @@ -440,20 +438,21 @@ bool RivenConsole::Cmd_ChangeStack(int argc, const char **argv) { return true; } - byte stackNum = 0; + uint stack = kStackUnknown; - for (i = 1; i <= tspit + 1; i++) - if (!scumm_stricmp(argv[1], _vm->getStackName(i - 1).c_str())) { - stackNum = i; + for (uint i = kStackFirst; i <= kStackLast; i++) { + if (!scumm_stricmp(argv[1], _vm->getStackName(i).c_str())) { + stack = i; break; } + } - if (!stackNum) { + if (stack == kStackUnknown) { DebugPrintf("\'%s\' is not a stack name!\n", argv[1]); return true; } - _vm->changeToStack(stackNum - 1); + _vm->changeToStack(stack); _vm->changeToCard((uint16)atoi(argv[2])); return false; @@ -494,21 +493,20 @@ bool RivenConsole::Cmd_DumpScript(int argc, const char **argv) { } uint16 oldStack = _vm->getCurStack(); + uint newStack = kStackUnknown; - byte newStack = 0; - - for (byte i = 1; i <= tspit + 1; i++) - if (!scumm_stricmp(argv[1], _vm->getStackName(i - 1).c_str())) { + for (uint i = kStackFirst; i <= kStackLast; i++) { + if (!scumm_stricmp(argv[1], _vm->getStackName(i).c_str())) { newStack = i; break; } + } - if (!newStack) { + if (newStack == kStackUnknown) { DebugPrintf("\'%s\' is not a stack name!\n", argv[1]); return true; } - newStack--; _vm->changeToStack(newStack); // Load in Variable Names diff --git a/engines/mohawk/riven.cpp b/engines/mohawk/riven.cpp index e1059bebaa..a7fe12b9e1 100644 --- a/engines/mohawk/riven.cpp +++ b/engines/mohawk/riven.cpp @@ -55,7 +55,7 @@ MohawkEngine_Riven::MohawkEngine_Riven(OSystem *syst, const MohawkGameDescriptio _activatedSLST = false; _ignoreNextMouseUp = false; _extrasFile = 0; - _curStack = aspit; + _curStack = kStackUnknown; _hotspots = 0; removeTimer(); @@ -161,7 +161,7 @@ Common::Error MohawkEngine_Riven::run() { // Let's begin, shall we? if (getFeatures() & GF_DEMO) { // Start the demo off with the videos - changeToStack(aspit); + changeToStack(kStackAspit); changeToCard(6); } else if (ConfMan.hasKey("save_slot")) { // Load game from launcher/command line if requested @@ -172,12 +172,12 @@ Common::Error MohawkEngine_Riven::run() { // Attempt to load the game. On failure, just send us to the main menu. if (_saveLoad->loadGame(savedGamesList[gameToLoad]).getCode() != Common::kNoError) { - changeToStack(aspit); + changeToStack(kStackAspit); changeToCard(1); } } else { // Otherwise, start us off at aspit's card 1 (the main menu) - changeToStack(aspit); + changeToStack(kStackAspit); changeToCard(1); } @@ -255,16 +255,16 @@ void MohawkEngine_Riven::handleEvents() { case Common::KEYCODE_r: // Return to the main menu in the demo on ctrl+r if (event.kbd.flags & Common::KBD_CTRL && getFeatures() & GF_DEMO) { - if (_curStack != aspit) - changeToStack(aspit); + if (_curStack != kStackAspit) + changeToStack(kStackAspit); changeToCard(1); } break; case Common::KEYCODE_p: // Play the intro videos in the demo on ctrl+p if (event.kbd.flags & Common::KBD_CTRL && getFeatures() & GF_DEMO) { - if (_curStack != aspit) - changeToStack(aspit); + if (_curStack != kStackAspit) + changeToStack(kStackAspit); changeToCard(6); } break; @@ -343,20 +343,22 @@ struct RivenSpecialChange { uint32 startCardRMAP; byte targetStack; uint32 targetCardRMAP; -} rivenSpecialChange[] = { - { aspit, 0x1f04, ospit, 0x44ad }, // Trap Book - { bspit, 0x1c0e7, ospit, 0x2e76 }, // Dome Linking Book - { gspit, 0x111b1, ospit, 0x2e76 }, // Dome Linking Book - { jspit, 0x28a18, rspit, 0xf94 }, // Tay Linking Book - { jspit, 0x26228, ospit, 0x2e76 }, // Dome Linking Book - { ospit, 0x5f0d, pspit, 0x3bf0 }, // Return from 233rd Age - { ospit, 0x470a, jspit, 0x1508e }, // Return from 233rd Age - { ospit, 0x5c52, gspit, 0x10bea }, // Return from 233rd Age - { ospit, 0x5d68, bspit, 0x1adfd }, // Return from 233rd Age - { ospit, 0x5e49, tspit, 0xe87 }, // Return from 233rd Age - { pspit, 0x4108, ospit, 0x2e76 }, // Dome Linking Book - { rspit, 0x32d8, jspit, 0x1c474 }, // Return from Tay - { tspit, 0x21b69, ospit, 0x2e76 } // Dome Linking Book +}; + +static const RivenSpecialChange rivenSpecialChange[] = { + { kStackAspit, 0x1f04, kStackOspit, 0x44ad }, // Trap Book + { kStackBspit, 0x1c0e7, kStackOspit, 0x2e76 }, // Dome Linking Book + { kStackGspit, 0x111b1, kStackOspit, 0x2e76 }, // Dome Linking Book + { kStackJspit, 0x28a18, kStackRspit, 0xf94 }, // Tay Linking Book + { kStackJspit, 0x26228, kStackOspit, 0x2e76 }, // Dome Linking Book + { kStackOspit, 0x5f0d, kStackPspit, 0x3bf0 }, // Return from 233rd Age + { kStackOspit, 0x470a, kStackJspit, 0x1508e }, // Return from 233rd Age + { kStackOspit, 0x5c52, kStackGspit, 0x10bea }, // Return from 233rd Age + { kStackOspit, 0x5d68, kStackBspit, 0x1adfd }, // Return from 233rd Age + { kStackOspit, 0x5e49, kStackTspit, 0xe87 }, // Return from 233rd Age + { kStackPspit, 0x4108, kStackOspit, 0x2e76 }, // Dome Linking Book + { kStackRspit, 0x32d8, kStackJspit, 0x1c474 }, // Return from Tay + { kStackTspit, 0x21b69, kStackOspit, 0x2e76 } // Dome Linking Book }; void MohawkEngine_Riven::changeToCard(uint16 dest) { @@ -556,16 +558,16 @@ void MohawkEngine_Riven::checkInventoryClick() { // In the demo, check if we've clicked the exit button if (getFeatures() & GF_DEMO) { if (g_demoExitRect->contains(mousePos)) { - if (_curStack == aspit && _curCard == 1) { + if (_curStack == kStackAspit && _curCard == 1) { // From the main menu, go to the "quit" screen changeToCard(12); - } else if (_curStack == aspit && _curCard == 12) { + } else if (_curStack == kStackAspit && _curCard == 12) { // From the "quit" screen, just quit _gameOver = true; } else { // Otherwise, return to the main menu - if (_curStack != aspit) - changeToStack(aspit); + if (_curStack != kStackAspit) + changeToStack(kStackAspit); changeToCard(1); } } @@ -573,7 +575,7 @@ void MohawkEngine_Riven::checkInventoryClick() { } // No inventory shown on aspit - if (_curStack == aspit) + if (_curStack == kStackAspit) return; // Set the return stack/card id's. @@ -589,31 +591,31 @@ void MohawkEngine_Riven::checkInventoryClick() { if (!hasCathBook) { if (g_atrusJournalRect1->contains(mousePos)) { _gfx->hideInventory(); - changeToStack(aspit); + changeToStack(kStackAspit); changeToCard(5); } } else if (!hasTrapBook) { if (g_atrusJournalRect2->contains(mousePos)) { _gfx->hideInventory(); - changeToStack(aspit); + changeToStack(kStackAspit); changeToCard(5); } else if (g_cathJournalRect2->contains(mousePos)) { _gfx->hideInventory(); - changeToStack(aspit); + changeToStack(kStackAspit); changeToCard(6); } } else { if (g_atrusJournalRect3->contains(mousePos)) { _gfx->hideInventory(); - changeToStack(aspit); + changeToStack(kStackAspit); changeToCard(5); } else if (g_cathJournalRect3->contains(mousePos)) { _gfx->hideInventory(); - changeToStack(aspit); + changeToStack(kStackAspit); changeToCard(6); } else if (g_trapBookRect3->contains(mousePos)) { _gfx->hideInventory(); - changeToStack(aspit); + changeToStack(kStackAspit); changeToCard(7); } } @@ -735,16 +737,20 @@ Common::Error MohawkEngine_Riven::saveGameState(int slot, const Common::String & Common::String MohawkEngine_Riven::getStackName(uint16 stack) const { static const char *rivenStackNames[] = { - "aspit", - "bspit", - "gspit", - "jspit", + "<unknown>", "ospit", "pspit", "rspit", - "tspit" + "tspit", + "bspit", + "gspit", + "jspit", + "aspit" }; + // Sanity check. + assert(stack < ARRAYSIZE(rivenStackNames)); + return rivenStackNames[stack]; } diff --git a/engines/mohawk/riven.h b/engines/mohawk/riven.h index c22b9f7f87..9c23d07c52 100644 --- a/engines/mohawk/riven.h +++ b/engines/mohawk/riven.h @@ -44,18 +44,20 @@ class RivenConsole; class RivenSaveLoad; class RivenOptionsDialog; -#define RIVEN_STACKS 8 - // Riven Stack Types enum { - aspit = 0, // Main Menu, Books, Setup - bspit = 1, // Book-Making Island - gspit = 2, // Garden Island - jspit = 3, // Jungle Island - ospit = 4, // 233rd Age (Gehn's Office) - pspit = 5, // Prison Island - rspit = 6, // Rebel Age (Tay) - tspit = 7 // Temple Island + kStackUnknown = 0, // Default value for ReturnStackID + kStackOspit = 1, // 233rd Age (Gehn's Office) + kStackPspit = 2, // Prison Island + kStackRspit = 3, // Temple Island + kStackTspit = 4, // Rebel Age (Tay) + kStackBspit = 5, // Book-Making Island + kStackGspit = 6, // Garden Island + kStackJspit = 7, // Jungle Island + kStackAspit = 8, // Main Menu, Books, Setup + + kStackFirst = kStackOspit, + kStackLast = kStackAspit }; // NAME Resource ID's diff --git a/engines/mohawk/riven_external.cpp b/engines/mohawk/riven_external.cpp index 10dcfd9fa7..3d0bccc47f 100644 --- a/engines/mohawk/riven_external.cpp +++ b/engines/mohawk/riven_external.cpp @@ -405,7 +405,7 @@ void RivenExternal::drawDomeSliders(uint16 startHotspot) { // On pspit, the rect is different by two pixels // (alternatively, we could just use hotspot 3 here, but only on pspit is there a hotspot for this) - if (_vm->getCurStack() == pspit) + if (_vm->getCurStack() == kStackPspit) dstAreaRect.translate(-2, 0); // Find out bitmap id @@ -2016,8 +2016,8 @@ void RivenExternal::xorollcredittime(uint16 argc, uint16 *argv) { // WORKAROUND: The special change stuff only handles one destination and it would // be messy to modify the way that currently works. If we use the trap book on Tay, // we should be using the Tay end game sequences. - if (_vm->_vars["returnstackid"] == rspit) { - _vm->changeToStack(rspit); + if (_vm->_vars["returnstackid"] == kStackRspit) { + _vm->changeToStack(kStackRspit); _vm->changeToCard(2); return; } diff --git a/engines/mohawk/riven_graphics.cpp b/engines/mohawk/riven_graphics.cpp index 615b2fdadb..b44fbb828e 100644 --- a/engines/mohawk/riven_graphics.cpp +++ b/engines/mohawk/riven_graphics.cpp @@ -289,7 +289,7 @@ void RivenGraphics::showInventory() { drawInventoryImage(101, g_demoExitRect); } else { // We don't want to show the inventory on setup screens or in other journals. - if (_vm->getCurStack() == aspit) + if (_vm->getCurStack() == kStackAspit) return; // There are three books and three vars. We have three different diff --git a/engines/mohawk/riven_saveload.cpp b/engines/mohawk/riven_saveload.cpp index d97d0e174b..6af66f7a2d 100644 --- a/engines/mohawk/riven_saveload.cpp +++ b/engines/mohawk/riven_saveload.cpp @@ -38,56 +38,6 @@ Common::StringArray RivenSaveLoad::generateSaveGameList() { return _saveFileMan->listSavefiles("*.rvn"); } -// Note: The stack numbers we use do not match up to what the original executable, -// so, match them ;) -static uint16 mapOldStackIDToNew(uint16 oldID) { - switch (oldID) { - case 1: - return ospit; - case 2: - return pspit; - case 3: - return rspit; - case 4: - return tspit; - case 5: - return bspit; - case 6: - return gspit; - case 7: - return jspit; - case 8: - return aspit; - } - - error("Unknown old stack ID %d", oldID); - return 0; -} - -static uint16 mapNewStackIDToOld(uint16 newID) { - switch (newID) { - case aspit: - return 8; - case bspit: - return 5; - case gspit: - return 6; - case jspit: - return 7; - case ospit: - return 1; - case pspit: - return 2; - case rspit: - return 3; - case tspit: - return 4; - } - - error("Unknown new stack ID %d", newID); - return 0; -} - Common::Error RivenSaveLoad::loadGame(Common::String filename) { if (_vm->getFeatures() & GF_DEMO) // Don't load games in the demo return Common::kNoError; @@ -141,9 +91,6 @@ Common::Error RivenSaveLoad::loadGame(Common::String filename) { names->readUint16BE(); // Skip unknown values uint32 curNamesPos = names->pos(); - uint16 stackID = 0; - uint16 cardID = 0; - for (uint32 i = 0; i < namesCount && !names->eos(); i++) { names->seek(curNamesPos); names->seek(stringOffsets[i], SEEK_CUR); @@ -165,25 +112,18 @@ Common::Error RivenSaveLoad::loadGame(Common::String filename) { uint32 &var = _vm->_vars[name]; name.toLowercase(); - // Handle any special variables here // WORKAROUND: time variables are reset here for one main reason: // The save does not store any start point for the time, so we don't know the real time. // Because of this, in many cases, the original would just give a 'free' Ytram upon saving // since the time would be used in a new (improper) time frame. - if (name.equalsIgnoreCase("CurrentStackID")) // Remap to our definitions, store for later - stackID = mapOldStackIDToNew(rawVariables[i]); - else if (name.equalsIgnoreCase("CurrentCardID")) // Store for later - cardID = rawVariables[i]; - else if (name.equalsIgnoreCase("ReturnStackID") && var != 0) // if 0, the game did not use the variable yet - var = mapOldStackIDToNew(rawVariables[i]); - else if (name.contains("time")) // WORKAROUND: See above + if (name.contains("time")) var = 0; - else // Otherwise, just store it + else var = rawVariables[i]; } - _vm->changeToStack(stackID); - _vm->changeToCard(cardID); + _vm->changeToStack(_vm->_vars["CurrentStackID"]); + _vm->changeToCard(_vm->_vars["CurrentCardID"]); delete names; delete[] stringOffsets; @@ -224,14 +164,7 @@ Common::MemoryWriteStreamDynamic *RivenSaveLoad::genVARSSection() { for (RivenVariableMap::const_iterator it = _vm->_vars.begin(); it != _vm->_vars.end(); it++) { stream->writeUint32BE(0); // Unknown stream->writeUint32BE(0); // Unknown - - // Remap returnstackid here because we don't actually want to change - // our internal returnstackid. - uint32 variable = it->_value; - if (it->_key == "returnstackid") - variable = mapNewStackIDToOld(variable); - - stream->writeUint32BE(variable); + stream->writeUint32BE(it->_value); } return stream; @@ -290,7 +223,7 @@ Common::Error RivenSaveLoad::saveGame(Common::String filename) { filename += ".rvn"; // Convert class variables to variable numbers - _vm->_vars["currentstackid"] = mapNewStackIDToOld(_vm->getCurStack()); + _vm->_vars["currentstackid"] = _vm->getCurStack(); _vm->_vars["currentcardid"] = _vm->getCurCard(); Common::OutSaveFile *saveFile = _saveFileMan->openForSaving(filename); diff --git a/engines/mohawk/riven_scripts.cpp b/engines/mohawk/riven_scripts.cpp index 06b6afdf30..29ee5cd50b 100644 --- a/engines/mohawk/riven_scripts.cpp +++ b/engines/mohawk/riven_scripts.cpp @@ -403,7 +403,7 @@ void RivenScript::stopSound(uint16 op, uint16 argc, uint16 *argv) { // would cause all ambient sounds not to play. An alternative // fix would be to stop all scripts on a stack change, but this // does fine for now. - if (_vm->getCurStack() == tspit && (_vm->getCurCardRMAP() == 0x6e9a || _vm->getCurCardRMAP() == 0xfeeb)) + if (_vm->getCurStack() == kStackTspit && (_vm->getCurCardRMAP() == 0x6e9a || _vm->getCurCardRMAP() == 0xfeeb)) return; // The argument is a bitflag for the setting. @@ -586,7 +586,7 @@ void RivenScript::activatePLST(uint16 op, uint16 argc, uint16 *argv) { void RivenScript::activateSLST(uint16 op, uint16 argc, uint16 *argv) { // WORKAROUND: Disable the SLST that is played during Riven's intro. // Riven X does this too (spoke this over with Jeff) - if (_vm->getCurStack() == tspit && _vm->getCurCardRMAP() == 0x6e9a && argv[0] == 2) + if (_vm->getCurStack() == kStackTspit && _vm->getCurCardRMAP() == 0x6e9a && argv[0] == 2) return; _vm->_sound->playSLST(argv[0], _vm->getCurCard()); |