[Scummvm-cvs-logs] SF.net SVN: scummvm:[38702] scummvm/trunk/engines/gob

drmccoy at users.sourceforge.net drmccoy at users.sourceforge.net
Sat Feb 21 16:58:51 CET 2009


Revision: 38702
          http://scummvm.svn.sourceforge.net/scummvm/?rev=38702&view=rev
Author:   drmccoy
Date:     2009-02-21 15:58:50 +0000 (Sat, 21 Feb 2009)

Log Message:
-----------
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

Modified Paths:
--------------
    scummvm/trunk/engines/gob/global.cpp
    scummvm/trunk/engines/gob/global.h
    scummvm/trunk/engines/gob/gob.cpp
    scummvm/trunk/engines/gob/util.cpp
    scummvm/trunk/engines/gob/util.h

Modified: scummvm/trunk/engines/gob/global.cpp
===================================================================
--- scummvm/trunk/engines/gob/global.cpp	2009-02-21 15:40:14 UTC (rev 38701)
+++ scummvm/trunk/engines/gob/global.cpp	2009-02-21 15:58:50 UTC (rev 38702)
@@ -41,9 +41,6 @@
 	_fakeVideoMode = 0;
 	_oldMode = 3;
 
-	_frameWaitTime = 0;
-	_startFrameTime = 0;
-
 	_soundFlags = 0;
 
 	_language = 0x8000;

Modified: scummvm/trunk/engines/gob/global.h
===================================================================
--- scummvm/trunk/engines/gob/global.h	2009-02-21 15:40:14 UTC (rev 38701)
+++ scummvm/trunk/engines/gob/global.h	2009-02-21 15:58:50 UTC (rev 38702)
@@ -78,9 +78,6 @@
 	int16 _fakeVideoMode;
 	int16 _oldMode;
 
-	int16 _frameWaitTime;
-	int32 _startFrameTime;
-
 	uint16 _soundFlags;
 
 	uint16 _language;

Modified: scummvm/trunk/engines/gob/gob.cpp
===================================================================
--- scummvm/trunk/engines/gob/gob.cpp	2009-02-21 15:40:14 UTC (rev 38701)
+++ scummvm/trunk/engines/gob/gob.cpp	2009-02-21 15:58:50 UTC (rev 38702)
@@ -265,6 +265,7 @@
 		uint32 duration = _system->getMillis() - _pauseStart;
 
 		_vm->_vidPlayer->notifyPaused(duration);
+		_vm->_util->notifyPaused(duration);
 
 		_vm->_game->_startTimeKey += duration;
 		_vm->_draw->_cursorTimeKey += duration;

Modified: scummvm/trunk/engines/gob/util.cpp
===================================================================
--- scummvm/trunk/engines/gob/util.cpp	2009-02-21 15:40:14 UTC (rev 38701)
+++ scummvm/trunk/engines/gob/util.cpp	2009-02-21 15:58:50 UTC (rev 38702)
@@ -43,6 +43,9 @@
 	_keyBufferTail = 0;
 	_fastMode = 0;
 	_frameRate = 12;
+	_frameWaitTime = 0;
+	_startFrameTime = 0;
+	_frameWaitLag = 0;
 }
 
 uint32 Util::getTimeKey(void) {
@@ -63,6 +66,10 @@
 	_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 @@
 		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 @@
 
 	_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;
 
-	_vm->_global->_startFrameTime = getTimeKey();
+	if (toWait > 0)
+		delay(toWait);
+
+	int32 now = getTimeKey();
+
+	_frameWaitLag = (now - _startFrameTime) - waitTime;
+
+	_startFrameTime = now;
 }
 
 void Util::setScrollOffset(int16 x, int16 y) {

Modified: scummvm/trunk/engines/gob/util.h
===================================================================
--- scummvm/trunk/engines/gob/util.h	2009-02-21 15:40:14 UTC (rev 38701)
+++ scummvm/trunk/engines/gob/util.h	2009-02-21 15:58:50 UTC (rev 38702)
@@ -54,6 +54,8 @@
 	int16 getRandom(int16 max);
 	void beep(int16 freq);
 
+	void notifyPaused(uint32 duration);
+
 	void delay(uint16 msecs);
 	void longDelay(uint16 msecs);
 
@@ -99,6 +101,9 @@
 	uint8 _fastMode;
 
 	int16 _frameRate;
+	int16 _frameWaitTime;
+	uint32 _startFrameTime;
+	int32 _frameWaitLag;
 
 	GobEngine *_vm;
 


This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.




More information about the Scummvm-git-logs mailing list