[Scummvm-cvs-logs] SF.net SVN: scummvm: [29284] scummvm/trunk/engines/scumm

fingolfin at users.sourceforge.net fingolfin at users.sourceforge.net
Sun Oct 28 13:57:26 CET 2007


Revision: 29284
          http://scummvm.svn.sourceforge.net/scummvm/?rev=29284&view=rev
Author:   fingolfin
Date:     2007-10-28 05:57:25 -0700 (Sun, 28 Oct 2007)

Log Message:
-----------
Refactored ScummEngine*::checkExecVerbs method

Modified Paths:
--------------
    scummvm/trunk/engines/scumm/he/intern_he.h
    scummvm/trunk/engines/scumm/input.cpp
    scummvm/trunk/engines/scumm/intern.h
    scummvm/trunk/engines/scumm/scumm.cpp
    scummvm/trunk/engines/scumm/scumm.h
    scummvm/trunk/engines/scumm/verbs.cpp

Modified: scummvm/trunk/engines/scumm/he/intern_he.h
===================================================================
--- scummvm/trunk/engines/scumm/he/intern_he.h	2007-10-28 12:04:38 UTC (rev 29283)
+++ scummvm/trunk/engines/scumm/he/intern_he.h	2007-10-28 12:57:25 UTC (rev 29284)
@@ -279,6 +279,7 @@
 	virtual void readMAXS(int blockSize);
 
 	virtual void redrawBGAreas();
+	virtual void checkExecVerbs();
 
 	byte *defineArray(int array, int type, int dim2start, int dim2end, int dim1start, int dim1end);
 	virtual int readArray(int array, int idx2, int idx1);
@@ -359,6 +360,8 @@
 	byte VAR_NUM_CHARSETS;
 
 	byte VAR_POLYGONS_ONLY;
+
+	byte VAR_MOUSE_STATE;			// Used in checkExecVerbs();
 };
 
 class ScummEngine_v80he : public ScummEngine_v72he {

Modified: scummvm/trunk/engines/scumm/input.cpp
===================================================================
--- scummvm/trunk/engines/scumm/input.cpp	2007-10-28 12:04:38 UTC (rev 29283)
+++ scummvm/trunk/engines/scumm/input.cpp	2007-10-28 12:57:25 UTC (rev 29284)
@@ -90,6 +90,8 @@
 			}
 
 			if (_game.heversion >= 80) {
+				// FIXME: Move this code & VAR_KEY_STATE to class ScummEngine_v80he
+
 				// Keyboard is controlled via variable
 				int keyState = 0;
 

Modified: scummvm/trunk/engines/scumm/intern.h
===================================================================
--- scummvm/trunk/engines/scumm/intern.h	2007-10-28 12:04:38 UTC (rev 29283)
+++ scummvm/trunk/engines/scumm/intern.h	2007-10-28 12:57:25 UTC (rev 29284)
@@ -332,6 +332,7 @@
 	void setUserState(byte state);
 
 	virtual void handleMouseOver(bool updateInventory);
+	virtual void checkExecVerbs();
 	void initV2MouseOver();
 	void initNESMouseOver();
 

Modified: scummvm/trunk/engines/scumm/scumm.cpp
===================================================================
--- scummvm/trunk/engines/scumm/scumm.cpp	2007-10-28 12:04:38 UTC (rev 29283)
+++ scummvm/trunk/engines/scumm/scumm.cpp	2007-10-28 12:57:25 UTC (rev 29284)
@@ -443,7 +443,6 @@
 
 	VAR_NUM_GLOBAL_OBJS = 0xFF;
 	VAR_KEY_STATE = 0xFF;
-	VAR_MOUSE_STATE = 0xFF;
 
 	// Use g_scumm from error() ONLY
 	g_scumm = this;
@@ -780,6 +779,7 @@
 	VAR_NUM_IMAGES = 0xFF;
 	VAR_NUM_CHARSETS = 0xFF;
 	VAR_POLYGONS_ONLY = 0xFF;
+	VAR_MOUSE_STATE = 0xFF;
 }
 
 ScummEngine_v80he::ScummEngine_v80he(OSystem *syst, const DetectorResult &dr)

Modified: scummvm/trunk/engines/scumm/scumm.h
===================================================================
--- scummvm/trunk/engines/scumm/scumm.h	2007-10-28 12:04:38 UTC (rev 29283)
+++ scummvm/trunk/engines/scumm/scumm.h	2007-10-28 12:57:25 UTC (rev 29284)
@@ -1342,7 +1342,6 @@
 	byte VAR_NUM_SCRIPT_CYCLES;		// Used in runAllScripts()
 
 	byte VAR_KEY_STATE;			// Used in parseEvents()
-	byte VAR_MOUSE_STATE;			// Used in checkExecVerbs();
 
 	// Exists both in V7 and in V72HE:
 	byte VAR_NUM_GLOBAL_OBJS;

Modified: scummvm/trunk/engines/scumm/verbs.cpp
===================================================================
--- scummvm/trunk/engines/scumm/verbs.cpp	2007-10-28 12:04:38 UTC (rev 29283)
+++ scummvm/trunk/engines/scumm/verbs.cpp	2007-10-28 12:57:25 UTC (rev 29284)
@@ -26,6 +26,7 @@
 
 #include "scumm/actor.h"
 #include "scumm/charset.h"
+#include "scumm/he/intern_he.h"
 #include "scumm/intern.h"
 #include "scumm/object.h"
 #include "scumm/resource.h"
@@ -513,19 +514,26 @@
 	drawSentence();
 }
 
+#ifndef DISABLE_HE
+void ScummEngine_v72he::checkExecVerbs() {
+	VAR(VAR_MOUSE_STATE) = 0;
+
+	if (_userPut <= 0 || _mouseAndKeyboardStat == 0)
+		return;
+
+	VAR(VAR_MOUSE_STATE) = _mouseAndKeyboardStat;
+
+	ScummEngine::checkExecVerbs();
+}
+#endif
+
 void ScummEngine::checkExecVerbs() {
 	int i, over;
 	VerbSlot *vs;
 
-	if (VAR_MOUSE_STATE != 0xFF)
-		VAR(VAR_MOUSE_STATE) = 0;
-
 	if (_userPut <= 0 || _mouseAndKeyboardStat == 0)
 		return;
 
-	if (VAR_MOUSE_STATE != 0xFF)
-		VAR(VAR_MOUSE_STATE) = _mouseAndKeyboardStat;
-
 	if (_mouseAndKeyboardStat < MBS_MAX_KEY) {
 		/* Check keypresses */
 		if (!(_game.id == GID_MONKEY && _game.platform == Common::kPlatformSegaCD)) {
@@ -572,7 +580,7 @@
 		if ((_game.platform == Common::kPlatformFMTowns && _game.id == GID_ZAK) &&
 			(_mouseAndKeyboardStat >= 315 && _mouseAndKeyboardStat <= 318)) {
 			// Hack: Handle switching to a person via F1-F4 keys.
-			// This feature isn't available in the scripts of the FM-TOWNS verison.
+			// This feature isn't available in the scripts of the FM-TOWNS version.
 			int fKey = _mouseAndKeyboardStat - 314;
 			int switchSlot = getVerbSlot(36, 0);
 			// check if switch-verb is enabled
@@ -590,25 +598,67 @@
 		runInputScript(kKeyClickArea, _mouseAndKeyboardStat, 1);
 	} else if (_mouseAndKeyboardStat & MBS_MOUSE_MASK) {
 		VirtScreen *zone = findVirtScreen(_mouse.y);
-		byte code = _mouseAndKeyboardStat & MBS_LEFT_CLICK ? 1 : 2;
-		int inventoryArea = (_game.platform == Common::kPlatformNES) ? 48: 32;
+		const byte code = _mouseAndKeyboardStat & MBS_LEFT_CLICK ? 1 : 2;
 
 		// This could be kUnkVirtScreen.
 		// Fixes bug #1536932: "MANIACNES: Crash on click in speechtext-area"
 		if (!zone)
 			return;
 
-		if (_game.version <= 2 && zone->number == kVerbVirtScreen && _mouse.y <= zone->topline + 8) {
+		over = findVerbAtPos(_mouse.x, _mouse.y);
+		if (over != 0) {
+			// Verb was clicked
+			runInputScript(kVerbClickArea, _verbs[over].verbid, code);
+		} else {
+			// Scene was clicked
+			runInputScript((zone->number == kMainVirtScreen) ? kSceneClickArea : kVerbClickArea, 0, code);
+		}
+	}
+}
+
+void ScummEngine_v2::checkExecVerbs() {
+	int i, over;
+	VerbSlot *vs;
+
+	if (_userPut <= 0 || _mouseAndKeyboardStat == 0)
+		return;
+
+	if (_mouseAndKeyboardStat < MBS_MAX_KEY) {
+		/* Check keypresses */
+		vs = &_verbs[1];
+		for (i = 1; i < _numVerbs; i++, vs++) {
+			if (vs->verbid && vs->saveid == 0 && vs->curmode == 1) {
+				if (_mouseAndKeyboardStat == vs->key) {
+					// Trigger verb as if the user clicked it
+					runInputScript(1, vs->verbid, 1);
+					return;
+				}
+			}
+		}
+	
+		// Generic keyboard input
+		runInputScript(4, _mouseAndKeyboardStat, 1);
+	} else if (_mouseAndKeyboardStat & MBS_MOUSE_MASK) {
+		VirtScreen *zone = findVirtScreen(_mouse.y);
+		const byte code = _mouseAndKeyboardStat & MBS_LEFT_CLICK ? 1 : 2;
+		const int inventoryArea = (_game.platform == Common::kPlatformNES) ? 48: 32;
+
+		// This could be kUnkVirtScreen.
+		// Fixes bug #1536932: "MANIACNES: Crash on click in speechtext-area"
+		if (!zone)
+			return;
+
+		if (zone->number == kVerbVirtScreen && _mouse.y <= zone->topline + 8) {
 			// Click into V2 sentence line
-			runInputScript(kSentenceClickArea, 0, 0);
-		} else if (_game.version <= 2 && zone->number == kVerbVirtScreen && _mouse.y > zone->topline + inventoryArea) {
+			runInputScript(5, 0, 0);
+		} else if (zone->number == kVerbVirtScreen && _mouse.y > zone->topline + inventoryArea) {
 			// Click into V2 inventory
-			((ScummEngine_v2 *)this)->checkV2Inventory(_mouse.x, _mouse.y);
+			checkV2Inventory(_mouse.x, _mouse.y);
 		} else {
 			over = findVerbAtPos(_mouse.x, _mouse.y);
 			if (over != 0) {
 				// Verb was clicked
-				runInputScript(kVerbClickArea, _verbs[over].verbid, code);
+				runInputScript(1, _verbs[over].verbid, code);
 			} else {
 				// Scene was clicked
 				runInputScript((zone->number == kMainVirtScreen) ? kSceneClickArea : kVerbClickArea, 0, code);


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