diff options
author | Filippos Karapetis | 2010-06-08 18:44:27 +0000 |
---|---|---|
committer | Filippos Karapetis | 2010-06-08 18:44:27 +0000 |
commit | 67690e89a37a27ff34ab515c934edbce887fa897 (patch) | |
tree | 6f99b5d07e429de3d8da79e74ca7fd9760fa87ca /engines/sci | |
parent | 3d0ac2a676bd726a1f390b83812f8f5ac7a52d4a (diff) | |
download | scummvm-rg350-67690e89a37a27ff34ab515c934edbce887fa897.tar.gz scummvm-rg350-67690e89a37a27ff34ab515c934edbce887fa897.tar.bz2 scummvm-rg350-67690e89a37a27ff34ab515c934edbce887fa897.zip |
Merged _game_run() inside game_run(). Some cleanup
svn-id: r49513
Diffstat (limited to 'engines/sci')
-rw-r--r-- | engines/sci/engine/kevent.cpp | 4 | ||||
-rw-r--r-- | engines/sci/engine/vm.cpp | 52 | ||||
-rw-r--r-- | engines/sci/engine/vm.h | 10 |
3 files changed, 24 insertions, 42 deletions
diff --git a/engines/sci/engine/kevent.cpp b/engines/sci/engine/kevent.cpp index fd7711f196..519a4bcc8f 100644 --- a/engines/sci/engine/kevent.cpp +++ b/engines/sci/engine/kevent.cpp @@ -79,7 +79,9 @@ reg_t kGetEvent(EngineState *s, int argc, reg_t *argv) { switch (curEvent.type) { case SCI_EVENT_QUIT: - quit_vm(s); + s->script_abort_flag = 1; // Terminate VM + g_debugState.seeking = kDebugSeekNothing; + g_debugState.runningStep = 0; break; case SCI_EVENT_KEYBOARD: diff --git a/engines/sci/engine/vm.cpp b/engines/sci/engine/vm.cpp index 1dcdf450ba..9ee2db71b4 100644 --- a/engines/sci/engine/vm.cpp +++ b/engines/sci/engine/vm.cpp @@ -1687,17 +1687,31 @@ static void _init_stack_base_with_selector(EngineState *s, Selector selector) { s->stack_base[1] = NULL_REG; } -static EngineState *_game_run(EngineState *&s) { - bool restoring = false; +void game_run(EngineState **_s) { + EngineState *s = *_s; + + debugC(2, kDebugLevelVM, "Calling %s::play()", g_sci->getGameID()); + _init_stack_base_with_selector(s, g_sci->getKernel()->_selectorCache.play); // Call the play selector + + // Now: Register the first element on the execution stack + if (!send_selector(s, s->_gameObj, s->_gameObj, s->stack_base, 2, s->stack_base)) { + g_sci->getSciDebugger()->printObject(s->_gameObj); + error("Failed to run the game! Aborting..."); + return; + } + // and ENGAGE! + + // Attach the debug console on game startup, if requested if (DebugMan.isDebugChannelEnabled(kDebugLevelOnStartup)) g_sci->getSciDebugger()->attach(); do { s->_executionStackPosChanged = false; - run_vm(s, restoring); + run_vm(s, s->restoring); + if (s->restarting_flags & SCI_GAME_IS_RESTARTING_NOW) { // Restart was requested? - restoring = false; + s->restoring = false; s->_executionStack.clear(); s->_executionStackPosChanged = false; @@ -1715,8 +1729,7 @@ static EngineState *_game_run(EngineState *&s) { s->restarting_flags = SCI_GAME_WAS_RESTARTED; } else { - restoring = s->restoring; - if (restoring) { + if (s->restoring) { game_exit(s); s->restoring = false; if (s->script_abort_flag == 2) { @@ -1735,34 +1748,7 @@ static EngineState *_game_run(EngineState *&s) { } } while (true); - return s; -} - -int game_run(EngineState **_s) { - EngineState *s = *_s; - - debugC(2, kDebugLevelVM, "Calling %s::play()", g_sci->getGameID()); - _init_stack_base_with_selector(s, g_sci->getKernel()->_selectorCache.play); // Call the play selector - - // Now: Register the first element on the execution stack- - if (!send_selector(s, s->_gameObj, s->_gameObj, s->stack_base, 2, s->stack_base)) { - Console *con = g_sci->getSciDebugger(); - con->printObject(s->_gameObj); - warning("Failed to run the game! Aborting..."); - return 1; - } - // and ENGAGE! - _game_run(*_s); - debugC(2, kDebugLevelVM, "Game::play() finished."); - - return 0; -} - -void quit_vm(EngineState *s) { - s->script_abort_flag = 1; // Terminate VM - g_debugState.seeking = kDebugSeekNothing; - g_debugState.runningStep = 0; } reg_t *ObjVarRef::getPointer(SegManager *segMan) const { diff --git a/engines/sci/engine/vm.h b/engines/sci/engine/vm.h index 67a6bd0dc3..8c84587284 100644 --- a/engines/sci/engine/vm.h +++ b/engines/sci/engine/vm.h @@ -375,9 +375,8 @@ int game_init_sound(EngineState *s, int sound_flags, SciVersion soundVersion); * Note that, EngineState *s may be changed during the game, e.g. if a game * state is restored. * @param[in] s Pointer to the pointer of the state to operate on - * @return 0 on success, 1 if an error occured. - */ -int game_run(EngineState **s); + */ +void game_run(EngineState **s); /** * Restores an SCI game state and runs the game @@ -398,11 +397,6 @@ int game_restore(EngineState **s, char *savegame_name); int game_exit(EngineState *s); /** - * Instructs the virtual machine to abort - */ -void quit_vm(EngineState *s); - -/** * Read a PMachine instruction from a memory buffer and return its length. * * @param[in] src address from which to start parsing |