aboutsummaryrefslogtreecommitdiff
path: root/saga
diff options
context:
space:
mode:
authorAndrew Kurushin2005-01-21 23:44:34 +0000
committerAndrew Kurushin2005-01-21 23:44:34 +0000
commit93a64d3ebd238e7e456c87ea9d12f3042df3e59b (patch)
tree9d010bda3d20ca29cf70caa583f500c2f35c80b4 /saga
parent1e07013f7f7b62247ce3d6af8f5d7dd09ea5c303 (diff)
downloadscummvm-rg350-93a64d3ebd238e7e456c87ea9d12f3042df3e59b.tar.gz
scummvm-rg350-93a64d3ebd238e7e456c87ea9d12f3042df3e59b.tar.bz2
scummvm-rg350-93a64d3ebd238e7e456c87ea9d12f3042df3e59b.zip
some opcode fixes:
opReturnV svn-id: r16609
Diffstat (limited to 'saga')
-rw-r--r--saga/sthread.cpp25
1 files changed, 15 insertions, 10 deletions
diff --git a/saga/sthread.cpp b/saga/sthread.cpp
index 029841dac5..d4be516628 100644
--- a/saga/sthread.cpp
+++ b/saga/sthread.cpp
@@ -181,7 +181,6 @@ void Script::runThread(ScriptThread *thread, uint instructionLimit) {
ScriptFunctionType scriptFunction;
uint16 data;
- uint16 scriptRetVal = 0;
int debug_print = 0;
int n_buf;
// int bitstate;
@@ -338,21 +337,21 @@ void Script::runThread(ScriptThread *thread, uint instructionLimit) {
break;
}
- if (operandChar == opCcall) // CALL function
+ if (operandChar == opCcall) {// CALL function
thread->push(thread->_returnValue);
+ }
if (thread->_flags & kTFlagAsleep)
instructionCount = instructionLimit; // break out of loop!
break;
- case opEnter: // Enter a function
+ CASEOP(opEnter)
thread->push(thread->_frameIndex);
thread->_frameIndex = thread->_stackTopIndex;
thread->_stackTopIndex -= (scriptS.readUint16LE() / 2);
break;
- case opReturn: // Return with value
- scriptRetVal = thread->pop();
- // Fall through
- case opReturnV: // Return with void
+ CASEOP(opReturn)
+ thread->_returnValue = thread->pop();
+ CASEOP(opReturnV)
thread->_stackTopIndex = thread->_frameIndex;
thread->_frameIndex = thread->pop();
if (thread->pushedSize() == 0) {
@@ -361,9 +360,15 @@ void Script::runThread(ScriptThread *thread, uint instructionLimit) {
return;
} else {
thread->_instructionOffset = thread->pop();
- /* int n_args = */ thread->pop();
- if (operandChar == opReturn)
- thread->push(scriptRetVal);
+ param1 = thread->pop();
+ param1 +=param1;
+ while (param1--) {
+ thread->pop();
+ }
+
+ if (operandChar == opReturn) {
+ thread->push(thread->_returnValue);
+ }
}
break;