diff options
Diffstat (limited to 'engines/gob/util.cpp')
-rw-r--r-- | engines/gob/util.cpp | 28 |
1 files changed, 21 insertions, 7 deletions
diff --git a/engines/gob/util.cpp b/engines/gob/util.cpp index 58430f0d41..2916caa340 100644 --- a/engines/gob/util.cpp +++ b/engines/gob/util.cpp @@ -43,6 +43,9 @@ Util::Util(GobEngine *vm) : _vm(vm) { _keyBufferTail = 0; _fastMode = 0; _frameRate = 12; + _frameWaitTime = 0; + _startFrameTime = 0; + _frameWaitLag = 0; } uint32 Util::getTimeKey(void) { @@ -63,6 +66,10 @@ void Util::beep(int16 freq) { _vm->_sound->speakerOn(freq, 50); } +void Util::notifyPaused(uint32 duration) { + _startFrameTime += duration; +} + void Util::delay(uint16 msecs) { g_system->delayMillis(msecs / _vm->_global->_speedFactor); } @@ -309,8 +316,8 @@ void Util::setFrameRate(int16 rate) { rate = 1; _frameRate = rate; - _vm->_global->_frameWaitTime = 1000 / rate; - _vm->_global->_startFrameTime = getTimeKey(); + _frameWaitTime = 1000 / rate; + _startFrameTime = getTimeKey(); } void Util::waitEndFrame() { @@ -318,16 +325,23 @@ void Util::waitEndFrame() { _vm->_video->waitRetrace(); - time = getTimeKey() - _vm->_global->_startFrameTime; + time = getTimeKey() - _startFrameTime; if ((time > 1000) || (time < 0)) { - _vm->_global->_startFrameTime = getTimeKey(); + _startFrameTime = getTimeKey(); return; } - if ((_vm->_global->_frameWaitTime - time) > 0) - delay(_vm->_global->_frameWaitTime - time); + int32 waitTime = _frameWaitTime - _frameWaitLag; + int32 toWait = waitTime - time; + + if (toWait > 0) + delay(toWait); + + int32 now = getTimeKey(); + + _frameWaitLag = (now - _startFrameTime) - waitTime; - _vm->_global->_startFrameTime = getTimeKey(); + _startFrameTime = now; } void Util::setScrollOffset(int16 x, int16 y) { |