From cfdbfaa28eb29cb17185d3d3d1ddde8c89a369c1 Mon Sep 17 00:00:00 2001 From: Filippos Karapetis Date: Mon, 14 Jun 2010 08:36:52 +0000 Subject: SCI: Limit the screen refresh rate to 60fps svn-id: r49647 --- engines/sci/engine/savegame.cpp | 1 + engines/sci/engine/state.h | 1 + engines/sci/event.cpp | 10 ++++++++-- engines/sci/sci.cpp | 2 +- 4 files changed, 11 insertions(+), 3 deletions(-) diff --git a/engines/sci/engine/savegame.cpp b/engines/sci/engine/savegame.cpp index 8c743189d7..a7310d2b6a 100644 --- a/engines/sci/engine/savegame.cpp +++ b/engines/sci/engine/savegame.cpp @@ -877,6 +877,7 @@ void gamestate_restore(EngineState *s, Common::SeekableReadStream *fh) { // Time state: s->lastWaitTime = g_system->getMillis(); s->gameStartTime = g_system->getMillis(); + s->_screenUpdateTime = g_system->getMillis(); #ifdef USE_OLD_MUSIC_FUNCTIONS s->_sound._it = NULL; diff --git a/engines/sci/engine/state.h b/engines/sci/engine/state.h index 1b1a1fa86c..b47b739007 100644 --- a/engines/sci/engine/state.h +++ b/engines/sci/engine/state.h @@ -113,6 +113,7 @@ public: uint32 gameStartTime; /**< The time at which the interpreter was started */ uint32 lastWaitTime; /**< The last time the game invoked Wait() */ + uint32 _screenUpdateTime; /**< The last time the game updated the screen */ void wait(int16 ticks); diff --git a/engines/sci/event.cpp b/engines/sci/event.cpp index cdddb26ca4..ed9c4bfd0d 100644 --- a/engines/sci/event.cpp +++ b/engines/sci/event.cpp @@ -319,8 +319,14 @@ sciEvent EventManager::get(unsigned int mask) { //sci_event_t error_event = { SCI_EVT_ERROR, 0, 0, 0 }; sciEvent event = { 0, 0, 0, 0 }; - // Update the screen here, since it's called very often - g_system->updateScreen(); + // Update the screen here, since it's called very often. + // Throttle the screen update rate to 60fps. + uint32 curTime = g_system->getMillis(); + uint32 duration = curTime - g_sci->getEngineState()->_screenUpdateTime; + if (duration >= 1000 / 60) { + g_system->updateScreen(); + g_sci->getEngineState()->_screenUpdateTime = g_system->getMillis(); + } // Get all queued events from graphics driver do { diff --git a/engines/sci/sci.cpp b/engines/sci/sci.cpp index 9e928b82d9..ee2f5845a2 100644 --- a/engines/sci/sci.cpp +++ b/engines/sci/sci.cpp @@ -325,7 +325,7 @@ bool SciEngine::initGame() { _vocabulary->parser_base = make_reg(_gamestate->_segMan->getSysStringsSegment(), SYS_STRING_PARSER_BASE); } - _gamestate->gameStartTime = _gamestate->lastWaitTime = g_system->getMillis(); + _gamestate->gameStartTime = _gamestate->lastWaitTime = _gamestate->_screenUpdateTime = g_system->getMillis(); srand(g_system->getMillis()); // Initialize random number generator -- cgit v1.2.3