diff options
Diffstat (limited to 'engines')
-rw-r--r-- | engines/composer/composer.cpp | 17 | ||||
-rw-r--r-- | engines/composer/composer.h | 2 | ||||
-rw-r--r-- | engines/composer/scripting.cpp | 4 |
3 files changed, 19 insertions, 4 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); } diff --git a/engines/composer/composer.h b/engines/composer/composer.h index c0d456daaa..03e895b59e 100644 --- a/engines/composer/composer.h +++ b/engines/composer/composer.h @@ -140,6 +140,8 @@ private: Audio::QueuingAudioStream *_audioStream; uint16 _currSoundPriority; + uint32 _currentTime, _lastTime; + bool _needsUpdate; Common::Array<Common::Rect> _dirtyRects; Graphics::Surface _surface; diff --git a/engines/composer/scripting.cpp b/engines/composer/scripting.cpp index d85bd524e0..83b6336889 100644 --- a/engines/composer/scripting.cpp +++ b/engines/composer/scripting.cpp @@ -531,7 +531,7 @@ int16 ComposerEngine::scriptFuncCall(uint16 id, int16 param1, int16 param2, int1 return 0; case kFuncQueueScript: debug(3, "kFuncQueueScript(%d, %d, %d)", param1, param2, param3); - _queuedScripts[param1]._baseTime = _system->getMillis(); + _queuedScripts[param1]._baseTime = _currentTime; _queuedScripts[param1]._duration = 10 * param2; _queuedScripts[param1]._count = 0xffffffff; _queuedScripts[param1]._scriptId = param3; @@ -642,7 +642,7 @@ int16 ComposerEngine::scriptFuncCall(uint16 id, int16 param1, int16 param2, int1 return 1; case kFuncQueueScriptOnce: debug(3, "kFuncQueueScriptOnce(%d, %d, %d)", param1, param2, param3); - _queuedScripts[param1]._baseTime = _system->getMillis(); + _queuedScripts[param1]._baseTime = _currentTime; _queuedScripts[param1]._duration = 10 * param2; _queuedScripts[param1]._count = 1; _queuedScripts[param1]._scriptId = param3; |