From 0e132ce687c601f65fafbbf2f9909e756e2f1106 Mon Sep 17 00:00:00 2001 From: Ethan Roseman Date: Sun, 18 Oct 2020 21:20:07 -0400 Subject: [PATCH] si_handle_bind_:lock: --- include/common_structs.h | 2 +- src/si.c | 50 +++++++++++++++++++++++++++++++--------- 2 files changed, 40 insertions(+), 12 deletions(-) diff --git a/include/common_structs.h b/include/common_structs.h index 0974e618f5..a42c9b9bbe 100644 --- a/include/common_structs.h +++ b/include/common_structs.h @@ -1131,7 +1131,7 @@ typedef struct TriggerDefinition { /* 0x10 */ char unk_10[4]; /* 0x14 */ s32 unk_14; /* 0x18 */ s32 inputArg3; - /* 0x1C */ char unk_1C[4]; + /* 0x1C */ s32 unk_1C; } TriggerDefinition; // size = 0x20 typedef struct CollisionStatus { diff --git a/src/si.c b/src/si.c index 0e26386890..8190e5365e 100644 --- a/src/si.c +++ b/src/si.c @@ -954,30 +954,30 @@ s32 _bound_script_trigger_handler(Trigger* trigger) { ApiStatus si_handle_bind(ScriptInstance* script) { Bytecode* args = script->ptrReadPos; Trigger* trigger; - s32 var0 = get_variable(script, *args++); - Bytecode flags = *args++; - Bytecode index = *args++; + Bytecode* triggerScript = get_variable(script, *args++); + Bytecode eventType = *args++; + Bytecode colliderIDVar = *args++; Bytecode a3 = *args++; - Bytecode a4 = *args++; + Bytecode triggerOut = *args++; TriggerDefinition def; - def.flags = flags | 0x1000000; - def.flagIndex = get_variable(script, index); - def.colliderIndex = get_variable_index(script, index); + def.flags = eventType | 0x1000000; + def.flagIndex = get_variable(script, colliderIDVar); + def.colliderIndex = get_variable_index(script, colliderIDVar); def.inputArg3 = a3; def.unk_14 = 0; def.function = _bound_script_trigger_handler; trigger = create_trigger(&def); - trigger->scriptStart = var0; + trigger->scriptStart = triggerScript; trigger->runningScript = NULL; trigger->priority = script->priority; trigger->scriptVars[0] = get_variable(script, script->varTable[0]); trigger->scriptVars[1] = get_variable(script, script->varTable[1]); trigger->scriptVars[2] = get_variable(script, script->varTable[2]); - if (a4 != 0) { - set_variable(script, a4, trigger); + if (triggerOut != 0) { + set_variable(script, triggerOut, trigger); } return ApiStatus_DONE2; @@ -1069,7 +1069,35 @@ void si_standard_trigger_executor(Trigger* trigger) { } } -INCLUDE_ASM(s32, "si", si_handle_bind_lock, ScriptInstance* script, s32 isInitialCall); +ApiStatus si_handle_bind_lock(ScriptInstance *script) { + Bytecode* args = script->ptrReadPos; + Trigger* trigger; + Bytecode* triggerScript = get_variable(script, *args++); + Bytecode eventType = *args++; + Bytecode colliderIDVar = *args++; + s32* itemList = get_variable(script, *args++); + Bytecode triggerOut = *args++; + s32 a5 = *args++; + TriggerDefinition def; + + def.flags = eventType | 0x1000000; + def.flagIndex = get_variable(script, colliderIDVar); + def.colliderIndex = get_variable_index(script, colliderIDVar); + def.unk_1C = itemList; + def.function = si_standard_trigger_executor; + def.unk_14 = triggerOut; + def.inputArg3 = a5; + + trigger = create_trigger(&def); + trigger->scriptStart = triggerScript; + trigger->runningScript = NULL; + trigger->priority = script->priority; + trigger->scriptVars[0] = get_variable(script, script->varTable[0]); + trigger->scriptVars[1] = get_variable(script, script->varTable[1]); + trigger->scriptVars[2] = get_variable(script, script->varTable[2]); + + return ApiStatus_DONE2; +} INCLUDE_ASM(s32, "si", si_handle_thread, ScriptInstance* script, s32 isInitialCall);