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
This commit is contained in:
parent
2fdfd35834
commit
d49f0b90a0
2 changed files with 17 additions and 5 deletions
|
@ -251,6 +251,8 @@ int Script::SF_faceTowards(R_SCRIPTFUNC_PARAMS) {
|
|||
|
||||
// Script function #15
|
||||
int Script::SF_setFollower(R_SCRIPTFUNC_PARAMS) {
|
||||
thread->stack->pop();
|
||||
thread->stack->pop();
|
||||
return R_SUCCESS;
|
||||
}
|
||||
|
||||
|
@ -363,6 +365,8 @@ int Script::SF_moveTo(R_SCRIPTFUNC_PARAMS) {
|
|||
|
||||
// Script function #34
|
||||
int Script::SF_swapActors(R_SCRIPTFUNC_PARAMS) {
|
||||
thread->stack->pop();
|
||||
thread->stack->pop();
|
||||
return R_SUCCESS;
|
||||
}
|
||||
|
||||
|
|
|
@ -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;
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue