[Scummvm-cvs-logs] SF.net SVN: scummvm:[46741] scummvm/trunk/engines/sci/engine

thebluegr at users.sourceforge.net thebluegr at users.sourceforge.net
Wed Dec 30 14:43:17 CET 2009


Revision: 46741
          http://scummvm.svn.sourceforge.net/scummvm/?rev=46741&view=rev
Author:   thebluegr
Date:     2009-12-30 13:43:17 +0000 (Wed, 30 Dec 2009)

Log Message:
-----------
Implemented ListFirstTrue(), thanks to the help of waltervn. Now, buttons can be highlighted and clicked when the control panel is shown in GK1, and the options dialog pops up when the options button is selected

Modified Paths:
--------------
    scummvm/trunk/engines/sci/engine/kernel.cpp
    scummvm/trunk/engines/sci/engine/kernel.h
    scummvm/trunk/engines/sci/engine/kernel32.cpp

Modified: scummvm/trunk/engines/sci/engine/kernel.cpp
===================================================================
--- scummvm/trunk/engines/sci/engine/kernel.cpp	2009-12-30 13:19:52 UTC (rev 46740)
+++ scummvm/trunk/engines/sci/engine/kernel.cpp	2009-12-30 13:43:17 UTC (rev 46741)
@@ -351,7 +351,9 @@
 	DEFUN("UpdatePlane", kUpdatePlane, "o"),
 	DEFUN("RepaintPlane", kRepaintPlane, "o"),
 	DEFUN("FrameOut", kFrameOut, ""),
-	DEFUN("ListEachElementDo", kListEachElementDo, ".*"),
+	DEFUN("ListEachElementDo", kListEachElementDo, "li.*"),
+	DEFUN("ListFirstTrue", kListFirstTrue, "li.*"),
+	//DEFUN("ListAllTrue", kListAllTrue, "li.*"),
 	DEFUN("ListIndexOf", kListIndexOf, "lo"),
 	DEFUN("OnMe", kOnMe, "iio.*"),
 

Modified: scummvm/trunk/engines/sci/engine/kernel.h
===================================================================
--- scummvm/trunk/engines/sci/engine/kernel.h	2009-12-30 13:19:52 UTC (rev 46740)
+++ scummvm/trunk/engines/sci/engine/kernel.h	2009-12-30 13:43:17 UTC (rev 46741)
@@ -408,6 +408,9 @@
 reg_t kFrameOut(EngineState *s, int argc, reg_t *argv);
 reg_t kListIndexOf(EngineState *s, int argc, reg_t *argv);
 reg_t kListEachElementDo(EngineState *s, int argc, reg_t *argv);
+reg_t kListFirstTrue(EngineState *s, int argc, reg_t *argv);
+// TODO: What is this supposed to return?
+//reg_t kListAllTrue(EngineState *s, int argc, reg_t *argv);
 reg_t kOnMe(EngineState *s, int argc, reg_t *argv);
 
 // SCI2.1 Kernel Functions

Modified: scummvm/trunk/engines/sci/engine/kernel32.cpp
===================================================================
--- scummvm/trunk/engines/sci/engine/kernel32.cpp	2009-12-30 13:19:52 UTC (rev 46740)
+++ scummvm/trunk/engines/sci/engine/kernel32.cpp	2009-12-30 13:43:17 UTC (rev 46741)
@@ -764,7 +764,7 @@
 
 		// First, check if the target selector is a variable
 		if (lookup_selector(s->_segMan, curObject, slc, &address, NULL) == kSelectorVariable) {
-			// This can only happen with 3 params (list, target object, variable)
+			// This can only happen with 3 params (list, target selector, variable)
 			if (argc != 3) {
 				warning("kListEachElementDo: Attempted to modify a variable selector with %d params", argc);
 			} else {
@@ -796,6 +796,55 @@
 	return s->r_acc;
 }
 
+reg_t kListFirstTrue(EngineState *s, int argc, reg_t *argv) {
+	List *list = s->_segMan->lookupList(argv[0]);
+
+	reg_t curAddress = list->first;
+	Node *curNode = s->_segMan->lookupNode(curAddress);
+	reg_t curObject;
+	Selector slc = argv[1].toUint16();
+
+	ObjVarRef address;
+
+	s->r_acc = NULL_REG;	// reset the accumulator
+
+	while (curNode) {
+		curObject = curNode->value;
+
+		// First, check if the target selector is a variable
+		if (lookup_selector(s->_segMan, curObject, slc, &address, NULL) == kSelectorVariable) {
+			// Can this happen with variable selectors?
+			warning("kListFirstTrue: Attempted to access a variable selector");
+		} else {
+			// FIXME: Yes, this is an ugly hack...
+			if (argc == 2) {
+				invoke_selector(s, curObject, slc, kContinueOnInvalidSelector, argv, argc, 0);
+			} else if (argc == 3) {
+				invoke_selector(s, curObject, slc, kContinueOnInvalidSelector, argv, argc, 1, argv[2]);
+			} else if (argc == 4) {
+				invoke_selector(s, curObject, slc, kContinueOnInvalidSelector, argv, argc, 2, argv[2], argv[3]);
+			} else if (argc == 5) {
+				invoke_selector(s, curObject, slc, kContinueOnInvalidSelector, argv, argc, 3, argv[2], argv[3], argv[4]);
+			} else {
+				warning("kListFirstTrue: called with %d params", argc);
+			}
+
+			// Check if the result is true
+			if (s->r_acc != NULL_REG)
+				return curObject;
+		}
+
+		// Lookup node again, since the nodetable it was in may have been reallocated
+		curNode = s->_segMan->lookupNode(curAddress);
+
+		curAddress = curNode->succ;
+		curNode = s->_segMan->lookupNode(curAddress);
+	}
+
+	// No selector returned true
+	return NULL_REG;
+}
+
 reg_t kOnMe(EngineState *s, int argc, reg_t *argv) {
 	// Tests if the cursor is on the passed object
 


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