[Scummvm-cvs-logs] SF.net SVN: scummvm:[33689] scummvm/trunk/engines/cine

buddha_ at users.sourceforge.net buddha_ at users.sourceforge.net
Thu Aug 7 23:46:56 CEST 2008


Revision: 33689
          http://scummvm.svn.sourceforge.net/scummvm/?rev=33689&view=rev
Author:   buddha_
Date:     2008-08-07 21:46:56 +0000 (Thu, 07 Aug 2008)

Log Message:
-----------
Implemented game speed changing by pressing - or + to e.g. ease testing.

Modified Paths:
--------------
    scummvm/trunk/engines/cine/cine.cpp
    scummvm/trunk/engines/cine/cine.h
    scummvm/trunk/engines/cine/main_loop.cpp
    scummvm/trunk/engines/cine/main_loop.h

Modified: scummvm/trunk/engines/cine/cine.cpp
===================================================================
--- scummvm/trunk/engines/cine/cine.cpp	2008-08-07 19:46:06 UTC (rev 33688)
+++ scummvm/trunk/engines/cine/cine.cpp	2008-08-07 21:46:56 UTC (rev 33689)
@@ -105,8 +105,22 @@
 	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());

Modified: scummvm/trunk/engines/cine/cine.h
===================================================================
--- scummvm/trunk/engines/cine/cine.h	2008-08-07 19:46:06 UTC (rev 33688)
+++ scummvm/trunk/engines/cine/cine.h	2008-08-07 21:46:56 UTC (rev 33689)
@@ -86,6 +86,8 @@
 
 	bool loadSaveDirectory(void);
 	void makeSystemMenu(void);
+	int modifyGameSpeed(int speedChange);
+	int getTimerDelay() const;
 
 	const CINEGameDescription *_gameDescription;
 	Common::File _partFileHandle;
@@ -109,6 +111,7 @@
 	void readVolCnf();
 
 	bool _preLoad;
+	int _timerDelayMultiplier;
 };
 
 extern CineEngine *g_cine;

Modified: scummvm/trunk/engines/cine/main_loop.cpp
===================================================================
--- scummvm/trunk/engines/cine/main_loop.cpp	2008-08-07 19:46:06 UTC (rev 33688)
+++ scummvm/trunk/engines/cine/main_loop.cpp	2008-08-07 21:46:56 UTC (rev 33689)
@@ -125,6 +125,14 @@
 				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 @@
 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)) {

Modified: scummvm/trunk/engines/cine/main_loop.h
===================================================================
--- scummvm/trunk/engines/cine/main_loop.h	2008-08-07 19:46:06 UTC (rev 33688)
+++ scummvm/trunk/engines/cine/main_loop.h	2008-08-07 21:46:56 UTC (rev 33689)
@@ -28,11 +28,6 @@
 
 namespace Cine {
 
-enum {
-	kGameTimerDelay = 1000 / (1193180 / 10923),
-	kGameSpeed = 12
-};
-
 void mainLoop(int bootScriptIdx);
 void manageEvents();
 


This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.




More information about the Scummvm-git-logs mailing list