aboutsummaryrefslogtreecommitdiff
path: root/engines
diff options
context:
space:
mode:
authorStrangerke2019-08-24 20:03:44 +0200
committerEugene Sandulenko2019-09-03 17:17:35 +0200
commit83d3af60091263d78df05121d67c8945fca76a5a (patch)
tree9f0b617b136277aed604ee1d4202c67b6c63504d /engines
parent4d186571d543a9e52afc62920ac00b7ebe5a35bd (diff)
downloadscummvm-rg350-83d3af60091263d78df05121d67c8945fca76a5a.tar.gz
scummvm-rg350-83d3af60091263d78df05121d67c8945fca76a5a.tar.bz2
scummvm-rg350-83d3af60091263d78df05121d67c8945fca76a5a.zip
HDB: Make the frame delay variable in order to have a more stable frame rate
Diffstat (limited to 'engines')
-rw-r--r--engines/hdb/hdb.cpp17
1 files changed, 12 insertions, 5 deletions
diff --git a/engines/hdb/hdb.cpp b/engines/hdb/hdb.cpp
index 1a8c81160d..62e2ec8d67 100644
--- a/engines/hdb/hdb.cpp
+++ b/engines/hdb/hdb.cpp
@@ -803,14 +803,12 @@ void HDBGame::drawProgressBar() {
}
void HDBGame::checkProgress() {
- int x, i;
-
if (!_progressActive)
return;
- x = _screenWidth / 2 - _progressGfx->_width / 2;
+ int x = _screenWidth / 2 - _progressGfx->_width / 2;
_progressGfx->drawMasked(x, g_hdb->_progressY);
- for (i = x; i < _progressXOffset; i += _progressMarkGfx->_width)
+ for (int i = x; i < _progressXOffset; i += _progressMarkGfx->_width)
_progressMarkGfx->drawMasked(i, g_hdb->_progressY);
_progressMarkGfx->drawMasked(_progressXOffset, g_hdb->_progressY);
}
@@ -943,6 +941,7 @@ Common::Error HDBGame::run() {
lua->executeFile("test.lua");
#endif
+ uint32 lastTime = g_system->getMillis();
while (!shouldQuit()) {
Common::Event event;
while (g_system->getEventManager()->pollEvent(event)) {
@@ -1053,7 +1052,15 @@ Common::Error HDBGame::run() {
while (g_hdb->_frames[0] < g_system->getMillis() - 1000)
g_hdb->_frames.remove_at(0);
}
- g_system->delayMillis(1000 / kGameFPS);
+ uint32 curTime = g_system->getMillis();
+ uint32 frameTime = curTime - lastTime;
+
+ uint32 frameCap = 1000 / kGameFPS;
+ if (frameTime < frameCap) {
+ g_system->delayMillis(frameCap - frameTime);
+ }
+
+ lastTime = g_system->getMillis();
}
return Common::kNoError;