aboutsummaryrefslogtreecommitdiff
path: root/engines/mohawk/myst.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'engines/mohawk/myst.cpp')
-rw-r--r--engines/mohawk/myst.cpp74
1 files changed, 49 insertions, 25 deletions
diff --git a/engines/mohawk/myst.cpp b/engines/mohawk/myst.cpp
index 852196e6ac..6b91e74bb2 100644
--- a/engines/mohawk/myst.cpp
+++ b/engines/mohawk/myst.cpp
@@ -66,19 +66,16 @@ MohawkEngine_Myst::MohawkEngine_Myst(OSystem *syst, const MohawkGameDescription
DebugMan.addDebugChannel(kDebugHelp, "Help", "Track Help File (HELP) Parsing");
DebugMan.addDebugChannel(kDebugCache, "Cache", "Track Resource Cache Accesses");
- // Engine tweaks
- // Disabling this makes engine behavior as per
- // original, including bugs, missing bits etc. :)
- _tweaksEnabled = true;
-
_currentCursor = 0;
_mainCursor = kDefaultMystCursor;
_showResourceRects = false;
_curCard = 0;
_needsUpdate = false;
+ _canSafelySaveLoad = false;
_curResource = -1;
_hoverResource = nullptr;
+ _sound = nullptr;
_gfx = nullptr;
_console = nullptr;
_scriptParser = nullptr;
@@ -92,6 +89,7 @@ MohawkEngine_Myst::~MohawkEngine_Myst() {
DebugMan.clearAllDebugChannels();
delete _gfx;
+ delete _sound;
delete _console;
delete _scriptParser;
delete _gameState;
@@ -151,7 +149,7 @@ void MohawkEngine_Myst::cachePreload(uint32 tag, uint16 id) {
}
}
- warning("cachePreload: Could not find a \'%s\' resource with ID %04x", tag2str(tag), id);
+ debugC(kDebugCache, "cachePreload: Could not find a \'%s\' resource with ID %04x", tag2str(tag), id);
}
static const char *mystFiles[] = {
@@ -224,6 +222,7 @@ Common::Error MohawkEngine_Myst::run() {
MohawkEngine::run();
_gfx = new MystGraphics(this);
+ _sound = new Sound(this);
_console = new MystConsole(this);
_gameState = new MystGameState(this, _saveFileMan);
_optionsDialog = new MystOptionsDialog(this);
@@ -234,12 +233,10 @@ Common::Error MohawkEngine_Myst::run() {
_cursor->showCursor();
// Load game from launcher/command line if requested
- if (ConfMan.hasKey("save_slot") && canLoadGameStateCurrently()) {
- uint32 gameToLoad = ConfMan.getInt("save_slot");
- Common::StringArray savedGamesList = _gameState->generateSaveGameList();
- if (gameToLoad > savedGamesList.size())
- error ("Could not find saved game");
- _gameState->load(savedGamesList[gameToLoad]);
+ if (ConfMan.hasKey("save_slot") && hasGameSaveSupport()) {
+ int saveSlot = ConfMan.getInt("save_slot");
+ if (!_gameState->load(saveSlot))
+ error("Failed to load save game from slot %i", saveSlot);
} else {
// Start us on the first stack.
if (getGameType() == GType_MAKINGOF)
@@ -267,7 +264,7 @@ Common::Error MohawkEngine_Myst::run() {
_needsUpdate = _video->updateMovies();
_scriptParser->runPersistentScripts();
- while (_eventMan->pollEvent(event)) {
+ while (pollEvent(event)) {
switch (event.type) {
case Common::EVENT_MOUSEMOVE: {
_needsUpdate = true;
@@ -311,8 +308,13 @@ Common::Error MohawkEngine_Myst::run() {
_needsPageDrop = false;
_needsShowMap = false;
_needsShowDemoMenu = false;
+ _needsShowCredits = false;
+ _canSafelySaveLoad = true;
runDialog(*_optionsDialog);
+ if (_optionsDialog->getLoadSlot() >= 0)
+ loadGameState(_optionsDialog->getLoadSlot());
+ _canSafelySaveLoad = false;
if (_needsPageDrop) {
dropPage();
@@ -328,6 +330,12 @@ Common::Error MohawkEngine_Myst::run() {
changeToStack(kDemoStack, 2002, 0, 0);
_needsShowDemoMenu = false;
}
+
+ if (_needsShowCredits) {
+ _cursor->hideCursor();
+ changeToStack(kCreditsStack, 10000, 0, 0);
+ _needsShowCredits = false;
+ }
break;
default:
break;
@@ -350,6 +358,15 @@ Common::Error MohawkEngine_Myst::run() {
return Common::kNoError;
}
+bool MohawkEngine_Myst::pollEvent(Common::Event &event) {
+ // Saving / Loading is allowed from the GMM only when the main event loop is running
+ _canSafelySaveLoad = true;
+ bool eventReturned = _eventMan->pollEvent(event);
+ _canSafelySaveLoad = false;
+
+ return eventReturned;
+}
+
bool MohawkEngine_Myst::skippableWait(uint32 duration) {
uint32 end = _system->getMillis() + duration;
bool skipped = false;
@@ -491,8 +508,9 @@ void MohawkEngine_Myst::changeToStack(uint16 stack, uint16 card, uint16 linkSrcS
flyby = "stoneship flyby";
break;
// Myst Flyby Movie not used in Original Masterpiece Edition Engine
+ // We play it when first arriving on Myst, and if the user has chosen so.
case kMystStack:
- if (_tweaksEnabled)
+ if (ConfMan.getBool("playmystflyby") && card == 4134)
flyby = "myst flyby";
break;
case kMechanicalStack:
@@ -587,10 +605,13 @@ void MohawkEngine_Myst::changeToCard(uint16 card, TransitionType transition) {
// Make sure the screen is updated
if (transition != kNoTransition) {
- if (!_gameState->_globals.transitions)
- transition = kTransitionCopy;
-
- _gfx->runTransition(transition, Common::Rect(544, 333), 10, 0);
+ if (_gameState->_globals.transitions) {
+ _gfx->runTransition(transition, Common::Rect(544, 333), 10, 0);
+ } else {
+ _gfx->copyBackBufferToScreen(Common::Rect(544, 333));
+ _system->updateScreen();
+ _needsUpdate = false;
+ }
}
// Make sure we have the right cursor showing
@@ -1066,27 +1087,30 @@ void MohawkEngine_Myst::loadResources() {
}
Common::Error MohawkEngine_Myst::loadGameState(int slot) {
- if (_gameState->load(_gameState->generateSaveGameList()[slot]))
+ if (_gameState->load(slot))
return Common::kNoError;
return Common::kUnknownError;
}
Common::Error MohawkEngine_Myst::saveGameState(int slot, const Common::String &desc) {
- Common::StringArray saveList = _gameState->generateSaveGameList();
-
- if ((uint)slot < saveList.size())
- _gameState->deleteSave(saveList[slot]);
+ return _gameState->save(slot, desc) ? Common::kNoError : Common::kUnknownError;
+}
- return _gameState->save(Common::String(desc)) ? Common::kNoError : Common::kUnknownError;
+bool MohawkEngine_Myst::hasGameSaveSupport() const {
+ return !(getFeatures() & GF_DEMO) && getGameType() != GType_MAKINGOF;
}
bool MohawkEngine_Myst::canLoadGameStateCurrently() {
// No loading in the demo/makingof
- return !(getFeatures() & GF_DEMO) && getGameType() != GType_MAKINGOF;
+ return _canSafelySaveLoad && hasGameSaveSupport();
}
bool MohawkEngine_Myst::canSaveGameStateCurrently() {
+ if (!_canSafelySaveLoad) {
+ return false;
+ }
+
// There's a limited number of stacks the game can save in
switch (_curStack) {
case kChannelwoodStack: