diff options
author | Sven Hesse | 2009-02-21 15:58:50 +0000 |
---|---|---|
committer | Sven Hesse | 2009-02-21 15:58:50 +0000 |
commit | e643565c2c6a6b9cae13bd338261706ffb597a0e (patch) | |
tree | ba05a293f8a72f03813b442d76165145da91aec4 /engines | |
parent | e514d9780afa2703c6293c782e1f50712ad764fa (diff) | |
download | scummvm-rg350-e643565c2c6a6b9cae13bd338261706ffb597a0e.tar.gz scummvm-rg350-e643565c2c6a6b9cae13bd338261706ffb597a0e.tar.bz2 scummvm-rg350-e643565c2c6a6b9cae13bd338261706ffb597a0e.zip |
Compensate small lags in Util::waitEndFrame(), so that the CD audio intro sequences in Gob1 and Gob2 CD hopefully won't de-sync so easily
svn-id: r38702
Diffstat (limited to 'engines')
-rw-r--r-- | engines/gob/global.cpp | 3 | ||||
-rw-r--r-- | engines/gob/global.h | 3 | ||||
-rw-r--r-- | engines/gob/gob.cpp | 1 | ||||
-rw-r--r-- | engines/gob/util.cpp | 28 | ||||
-rw-r--r-- | engines/gob/util.h | 5 |
5 files changed, 27 insertions, 13 deletions
diff --git a/engines/gob/global.cpp b/engines/gob/global.cpp index acca5564dd..8283552f2c 100644 --- a/engines/gob/global.cpp +++ b/engines/gob/global.cpp @@ -41,9 +41,6 @@ Global::Global(GobEngine *vm) : _vm(vm) { _fakeVideoMode = 0; _oldMode = 3; - _frameWaitTime = 0; - _startFrameTime = 0; - _soundFlags = 0; _language = 0x8000; diff --git a/engines/gob/global.h b/engines/gob/global.h index 32651cf15d..5c63f2b68a 100644 --- a/engines/gob/global.h +++ b/engines/gob/global.h @@ -78,9 +78,6 @@ public: int16 _fakeVideoMode; int16 _oldMode; - int16 _frameWaitTime; - int32 _startFrameTime; - uint16 _soundFlags; uint16 _language; diff --git a/engines/gob/gob.cpp b/engines/gob/gob.cpp index ced85357a3..dc11d29f55 100644 --- a/engines/gob/gob.cpp +++ b/engines/gob/gob.cpp @@ -265,6 +265,7 @@ void GobEngine::pauseEngineIntern(bool pause) { uint32 duration = _system->getMillis() - _pauseStart; _vm->_vidPlayer->notifyPaused(duration); + _vm->_util->notifyPaused(duration); _vm->_game->_startTimeKey += duration; _vm->_draw->_cursorTimeKey += duration; 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) { diff --git a/engines/gob/util.h b/engines/gob/util.h index 926338e271..19b11801bc 100644 --- a/engines/gob/util.h +++ b/engines/gob/util.h @@ -54,6 +54,8 @@ public: int16 getRandom(int16 max); void beep(int16 freq); + void notifyPaused(uint32 duration); + void delay(uint16 msecs); void longDelay(uint16 msecs); @@ -99,6 +101,9 @@ protected: uint8 _fastMode; int16 _frameRate; + int16 _frameWaitTime; + uint32 _startFrameTime; + int32 _frameWaitLag; GobEngine *_vm; |