Fix ruined stack in rm_mult_objs_from_inven and name remaining opcodes (#289)

This commit is contained in:
Vlad 2023-05-23 22:45:18 +02:00 committed by GitHub
parent d641fefc13
commit 61293bd39c
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 43 additions and 43 deletions

View File

@ -87,17 +87,17 @@ static void opLeaveCriticalSection(Program* program);
static void opEnterCriticalSection(Program* program); static void opEnterCriticalSection(Program* program);
static void opJump(Program* program); static void opJump(Program* program);
static void opCall(Program* program); static void opCall(Program* program);
static void op801F(Program* program); static void opPopFlags(Program* program);
static void op801C(Program* program); static void opPopReturn(Program* program);
static void op801D(Program* program); static void opPopExit(Program* program);
static void op8020(Program* program); static void opPopFlagsReturn(Program* program);
static void op8021(Program* program); static void opPopFlagsExit(Program* program);
static void op8025(Program* program); static void opPopFlagsReturnValExit(Program* program);
static void op8026(Program* program); static void opPopFlagsReturnValExitExtern(Program* program);
static void op8022(Program* program); static void opPopFlagsReturnExtern(Program* program);
static void op8023(Program* program); static void opPopFlagsExitExtern(Program* program);
static void op8024(Program* program); static void opPopFlagsReturnValExtern(Program* program);
static void op801E(Program* program); static void opPopAddress(Program* program);
static void opAtoD(Program* program); static void opAtoD(Program* program);
static void opDtoA(Program* program); static void opDtoA(Program* program);
static void opExitProgram(Program* program); static void opExitProgram(Program* program);
@ -2042,7 +2042,7 @@ static void opCall(Program* program)
} }
// 0x46B590 // 0x46B590
static void op801F(Program* program) static void opPopFlags(Program* program)
{ {
program->windowId = programStackPopInteger(program); program->windowId = programStackPopInteger(program);
program->checkWaitFunc = (InterpretCheckWaitFunc*)programStackPopPointer(program); program->checkWaitFunc = (InterpretCheckWaitFunc*)programStackPopPointer(program);
@ -2051,13 +2051,13 @@ static void op801F(Program* program)
// pop stack 2 -> set program address // pop stack 2 -> set program address
// 0x46B63C // 0x46B63C
static void op801C(Program* program) static void opPopReturn(Program* program)
{ {
program->instructionPointer = programReturnStackPopInteger(program); program->instructionPointer = programReturnStackPopInteger(program);
} }
// 0x46B658 // 0x46B658
static void op801D(Program* program) static void opPopExit(Program* program)
{ {
program->instructionPointer = programReturnStackPopInteger(program); program->instructionPointer = programReturnStackPopInteger(program);
@ -2065,37 +2065,37 @@ static void op801D(Program* program)
} }
// 0x46B67C // 0x46B67C
static void op8020(Program* program) static void opPopFlagsReturn(Program* program)
{ {
op801F(program); opPopFlags(program);
program->instructionPointer = programReturnStackPopInteger(program); program->instructionPointer = programReturnStackPopInteger(program);
} }
// 0x46B698 // 0x46B698
static void op8021(Program* program) static void opPopFlagsExit(Program* program)
{ {
op801F(program); opPopFlags(program);
program->instructionPointer = programReturnStackPopInteger(program); program->instructionPointer = programReturnStackPopInteger(program);
program->flags |= PROGRAM_FLAG_0x40; program->flags |= PROGRAM_FLAG_0x40;
} }
// 0x46B6BC // 0x46B6BC
static void op8025(Program* program) static void opPopFlagsReturnValExit(Program* program)
{ {
ProgramValue value = programStackPopValue(program); ProgramValue value = programStackPopValue(program);
op801F(program); opPopFlags(program);
program->instructionPointer = programReturnStackPopInteger(program); program->instructionPointer = programReturnStackPopInteger(program);
program->flags |= PROGRAM_FLAG_0x40; program->flags |= PROGRAM_FLAG_0x40;
programStackPushValue(program, value); programStackPushValue(program, value);
} }
// 0x46B73C // 0x46B73C
static void op8026(Program* program) static void opPopFlagsReturnValExitExtern(Program* program)
{ {
ProgramValue value = programStackPopValue(program); ProgramValue value = programStackPopValue(program);
op801F(program); opPopFlags(program);
Program* v1 = (Program*)programReturnStackPopPointer(program); Program* v1 = (Program*)programReturnStackPopPointer(program);
v1->checkWaitFunc = (InterpretCheckWaitFunc*)programReturnStackPopPointer(program); v1->checkWaitFunc = (InterpretCheckWaitFunc*)programReturnStackPopPointer(program);
@ -2109,9 +2109,9 @@ static void op8026(Program* program)
} }
// 0x46B808 // 0x46B808
static void op8022(Program* program) static void opPopFlagsReturnExtern(Program* program)
{ {
op801F(program); opPopFlags(program);
Program* v1 = (Program*)programReturnStackPopPointer(program); Program* v1 = (Program*)programReturnStackPopPointer(program);
v1->checkWaitFunc = (InterpretCheckWaitFunc*)programReturnStackPopPointer(program); v1->checkWaitFunc = (InterpretCheckWaitFunc*)programReturnStackPopPointer(program);
@ -2121,9 +2121,9 @@ static void op8022(Program* program)
} }
// 0x46B86C // 0x46B86C
static void op8023(Program* program) static void opPopFlagsExitExtern(Program* program)
{ {
op801F(program); opPopFlags(program);
Program* v1 = (Program*)programReturnStackPopPointer(program); Program* v1 = (Program*)programReturnStackPopPointer(program);
v1->checkWaitFunc = (InterpretCheckWaitFunc*)programReturnStackPopPointer(program); v1->checkWaitFunc = (InterpretCheckWaitFunc*)programReturnStackPopPointer(program);
@ -2136,11 +2136,11 @@ static void op8023(Program* program)
// pop value from stack 1 and push it to script popped from stack 2 // pop value from stack 1 and push it to script popped from stack 2
// 0x46B8D8 // 0x46B8D8
static void op8024(Program* program) static void opPopFlagsReturnValExtern(Program* program)
{ {
ProgramValue value = programStackPopValue(program); ProgramValue value = programStackPopValue(program);
op801F(program); opPopFlags(program);
Program* v10 = (Program*)programReturnStackPopPointer(program); Program* v10 = (Program*)programReturnStackPopPointer(program);
v10->checkWaitFunc = (InterpretCheckWaitFunc*)programReturnStackPopPointer(program); v10->checkWaitFunc = (InterpretCheckWaitFunc*)programReturnStackPopPointer(program);
@ -2164,7 +2164,7 @@ static void op8024(Program* program)
} }
// 0x46BA10 // 0x46BA10
static void op801E(Program* program) static void opPopAddress(Program* program)
{ {
programReturnStackPopValue(program); programReturnStackPopValue(program);
} }
@ -2540,17 +2540,17 @@ void interpreterRegisterOpcodeHandlers()
interpreterRegisterOpcode(OPCODE_SWAPA, opSwapReturnStack); interpreterRegisterOpcode(OPCODE_SWAPA, opSwapReturnStack);
interpreterRegisterOpcode(OPCODE_POP, opPop); interpreterRegisterOpcode(OPCODE_POP, opPop);
interpreterRegisterOpcode(OPCODE_DUP, opDuplicate); interpreterRegisterOpcode(OPCODE_DUP, opDuplicate);
interpreterRegisterOpcode(OPCODE_POP_RETURN, op801C); interpreterRegisterOpcode(OPCODE_POP_RETURN, opPopReturn);
interpreterRegisterOpcode(OPCODE_POP_EXIT, op801D); interpreterRegisterOpcode(OPCODE_POP_EXIT, opPopExit);
interpreterRegisterOpcode(OPCODE_POP_ADDRESS, op801E); interpreterRegisterOpcode(OPCODE_POP_ADDRESS, opPopAddress);
interpreterRegisterOpcode(OPCODE_POP_FLAGS, op801F); interpreterRegisterOpcode(OPCODE_POP_FLAGS, opPopFlags);
interpreterRegisterOpcode(OPCODE_POP_FLAGS_RETURN, op8020); interpreterRegisterOpcode(OPCODE_POP_FLAGS_RETURN, opPopFlagsReturn);
interpreterRegisterOpcode(OPCODE_POP_FLAGS_EXIT, op8021); interpreterRegisterOpcode(OPCODE_POP_FLAGS_EXIT, opPopFlagsExit);
interpreterRegisterOpcode(OPCODE_POP_FLAGS_RETURN_EXTERN, op8022); interpreterRegisterOpcode(OPCODE_POP_FLAGS_RETURN_EXTERN, opPopFlagsReturnExtern);
interpreterRegisterOpcode(OPCODE_POP_FLAGS_EXIT_EXTERN, op8023); interpreterRegisterOpcode(OPCODE_POP_FLAGS_EXIT_EXTERN, opPopFlagsExitExtern);
interpreterRegisterOpcode(OPCODE_POP_FLAGS_RETURN_VAL_EXTERN, op8024); interpreterRegisterOpcode(OPCODE_POP_FLAGS_RETURN_VAL_EXTERN, opPopFlagsReturnValExtern);
interpreterRegisterOpcode(OPCODE_POP_FLAGS_RETURN_VAL_EXIT, op8025); interpreterRegisterOpcode(OPCODE_POP_FLAGS_RETURN_VAL_EXIT, opPopFlagsReturnValExit);
interpreterRegisterOpcode(OPCODE_POP_FLAGS_RETURN_VAL_EXIT_EXTERN, op8026); interpreterRegisterOpcode(OPCODE_POP_FLAGS_RETURN_VAL_EXIT_EXTERN, opPopFlagsReturnValExitExtern);
interpreterRegisterOpcode(OPCODE_CHECK_PROCEDURE_ARGUMENT_COUNT, opCheckProcedureArgumentCount); interpreterRegisterOpcode(OPCODE_CHECK_PROCEDURE_ARGUMENT_COUNT, opCheckProcedureArgumentCount);
interpreterRegisterOpcode(OPCODE_LOOKUP_PROCEDURE_BY_NAME, opLookupStringProc); interpreterRegisterOpcode(OPCODE_LOOKUP_PROCEDURE_BY_NAME, opLookupStringProc);
interpreterRegisterOpcode(OPCODE_POP_BASE, opPopBase); interpreterRegisterOpcode(OPCODE_POP_BASE, opPopBase);

View File

@ -3098,8 +3098,7 @@ static void _op_inven_cmds(Program* program)
break; break;
} }
} else { } else {
// FIXME: Should be inven_cmds. scriptPredefinedError(program, "inven_cmds", SCRIPT_ERROR_OBJECT_IS_NULL);
scriptPredefinedError(program, "anim", SCRIPT_ERROR_OBJECT_IS_NULL);
} }
programStackPushPointer(program, item); programStackPushPointer(program, item);
@ -3657,7 +3656,8 @@ static void opRemoveMultipleObjectsFromInventory(Program* program)
Object* owner = static_cast<Object*>(programStackPopPointer(program)); Object* owner = static_cast<Object*>(programStackPopPointer(program));
if (owner == NULL || item == NULL) { if (owner == NULL || item == NULL) {
// FIXME: Ruined stack. scriptPredefinedError(program, "rm_mult_objs_from_inven", SCRIPT_ERROR_OBJECT_IS_NULL);
programStackPushInteger(program, 0);
return; return;
} }