diff options
author | Martin Kiewitz | 2016-01-31 20:53:36 +0100 |
---|---|---|
committer | Martin Kiewitz | 2016-01-31 20:53:36 +0100 |
commit | fd9c46831df3bcd09bc6f85d5e41c2beb3f7c024 (patch) | |
tree | 7e85bd08b17c976e78d628fe0da427726ba0ccf3 /engines/agi/cycle.cpp | |
parent | 9acbe6f3f42a35becf3dcff04d758b3286c05c7e (diff) | |
download | scummvm-rg350-fd9c46831df3bcd09bc6f85d5e41c2beb3f7c024.tar.gz scummvm-rg350-fd9c46831df3bcd09bc6f85d5e41c2beb3f7c024.tar.bz2 scummvm-rg350-fd9c46831df3bcd09bc6f85d5e41c2beb3f7c024.zip |
AGI: remove timer hack, implement in game timer
in game timer is now updated, when scripts read in game timer
VM variables and during main loop. ScummVM total play time feature
is used for it. Game cycle syncing is done at the same time.
Diffstat (limited to 'engines/agi/cycle.cpp')
-rw-r--r-- | engines/agi/cycle.cpp | 42 |
1 files changed, 9 insertions, 33 deletions
diff --git a/engines/agi/cycle.cpp b/engines/agi/cycle.cpp index 85a465cb02..6506ee29eb 100644 --- a/engines/agi/cycle.cpp +++ b/engines/agi/cycle.cpp @@ -173,37 +173,6 @@ void AgiEngine::interpretCycle() { //_gfx->doUpdate(); } -/** - * Update AGI interpreter timer. - */ -void AgiEngine::updateTimer() { - _clockCount++; - if (_clockCount <= TICK_SECONDS) - return; - - _clockCount -= TICK_SECONDS; - - if (!_game.clockEnabled) - return; - - setVar(VM_VAR_SECONDS, getVar(VM_VAR_SECONDS) + 1); - if (getVar(VM_VAR_SECONDS) < 60) - return; - - setVar(VM_VAR_SECONDS, 0); - setVar(VM_VAR_MINUTES, getVar(VM_VAR_MINUTES) + 1); - if (getVar(VM_VAR_MINUTES) < 60) - return; - - setVar(VM_VAR_MINUTES, 0); - setVar(VM_VAR_HOURS, getVar(VM_VAR_HOURS) + 1); - if (getVar(VM_VAR_HOURS) < 24) - return; - - setVar(VM_VAR_HOURS, 0); - setVar(VM_VAR_DAYS, getVar(VM_VAR_DAYS) + 1); -} - void AgiEngine::newInputMode(InputMode mode) { //if (mode == INPUTMODE_MENU && !getflag(VM_FLAG_MENUS_WORK) && !(getFeatures() & GF_MENUS)) // return; @@ -224,7 +193,6 @@ int AgiEngine::mainCycle(bool onlyCheckForEvents) { if (!onlyCheckForEvents) { pollTimer(); - updateTimer(); } if (_menu->delayedExecuteActive()) { @@ -402,7 +370,11 @@ int AgiEngine::playGame() { if (!mainCycle()) continue; - if (getVar(VM_VAR_TIME_DELAY) == 0 || (1 + _clockCount) % getVar(VM_VAR_TIME_DELAY) == 0) { + inGameTimerUpdate(); + + if (_passedPlayTimeCycles >= getVar(VM_VAR_TIME_DELAY)) { + _passedPlayTimeCycles = 0; + if (!_game.hasPrompt && _game.inputMode == INPUTMODE_NORMAL) { _text->promptRedraw(); _game.hasPrompt = 1; @@ -468,6 +440,10 @@ int AgiEngine::runGame() { if (_restartGame) { setFlag(VM_FLAG_RESTART_GAME, true); setVar(VM_VAR_TIME_DELAY, 2); // "normal" speed + + // Reset in-game timer + inGameTimerReset(); + _restartGame = false; } |