diff options
author | Colin Snover | 2017-07-30 00:22:11 -0500 |
---|---|---|
committer | Colin Snover | 2017-07-30 19:21:55 -0500 |
commit | 5c3a2cf16afe29d950df4b6511b2d6c999561608 (patch) | |
tree | 057e8553c44b455d89a4031784ec507465d56f93 | |
parent | 49e8f057144b0a212af380525717a96a152569bc (diff) | |
download | scummvm-rg350-5c3a2cf16afe29d950df4b6511b2d6c999561608.tar.gz scummvm-rg350-5c3a2cf16afe29d950df4b6511b2d6c999561608.tar.bz2 scummvm-rg350-5c3a2cf16afe29d950df4b6511b2d6c999561608.zip |
SCI32: Add load from launcher support for Phant2
Adding a hook into kPlayDuck to skip the intro video feels kind of
crappy, but it seemed simpler, consistent with the other hooks for
launch loading, and therefore preferable versus hot-patching the
script or messing with PC in the VM or something.
-rw-r--r-- | engines/sci/engine/guest_additions.cpp | 29 | ||||
-rw-r--r-- | engines/sci/engine/guest_additions.h | 7 | ||||
-rw-r--r-- | engines/sci/engine/kvideo.cpp | 4 | ||||
-rw-r--r-- | engines/sci/engine/selector.cpp | 2 | ||||
-rw-r--r-- | engines/sci/engine/selector.h | 2 |
5 files changed, 42 insertions, 2 deletions
diff --git a/engines/sci/engine/guest_additions.cpp b/engines/sci/engine/guest_additions.cpp index 373a1e9c13..17ae74e25a 100644 --- a/engines/sci/engine/guest_additions.cpp +++ b/engines/sci/engine/guest_additions.cpp @@ -261,12 +261,25 @@ bool GuestAdditions::kGetEventHook() const { } bool GuestAdditions::kWaitHook() const { - if (_state->_delayedRestoreGameId != -1) { + if (_state->_delayedRestoreGameId != -1 && + // kWait cannot be used in Phant2 for delayed restore because it is + // called during the fade-in of music in the intro room, before graphics + // are fully initialized, which causes "Click to continue" text to be + // brokenly drawn over the game and then crashes the engine on the next + // room transition + g_sci->getGameId() != GID_PHANTASMAGORIA2) { + return g_sci->_guestAdditions->restoreFromLauncher(); } return false; } +#ifdef ENABLE_SCI32 +bool GuestAdditions::kPlayDuckPlayHook() const { + return _state->_delayedRestoreGameId != -1; +} +#endif + #pragma mark - #pragma mark Integrated save & restore @@ -575,7 +588,19 @@ bool GuestAdditions::restoreFromLauncher() const { _restoring = true; - if (g_sci->getGameId() == GID_SHIVERS) { + // Any events queued up before the game restore can cause accidental + // input into the game if they are not flushed (this is particularly + // noticeable in Phant2, where the game will display "Click to continue" + // for one frame if the user clicked during startup) + g_sci->getEventManager()->flushEvents(); + + if (g_sci->getGameId() == GID_PHANTASMAGORIA2) { + // Phantasmagoria 2 moves the function that actually restores + // a game, and uses a property of the main game object when picking + // the save game to restore + writeSelectorValue(_segMan, g_sci->getGameObject(), SELECTOR(num), _state->_delayedRestoreGameId - kSaveIdShift); + invokeSelector(g_sci->getGameObject(), SELECTOR(reallyRestore)); + } else if (g_sci->getGameId() == GID_SHIVERS) { // Shivers accepts the save game number as a parameter to // `SHIVERS::restore` reg_t args[] = { make_reg(0, _state->_delayedRestoreGameId - kSaveIdShift) }; diff --git a/engines/sci/engine/guest_additions.h b/engines/sci/engine/guest_additions.h index eed1ee3154..cfa1139c5f 100644 --- a/engines/sci/engine/guest_additions.h +++ b/engines/sci/engine/guest_additions.h @@ -146,6 +146,13 @@ public: */ bool kWaitHook() const; +#ifdef ENABLE_SCI32 + /** + * Guest additions hook for kPlayDuck(Play). + */ + bool kPlayDuckPlayHook() const; +#endif + #pragma mark - #pragma mark Integrated save & restore diff --git a/engines/sci/engine/kvideo.cpp b/engines/sci/engine/kvideo.cpp index 37e4eeeab3..feb98f2eef 100644 --- a/engines/sci/engine/kvideo.cpp +++ b/engines/sci/engine/kvideo.cpp @@ -42,6 +42,7 @@ #include "video/qt_decoder.h" #include "sci/video/seq_decoder.h" #ifdef ENABLE_SCI32 +#include "sci/engine/guest_additions.h" #include "sci/graphics/frameout.h" #include "sci/graphics/video32.h" #include "sci/video/robot_decoder.h" @@ -484,6 +485,9 @@ reg_t kPlayDuck(EngineState *s, int argc, reg_t *argv) { } reg_t kPlayDuckPlay(EngineState *s, int argc, reg_t *argv) { + if (g_sci->_guestAdditions->kPlayDuckPlayHook()) { + return NULL_REG; + } kPlayDuckOpen(s, argc, argv); g_sci->_video32->getDuckPlayer().play(-1); g_sci->_video32->getDuckPlayer().close(); diff --git a/engines/sci/engine/selector.cpp b/engines/sci/engine/selector.cpp index e99f734272..971802affb 100644 --- a/engines/sci/engine/selector.cpp +++ b/engines/sci/engine/selector.cpp @@ -224,6 +224,8 @@ void Kernel::mapSelectors() { FIND_SELECTOR(physicalBar); FIND_SELECTOR(init); FIND_SELECTOR(scratch); + FIND_SELECTOR(num); + FIND_SELECTOR(reallyRestore); #endif } diff --git a/engines/sci/engine/selector.h b/engines/sci/engine/selector.h index d26a0d740f..e2afa74c7a 100644 --- a/engines/sci/engine/selector.h +++ b/engines/sci/engine/selector.h @@ -181,6 +181,8 @@ struct SelectorCache { Selector physicalBar; // for Phant2 volume sync Selector init; // for Phant2 save/load patching Selector scratch; // for Phant2 save/load patching + Selector num; // for Phant2 restore from launcher + Selector reallyRestore; // for Phant2 restore from launcher #endif }; |