diff options
author | Johannes Schickel | 2008-11-03 19:51:34 +0000 |
---|---|---|
committer | Johannes Schickel | 2008-11-03 19:51:34 +0000 |
commit | 6eab0dcc6ef053ed70eeee3145e891dba7e5749d (patch) | |
tree | 70ff6041dfa897a249539d88a28d676e2996a95a /engines/kyra | |
parent | f3f3c69f6306a5f783826045fab0efe288f49058 (diff) | |
download | scummvm-rg350-6eab0dcc6ef053ed70eeee3145e891dba7e5749d.tar.gz scummvm-rg350-6eab0dcc6ef053ed70eeee3145e891dba7e5749d.tar.bz2 scummvm-rg350-6eab0dcc6ef053ed70eeee3145e891dba7e5749d.zip |
Preliminary support for loading via GMM for KYRA engine.
svn-id: r34885
Diffstat (limited to 'engines/kyra')
-rw-r--r-- | engines/kyra/detection.cpp | 3 | ||||
-rw-r--r-- | engines/kyra/kyra_lok.cpp | 8 | ||||
-rw-r--r-- | engines/kyra/kyra_v1.cpp | 2 | ||||
-rw-r--r-- | engines/kyra/kyra_v1.h | 7 | ||||
-rw-r--r-- | engines/kyra/kyra_v2.cpp | 5 | ||||
-rw-r--r-- | engines/kyra/lol.h | 1 | ||||
-rw-r--r-- | engines/kyra/saveload.cpp | 10 | ||||
-rw-r--r-- | engines/kyra/sound_adlib.cpp | 12 |
8 files changed, 47 insertions, 1 deletions
diff --git a/engines/kyra/detection.cpp b/engines/kyra/detection.cpp index cc662d1b82..8b859c62e1 100644 --- a/engines/kyra/detection.cpp +++ b/engines/kyra/detection.cpp @@ -1078,7 +1078,8 @@ bool KyraMetaEngine::hasFeature(MetaEngineFeature f) const { (f == kSupportsLoadingDuringStartup) || (f == kSupportsDeleteSave) || (f == kSavesSupportMetaInfo) || - (f == kSavesSupportThumbnail); + (f == kSavesSupportThumbnail) || + (f == kSupportsLoadingDuringRuntime); } bool KyraMetaEngine::createInstance(OSystem *syst, Engine **engine, const Common::ADGameDescription *desc) const { diff --git a/engines/kyra/kyra_lok.cpp b/engines/kyra/kyra_lok.cpp index 5a3376a3e6..e8db3467fc 100644 --- a/engines/kyra/kyra_lok.cpp +++ b/engines/kyra/kyra_lok.cpp @@ -463,7 +463,12 @@ void KyraEngine_LoK::delay(uint32 amount, bool update, bool isMainLoop) { uint32 start = _system->getMillis(); do { + if (isMainLoop) + _isSaveAllowed = true; + while (_eventMan->pollEvent(event)) { + _isSaveAllowed = false; + switch (event.type) { case Common::EVENT_KEYDOWN: if (event.kbd.keycode >= '1' && event.kbd.keycode <= '9' && @@ -513,6 +518,9 @@ void KyraEngine_LoK::delay(uint32 amount, bool update, bool isMainLoop) { default: break; } + + if (isMainLoop) + _isSaveAllowed = true; } if (_debugger->isAttached()) diff --git a/engines/kyra/kyra_v1.cpp b/engines/kyra/kyra_v1.cpp index 2a6cfb6f06..0d398f6c64 100644 --- a/engines/kyra/kyra_v1.cpp +++ b/engines/kyra/kyra_v1.cpp @@ -65,6 +65,8 @@ KyraEngine_v1::KyraEngine_v1(OSystem *system, const GameFlags &flags) memset(_flagsTable, 0, sizeof(_flagsTable)); + _isSaveAllowed = false; + // sets up all engine specific debug levels Common::addSpecialDebugLevel(kDebugLevelScriptFuncs, "ScriptFuncs", "Script function debug level"); Common::addSpecialDebugLevel(kDebugLevelScript, "Script", "Script interpreter debug level"); diff --git a/engines/kyra/kyra_v1.h b/engines/kyra/kyra_v1.h index f4c2442c0e..114536c381 100644 --- a/engines/kyra/kyra_v1.h +++ b/engines/kyra/kyra_v1.h @@ -274,6 +274,11 @@ protected: uint32 _lastAutosave; void checkAutosave(); + bool _isSaveAllowed; + + bool canLoadGameStateCurrently() { return _isSaveAllowed; } + bool canSaveGameStateCurrently() { return _isSaveAllowed; } + const char *getSavegameFilename(int num); static Common::String getSavegameFilename(const Common::String &target, int num); bool saveFileLoadable(int slot); @@ -299,6 +304,8 @@ protected: static kReadSaveHeaderError readSaveHeader(Common::SeekableReadStream *file, bool loadThumbnail, SaveHeader &header); + int loadGameState(int slot); + virtual void loadGame(const char *fileName) = 0; virtual void saveGame(const char *fileName, const char *saveName, const Graphics::Surface *thumbnail) = 0; Common::SeekableReadStream *openSaveForReading(const char *filename, SaveHeader &header); diff --git a/engines/kyra/kyra_v2.cpp b/engines/kyra/kyra_v2.cpp index a1124bf98d..1cdb659c6a 100644 --- a/engines/kyra/kyra_v2.cpp +++ b/engines/kyra/kyra_v2.cpp @@ -164,8 +164,13 @@ void KyraEngine_v2::delay(uint32 amount, bool updateGame, bool isMainLoop) { int KyraEngine_v2::checkInput(Button *buttonList, bool mainLoop) { debugC(9, kDebugLevelMain, "KyraEngine_v2::checkInput(%p, %d)", (const void*)buttonList, mainLoop); + if (mainLoop) + _isSaveAllowed = true; + updateInput(); + _isSaveAllowed = false; + int keys = 0; int8 mouseWheel = 0; diff --git a/engines/kyra/lol.h b/engines/kyra/lol.h index 2ae4d71580..71d184f062 100644 --- a/engines/kyra/lol.h +++ b/engines/kyra/lol.h @@ -149,6 +149,7 @@ private: bool lineIsPassable(int, int) { return false; } // save + void loadGame(const char *fileName) {} void saveGame(const char *fileName, const char *saveName, const Graphics::Surface *thumbnail) {} }; diff --git a/engines/kyra/saveload.cpp b/engines/kyra/saveload.cpp index d094dd1ccb..e85346a9ba 100644 --- a/engines/kyra/saveload.cpp +++ b/engines/kyra/saveload.cpp @@ -244,6 +244,16 @@ bool KyraEngine_v1::saveFileLoadable(int slot) { return false; } +int KyraEngine_v1::loadGameState(int slot) { + if (!_isSaveAllowed) + return -1; + + const char *filename = getSavegameFilename(slot); + loadGame(filename); + + return 0; +} + void KyraEngine_v1::checkAutosave() { if (shouldPerformAutoSave(_lastAutosave)) { saveGame(getSavegameFilename(999), "Autosave", 0); diff --git a/engines/kyra/sound_adlib.cpp b/engines/kyra/sound_adlib.cpp index 62551d2b09..32b09ecd2d 100644 --- a/engines/kyra/sound_adlib.cpp +++ b/engines/kyra/sound_adlib.cpp @@ -2303,11 +2303,23 @@ void SoundAdlibPC::play(uint8 track) { if ((soundId == 0xFFFF && _v2) || (soundId == 0xFF && !_v2) || !_soundDataPtr) return; + // HACK: Since we might call this when the engines is paused (on game load via GMM) + // we must unpause the engine here, so this will work properly + + int pauseCount = 0; + while (_vm->isPaused()) { + ++pauseCount; + _vm->pauseEngine(false); + } + while ((_driver->callback(16, 0) & 8)) { // We call the system delay and not the game delay to avoid concurrency issues. _vm->_system->delayMillis(10); } + while (pauseCount--) + _vm->pauseEngine(true); + if (_sfxPlayingSound != -1) { // Restore the sounds's normal values. _driver->callback(10, _sfxPlayingSound, int(1), int(_sfxPriority)); |