diff options
author | Sylvain Dupont | 2011-02-05 12:11:57 +0000 |
---|---|---|
committer | Sylvain Dupont | 2011-02-05 12:11:57 +0000 |
commit | 58884b1244e2ff88aeeec4d5f281c56ec9ba3139 (patch) | |
tree | c3d29f3e6b8cf856ce51e4182a2ec0ad8e9e4c3f /engines | |
parent | 47dbd520bb6bfe92fb05566b08a77a3e77eb7554 (diff) | |
download | scummvm-rg350-58884b1244e2ff88aeeec4d5f281c56ec9ba3139.tar.gz scummvm-rg350-58884b1244e2ff88aeeec4d5f281c56ec9ba3139.tar.bz2 scummvm-rg350-58884b1244e2ff88aeeec4d5f281c56ec9ba3139.zip |
TOON: Add some sleep if the game refreshes too fast
Prevents the game from using 100% CPU?
svn-id: r55786
Diffstat (limited to 'engines')
-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; |