From ec2560d4bafb8bb6c65ec69cb57233d884274cf3 Mon Sep 17 00:00:00 2001 From: Ryan Dwyer Date: Tue, 8 Oct 2019 22:11:55 +1000 Subject: [PATCH] Decompile aiIfNeverBeenOnScreen --- src/game/chr/chraicommands.c | 42 ++++++++-------------------- src/include/game/chr/chraicommands.h | 2 +- src/setup/setup_000000.c | 2 +- 3 files changed, 13 insertions(+), 33 deletions(-) diff --git a/src/game/chr/chraicommands.c b/src/game/chr/chraicommands.c index c6e7cfa69..1d34d0439 100644 --- a/src/game/chr/chraicommands.c +++ b/src/game/chr/chraicommands.c @@ -1824,37 +1824,17 @@ bool ai0045(void) /** * @cmd 0046 */ -GLOBAL_ASM( -glabel ai0046 -/* f050210: 3c03800a */ lui $v1,0x800a -/* f050214: 24639fc0 */ addiu $v1,$v1,-24640 -/* f050218: 8c6e0424 */ lw $t6,0x424($v1) -/* f05021c: 27bdffe8 */ addiu $sp,$sp,-24 -/* f050220: afbf0014 */ sw $ra,0x14($sp) -/* f050224: 8dcf0018 */ lw $t7,0x18($t6) -/* f050228: 31f80008 */ andi $t8,$t7,0x8 -/* f05022c: 5700000b */ bnezl $t8,.L0f05025c -/* f050230: 8c790438 */ lw $t9,0x438($v1) -/* f050234: 8c640434 */ lw $a0,0x434($v1) -/* f050238: 8c650438 */ lw $a1,0x438($v1) -/* f05023c: 00851021 */ addu $v0,$a0,$a1 -/* f050240: 0fc13583 */ jal chraiGoToLabel -/* f050244: 90460002 */ lbu $a2,0x2($v0) -/* f050248: 3c03800a */ lui $v1,0x800a -/* f05024c: 24639fc0 */ addiu $v1,$v1,-24640 -/* f050250: 10000004 */ beqz $zero,.L0f050264 -/* f050254: ac620438 */ sw $v0,0x438($v1) -/* f050258: 8c790438 */ lw $t9,0x438($v1) -.L0f05025c: -/* f05025c: 27280003 */ addiu $t0,$t9,0x3 -/* f050260: ac680438 */ sw $t0,0x438($v1) -.L0f050264: -/* f050264: 8fbf0014 */ lw $ra,0x14($sp) -/* f050268: 27bd0018 */ addiu $sp,$sp,0x18 -/* f05026c: 00001025 */ or $v0,$zero,$zero -/* f050270: 03e00008 */ jr $ra -/* f050274: 00000000 */ sll $zero,$zero,0x0 -); +bool aiIfNeverBeenOnScreen(void) +{ + if ((g_Vars.chrdata->chrflags & CHRFLAG3_NEVER_BEEN_ON_SCREEN) == 0) { + u8 *cmd = g_Vars.ailist + g_Vars.aioffset; + g_Vars.aioffset = chraiGoToLabel(g_Vars.ailist, g_Vars.aioffset, cmd[2]); + } else { + g_Vars.aioffset += 3; + } + + return false; +} /** * @cmd 0047 diff --git a/src/include/game/chr/chraicommands.h b/src/include/game/chr/chraicommands.h index 815d1de51..79df02973 100644 --- a/src/include/game/chr/chraicommands.h +++ b/src/include/game/chr/chraicommands.h @@ -73,7 +73,7 @@ /*0x0043*/ bool ai0043(void); /*0x0044*/ bool aiIfShotAtCloseRange(void); /*0x0045*/ bool ai0045(void); -/*0x0046*/ bool ai0046(void); +/*0x0046*/ bool aiIfNeverBeenOnScreen(void); /*0x0047*/ bool ai0047(void); /*0x0048*/ bool ai0048(void); /*0x0049*/ bool ai0049(void); diff --git a/src/setup/setup_000000.c b/src/setup/setup_000000.c index 2fd5cff23..1668098ee 100644 --- a/src/setup/setup_000000.c +++ b/src/setup/setup_000000.c @@ -14019,7 +14019,7 @@ bool (*command_pointers[])(void) = { /*0x0043*/ ai0043, /*0x0044*/ aiIfShotAtCloseRange, /*0x0045*/ ai0045, - /*0x0046*/ ai0046, + /*0x0046*/ aiIfNeverBeenOnScreen, /*0x0047*/ ai0047, /*0x0048*/ ai0048, /*0x0049*/ ai0049,