decomped GroundScript_ExecuteTrigger

This commit is contained in:
Seth Barberee 2024-08-15 01:32:36 -07:00
parent 3438e615f3
commit 3bfc80f8f7
3 changed files with 37 additions and 71 deletions

View File

@ -5,73 +5,6 @@
.text
thumb_func_start GroundScript_ExecuteTrigger
GroundScript_ExecuteTrigger:
push {r4,r5,lr}
sub sp, 0xF4
lsls r0, 16
asrs r4, r0, 16
lsls r0, r4, 1
adds r0, r4
lsls r0, 2
ldr r1, _080A14C8
adds r0, r1
movs r1, 0x2
ldrsh r0, [r0, r1]
cmp r0, 0xB
bne _080A14C4
add r5, sp, 0x10
ldr r1, _080A14CC
movs r0, 0
str r0, [sp]
adds r0, r5, 0
movs r2, 0
movs r3, 0
bl InitActionWithParams
movs r0, 0
add r1, sp, 0x4
adds r2, r4, 0
bl sub_809D710
ldr r3, _080A14D0
adds r0, r5, 0
movs r1, 0
add r2, sp, 0x4
bl GroundScript_ExecutePP
add r1, sp, 0x44
add r0, sp, 0x38
ldm r0!, {r2-r4}
stm r1!, {r2-r4}
ldr r0, _080A14D4
str r0, [r5, 0x34]
str r0, [r5, 0x38]
ldr r1, _080A14D8
adds r0, r5, 0
bl HandleAction
adds r4, r0, 0
lsls r4, 16
asrs r4, 16
adds r0, r5, 0
bl sub_809D648
cmp r4, 0
beq _080A14DC
_080A14C4:
movs r0, 0
b _080A14DE
.align 2, 0
_080A14C8: .4byte gFunctionScriptTable
_080A14CC: .4byte gUnknown_8116488
_080A14D0: .4byte gUnknown_81166F8
_080A14D4: .4byte gUnknown_81164E4
_080A14D8: .4byte gUnknown_8116704
_080A14DC:
movs r0, 0x1
_080A14DE:
add sp, 0xF4
pop {r4,r5}
pop {r1}
bx r1
thumb_func_end GroundScript_ExecuteTrigger
thumb_func_start sub_80A14E8
sub_80A14E8:
push {r4-r7,lr}

View File

@ -129,7 +129,8 @@ typedef struct GroundMapAction
typedef struct FunctionScript
{
u32 unk0;
u16 unk0;
s16 unk2;
u8 *funcName;
ScriptCommand *script;
} FunctionScript;

View File

@ -182,6 +182,11 @@ void DeleteBlankGroundLives(void);
void DeleteBlankGroundObjects(void);
void DeleteBlankGroundEffects(void);
u32 sub_80A14E8(u32, u8, u32, u32);
extern void InitActionWithParams(Action *action, const CallbackData *callbacks, void *parent, s16 group, s8 sector);
s16 HandleAction(void *, DebugLocation *);
extern void sub_809D648(void *);
extern int gFormatData_202DE30[10];
extern s16 gCurrentMap;
@ -205,8 +210,11 @@ extern char gUnknown_8116684[];
extern char gUnknown_81166C0[];
extern char gUnknown_81166D8[];
extern const CallbackData gUnknown_8116488;
extern DebugLocation gUnknown_81166B4;
extern DebugLocation gUnknown_81166F8;
extern DebugLocation gUnknown_8116704;
extern ScriptCommand gUnknown_81164E4;
// Return values:
// This function returns what's likely an enum, which controls the state of the script engine state machine, and possibly provides information to code calling the engine.
@ -1871,9 +1879,33 @@ s32 ExecuteScriptCommand(Action *action) {
}
}
u32 sub_80A14E8(u32, u8, u32, u32);
UNUSED u32 sub_80A1440(u32 r0, u32 r1, u32 r2)
{
return sub_80A14E8(0, r0, r1, r2);
}
UNUSED bool8 GroundScript_ExecuteTrigger(s16 r0)
{
s32 ret;
ScriptInfoSmall scriptInfo;
Action action;
FunctionScript *ptr;
ptr = &gFunctionScriptTable[r0];
if(ptr->unk2 != 0xB)
return FALSE;
InitActionWithParams(&action, &gUnknown_8116488, NULL, 0, 0);
sub_809D710(NULL, &scriptInfo, r0);
GroundScript_ExecutePP(&action, NULL, &scriptInfo, &gUnknown_81166F8);
action.scriptData.savedScript = action.scriptData.script;
action.scriptData.savedScript.ptr = &gUnknown_81164E4;
action.scriptData.savedScript.ptr2 = &gUnknown_81164E4;
ret = HandleAction(&action, &gUnknown_8116704);
sub_809D648(&action);
if(ret == 0)
return TRUE;
else
return FALSE;
}