aboutsummaryrefslogtreecommitdiff
path: root/saga/sthread.cpp
diff options
context:
space:
mode:
authorTorbjörn Andersson2004-09-21 06:35:00 +0000
committerTorbjörn Andersson2004-09-21 06:35:00 +0000
commitd49f0b90a0bb870f192689100bbe7a34a96e6fc3 (patch)
tree2a6ea2c73befeb45e6b2c1ace522890953c838cc /saga/sthread.cpp
parent2fdfd35834bd03496357c63dfcf6c4c5c35b2548 (diff)
downloadscummvm-rg350-d49f0b90a0bb870f192689100bbe7a34a96e6fc3.tar.gz
scummvm-rg350-d49f0b90a0bb870f192689100bbe7a34a96e6fc3.tar.bz2
scummvm-rg350-d49f0b90a0bb870f192689100bbe7a34a96e6fc3.zip
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. svn-id: r15215
Diffstat (limited to 'saga/sthread.cpp')
-rw-r--r--saga/sthread.cpp18
1 files changed, 13 insertions, 5 deletions
diff --git a/saga/sthread.cpp b/saga/sthread.cpp
index 623640a922..2c919d9849 100644
--- a/saga/sthread.cpp
+++ b/saga/sthread.cpp
@@ -220,11 +220,13 @@ int Script::SThreadRun(R_SCRIPT_THREAD *thread, int instr_limit, int msec) {
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 @@ int Script::SThreadRun(R_SCRIPT_THREAD *thread, int instr_limit, int msec) {
// (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 @@ int Script::SThreadRun(R_SCRIPT_THREAD *thread, int instr_limit, int msec) {
thread->executing = 0;
} else {
data = thread->stack->pop();
+ /* int n_args = */ thread->stack->pop();
thread->i_offset = data;
}
break;