[Scummvm-cvs-logs] CVS: scummvm/saga sfuncs.cpp,1.16,1.17 sthread.cpp,1.25,1.26

Torbjörn Andersson eriktorbjorn at users.sourceforge.net
Mon Sep 20 23:36:01 CEST 2004


Update of /cvsroot/scummvm/scummvm/saga
In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv11361

Modified Files:
	sfuncs.cpp sthread.cpp 
Log Message:
The TourneySetup script now runs and finishes cleanly. However, this is not
as exciting as it first sounds, because even before this patch the script
would run in its entirety - it just didn't know when to stop.

I guess the exciting things don't happen until the next script is triggered
(TorneyScene?). I think it will be easier to start fixing the numerous
deficiencies (stack handling, SData, missing script functions, etc.) when
we have something more concrete to work with.


Index: sfuncs.cpp
===================================================================
RCS file: /cvsroot/scummvm/scummvm/saga/sfuncs.cpp,v
retrieving revision 1.16
retrieving revision 1.17
diff -u -d -r1.16 -r1.17
--- sfuncs.cpp	12 Aug 2004 23:57:45 -0000	1.16
+++ sfuncs.cpp	21 Sep 2004 06:35:00 -0000	1.17
@@ -251,6 +251,8 @@
 
 // Script function #15
 int Script::SF_setFollower(R_SCRIPTFUNC_PARAMS) {
+	thread->stack->pop();
+	thread->stack->pop();
 	return R_SUCCESS;
 }
 
@@ -363,6 +365,8 @@
 
 // Script function #34
 int Script::SF_swapActors(R_SCRIPTFUNC_PARAMS) {
+	thread->stack->pop();
+	thread->stack->pop();
 	return R_SUCCESS;
 }
 

Index: sthread.cpp
===================================================================
RCS file: /cvsroot/scummvm/scummvm/saga/sthread.cpp,v
retrieving revision 1.25
retrieving revision 1.26
diff -u -d -r1.25 -r1.26
--- sthread.cpp	19 Sep 2004 14:49:00 -0000	1.25
+++ sthread.cpp	21 Sep 2004 06:35:00 -0000	1.26
@@ -220,11 +220,13 @@
 		saved_offset = thread->i_offset;
 		in_char = scriptS.readByte();
 
-		debug(0, "Executing thread offset: %lu (%x)", thread->i_offset, in_char);
+		debug(0, "Executing thread offset: %lu (%x) stack: %d", thread->i_offset, in_char, thread->stack->size());
 
 		switch (in_char) {
 		case 0x01: // nextblock
-			debug(0, "Stub: opcode 0x01(nextblock)");
+			// Some sort of "jump to the start of the next memory
+			// page" instruction, I think.
+			thread->i_offset = 1024 * ((thread->i_offset / 1024) + 1);
 			break;
 
 // STACK INSTRUCTIONS
@@ -300,14 +302,19 @@
 			// (GOSB): Call subscript ?
 		case 0x17:
 			{
+				int n_args;
 				int temp;
-				int temp2;
 
+				n_args = scriptS.readByte();
 				temp = scriptS.readByte();
-				temp2 = scriptS.readByte();
+				if (temp != 2)
+					error("Calling dynamically generated script? Wow");
 				param1 = (SDataWord_T)scriptS.readUint16LE();
 				data = scriptS.pos();
-				//thread->stack->push((SDataWord_T)temp);
+				thread->stack->push(n_args);
+				// NOTE: The original pushes the program
+				// counter as a pointer here. But I don't think
+				// we will have to do that.
 				thread->stack->push(data);
 				thread->i_offset = (unsigned long)param1;
 			}
@@ -360,6 +367,7 @@
 				thread->executing = 0;
 			} else {
 				data = thread->stack->pop();
+				/* int n_args = */ thread->stack->pop();
 				thread->i_offset = data;
 			}
 			break;





More information about the Scummvm-git-logs mailing list