[Scummvm-cvs-logs] SF.net SVN: scummvm: [32135] scummvm/trunk/engines/parallaction

peres001 at users.sourceforge.net peres001 at users.sourceforge.net
Thu May 15 03:18:27 CEST 2008


Revision: 32135
          http://scummvm.svn.sourceforge.net/scummvm/?rev=32135&view=rev
Author:   peres001
Date:     2008-05-14 18:18:26 -0700 (Wed, 14 May 2008)

Log Message:
-----------
* Cleanup of input code.
* Removed old timer routines.

Modified Paths:
--------------
    scummvm/trunk/engines/parallaction/callables_ns.cpp
    scummvm/trunk/engines/parallaction/gui_ns.cpp
    scummvm/trunk/engines/parallaction/input.cpp
    scummvm/trunk/engines/parallaction/input.h
    scummvm/trunk/engines/parallaction/parallaction.cpp
    scummvm/trunk/engines/parallaction/parallaction.h
    scummvm/trunk/engines/parallaction/parallaction_ns.cpp

Modified: scummvm/trunk/engines/parallaction/callables_ns.cpp
===================================================================
--- scummvm/trunk/engines/parallaction/callables_ns.cpp	2008-05-15 00:44:44 UTC (rev 32134)
+++ scummvm/trunk/engines/parallaction/callables_ns.cpp	2008-05-15 01:18:26 UTC (rev 32135)
@@ -468,7 +468,6 @@
 
 	debugC(1, kDebugExec, "endIntro()");
 
-	uint32 event;
 	uint id[2];
 	for (uint16 _si = 0; _si < 6; _si++) {
 		id[0] = _gfx->createLabel(_menuFont, _credits[_si]._role, 1);
@@ -479,15 +478,8 @@
 
 		_gfx->updateScreen();
 
-		for (uint16 v2 = 0; v2 < 100; v2++) {
-			_input->readInput();
-			event = _input->getLastButtonEvent();
-			if (event == kMouseLeftUp)
-				break;
+		_input->waitForButtonEvent(kMouseLeftUp, 5500);
 
-			waitTime( 1 );
-		}
-
 		_gfx->freeLabels();
 	}
 	debugC(1, kDebugExec, "endIntro(): done showing credits");

Modified: scummvm/trunk/engines/parallaction/gui_ns.cpp
===================================================================
--- scummvm/trunk/engines/parallaction/gui_ns.cpp	2008-05-15 00:44:44 UTC (rev 32134)
+++ scummvm/trunk/engines/parallaction/gui_ns.cpp	2008-05-15 01:18:26 UTC (rev 32135)
@@ -213,11 +213,7 @@
 
 	_input->waitForButtonEvent(kMouseLeftUp | kMouseRightUp);
 	uint32 event = _input->getLastButtonEvent();
-/*
-	do {
-		_input->readInput();
-	} while (_mouseButtons != kMouseLeftUp && _mouseButtons != kMouseRightUp);
-*/
+
 	_input->showCursor(true);
 
 	_gfx->freeLabels();

Modified: scummvm/trunk/engines/parallaction/input.cpp
===================================================================
--- scummvm/trunk/engines/parallaction/input.cpp	2008-05-15 00:44:44 UTC (rev 32134)
+++ scummvm/trunk/engines/parallaction/input.cpp	2008-05-15 01:18:26 UTC (rev 32135)
@@ -83,7 +83,7 @@
 			// TODO: don't quit() here, just have caller routines to check
 			// on kEngineQuit and exit gracefully to allow the engine to shut down
 			_engineFlags |= kEngineQuit;
-			g_system->quit();
+			_vm->_system->quit();
 			break;
 
 		default:
@@ -101,17 +101,26 @@
 }
 
 // FIXME: see comment for readInput()
-void Input::waitForButtonEvent(uint32 buttonEventMask) {
+void Input::waitForButtonEvent(uint32 buttonEventMask, int32 timeout) {
 
 	if (buttonEventMask == kMouseNone) {
 		_mouseButtons = kMouseNone;	// don't wait on nothing
 		return;
 	}
 
-	do {
-		readInput();
-		g_system->delayMillis(30);
-	} while ((_mouseButtons & buttonEventMask) == 0);
+	const int32 LOOP_RESOLUTION = 30;
+	if (timeout <= 0) {
+		do {
+			readInput();
+			_vm->_system->delayMillis(LOOP_RESOLUTION);
+		} while ((_mouseButtons & buttonEventMask) == 0);
+	} else {
+		do {
+			readInput();
+			_vm->_system->delayMillis(LOOP_RESOLUTION);
+			timeout -= LOOP_RESOLUTION;
+		} while ((timeout > 0) && (_mouseButtons & buttonEventMask) == 0);
+	}
 
 }
 
@@ -121,39 +130,13 @@
 	do {
 		readInput();
 		_vm->_gfx->updateScreen();
-		g_system->delayMillis(30);
+		_vm->_system->delayMillis(30);
 	} while (_mouseButtons != kMouseLeftUp);
 
 	return;
 }
 
-void Parallaction::runGame() {
 
-	InputData *data = _input->updateInput();
-	if (data->_event != kEvNone) {
-		processInput(data);
-	}
-
-	runPendingZones();
-
-	if (_engineFlags & kEngineChangeLocation) {
-		changeLocation(_location._name);
-	}
-
-
-	_gfx->beginFrame();
-
-	if (_input->_inputMode == Input::kInputModeGame) {
-		runScripts();
-		walk();
-		drawAnimations();
-	}
-
-	// change this to endFrame?
-	updateView();
-
-}
-
 void Input::updateGameInput() {
 
 	int16 keyDown = readInput();

Modified: scummvm/trunk/engines/parallaction/input.h
===================================================================
--- scummvm/trunk/engines/parallaction/input.h	2008-05-15 00:44:44 UTC (rev 32134)
+++ scummvm/trunk/engines/parallaction/input.h	2008-05-15 01:18:26 UTC (rev 32135)
@@ -68,6 +68,7 @@
 	uint16	_mouseButtons;
 
 	bool		_mouseHidden;
+	ZonePtr			_hoverZone;
 
 public:
 	enum {
@@ -94,13 +95,12 @@
 	}
 
 	int				_inputMode;
-	ZonePtr			_hoverZone;
 	InventoryItem	_activeItem;
 
 	uint16	readInput();
 	InputData* 	updateInput();
 	void 	waitUntilLeftClick();
-	void	waitForButtonEvent(uint32 buttonEventMask);
+	void	waitForButtonEvent(uint32 buttonEventMask, int32 timeout = -1);
 	uint32	getLastButtonEvent() { return _mouseButtons; }
 
 	void stopHovering() {

Modified: scummvm/trunk/engines/parallaction/parallaction.cpp
===================================================================
--- scummvm/trunk/engines/parallaction/parallaction.cpp	2008-05-15 00:44:44 UTC (rev 32134)
+++ scummvm/trunk/engines/parallaction/parallaction.cpp	2008-05-15 01:18:26 UTC (rev 32135)
@@ -153,30 +153,7 @@
 }
 
 
-uint32 Parallaction::getElapsedTime() {
-	return g_system->getMillis() - _baseTime;
-}
 
-void Parallaction::resetTimer() {
-	_baseTime = g_system->getMillis();
-	return;
-}
-
-
-void Parallaction::waitTime(uint32 t) {
-
-	uint32 v4 = 0;
-
-	while (v4 < t * (1000 / 18.2)) {
-		v4 = getElapsedTime();
-	}
-
-	resetTimer();
-
-	return;
-}
-
-
 void Parallaction::freeCharacter() {
 	debugC(1, kDebugExec, "freeCharacter()");
 
@@ -370,9 +347,36 @@
 	return;
 }
 
+void Parallaction::runGame() {
 
+	InputData *data = _input->updateInput();
+	if (data->_event != kEvNone) {
+		processInput(data);
+	}
 
+	runPendingZones();
 
+	if (_engineFlags & kEngineChangeLocation) {
+		changeLocation(_location._name);
+	}
+
+
+	_gfx->beginFrame();
+
+	if (_input->_inputMode == Input::kInputModeGame) {
+		runScripts();
+		walk();
+		drawAnimations();
+	}
+
+	// change this to endFrame?
+	updateView();
+
+}
+
+
+
+
 //	displays transition before a new location
 //
 //	clears screen (in white??)
@@ -409,8 +413,8 @@
 	for (uint16 _si = 0; _si<6; _si++) {
 		pal.fadeTo(_gfx->_palette, 4);
 		_gfx->setPalette(pal);
-		waitTime( 1 );
 		_gfx->updateScreen();
+		g_system->delayMillis(20);
 	}
 
 	_gfx->setPalette(_gfx->_palette);

Modified: scummvm/trunk/engines/parallaction/parallaction.h
===================================================================
--- scummvm/trunk/engines/parallaction/parallaction.h	2008-05-15 00:44:44 UTC (rev 32134)
+++ scummvm/trunk/engines/parallaction/parallaction.h	2008-05-15 01:18:26 UTC (rev 32135)
@@ -259,8 +259,6 @@
 
 	Input	*_input;
 
-	void		waitTime(uint32 t);
-
 	OpcodeSet	_commandOpcodes;
 
 	struct ParallactionStruct1 {
@@ -368,8 +366,6 @@
 	void		initGlobals();
 	void		runGame();
 	void		updateView();
-	uint32		getElapsedTime();
-	void		resetTimer();
 
 	void		scheduleLocationSwitch(const char *location);
 	void		doLocationEnterTransition();

Modified: scummvm/trunk/engines/parallaction/parallaction_ns.cpp
===================================================================
--- scummvm/trunk/engines/parallaction/parallaction_ns.cpp	2008-05-15 00:44:44 UTC (rev 32134)
+++ scummvm/trunk/engines/parallaction/parallaction_ns.cpp	2008-05-15 01:18:26 UTC (rev 32135)
@@ -299,7 +299,7 @@
 	_gfx->setFloatingLabel(0);
 	_gfx->freeLabels();
 
-	_input->_hoverZone = nullZonePtr;
+	_input->stopHovering();
 	if (_engineFlags & kEngineBlockInput) {
 		setArrowCursor();
 	}


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