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

thebluegr at users.sourceforge.net thebluegr at users.sourceforge.net
Sat Jul 11 08:19:29 CEST 2009


Revision: 42371
          http://scummvm.svn.sourceforge.net/scummvm/?rev=42371&view=rev
Author:   thebluegr
Date:     2009-07-11 06:19:29 +0000 (Sat, 11 Jul 2009)

Log Message:
-----------
Fixed regression in the script parser from commit 42260

Modified Paths:
--------------
    scummvm/trunk/engines/sci/console.cpp
    scummvm/trunk/engines/sci/debug.h
    scummvm/trunk/engines/sci/engine/scriptdebug.cpp
    scummvm/trunk/engines/sci/engine/vm.cpp

Modified: scummvm/trunk/engines/sci/console.cpp
===================================================================
--- scummvm/trunk/engines/sci/console.cpp	2009-07-11 05:14:42 UTC (rev 42370)
+++ scummvm/trunk/engines/sci/console.cpp	2009-07-11 06:19:29 UTC (rev 42371)
@@ -545,7 +545,7 @@
 
 bool Console::cmdRegisters(int argc, const char **argv) {
 	DebugPrintf("Current register values:\n");
-	DebugPrintf("acc=%04x:%04x prev=%04x:%04x &rest=%x\n", PRINT_REG(_vm->_gamestate->r_acc), PRINT_REG(_vm->_gamestate->r_prev), scriptState.restadjust);
+	DebugPrintf("acc=%04x:%04x prev=%04x:%04x &rest=%x\n", PRINT_REG(_vm->_gamestate->r_acc), PRINT_REG(_vm->_gamestate->r_prev), scriptState.restAdjust);
 
 	if (!_vm->_gamestate->_executionStack.empty()) {
 		EngineState *s = _vm->_gamestate;	// for PRINT_STK
@@ -3226,11 +3226,6 @@
 int c_stepover(EngineState *s, const Common::Array<cmd_param_t> &cmdParams) {
 	int opcode, opnumber;
 
-	if (!g_debugstate_valid) {
-		printf("Not in debug state\n");
-		return 1;
-	}
-
 	opcode = s->_heap[*p_pc];
 	opnumber = opcode >> 1;
 	if (opnumber == 0x22 /* callb */ || opnumber == 0x23 /* calle */ ||

Modified: scummvm/trunk/engines/sci/debug.h
===================================================================
--- scummvm/trunk/engines/sci/debug.h	2009-07-11 05:14:42 UTC (rev 42370)
+++ scummvm/trunk/engines/sci/debug.h	2009-07-11 06:19:29 UTC (rev 42371)
@@ -46,7 +46,7 @@
 	int old_pc_offset;
 	StackPtr old_sp;
 	ExecStack *xs;
-	int16 restadjust;
+	int16 restAdjust;
 	reg_t *variables[4];		// global, local, temp, param, as immediate pointers
 	reg_t *variables_base[4];	// Used for referencing VM ops
 	SegmentId variables_seg[4];	// Same as above, contains segment IDs

Modified: scummvm/trunk/engines/sci/engine/scriptdebug.cpp
===================================================================
--- scummvm/trunk/engines/sci/engine/scriptdebug.cpp	2009-07-11 05:14:42 UTC (rev 42370)
+++ scummvm/trunk/engines/sci/engine/scriptdebug.cpp	2009-07-11 06:19:29 UTC (rev 42371)
@@ -235,11 +235,11 @@
 
 	if (pos == scriptState.xs->addr.pc) { // Extra information if debugging the current opcode
 		if (opcode == op_callk) {
-			int stackframe = (scr[pos.offset + 2] >> 1) + (scriptState.restadjust);
+			int stackframe = (scr[pos.offset + 2] >> 1) + (scriptState.restAdjust);
 			int argc = ((scriptState.xs->sp)[- stackframe - 1]).offset;
 
 			if (!s->_kernel->hasOldScriptHeader())
-				argc += (scriptState.restadjust);
+				argc += (scriptState.restAdjust);
 
 			printf(" Kernel params: (");
 
@@ -250,7 +250,7 @@
 			}
 			printf(")\n");
 		} else if ((opcode == op_send) || (opcode == op_self)) {
-			int restmod = scriptState.restadjust;
+			int restmod = scriptState.restAdjust;
 			int stackframe = (scr[pos.offset + 1] >> 1) + restmod;
 			reg_t *sb = scriptState.xs->sp;
 			uint16 selector;

Modified: scummvm/trunk/engines/sci/engine/vm.cpp
===================================================================
--- scummvm/trunk/engines/sci/engine/vm.cpp	2009-07-11 05:14:42 UTC (rev 42370)
+++ scummvm/trunk/engines/sci/engine/vm.cpp	2009-07-11 06:19:29 UTC (rev 42371)
@@ -552,7 +552,7 @@
 	StackPtr s_temp; // Temporary stack pointer
 	int16 opparams[4]; // opcode parameters
 
-	scriptState.restadjust = s->restAdjust;
+	scriptState.restAdjust = s->restAdjust;
 	// &rest adjusts the parameter count by this value
 	// Current execution data:
 	scriptState.xs = &(s->_executionStack.back());
@@ -931,17 +931,17 @@
 
 		case 0x20: { // call
 			int argc = (opparams[1] >> 1) // Given as offset, but we need count
-			           + 1 + scriptState.restadjust;
+			           + 1 + scriptState.restAdjust;
 			StackPtr call_base = scriptState.xs->sp - argc;
-			scriptState.xs->sp[1].offset += scriptState.restadjust;
+			scriptState.xs->sp[1].offset += scriptState.restAdjust;
 
-			xs_new = add_exec_stack_entry(s, make_reg(scriptState.xs->addr.pc.segment, 
-										  scriptState.xs->addr.pc.offset + opparams[0]),
-			                              scriptState.xs->sp, scriptState.xs->objp,
-										  (validate_arithmetic(*call_base)) + scriptState.restadjust,
-			                              call_base, NULL_SELECTOR, scriptState.xs->objp, 
-										  s->_executionStack.size()-1, scriptState.xs->local_segment);
-			scriptState.restadjust = 0; // Used up the &rest adjustment
+			xs_new = add_exec_stack_entry(s, make_reg(scriptState.xs->addr.pc.segment,
+											scriptState.xs->addr.pc.offset + opparams[0]),
+											scriptState.xs->sp, scriptState.xs->objp, 
+											(validate_arithmetic(*call_base)) + scriptState.restAdjust,
+											call_base, NULL_SELECTOR, scriptState.xs->objp,
+											s->_executionStack.size()-1, scriptState.xs->local_segment);
+			scriptState.restAdjust = 0; // Used up the &rest adjustment
 			scriptState.xs->sp = call_base;
 
 			s->_executionStackPosChanged = true;
@@ -953,8 +953,8 @@
 
 			scriptState.xs->sp -= (opparams[1] >> 1) + 1;
 			if (!s->_kernel->hasOldScriptHeader()) {
-				scriptState.xs->sp -= scriptState.restadjust;
-				s->restAdjust = 0; // We just used up the restadjust, remember?
+				scriptState.xs->sp -= scriptState.restAdjust;
+				s->restAdjust = 0; // We just used up the scriptState.restAdjust, remember?
 			}
 
 			if (opparams[0] >= (int)s->_kernel->_kernelFuncs.size()) {
@@ -963,15 +963,15 @@
 				int argc = ASSERT_ARITHMETIC(scriptState.xs->sp[0]);
 
 				if (!s->_kernel->hasOldScriptHeader())
-					argc += scriptState.restadjust;
+					argc += scriptState.restAdjust;
 
 				if (s->_kernel->_kernelFuncs[opparams[0]].signature
-				        && !kernel_matches_signature(s, 
-							s->_kernel->_kernelFuncs[opparams[0]].signature, argc, 
-							scriptState.xs->sp + 1)) {
+						&& !kernel_matches_signature(s,
+						s->_kernel->_kernelFuncs[opparams[0]].signature, argc,
+						scriptState.xs->sp + 1)) {
 					error("[VM] Invalid arguments to kernel call %x\n", opparams[0]);
 				} else {
-					s->r_acc = s->_kernel->_kernelFuncs[opparams[0]].fun(s, opparams[0], 
+					s->r_acc = s->_kernel->_kernelFuncs[opparams[0]].fun(s, opparams[0],
 														argc, scriptState.xs->sp + 1);
 				}
 				// Call kernel function
@@ -983,33 +983,33 @@
 				s->_executionStackPosChanged = true;
 
 				if (!s->_kernel->hasOldScriptHeader())
-					scriptState.restadjust = s->restAdjust;
+					scriptState.restAdjust = s->restAdjust;
 
 			}
 			break;
 
 		case 0x22: // callb
-			temp = ((opparams[1] >> 1) + scriptState.restadjust + 1);
+			temp = ((opparams[1] >> 1) + scriptState.restAdjust + 1);
 			s_temp = scriptState.xs->sp;
 			scriptState.xs->sp -= temp;
 
-			scriptState.xs->sp[0].offset += scriptState.restadjust;
-			xs_new = execute_method(s, 0, opparams[0], s_temp, scriptState.xs->objp, 
+			scriptState.xs->sp[0].offset += scriptState.restAdjust;
+			xs_new = execute_method(s, 0, opparams[0], s_temp, scriptState.xs->objp,
 									scriptState.xs->sp[0].offset, scriptState.xs->sp);
-			scriptState.restadjust = 0; // Used up the &rest adjustment
+			scriptState.restAdjust = 0; // Used up the &rest adjustment
 			if (xs_new)    // in case of error, keep old stack
 				s->_executionStackPosChanged = true;
 			break;
 
 		case 0x23: // calle
-			temp = ((opparams[2] >> 1) + scriptState.restadjust + 1);
+			temp = ((opparams[2] >> 1) + scriptState.restAdjust + 1);
 			s_temp = scriptState.xs->sp;
 			scriptState.xs->sp -= temp;
 
-			scriptState.xs->sp[0].offset += scriptState.restadjust;
-			xs_new = execute_method(s, opparams[0], opparams[1], s_temp, scriptState.xs->objp, 
+			scriptState.xs->sp[0].offset += scriptState.restAdjust;
+			xs_new = execute_method(s, opparams[0], opparams[1], s_temp, scriptState.xs->objp,
 									scriptState.xs->sp[0].offset, scriptState.xs->sp);
-			scriptState.restadjust = 0; // Used up the &rest adjustment
+			scriptState.restAdjust = 0; // Used up the &rest adjustment
 
 			if (xs_new)  // in case of error, keep old stack
 				s->_executionStackPosChanged = true;
@@ -1027,7 +1027,7 @@
 					s->_executionStack.pop_back();
 
 					s->_executionStackPosChanged = true;
-					s->restAdjust = scriptState.restadjust; // Update &rest
+					s->restAdjust = scriptState.restAdjust; // Update &rest
 					return; // "Hard" return
 				}
 
@@ -1059,37 +1059,37 @@
 
 		case 0x25: // send
 			s_temp = scriptState.xs->sp;
-			scriptState.xs->sp -= ((opparams[0] >> 1) + scriptState.restadjust); // Adjust stack
+			scriptState.xs->sp -= ((opparams[0] >> 1) + scriptState.restAdjust); // Adjust stack
 
-			scriptState.xs->sp[1].offset += scriptState.restadjust;
-			xs_new = send_selector(s, s->r_acc, s->r_acc, s_temp, 
-					(int)(opparams[0] >> 1) + scriptState.restadjust, scriptState.xs->sp);
+			scriptState.xs->sp[1].offset += scriptState.restAdjust;
+			xs_new = send_selector(s, s->r_acc, s->r_acc, s_temp,
+									(int)(opparams[0] >> 1) + (uint16)scriptState.restAdjust, scriptState.xs->sp);
 
 			if (xs_new && xs_new != scriptState.xs)
 				s->_executionStackPosChanged = true;
 
-			scriptState.restadjust = 0;
+			scriptState.restAdjust = 0;
 
 			break;
 
 		case 0x28: // class
-			s->r_acc = get_class_address(s, (unsigned)opparams[0], SCRIPT_GET_LOCK, 
+			s->r_acc = get_class_address(s, (unsigned)opparams[0], SCRIPT_GET_LOCK,
 											scriptState.xs->addr.pc);
 			break;
 
 		case 0x2a: // self
 			s_temp = scriptState.xs->sp;
-			scriptState.xs->sp -= ((opparams[0] >> 1) + scriptState.restadjust); // Adjust stack
+			scriptState.xs->sp -= ((opparams[0] >> 1) + scriptState.restAdjust); // Adjust stack
 
-			scriptState.xs->sp[1].offset += scriptState.restadjust;
-			xs_new = send_selector(s, scriptState.xs->objp, scriptState.xs->objp, 
-									s_temp, (int)(opparams[0] >> 1) + scriptState.restadjust, 
+			scriptState.xs->sp[1].offset += scriptState.restAdjust;
+			xs_new = send_selector(s, scriptState.xs->objp, scriptState.xs->objp,
+									s_temp, (int)(opparams[0] >> 1) + (uint16)scriptState.restAdjust,
 									scriptState.xs->sp);
 
 			if (xs_new && xs_new != scriptState.xs)
 				s->_executionStackPosChanged = true;
 
-			scriptState.restadjust = 0;
+			scriptState.restAdjust = 0;
 			break;
 
 		case 0x2b: // super
@@ -1099,24 +1099,24 @@
 				error("[VM]: Invalid superclass in object");
 			else {
 				s_temp = scriptState.xs->sp;
-				scriptState.xs->sp -= ((opparams[1] >> 1) + scriptState.restadjust); // Adjust stack
+				scriptState.xs->sp -= ((opparams[1] >> 1) + scriptState.restAdjust); // Adjust stack
 
-				scriptState.xs->sp[1].offset += scriptState.restadjust;
-				xs_new = send_selector(s, r_temp, scriptState.xs->objp, s_temp, 
-										(int)(opparams[1] >> 1) + scriptState.restadjust, 
+				scriptState.xs->sp[1].offset += scriptState.restAdjust;
+				xs_new = send_selector(s, r_temp, scriptState.xs->objp, s_temp,
+										(int)(opparams[1] >> 1) + (uint16)scriptState.restAdjust,
 										scriptState.xs->sp);
 
 				if (xs_new && xs_new != scriptState.xs)
 					s->_executionStackPosChanged = true;
 
-				scriptState.restadjust = 0;
+				scriptState.restAdjust = 0;
 			}
 
 			break;
 
 		case 0x2c: // &rest
 			temp = (uint16) opparams[0]; // First argument
-			scriptState.restadjust = MAX<uint16>(scriptState.xs->argc - temp + 1, 0); // +1 because temp counts the paramcount while argc doesn't
+			scriptState.restAdjust = MAX<int16>(scriptState.xs->argc - temp + 1, 0); // +1 because temp counts the paramcount while argc doesn't
 
 			for (; temp <= scriptState.xs->argc; temp++)
 				PUSH32(scriptState.xs->variables_argp[temp]);


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