[Scummvm-git-logs] scummvm master -> 8a1bca083156ecb84bb0f1ec32bf0e94d31a5834
AndywinXp
noreply at scummvm.org
Wed Jun 18 08:33:04 UTC 2025
This automated email contains information about 1 new commit which have been
pushed to the 'scummvm' repo located at https://api.github.com/repos/scummvm/scummvm .
Summary:
8a1bca0831 LASTEXPRESS: Improve frame pacing and CPU usage
Commit: 8a1bca083156ecb84bb0f1ec32bf0e94d31a5834
https://github.com/scummvm/scummvm/commit/8a1bca083156ecb84bb0f1ec32bf0e94d31a5834
Author: AndywinXp (andywinxp at gmail.com)
Date: 2025-06-18T10:32:56+02:00
Commit Message:
LASTEXPRESS: Improve frame pacing and CPU usage
Changed paths:
engines/lastexpress/fight/fight.cpp
engines/lastexpress/game/credits.cpp
engines/lastexpress/game/nis.cpp
engines/lastexpress/lastexpress.cpp
engines/lastexpress/lastexpress.h
diff --git a/engines/lastexpress/fight/fight.cpp b/engines/lastexpress/fight/fight.cpp
index 84929b1faac..a7a8d44773e 100644
--- a/engines/lastexpress/fight/fight.cpp
+++ b/engines/lastexpress/fight/fight.cpp
@@ -210,7 +210,7 @@ int CFight::process() {
while (_fightIsHappening) {
_engine->getMessageManager()->process();
_engine->getSoundManager()->soundThread();
- _engine->handleEvents();
+ _engine->waitForTimer(5);
}
return _outcome;
diff --git a/engines/lastexpress/game/credits.cpp b/engines/lastexpress/game/credits.cpp
index eb32719433e..f941f531034 100644
--- a/engines/lastexpress/game/credits.cpp
+++ b/engines/lastexpress/game/credits.cpp
@@ -93,9 +93,10 @@ void LastExpressEngine::doCredits() {
do {
getSoundManager()->soundThread();
- handleEvents();
} while (getMessageManager()->process());
+ waitForTimer(5);
+
setEventTickInternal(false);
_savedFrameInterval = getSoundFrameCounter();
@@ -104,9 +105,10 @@ void LastExpressEngine::doCredits() {
while (_doCredits) {
do {
getSoundManager()->soundThread();
- handleEvents();
} while (_doCredits && getMessageManager()->process());
+ waitForTimer(5);
+
if (!_savedFrameCounter) {
// Handle the background map transition
if (_doCredits == 1) {
@@ -531,7 +533,7 @@ bool LastExpressEngine::demoEnding(bool wonGame) {
getMessageManager()->process();
getSoundManager()->soundThread();
getSubtitleManager()->subThread();
- handleEvents();
+ waitForTimer(5);
}
}
diff --git a/engines/lastexpress/game/nis.cpp b/engines/lastexpress/game/nis.cpp
index d1e39ca5fce..06d9882e9e6 100644
--- a/engines/lastexpress/game/nis.cpp
+++ b/engines/lastexpress/game/nis.cpp
@@ -615,7 +615,7 @@ bool NISManager::doNIS(const char *name, int32 flags) {
_engine->getSoundManager()->soundThread();
_engine->getSubtitleManager()->subThread();
_engine->getMessageManager()->process();
- _engine->handleEvents();
+ _engine->waitForTimer(5);
for (slot = _engine->getSoundManager()->_soundCache; slot; slot = slot->getNext()) {
if (slot->hasTag(kSoundTagNIS))
@@ -642,7 +642,7 @@ bool NISManager::doNIS(const char *name, int32 flags) {
if (!_engine->getMessageManager()->process())
break;
- _engine->handleEvents();
+ _engine->waitForTimer(5);
_engine->getSubtitleManager()->subThread();
_engine->getSoundManager()->soundThread();
diff --git a/engines/lastexpress/lastexpress.cpp b/engines/lastexpress/lastexpress.cpp
index d6323ebd77f..2b67e039e09 100644
--- a/engines/lastexpress/lastexpress.cpp
+++ b/engines/lastexpress/lastexpress.cpp
@@ -219,7 +219,11 @@ Common::Error LastExpressEngine::run() {
getSubtitleManager()->subThread();
} while (getMessageManager()->process());
- waitForTimer(4); // Wait 4 ticks (tick duration: 17 ms dictated by the sound timer)
+ // Originally the game waited for at most four frames (17 * 4 ms).
+ // Since the game relies on the sound timer for actual engine pacing,
+ // we can reduce the time to 5 milliseconds of wait time, fetching
+ // input in the meanwhile, making the cursor a lot smoother.
+ waitForTimer(5);
}
bool haveEvent = true;
@@ -441,15 +445,9 @@ bool LastExpressEngine::mouseHasRightClicked() {
return _mouseHasRightClicked;
}
-void LastExpressEngine::waitForTimer(int frames) {
- uint32 startTime = _system->getMillis();
- uint32 waitTime = 17;
-
- for (int i = 0; i < frames; i++) {
- while (_system->getMillis() - startTime < waitTime) {
- handleEvents();
- }
- }
+void LastExpressEngine::waitForTimer(int millis) {
+ handleEvents();
+ _system->delayMillis(millis);
}
bool LastExpressEngine::handleEvents() {
diff --git a/engines/lastexpress/lastexpress.h b/engines/lastexpress/lastexpress.h
index eddc546001d..ffcd128e7c0 100644
--- a/engines/lastexpress/lastexpress.h
+++ b/engines/lastexpress/lastexpress.h
@@ -636,7 +636,7 @@ public:
void startUp();
void shutDown();
- void waitForTimer(int frames);
+ void waitForTimer(int millis);
void initGameData();
void startNewGame();
void engineEventHandler(Event *event);
More information about the Scummvm-git-logs
mailing list