diff options
author | Paul Gilbert | 2011-07-16 22:28:49 +1000 |
---|---|---|
committer | Paul Gilbert | 2011-07-16 22:28:49 +1000 |
commit | e1df646ace3f0b487ef810a5489c3f0c2090da71 (patch) | |
tree | cf52ac9f95e7b4e1adcd1fd9903da92c60e40013 | |
parent | 00061bc5dd6492fcb3be9781b134f1928f69205b (diff) | |
download | scummvm-rg350-e1df646ace3f0b487ef810a5489c3f0c2090da71.tar.gz scummvm-rg350-e1df646ace3f0b487ef810a5489c3f0c2090da71.tar.bz2 scummvm-rg350-e1df646ace3f0b487ef810a5489c3f0c2090da71.zip |
CGE: Set up a separate variable for the game tick speed, independent from frame rate
-rw-r--r-- | engines/cge/cge.cpp | 1 | ||||
-rw-r--r-- | engines/cge/cge.h | 3 | ||||
-rw-r--r-- | engines/cge/cge_main.cpp | 25 |
3 files changed, 23 insertions, 6 deletions
diff --git a/engines/cge/cge.cpp b/engines/cge/cge.cpp index bb5b786330..97712591fa 100644 --- a/engines/cge/cge.cpp +++ b/engines/cge/cge.cpp @@ -58,6 +58,7 @@ CGEEngine::CGEEngine(OSystem *syst, const ADGameDescription *gameDescription) void CGEEngine::setup() { // Initialise fields _lastFrame = 0; + _lastTick = 0; _hero = NULL; _shadow = NULL; _miniCave = NULL; diff --git a/engines/cge/cge.h b/engines/cge/cge.h index 851a1166ab..5187e57c0f 100644 --- a/engines/cge/cge.h +++ b/engines/cge/cge.h @@ -74,7 +74,7 @@ extern const char *SAVEGAME_STR; class CGEEngine : public Engine { private: - uint32 _lastFrame; + uint32 _lastFrame, _lastTick; void tick(); void syncHeader(Common::Serializer &s); static void writeSavegameHeader(Common::OutSaveFile *out, SavegameHeader &header); @@ -156,6 +156,7 @@ public: void setIRQ(); void setDMA(); void mainLoop(); + void handleFrame(); void saveGame(int slotNumber, const Common::String &desc); static bool readSavegameHeader(Common::InSaveFile *in, SavegameHeader &header); void switchMusic(); diff --git a/engines/cge/cge_main.cpp b/engines/cge/cge_main.cpp index f3b2784ca6..ad31a5c1e6 100644 --- a/engines/cge/cge_main.cpp +++ b/engines/cge/cge_main.cpp @@ -1411,6 +1411,7 @@ void CGEEngine::loadScript(const char *fname) { } #define GAME_FRAME_DELAY (1000 / 50) +#define GAME_TICK_DELAY (1000 / 62) void CGEEngine::mainLoop() { sayDebug(); @@ -1432,23 +1433,37 @@ void CGEEngine::mainLoop() { _snail_->runCom(); _snail->runCom(); + // Handle a delay between game frames + handleFrame(); + + // Handle any pending events + _eventManager->poll(); +} + +void CGEEngine::handleFrame() { // Game frame delay uint32 millis = g_system->getMillis(); while (!_eventManager->_quitFlag && (millis < (_lastFrame + GAME_FRAME_DELAY))) { // Handle any pending events _eventManager->poll(); + if (millis >= (_lastTick + GAME_TICK_DELAY)) { + // Dispatch the tick to any active objects + tick(); + _lastTick = millis; + } + // Slight delay g_system->delayMillis(10); millis = g_system->getMillis(); } _lastFrame = millis; - // Dispatch the tick to any active objects - tick(); - - // Handle any pending events - _eventManager->poll(); + if (millis >= (_lastTick + GAME_TICK_DELAY)) { + // Dispatch the tick to any active objects + tick(); + _lastTick = millis; + } } void CGEEngine::tick() { |