diff options
author | Strangerke | 2019-08-24 20:03:44 +0200 |
---|---|---|
committer | Eugene Sandulenko | 2019-09-03 17:17:35 +0200 |
commit | 83d3af60091263d78df05121d67c8945fca76a5a (patch) | |
tree | 9f0b617b136277aed604ee1d4202c67b6c63504d /engines/hdb/hdb.cpp | |
parent | 4d186571d543a9e52afc62920ac00b7ebe5a35bd (diff) | |
download | scummvm-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/hdb/hdb.cpp')
-rw-r--r-- | engines/hdb/hdb.cpp | 17 |
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; |