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

thebluegr at users.sourceforge.net thebluegr at users.sourceforge.net
Sat Dec 26 16:47:57 CET 2009


Revision: 46591
          http://scummvm.svn.sourceforge.net/scummvm/?rev=46591&view=rev
Author:   thebluegr
Date:     2009-12-26 15:47:57 +0000 (Sat, 26 Dec 2009)

Log Message:
-----------
SCI2: Implemented kListEachElementDo (a more advanced version of SciGuiAnimate:invoke()) and kListAt. Now, the Sierra logo music can be heard, and game logic is running on objects of the animated views list

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-26 15:12:56 UTC (rev 46590)
+++ scummvm/trunk/engines/sci/engine/kernel.cpp	2009-12-26 15:47:57 UTC (rev 46591)
@@ -341,6 +341,7 @@
 	// SCI2 Kernel Functions
 	DEFUN("IsHiRes", kIsHiRes, ""),
 	DEFUN("Array", kArray, ".*"),
+	DEFUN("ListAt", kListAt, ".*"),
 	DEFUN("String", kString, ".*"),
 	DEFUN("AddScreenItem", kAddScreenItem, "o"),
 	DEFUN("UpdateScreenItem", kUpdateScreenItem, "o"),

Modified: scummvm/trunk/engines/sci/engine/kernel.h
===================================================================
--- scummvm/trunk/engines/sci/engine/kernel.h	2009-12-26 15:12:56 UTC (rev 46590)
+++ scummvm/trunk/engines/sci/engine/kernel.h	2009-12-26 15:47:57 UTC (rev 46591)
@@ -394,6 +394,7 @@
 // SCI2 Kernel Functions
 reg_t kIsHiRes(EngineState *s, int argc, reg_t *argv);
 reg_t kArray(EngineState *s, int argc, reg_t *argv);
+reg_t kListAt(EngineState *s, int argc, reg_t *argv);
 reg_t kString(EngineState *s, int argc, reg_t *argv);
 // "Screen items" in SCI32 are views
 reg_t kAddScreenItem(EngineState *s, int argc, reg_t *argv);

Modified: scummvm/trunk/engines/sci/engine/kernel32.cpp
===================================================================
--- scummvm/trunk/engines/sci/engine/kernel32.cpp	2009-12-26 15:12:56 UTC (rev 46590)
+++ scummvm/trunk/engines/sci/engine/kernel32.cpp	2009-12-26 15:47:57 UTC (rev 46591)
@@ -456,6 +456,34 @@
 	return NULL_REG;
 }
 
+reg_t kListAt(EngineState *s, int argc, reg_t *argv) {
+	if (argc != 2) {
+		warning("kListAt called with %d parameters", argc);
+		return NULL_REG;
+	}
+
+	List *list = s->_segMan->lookupList(argv[0]);
+	reg_t curAddress = list->first;
+	Node *curNode = s->_segMan->lookupNode(curAddress);
+	reg_t curObject = curNode->value;
+	int16 listIndex = argv[1].toUint16();
+	int curIndex = 0;
+
+	while (curIndex != listIndex) {
+		if (curNode->succ.isNull()) {	// end of the list?
+			return NULL_REG;
+		}
+
+		curAddress = curNode->succ;
+		curNode = s->_segMan->lookupNode(curAddress);
+		curObject = curNode->value;
+
+		curIndex++;
+	}
+
+	return curObject;
+}
+
 reg_t kString(EngineState *s, int argc, reg_t *argv) {	
 	switch (argv[0].toUint16()) {
 	case 0: { // New
@@ -695,22 +723,37 @@
 }
 
 reg_t kListEachElementDo(EngineState *s, int argc, reg_t *argv) {
+	List *list = s->_segMan->lookupList(argv[0]);
 
-	// Called with 2 or 3 parameters
-	// object, selector and optionally a third unknown parameter
+	reg_t curAddress = list->first;
+	Node *curNode = s->_segMan->lookupNode(curAddress);
+	reg_t curObject;
 
-	// With 2 parameters, the selector can be:
-	// - 0x45 (doit)
-	// - 0x5c (delete)
-	// - 0xfd (check)
+	while (curNode) {
+		curObject = curNode->value;
 
-	// With 3 parameters, the selector can be:
-	// - 0x145 (checkDetail)
-	// - 0x211 (newRoom) - that one seems a bit odd
+		// FIXME: Yes, this is an ugly hack...
+		if (argc == 2) {
+			invoke_selector(s, curObject, argv[1].toUint16(), kContinueOnInvalidSelector, argv, argc, 0);
+		} else if (argc == 3) {
+			invoke_selector(s, curObject, argv[1].toUint16(), kContinueOnInvalidSelector, argv, argc, 1, argv[2]);
+		} else if (argc == 4) {
+			invoke_selector(s, curObject, argv[1].toUint16(), kContinueOnInvalidSelector, argv, argc, 2, argv[2], argv[3]);
+		} else if (argc == 5) {
+			invoke_selector(s, curObject, argv[1].toUint16(), kContinueOnInvalidSelector, argv, argc, 3, argv[2], argv[3], argv[4]);
+		} else {
+			warning("kListEachElementDo: called with %d params", argc);
+		}
 
-	// TODO
+		// Lookup node again, since the nodetable it was in may have been reallocated
+		curNode = s->_segMan->lookupNode(curAddress);
 
-	return NULL_REG;
+		curAddress = curNode->succ;
+		curNode = s->_segMan->lookupNode(curAddress);
+	}
+
+
+	return s->r_acc;
 }
 
 reg_t kOnMe(EngineState *s, int argc, reg_t *argv) {
@@ -720,7 +763,7 @@
 	// TODO
 
 	warning("kOnMe: (%d, %d) on object %04x:%04x", argv[0].toUint16(), argv[1].toUint16(), PRINT_REG(argv[2]));
-	return NULL_REG;
+	return s->r_acc;
 }
 
 } // End of namespace Sci


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