aboutsummaryrefslogtreecommitdiff
path: root/engines/composer/composer.cpp
diff options
context:
space:
mode:
authorAlyssa Milburn2011-08-23 23:13:18 +0200
committerAlyssa Milburn2011-08-23 23:13:18 +0200
commitfca52e05148f350ee31f9921f260404fad03152d (patch)
treed0ad7eb1821caa53a4e9a6917e5e97dc3793193a /engines/composer/composer.cpp
parentb777a2f7b98bbccc5c723f5c40cb64e03f1bbba4 (diff)
downloadscummvm-rg350-fca52e05148f350ee31f9921f260404fad03152d.tar.gz
scummvm-rg350-fca52e05148f350ee31f9921f260404fad03152d.tar.bz2
scummvm-rg350-fca52e05148f350ee31f9921f260404fad03152d.zip
COMPOSER: Another attempt to fix timing issues.
Diffstat (limited to 'engines/composer/composer.cpp')
-rw-r--r--engines/composer/composer.cpp17
1 files changed, 15 insertions, 2 deletions
diff --git a/engines/composer/composer.cpp b/engines/composer/composer.cpp
index c31111aec2..45ca714d8a 100644
--- a/engines/composer/composer.cpp
+++ b/engines/composer/composer.cpp
@@ -97,9 +97,13 @@ Common::Error ComposerEngine::run() {
loadLibrary(0);
+ _currentTime = 0;
+ _lastTime = 0;
+
uint fps = atoi(getStringFromConfig("Common", "FPS").c_str());
uint frameTime = 1000 / fps;
uint32 lastDrawTime = 0;
+
while (!shouldQuit()) {
for (uint i = 0; i < _pendingPageChanges.size(); i++) {
if (_pendingPageChanges[i]._remove)
@@ -112,15 +116,24 @@ Common::Error ComposerEngine::run() {
_pendingPageChanges.clear();
uint32 thisTime = _system->getMillis();
+ // maintain our own internal timing, since otherwise we get
+ // confused when starved of CPU (for example when the user
+ // is dragging the scummvm window around)
+ if (thisTime > _lastTime + frameTime)
+ _currentTime += frameTime;
+ else
+ _currentTime += thisTime - _lastTime;
+ _lastTime = thisTime;
+
for (uint i = 0; i < _queuedScripts.size(); i++) {
QueuedScript &script = _queuedScripts[i];
if (!script._count)
continue;
- if (script._baseTime + script._duration > thisTime)
+ if (script._baseTime + script._duration > _currentTime)
continue;
if (script._count != 0xffffffff)
script._count--;
- script._baseTime = thisTime;
+ script._baseTime = _currentTime;
runScript(script._scriptId, i, 0, 0);
}