aboutsummaryrefslogtreecommitdiff
path: root/engines/gob/util.cpp
diff options
context:
space:
mode:
authorSven Hesse2009-02-21 15:58:50 +0000
committerSven Hesse2009-02-21 15:58:50 +0000
commite643565c2c6a6b9cae13bd338261706ffb597a0e (patch)
treeba05a293f8a72f03813b442d76165145da91aec4 /engines/gob/util.cpp
parente514d9780afa2703c6293c782e1f50712ad764fa (diff)
downloadscummvm-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/gob/util.cpp')
-rw-r--r--engines/gob/util.cpp28
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) {