diff options
-rw-r--r-- | engines/toon/toon.cpp | 10 | ||||
-rw-r--r-- | engines/toon/toon.h | 1 |
2 files changed, 11 insertions, 0 deletions
diff --git a/engines/toon/toon.cpp b/engines/toon/toon.cpp index eb4120123d..a9b0d7aa5e 100644 --- a/engines/toon/toon.cpp +++ b/engines/toon/toon.cpp @@ -160,6 +160,7 @@ void ToonEngine::init() { _lastMouseButton = 0; _mouseButton = 0; + _lastRenderTime = _system->getMillis(); } void ToonEngine::waitForScriptStep() { @@ -417,6 +418,15 @@ void ToonEngine::render() { } else { copyToVirtualScreen(true); } + + // add a little sleep here if needed. + int32 newMillis = (int32)_system->getMillis(); + if(newMillis - _lastRenderTime < _tickLength) { + int32 sleepMs = _tickLength - ( _system->getMillis() - _lastRenderTime ); + assert(sleepMs >= 0); + _system->delayMillis(sleepMs); + } + _lastRenderTime = _system->getMillis(); } void ToonEngine::doMagnifierEffect() { diff --git a/engines/toon/toon.h b/engines/toon/toon.h index c16336722d..0627674cd6 100644 --- a/engines/toon/toon.h +++ b/engines/toon/toon.h @@ -407,6 +407,7 @@ protected: int32 _oldTimer; int32 _oldTimer2; + int32 _lastRenderTime; Movie *_moviePlayer; |