[Scummvm-git-logs] scummvm master -> 638bad3bed088fca5e1a57551b08cf3a4356fb9e
eriktorbjorn
noreply at scummvm.org
Wed Mar 16 11:10:18 UTC 2022
This automated email contains information about 2 new commits which have been
pushed to the 'scummvm' repo located at https://github.com/scummvm/scummvm .
Summary:
f4c14d9b38 SCUMM: Attempt to improve timing
638bad3bed SCUMM: Make WaitForTimer() a bit more precise
Commit: f4c14d9b38557bdbc137666d07ccbb0dcfd326d4
https://github.com/scummvm/scummvm/commit/f4c14d9b38557bdbc137666d07ccbb0dcfd326d4
Author: Torbjörn Andersson (eriktorbjorn at users.sourceforge.net)
Date: 2022-03-16T12:10:11+01:00
Commit Message:
SCUMM: Attempt to improve timing
The waitForTimer() function is almost guaranteed to overshoot its
target. Keep assuming that it's exact, but factor in the difference when
timing how long scummLoop() takes.
Changed paths:
engines/scumm/scumm.cpp
diff --git a/engines/scumm/scumm.cpp b/engines/scumm/scumm.cpp
index 3dbacad8e74..62e9f248ac5 100644
--- a/engines/scumm/scumm.cpp
+++ b/engines/scumm/scumm.cpp
@@ -2445,11 +2445,14 @@ Common::Error ScummEngine::go() {
delta = 6;
}
- // Wait...
- waitForTimer(delta * 1000 / 60 - diff);
-
- // Start the stop watch!
- diff = _system->getMillis();
+ // Wait, then start the stop watch. Assume that waiting is
+ // exact, even though it's almost certain to overshoot the
+ // target. That way we factor in the difference when timing
+ // how long the main loop takes.
+ int delayMsecs = delta * 1000 / 60 - diff;
+ diff = _system->getMillis() + delayMsecs;
+
+ waitForTimer(delayMsecs);
// Run the main loop
scummLoop(delta);
Commit: 638bad3bed088fca5e1a57551b08cf3a4356fb9e
https://github.com/scummvm/scummvm/commit/638bad3bed088fca5e1a57551b08cf3a4356fb9e
Author: Torbjörn Andersson (eriktorbjorn at users.sourceforge.net)
Date: 2022-03-16T12:10:11+01:00
Commit Message:
SCUMM: Make WaitForTimer() a bit more precise
It doesn't matter for the main loop, since any overshoot is still
accounted for and they're just fewer and smaller now. But the function
is called from some other places as well.
Changed paths:
engines/scumm/scumm.cpp
diff --git a/engines/scumm/scumm.cpp b/engines/scumm/scumm.cpp
index 62e9f248ac5..0b2ee081b46 100644
--- a/engines/scumm/scumm.cpp
+++ b/engines/scumm/scumm.cpp
@@ -2445,10 +2445,11 @@ Common::Error ScummEngine::go() {
delta = 6;
}
- // Wait, then start the stop watch. Assume that waiting is
- // exact, even though it's almost certain to overshoot the
- // target. That way we factor in the difference when timing
- // how long the main loop takes.
+ // Wait and start the stop watch at the time the wait is assumed
+ // to end. There is no guarantee that the wait is that exact,
+ // but this way if it overshoots that time will count as part
+ // of the main loop.
+
int delayMsecs = delta * 1000 / 60 - diff;
diff = _system->getMillis() + delayMsecs;
@@ -2471,14 +2472,14 @@ Common::Error ScummEngine::go() {
}
void ScummEngine::waitForTimer(int msec_delay) {
- uint32 start_time;
+ uint32 end_time;
if (_fastMode & 2)
msec_delay = 0;
else if (_fastMode & 1)
msec_delay = 10;
- start_time = _system->getMillis();
+ end_time = _system->getMillis() + msec_delay;
while (!shouldQuit()) {
_sound->updateCD(); // Loop CD Audio if needed
@@ -2500,9 +2501,9 @@ void ScummEngine::waitForTimer(int msec_delay) {
_refreshDuration[_refreshArrayPos] = (int)(cur - screenUpdateTimerStart);
_refreshArrayPos = (_refreshArrayPos + 1) % ARRAYSIZE(_refreshDuration);
#endif
- if (cur >= start_time + msec_delay)
+ if (cur >= end_time)
break;
- _system->delayMillis(10);
+ _system->delayMillis(MIN<uint32>(10, end_time - cur));
}
}
More information about the Scummvm-git-logs
mailing list