[Scummvm-git-logs] scummvm master -> 75fe5b5024d8532b0f84fa220391b58806d23ba8

dreammaster paulfgilbert at gmail.com
Sat Jun 15 05:12:03 CEST 2019


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

Summary:
75fe5b5024 GLK: ADVSYS: Script interpreter fixes


Commit: 75fe5b5024d8532b0f84fa220391b58806d23ba8
    https://github.com/scummvm/scummvm/commit/75fe5b5024d8532b0f84fa220391b58806d23ba8
Author: Paul Gilbert (dreammaster at scummvm.org)
Date: 2019-06-14T20:11:47-07:00

Commit Message:
GLK: ADVSYS: Script interpreter fixes

Changed paths:
    engines/glk/advsys/vm.cpp
    engines/glk/advsys/vm.h


diff --git a/engines/glk/advsys/vm.cpp b/engines/glk/advsys/vm.cpp
index e21c5ac..b1ba7a0 100644
--- a/engines/glk/advsys/vm.cpp
+++ b/engines/glk/advsys/vm.cpp
@@ -106,6 +106,12 @@ void VM::executeOpcode() {
 	// Get next opcode
 	uint opcode = readCodeByte();
 
+	if (gDebugLevel > 0) {
+		Common::String s;
+		for (int idx = (int)_stack.size() - 1; idx >= 0; --idx) s += Common::String::format("  %d", _stack[idx]);
+		debug("%.4x - %.2x - %d%s", _pc - 1, opcode, _stack.size(), s.c_str());
+	}
+
 	if (opcode >= OP_BRT && opcode <= OP_VOWEL) {
 		(this->*_METHODS[(int)opcode - 1])();
 	} else if (opcode >= OP_XVAR && opcode < OP_XSET) {
@@ -256,7 +262,7 @@ void VM::opEXIT() {
 }
 
 void VM::opRETURN() {
-	if (_stack.empty()) {
+	if (_fp == 0) {
 		_status = CHAIN;
 	} else {
 		int val = _stack.top();
@@ -314,18 +320,16 @@ void VM::opRESTORE() {
 
 void VM::opARG() {
 	int argNum = readCodeByte();
-	int varsSize = _stack[_fp - 3];
-	if (argNum >= varsSize)
+	if (argNum >= _fp[FP_ARGS_SIZE])
 		error("Invalid argument number");
-	_stack.top() = _stack[_fp - 4 - argNum];
+	_stack.top() = _fp[argNum + FP_ARGS];
 }
 
 void VM::opASET() {
 	int argNum = readCodeByte();
-	int varsSize = _stack[_fp - 3];
-	if (argNum >= varsSize)
+	if (argNum >= _fp[FP_ARGS_SIZE])
 		error("Invalid argument number");
-	_stack[_fp - 4 - argNum] = _stack.top();
+	_fp[argNum + FP_ARGS] = _stack.top();
 }
 
 void VM::opTMP() {
diff --git a/engines/glk/advsys/vm.h b/engines/glk/advsys/vm.h
index 76f05de..5868917 100644
--- a/engines/glk/advsys/vm.h
+++ b/engines/glk/advsys/vm.h
@@ -253,7 +253,9 @@ private:
 	 * Gets the next code word and increases the PC counter to after it
 	 */
 	int readCodeWord() {
-		return getCodeWord(_pc += 2);
+		int v = getCodeWord(_pc);
+		_pc += 2;
+		return v;
 	}
 
 	/**





More information about the Scummvm-git-logs mailing list