aboutsummaryrefslogtreecommitdiff
path: root/engines/toltecs/script.cpp
diff options
context:
space:
mode:
authorTorbjörn Andersson2011-11-20 23:37:25 +0100
committerTorbjörn Andersson2011-11-20 23:45:29 +0100
commit9f5f240e904374a47f85c08899955376f18474f6 (patch)
tree53e1d2ec029c3b093c3caa25b32546d409c37721 /engines/toltecs/script.cpp
parentbc4397bf3ebc1285a1109401224d71dd140fcf2e (diff)
downloadscummvm-rg350-9f5f240e904374a47f85c08899955376f18474f6.tar.gz
scummvm-rg350-9f5f240e904374a47f85c08899955376f18474f6.tar.bz2
scummvm-rg350-9f5f240e904374a47f85c08899955376f18474f6.zip
TOLTECS: Change the updateScreen() logic a bit
Updating the screen when getMillis() % 10 is 0 seems sub-optimal to me. It could be true several iterations in a row (shouldn't be harmful, since updateScreen is assumed to be cheap if the screen hasn't changed) or we could miss it every single time. Let's measure the time between updates instead, just to be safer.
Diffstat (limited to 'engines/toltecs/script.cpp')
-rw-r--r--engines/toltecs/script.cpp9
1 files changed, 7 insertions, 2 deletions
diff --git a/engines/toltecs/script.cpp b/engines/toltecs/script.cpp
index 708afb7008..959db8b277 100644
--- a/engines/toltecs/script.cpp
+++ b/engines/toltecs/script.cpp
@@ -183,6 +183,7 @@ void ScriptInterpreter::setMainScript(uint slotIndex) {
}
void ScriptInterpreter::runScript() {
+ uint32 lastScreenUpdate = 0;
while (!_vm->shouldQuit()) {
@@ -217,9 +218,13 @@ void ScriptInterpreter::runScript() {
byte opcode = readByte();
execOpcode(opcode);
- // Call updateScreen roughly every 10ms else the mouse cursor will be jerky
- if (_vm->_system->getMillis() % 10 == 0)
+ // Update the screen at semi-regular intervals, else the mouse
+ // cursor will be jerky.
+ uint32 now = _vm->_system->getMillis();
+ if (now < lastScreenUpdate || now - lastScreenUpdate > 10) {
_vm->_system->updateScreen();
+ lastScreenUpdate = _vm->_system->getMillis();
+ }
}