From f755ba63984b75b526da033ef8f075e4d9bd495c Mon Sep 17 00:00:00 2001 From: Ryan Dwyer Date: Thu, 10 Oct 2019 21:25:52 +1000 Subject: [PATCH] Decompile aiIfTimerStopped --- src/game/chr/chraicommands.c | 41 ++++++++-------------------- src/include/commands.h | 4 +++ src/include/game/chr/chraicommands.h | 2 +- src/setup/setup_000000.c | 2 +- 4 files changed, 18 insertions(+), 31 deletions(-) diff --git a/src/game/chr/chraicommands.c b/src/game/chr/chraicommands.c index 5b7e05662..6058b1660 100644 --- a/src/game/chr/chraicommands.c +++ b/src/game/chr/chraicommands.c @@ -7796,35 +7796,18 @@ bool aiResumeTimer(void) /** * @cmd 00ba */ -GLOBAL_ASM( -glabel ai00ba -/* f055014: 3c03800a */ lui $v1,0x800a -/* f055018: 24639fc0 */ addiu $v1,$v1,-24640 -/* f05501c: 8c6e0424 */ lw $t6,0x424($v1) -/* f055020: 27bdffe8 */ addiu $sp,$sp,-24 -/* f055024: afbf0014 */ sw $ra,0x14($sp) -/* f055028: 8dcf0014 */ lw $t7,0x14($t6) -/* f05502c: 8c640434 */ lw $a0,0x434($v1) -/* f055030: 8c650438 */ lw $a1,0x438($v1) -/* f055034: 31f80040 */ andi $t8,$t7,0x40 -/* f055038: 17000007 */ bnez $t8,.L0f055058 -/* f05503c: 00851021 */ addu $v0,$a0,$a1 -/* f055040: 0fc13583 */ jal chraiGoToLabel -/* f055044: 90460002 */ lbu $a2,0x2($v0) -/* f055048: 3c03800a */ lui $v1,0x800a -/* f05504c: 24639fc0 */ addiu $v1,$v1,-24640 -/* f055050: 10000003 */ beqz $zero,.L0f055060 -/* f055054: ac620438 */ sw $v0,0x438($v1) -.L0f055058: -/* f055058: 24b90003 */ addiu $t9,$a1,0x3 -/* f05505c: ac790438 */ sw $t9,0x438($v1) -.L0f055060: -/* f055060: 8fbf0014 */ lw $ra,0x14($sp) -/* f055064: 27bd0018 */ addiu $sp,$sp,0x18 -/* f055068: 00001025 */ or $v0,$zero,$zero -/* f05506c: 03e00008 */ jr $ra -/* f055070: 00000000 */ sll $zero,$zero,0x0 -); +bool aiIfTimerStopped(void) +{ + u8 *cmd = g_Vars.ailist + g_Vars.aioffset; + + if ((g_Vars.chrdata->hidden & CHRFLAG2_TIMER_RUNNING) == 0) { + g_Vars.aioffset = chraiGoToLabel(g_Vars.ailist, g_Vars.aioffset, cmd[2]); + } else { + g_Vars.aioffset += 3; + } + + return false; +} /** * @cmd 00bb diff --git a/src/include/commands.h b/src/include/commands.h index 4c25acb7e..a422f2c18 100644 --- a/src/include/commands.h +++ b/src/include/commands.h @@ -754,6 +754,10 @@ #define resume_timer \ mkshort(0x00b9), +#define if_timer_stopped(label) \ + mkshort(0x00ba), \ + label, + #define if_timer_gt(value, label) \ mkshort(0x00bd), \ 0x00, \ diff --git a/src/include/game/chr/chraicommands.h b/src/include/game/chr/chraicommands.h index 53a7770f9..8f2ad2d3c 100644 --- a/src/include/game/chr/chraicommands.h +++ b/src/include/game/chr/chraicommands.h @@ -188,7 +188,7 @@ /*0x00b7*/ bool aiResetTimer(void); /*0x00b8*/ bool aiPauseTimer(void); /*0x00b9*/ bool aiResumeTimer(void); -/*0x00ba*/ bool ai00ba(void); +/*0x00ba*/ bool aiIfTimerStopped(void); /*0x00bb*/ bool ai00bb(void); /*0x00bc*/ bool ai00bc(void); /*0x00bd*/ bool ai00bd(void); diff --git a/src/setup/setup_000000.c b/src/setup/setup_000000.c index 447e17ddc..d2012955b 100644 --- a/src/setup/setup_000000.c +++ b/src/setup/setup_000000.c @@ -14135,7 +14135,7 @@ bool (*command_pointers[])(void) = { /*0x00b7*/ aiResetTimer, /*0x00b8*/ aiPauseTimer, /*0x00b9*/ aiResumeTimer, - /*0x00ba*/ ai00ba, + /*0x00ba*/ aiIfTimerStopped, /*0x00bb*/ ai00bb, /*0x00bc*/ ai00bc, /*0x00bd*/ ai00bd,