diff options
author | Kari Salminen | 2008-08-07 21:46:56 +0000 |
---|---|---|
committer | Kari Salminen | 2008-08-07 21:46:56 +0000 |
commit | 092d7224b95d611414c2940bf48b095ade6dcf40 (patch) | |
tree | 434d67c2baf580e6d357d7a3e4aec56502b5d08c /engines | |
parent | da84a546943bd28615ccc6e4999e697c855e58d6 (diff) | |
download | scummvm-rg350-092d7224b95d611414c2940bf48b095ade6dcf40.tar.gz scummvm-rg350-092d7224b95d611414c2940bf48b095ade6dcf40.tar.bz2 scummvm-rg350-092d7224b95d611414c2940bf48b095ade6dcf40.zip |
Implemented game speed changing by pressing - or + to e.g. ease testing.
svn-id: r33689
Diffstat (limited to 'engines')
-rw-r--r-- | engines/cine/cine.cpp | 14 | ||||
-rw-r--r-- | engines/cine/cine.h | 3 | ||||
-rw-r--r-- | engines/cine/main_loop.cpp | 10 | ||||
-rw-r--r-- | engines/cine/main_loop.h | 5 |
4 files changed, 26 insertions, 6 deletions
diff --git a/engines/cine/cine.cpp b/engines/cine/cine.cpp index 9594b42e51..2caf69da6c 100644 --- a/engines/cine/cine.cpp +++ b/engines/cine/cine.cpp @@ -105,8 +105,22 @@ int CineEngine::go() { return 0; } +int CineEngine::getTimerDelay() const { + return (10923000 * _timerDelayMultiplier) / 1193180; +} + +/*! \brief Modify game speed + * \param speedChange Negative values slow game down, positive values speed it up, zero does nothing + * \return Timer delay multiplier's value after the game speed change + */ +int CineEngine::modifyGameSpeed(int speedChange) { + // If we want more speed we decrement the timer delay multiplier and vice versa. + _timerDelayMultiplier = CLIP(_timerDelayMultiplier - speedChange, 1, 50); + return _timerDelayMultiplier; +} void CineEngine::initialize() { + _timerDelayMultiplier = 12; // Set default speed setupOpcodes(); initLanguage(g_cine->getLanguage()); diff --git a/engines/cine/cine.h b/engines/cine/cine.h index eaae555812..431cdc2c22 100644 --- a/engines/cine/cine.h +++ b/engines/cine/cine.h @@ -86,6 +86,8 @@ public: bool loadSaveDirectory(void); void makeSystemMenu(void); + int modifyGameSpeed(int speedChange); + int getTimerDelay() const; const CINEGameDescription *_gameDescription; Common::File _partFileHandle; @@ -109,6 +111,7 @@ private: void readVolCnf(); bool _preLoad; + int _timerDelayMultiplier; }; extern CineEngine *g_cine; diff --git a/engines/cine/main_loop.cpp b/engines/cine/main_loop.cpp index 80a8905465..654dd6b78c 100644 --- a/engines/cine/main_loop.cpp +++ b/engines/cine/main_loop.cpp @@ -125,6 +125,14 @@ static void processEvent(Common::Event &event) { g_cine->makeSystemMenu(); } break; + case Common::KEYCODE_MINUS: + case Common::KEYCODE_KP_MINUS: + g_cine->modifyGameSpeed(-1); // Slower + break; + case Common::KEYCODE_PLUS: + case Common::KEYCODE_KP_PLUS: + g_cine->modifyGameSpeed(+1); // Faster + break; default: lastKeyStroke = event.kbd.keycode; break; @@ -138,7 +146,7 @@ static void processEvent(Common::Event &event) { void manageEvents() { Common::EventManager *eventMan = g_system->getEventManager(); - uint32 nextFrame = g_system->getMillis() + kGameTimerDelay * kGameSpeed; + uint32 nextFrame = g_system->getMillis() + g_cine->getTimerDelay(); do { Common::Event event; while (eventMan->pollEvent(event)) { diff --git a/engines/cine/main_loop.h b/engines/cine/main_loop.h index a2f828fd34..c729b324ca 100644 --- a/engines/cine/main_loop.h +++ b/engines/cine/main_loop.h @@ -28,11 +28,6 @@ namespace Cine { -enum { - kGameTimerDelay = 1000 / (1193180 / 10923), - kGameSpeed = 12 -}; - void mainLoop(int bootScriptIdx); void manageEvents(); |