[Scummvm-cvs-logs] scummvm master -> 413394585037996b8c4afe60ac4e868d5aacca55

bluegr md5 at scummvm.org
Mon Mar 28 03:47:30 CEST 2011


This automated email contains information about 3 new commits which have been
pushed to the 'scummvm' repo located at https://github.com/scummvm/scummvm .

Summary:
76b68bf88c SCI: Set the GC_INTERVAL define to its hexadecimal equivalent
9adae61df3 SCI: Error out when kMemorySegment() is requested to save more than 256 bytes
4133945850 SCI: Renamed restAdjust to r_rest (like r_acc and r_prev)


Commit: 76b68bf88cf91c2b114f2f0682b602ac339bf073
    https://github.com/scummvm/scummvm/commit/76b68bf88cf91c2b114f2f0682b602ac339bf073
Author: md5 (md5 at scummvm.org)
Date: 2011-03-27T16:23:56-07:00

Commit Message:
SCI: Set the GC_INTERVAL define to its hexadecimal equivalent

Changed paths:
    engines/sci/engine/vm.h



diff --git a/engines/sci/engine/vm.h b/engines/sci/engine/vm.h
index 9ff332d..5947579 100644
--- a/engines/sci/engine/vm.h
+++ b/engines/sci/engine/vm.h
@@ -139,7 +139,7 @@ enum {
 
 /** Number of kernel calls in between gcs; should be < 50000 */
 enum {
-	GC_INTERVAL = 32768
+	GC_INTERVAL = 0x8000
 };
 
 // Opcode formats


Commit: 9adae61df3372e6cfdac97e65a6b7573bf18ae00
    https://github.com/scummvm/scummvm/commit/9adae61df3372e6cfdac97e65a6b7573bf18ae00
Author: md5 (md5 at scummvm.org)
Date: 2011-03-27T16:23:57-07:00

Commit Message:
SCI: Error out when kMemorySegment() is requested to save more than 256 bytes

Changed paths:
    engines/sci/engine/kmisc.cpp



diff --git a/engines/sci/engine/kmisc.cpp b/engines/sci/engine/kmisc.cpp
index 723aece..907e0ba 100644
--- a/engines/sci/engine/kmisc.cpp
+++ b/engines/sci/engine/kmisc.cpp
@@ -151,8 +151,13 @@ reg_t kMemorySegment(EngineState *s, int argc, reg_t *argv) {
 		if (!size)
 			size = s->_segMan->strlen(argv[1]) + 1;
 
-		if (size > EngineState::kMemorySegmentMax)
-			size = EngineState::kMemorySegmentMax;
+		if (size > EngineState::kMemorySegmentMax) {
+			// This was set to cut the block to 256 bytes. This should be an
+			// error, as we won't restore the full block that the game scripts
+			// request, thus error out instead.
+			//size = EngineState::kMemorySegmentMax;
+			error("kMemorySegment: Requested to save more than 256 bytes (%d)", size);
+		}
 
 		s->_memorySegmentSize = size;
 


Commit: 413394585037996b8c4afe60ac4e868d5aacca55
    https://github.com/scummvm/scummvm/commit/413394585037996b8c4afe60ac4e868d5aacca55
Author: md5 (md5 at scummvm.org)
Date: 2011-03-27T16:23:58-07:00

Commit Message:
SCI: Renamed restAdjust to r_rest (like r_acc and r_prev)

Changed paths:
    engines/sci/console.cpp
    engines/sci/engine/scriptdebug.cpp
    engines/sci/engine/state.cpp
    engines/sci/engine/state.h
    engines/sci/engine/vm.cpp
    engines/sci/sci.cpp



diff --git a/engines/sci/console.cpp b/engines/sci/console.cpp
index e2e5ee9..7c351c6 100644
--- a/engines/sci/console.cpp
+++ b/engines/sci/console.cpp
@@ -633,7 +633,7 @@ bool Console::cmdSetParseNodes(int argc, const char **argv) {
 bool Console::cmdRegisters(int argc, const char **argv) {
 	EngineState *s = _engine->_gamestate;
 	DebugPrintf("Current register values:\n");
-	DebugPrintf("acc=%04x:%04x prev=%04x:%04x &rest=%x\n", PRINT_REG(s->r_acc), PRINT_REG(s->r_prev), s->restAdjust);
+	DebugPrintf("acc=%04x:%04x prev=%04x:%04x &rest=%x\n", PRINT_REG(s->r_acc), PRINT_REG(s->r_prev), s->r_rest);
 
 	if (!s->_executionStack.empty()) {
 		DebugPrintf("pc=%04x:%04x obj=%04x:%04x fp=ST:%04x sp=ST:%04x\n",
diff --git a/engines/sci/engine/scriptdebug.cpp b/engines/sci/engine/scriptdebug.cpp
index 857b074..596494d 100644
--- a/engines/sci/engine/scriptdebug.cpp
+++ b/engines/sci/engine/scriptdebug.cpp
@@ -208,12 +208,12 @@ reg_t disassemble(EngineState *s, reg_t pos, bool printBWTag, bool printBytecode
 
 	if (pos == s->xs->addr.pc) { // Extra information if debugging the current opcode
 		if (opcode == op_callk) {
-			int stackframe = (scr[pos.offset + 2] >> 1) + (s->restAdjust);
+			int stackframe = (scr[pos.offset + 2] >> 1) + (s->r_rest);
 			int argc = ((s->xs->sp)[- stackframe - 1]).offset;
 			bool oldScriptHeader = (getSciVersion() == SCI_VERSION_0_EARLY);
 
 			if (!oldScriptHeader)
-				argc += (s->restAdjust);
+				argc += (s->r_rest);
 
 			debugN(" Kernel params: (");
 
@@ -224,7 +224,7 @@ reg_t disassemble(EngineState *s, reg_t pos, bool printBWTag, bool printBytecode
 			}
 			debugN(")\n");
 		} else if ((opcode == op_send) || (opcode == op_self)) {
-			int restmod = s->restAdjust;
+			int restmod = s->r_rest;
 			int stackframe = (scr[pos.offset + 1] >> 1) + restmod;
 			reg_t *sb = s->xs->sp;
 			uint16 selector;
diff --git a/engines/sci/engine/state.cpp b/engines/sci/engine/state.cpp
index 12795ad..f9d6c70 100644
--- a/engines/sci/engine/state.cpp
+++ b/engines/sci/engine/state.cpp
@@ -94,10 +94,9 @@ void EngineState::reset(bool isRestoring) {
 	stack_base = 0;
 	stack_top = 0;
 
-	restAdjust = 0;
-
 	r_acc = NULL_REG;
 	r_prev = NULL_REG;
+	r_rest = 0;
 
 	lastWaitTime = 0;
 
diff --git a/engines/sci/engine/state.h b/engines/sci/engine/state.h
index 861182f..d91118e 100644
--- a/engines/sci/engine/state.h
+++ b/engines/sci/engine/state.h
@@ -183,9 +183,10 @@ public:
 	int executionStackBase;
 	bool _executionStackPosChanged;   /**< Set to true if the execution stack position should be re-evaluated by the vm */
 
+	// Registers
 	reg_t r_acc; /**< Accumulator */
-	int16 restAdjust; /**< current &rest register */
 	reg_t r_prev; /**< previous comparison result */
+	int16 r_rest; /**< current &rest register */
 
 	StackPtr stack_base; /**< Pointer to the least stack element */
 	StackPtr stack_top; /**< First invalid stack element */
@@ -226,7 +227,7 @@ public:
 	enum {
 		kMemorySegmentMax = 256
 	};
-	uint _memorySegmentSize;
+	uint16 _memorySegmentSize;
 	byte _memorySegment[kMemorySegmentMax];
 
 	VideoState _videoState;
diff --git a/engines/sci/engine/vm.cpp b/engines/sci/engine/vm.cpp
index f1e1980..496efb6 100644
--- a/engines/sci/engine/vm.cpp
+++ b/engines/sci/engine/vm.cpp
@@ -84,10 +84,9 @@ static reg_t &validate_property(EngineState *s, Object *obj, int index) {
 static StackPtr validate_stack_addr(EngineState *s, StackPtr sp) {
 	if (sp >= s->stack_base && sp < s->stack_top)
 		return sp;
-
+	else
 	error("[VM] Stack index %d out of valid range [%d..%d]",
 		(int)(sp - s->stack_base), 0, (int)(s->stack_top - s->stack_base - 1));
-	return 0;
 }
 
 static bool validate_variable(reg_t *r, reg_t *stack_base, int type, int max, int index) {
@@ -553,7 +552,7 @@ void run_vm(EngineState *s) {
 	StackPtr s_temp; // Temporary stack pointer
 	int16 opparams[4]; // opcode parameters
 
-	s->restAdjust = 0;	// &rest adjusts the parameter count by this value
+	s->r_rest = 0;	// &rest adjusts the parameter count by this value
 	// Current execution data:
 	s->xs = &(s->_executionStack.back());
 	ExecStack *xs_new = NULL;
@@ -826,14 +825,14 @@ void run_vm(EngineState *s) {
 		case op_call: { // 0x20 (32)
 			// Call a script subroutine
 			int argc = (opparams[1] >> 1) // Given as offset, but we need count
-			           + 1 + s->restAdjust;
+			           + 1 + s->r_rest;
 			StackPtr call_base = s->xs->sp - argc;
-			s->xs->sp[1].offset += s->restAdjust;
+			s->xs->sp[1].offset += s->r_rest;
 
 			uint16 localCallOffset = s->xs->addr.pc.offset + opparams[0];
 
 			ExecStack xstack(s->xs->objp, s->xs->objp, s->xs->sp, 
-							(call_base->requireUint16()) + s->restAdjust, call_base,
+							(call_base->requireUint16()) + s->r_rest, call_base,
 							s->xs->local_segment, make_reg(s->xs->addr.pc.segment, localCallOffset),
 							NULL_SELECTOR, -1, localCallOffset, s->_executionStack.size() - 1, 
 							EXEC_STACK_TYPE_CALL);
@@ -841,7 +840,7 @@ void run_vm(EngineState *s) {
 			s->_executionStack.push_back(xstack);
 			xs_new = &(s->_executionStack.back());
 
-			s->restAdjust = 0; // Used up the &rest adjustment
+			s->r_rest = 0; // Used up the &rest adjustment
 			s->xs->sp = call_base;
 
 			s->_executionStackPosChanged = true;
@@ -860,17 +859,17 @@ void run_vm(EngineState *s) {
 
 			bool oldScriptHeader = (getSciVersion() == SCI_VERSION_0_EARLY);
 			if (!oldScriptHeader)
-				s->xs->sp -= s->restAdjust;
+				s->xs->sp -= s->r_rest;
 
 			int argc = s->xs->sp[0].requireUint16();
 
 			if (!oldScriptHeader)
-				argc += s->restAdjust;
+				argc += s->r_rest;
 
 			callKernelFunc(s, opparams[0], argc);
 
 			if (!oldScriptHeader)
-				s->restAdjust = 0;
+				s->r_rest = 0;
 
 			// Calculate xs again: The kernel function might
 			// have spawned a new VM
@@ -887,28 +886,28 @@ void run_vm(EngineState *s) {
 
 		case op_callb: // 0x22 (34)
 			// Call base script
-			temp = ((opparams[1] >> 1) + s->restAdjust + 1);
+			temp = ((opparams[1] >> 1) + s->r_rest + 1);
 			s_temp = s->xs->sp;
 			s->xs->sp -= temp;
 
-			s->xs->sp[0].offset += s->restAdjust;
+			s->xs->sp[0].offset += s->r_rest;
 			xs_new = execute_method(s, 0, opparams[0], s_temp, s->xs->objp,
 									s->xs->sp[0].offset, s->xs->sp);
-			s->restAdjust = 0; // Used up the &rest adjustment
+			s->r_rest = 0; // Used up the &rest adjustment
 			if (xs_new)    // in case of error, keep old stack
 				s->_executionStackPosChanged = true;
 			break;
 
 		case op_calle: // 0x23 (35)
 			// Call external script
-			temp = ((opparams[2] >> 1) + s->restAdjust + 1);
+			temp = ((opparams[2] >> 1) + s->r_rest + 1);
 			s_temp = s->xs->sp;
 			s->xs->sp -= temp;
 
-			s->xs->sp[0].offset += s->restAdjust;
+			s->xs->sp[0].offset += s->r_rest;
 			xs_new = execute_method(s, opparams[0], opparams[1], s_temp, s->xs->objp,
 									s->xs->sp[0].offset, s->xs->sp);
-			s->restAdjust = 0; // Used up the &rest adjustment
+			s->r_rest = 0; // Used up the &rest adjustment
 
 			if (xs_new)  // in case of error, keep old stack
 				s->_executionStackPosChanged = true;
@@ -960,16 +959,16 @@ void run_vm(EngineState *s) {
 		case op_send: // 0x25 (37)
 			// Send for one or more selectors
 			s_temp = s->xs->sp;
-			s->xs->sp -= ((opparams[0] >> 1) + s->restAdjust); // Adjust stack
+			s->xs->sp -= ((opparams[0] >> 1) + s->r_rest); // Adjust stack
 
-			s->xs->sp[1].offset += s->restAdjust;
+			s->xs->sp[1].offset += s->r_rest;
 			xs_new = send_selector(s, s->r_acc, s->r_acc, s_temp,
-									(int)(opparams[0] >> 1) + (uint16)s->restAdjust, s->xs->sp);
+									(int)(opparams[0] >> 1) + (uint16)s->r_rest, s->xs->sp);
 
 			if (xs_new && xs_new != s->xs)
 				s->_executionStackPosChanged = true;
 
-			s->restAdjust = 0;
+			s->r_rest = 0;
 
 			break;
 
@@ -1003,17 +1002,17 @@ void run_vm(EngineState *s) {
 		case op_self: // 0x2a (42)
 			// Send to self
 			s_temp = s->xs->sp;
-			s->xs->sp -= ((opparams[0] >> 1) + s->restAdjust); // Adjust stack
+			s->xs->sp -= ((opparams[0] >> 1) + s->r_rest); // Adjust stack
 
-			s->xs->sp[1].offset += s->restAdjust;
+			s->xs->sp[1].offset += s->r_rest;
 			xs_new = send_selector(s, s->xs->objp, s->xs->objp,
-									s_temp, (int)(opparams[0] >> 1) + (uint16)s->restAdjust,
+									s_temp, (int)(opparams[0] >> 1) + (uint16)s->r_rest,
 									s->xs->sp);
 
 			if (xs_new && xs_new != s->xs)
 				s->_executionStackPosChanged = true;
 
-			s->restAdjust = 0;
+			s->r_rest = 0;
 			break;
 
 		case op_super: // 0x2b (43)
@@ -1024,17 +1023,17 @@ void run_vm(EngineState *s) {
 				error("[VM]: Invalid superclass in object");
 			else {
 				s_temp = s->xs->sp;
-				s->xs->sp -= ((opparams[1] >> 1) + s->restAdjust); // Adjust stack
+				s->xs->sp -= ((opparams[1] >> 1) + s->r_rest); // Adjust stack
 
-				s->xs->sp[1].offset += s->restAdjust;
+				s->xs->sp[1].offset += s->r_rest;
 				xs_new = send_selector(s, r_temp, s->xs->objp, s_temp,
-										(int)(opparams[1] >> 1) + (uint16)s->restAdjust,
+										(int)(opparams[1] >> 1) + (uint16)s->r_rest,
 										s->xs->sp);
 
 				if (xs_new && xs_new != s->xs)
 					s->_executionStackPosChanged = true;
 
-				s->restAdjust = 0;
+				s->r_rest = 0;
 			}
 
 			break;
@@ -1042,7 +1041,7 @@ void run_vm(EngineState *s) {
 		case op_rest: // 0x2c (44)
 			// Pushes all or part of the parameter variable list on the stack
 			temp = (uint16) opparams[0]; // First argument
-			s->restAdjust = MAX<int16>(s->xs->argc - temp + 1, 0); // +1 because temp counts the paramcount while argc doesn't
+			s->r_rest = MAX<int16>(s->xs->argc - temp + 1, 0); // +1 because temp counts the paramcount while argc doesn't
 
 			for (; temp <= s->xs->argc; temp++)
 				PUSH32(s->xs->variables_argp[temp]);
diff --git a/engines/sci/sci.cpp b/engines/sci/sci.cpp
index bcbb005..85c2ece 100644
--- a/engines/sci/sci.cpp
+++ b/engines/sci/sci.cpp
@@ -575,9 +575,8 @@ bool SciEngine::initGame() {
 	}
 
 	// Reset parser
-	if (_vocabulary) {
+	if (_vocabulary)
 		_vocabulary->reset();
-	}
 
 	_gamestate->lastWaitTime = _gamestate->_screenUpdateTime = g_system->getMillis();
 






More information about the Scummvm-git-logs mailing list