[Scummvm-cvs-logs] SF.net SVN: scummvm: [26461] scummvm/trunk/engines/gob

drmccoy at users.sourceforge.net drmccoy at users.sourceforge.net
Fri Apr 13 21:55:09 CEST 2007


Revision: 26461
          http://scummvm.svn.sourceforge.net/scummvm/?rev=26461&view=rev
Author:   drmccoy
Date:     2007-04-13 12:55:09 -0700 (Fri, 13 Apr 2007)

Log Message:
-----------
Implemented fast modes: CTRL-f for double and CTRL-g for triple speed
Though I think it shouldn't break anything, use it at your own risk

Modified Paths:
--------------
    scummvm/trunk/engines/gob/global.cpp
    scummvm/trunk/engines/gob/global.h
    scummvm/trunk/engines/gob/util.cpp
    scummvm/trunk/engines/gob/util.h

Modified: scummvm/trunk/engines/gob/global.cpp
===================================================================
--- scummvm/trunk/engines/gob/global.cpp	2007-04-13 13:09:00 UTC (rev 26460)
+++ scummvm/trunk/engines/gob/global.cpp	2007-04-13 19:55:09 UTC (rev 26461)
@@ -125,6 +125,8 @@
 
 	_inter_mouseX = 0;
 	_inter_mouseY = 0;
+
+	_speedFactor = 1;
 }
 
 Global::~Global() {

Modified: scummvm/trunk/engines/gob/global.h
===================================================================
--- scummvm/trunk/engines/gob/global.h	2007-04-13 13:09:00 UTC (rev 26460)
+++ scummvm/trunk/engines/gob/global.h	2007-04-13 19:55:09 UTC (rev 26461)
@@ -125,6 +125,9 @@
 	int16 _inter_mouseX;
 	int16 _inter_mouseY;
 
+	// Can be 1, 2 or 3 for normal, double and triple speed, respectively
+	uint8 _speedFactor;
+
 	void clearVars(uint32 count) {
 		uint32 size = count * 4;
 

Modified: scummvm/trunk/engines/gob/util.cpp
===================================================================
--- scummvm/trunk/engines/gob/util.cpp	2007-04-13 13:09:00 UTC (rev 26460)
+++ scummvm/trunk/engines/gob/util.cpp	2007-04-13 19:55:09 UTC (rev 26461)
@@ -42,10 +42,11 @@
 		_keyBuffer[i] = 0;
 	_keyBufferHead = 0;
 	_keyBufferTail = 0;
+	_fastMode = 0;
 }
 
 uint32 Util::getTimeKey(void) {
-	return g_system->getMillis();
+	return g_system->getMillis() * _vm->_global->_speedFactor;
 }
 
 int16 Util::getRandom(int16 max) {
@@ -60,16 +61,17 @@
 }
 
 void Util::delay(uint16 msecs) {
-	g_system->delayMillis(msecs);
+	g_system->delayMillis(msecs / _vm->_global->_speedFactor);
 }
 
 void Util::longDelay(uint16 msecs) {
-	uint32 time = g_system->getMillis() + msecs;
+	uint32 time = g_system->getMillis() * _vm->_global->_speedFactor + msecs;
 	do {
 		_vm->_video->waitRetrace();
 		processInput();
 		delay(15);
-	} while (!_vm->_quitRequested && (g_system->getMillis() < time));
+	} while (!_vm->_quitRequested &&
+	         ((g_system->getMillis() * _vm->_global->_speedFactor) < time));
 }
 
 void Util::initInput(void) {
@@ -103,6 +105,13 @@
 			_mouseButtons &= ~2;
 			break;
 		case Common::EVENT_KEYDOWN:
+			if (event.kbd.flags == Common::KBD_CTRL) {
+				if (event.kbd.keycode == 'f')
+					_fastMode ^= 1;
+				else if (event.kbd.keycode == 'g')
+					_fastMode ^= 2;
+				break;
+			}
 			addKeyToBuffer(event.kbd.keycode);
 			break;
 		case Common::EVENT_KEYUP:
@@ -115,6 +124,7 @@
 		}
 	}
 
+	_vm->_global->_speedFactor = MIN(_fastMode + 1, 3);
 	if (scroll && hasMove)
 		_vm->_game->evaluateScroll(x, y);
 }
@@ -190,7 +200,7 @@
 		processInput();
 
 		if (keyBufferEmpty())
-			g_system->delayMillis(10);
+			g_system->delayMillis(10 / _vm->_global->_speedFactor);
 	}
 	return translateKey(key);
 }

Modified: scummvm/trunk/engines/gob/util.h
===================================================================
--- scummvm/trunk/engines/gob/util.h	2007-04-13 13:09:00 UTC (rev 26460)
+++ scummvm/trunk/engines/gob/util.h	2007-04-13 19:55:09 UTC (rev 26461)
@@ -91,6 +91,8 @@
 	int16 _keyBufferHead;
 	int16 _keyBufferTail;
 
+	uint8 _fastMode;
+
 	GobEngine *_vm;
 
 	bool keyBufferEmpty();


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