From 50f82ba0f6757c58cf12e28ce6245e63c41701b0 Mon Sep 17 00:00:00 2001 From: Ryan Dwyer Date: Mon, 7 Oct 2019 23:01:46 +1000 Subject: [PATCH] Decompile aiGoToChr --- src/files/setup/setupcave.c | 2 +- src/files/setup/setuprit.c | 2 +- src/game/chr/chraicommands.c | 49 +++++++--------------------- src/include/commands.h | 2 +- src/include/game/chr/chraicommands.h | 2 +- src/setup/ailists.c | 2 +- src/setup/setup_000000.c | 2 +- 7 files changed, 18 insertions(+), 43 deletions(-) diff --git a/src/files/setup/setupcave.c b/src/files/setup/setupcave.c index f31413219..d89dd8159 100644 --- a/src/files/setup/setupcave.c +++ b/src/files/setup/setupcave.c @@ -1277,7 +1277,7 @@ u8 func0407_stewardess[] = { goto_first(0x62) label(0x0f) - chr_try_run_to_target_chr_with_hand_up(0xfb, /*goto*/ 0x49) + try_run_to_chr_with_hand_up(CHR_FRIEND, /*goto*/ 0x49) dprint 'W','A','L','K','F','A','I','L','\n',0, beginloop(0x49) diff --git a/src/files/setup/setuprit.c b/src/files/setup/setuprit.c index 3529c9c23..4a4b2860a 100644 --- a/src/files/setup/setuprit.c +++ b/src/files/setup/setuprit.c @@ -2377,7 +2377,7 @@ u8 func040b_defend_president[] = { if_self_distance_to_chr_lt(200, CHR_PRESIDENT, /*goto*/ 0x06) label(0x03) - chr_try_run_to_target_chr_with_hand_up(CHR_PRESIDENT, /*goto*/ 0x04) + try_run_to_chr_with_hand_up(CHR_PRESIDENT, /*goto*/ 0x04) beginloop(0x04) dprint 'G','O',' ','T','O',' ','P','A','D','\n',0, diff --git a/src/game/chr/chraicommands.c b/src/game/chr/chraicommands.c index c11b00c2f..314680291 100644 --- a/src/game/chr/chraicommands.c +++ b/src/game/chr/chraicommands.c @@ -1301,43 +1301,18 @@ bool ai002e(void) /** * @cmd 002f */ -GLOBAL_ASM( -glabel ai002f -/* f04f55c: 3c03800a */ lui $v1,0x800a -/* f04f560: 24639fc0 */ addiu $v1,$v1,-24640 -/* f04f564: 8c6e0434 */ lw $t6,0x434($v1) -/* f04f568: 8c6f0438 */ lw $t7,0x438($v1) -/* f04f56c: 27bdffe0 */ addiu $sp,$sp,-32 -/* f04f570: afbf0014 */ sw $ra,0x14($sp) -/* f04f574: 01cf3821 */ addu $a3,$t6,$t7 -/* f04f578: 90e50002 */ lbu $a1,0x2($a3) -/* f04f57c: afa7001c */ sw $a3,0x1c($sp) -/* f04f580: 8c640424 */ lw $a0,0x424($v1) -/* f04f584: 0fc0eab2 */ jal func0f03aac8 -/* f04f588: 24060001 */ addiu $a2,$zero,0x1 -/* f04f58c: 3c03800a */ lui $v1,0x800a -/* f04f590: 24639fc0 */ addiu $v1,$v1,-24640 -/* f04f594: 10400009 */ beqz $v0,.L0f04f5bc -/* f04f598: 8fa7001c */ lw $a3,0x1c($sp) -/* f04f59c: 8c640434 */ lw $a0,0x434($v1) -/* f04f5a0: 8c650438 */ lw $a1,0x438($v1) -/* f04f5a4: 0fc13583 */ jal chraiGoToLabel -/* f04f5a8: 90e60003 */ lbu $a2,0x3($a3) -/* f04f5ac: 3c03800a */ lui $v1,0x800a -/* f04f5b0: 24639fc0 */ addiu $v1,$v1,-24640 -/* f04f5b4: 10000004 */ beqz $zero,.L0f04f5c8 -/* f04f5b8: ac620438 */ sw $v0,0x438($v1) -.L0f04f5bc: -/* f04f5bc: 8c780438 */ lw $t8,0x438($v1) -/* f04f5c0: 27190004 */ addiu $t9,$t8,0x4 -/* f04f5c4: ac790438 */ sw $t9,0x438($v1) -.L0f04f5c8: -/* f04f5c8: 8fbf0014 */ lw $ra,0x14($sp) -/* f04f5cc: 27bd0020 */ addiu $sp,$sp,0x20 -/* f04f5d0: 00001025 */ or $v0,$zero,$zero -/* f04f5d4: 03e00008 */ jr $ra -/* f04f5d8: 00000000 */ sll $zero,$zero,0x0 -); +bool aiGoToChr(void) +{ + u8 *cmd = g_Vars.ailist + g_Vars.aioffset; + + if (func0f03aac8(g_Vars.chrdata, cmd[2], 1)) { + g_Vars.aioffset = chraiGoToLabel(g_Vars.ailist, g_Vars.aioffset, cmd[3]); + } else { + g_Vars.aioffset += 4; + } + + return false; +} /** * @cmd 0030 diff --git a/src/include/commands.h b/src/include/commands.h index 32b73ff4d..1de7acfd7 100644 --- a/src/include/commands.h +++ b/src/include/commands.h @@ -180,7 +180,7 @@ mkshort(0x002d), \ label, -#define chr_try_run_to_target_chr_with_hand_up(chr, label) \ +#define try_run_to_chr_with_hand_up(chr, label) \ mkshort(0x002f), \ chr, \ label, diff --git a/src/include/game/chr/chraicommands.h b/src/include/game/chr/chraicommands.h index 8da46e67c..6973aa9c5 100644 --- a/src/include/game/chr/chraicommands.h +++ b/src/include/game/chr/chraicommands.h @@ -50,7 +50,7 @@ /*0x002c*/ bool ai002c(void); /*0x002d*/ bool ai002d(void); /*0x002e*/ bool ai002e(void); -/*0x002f*/ bool ai002f(void); +/*0x002f*/ bool aiGoToChr(void); /*0x0030*/ bool ai0030(void); /*0x0031*/ bool ai0031(void); /*0x0032*/ bool aiIfStopped(void); diff --git a/src/setup/ailists.c b/src/setup/ailists.c index c8cb2b131..83685a3fd 100644 --- a/src/setup/ailists.c +++ b/src/setup/ailists.c @@ -533,7 +533,7 @@ u8 func0006_unalerted[] = { label(0x17) if_self_flag_bankx_eq(CHRFLAG0_CAN_EXAMINE_BODY, FALSE, BANK_0, /*goto*/ 0x7d) - chr_try_run_to_target_chr_with_hand_up(CHR_FRIEND, /*goto*/ 0x7e) + try_run_to_chr_with_hand_up(CHR_FRIEND, /*goto*/ 0x7e) dprint 'W','A','L','K','F','A','I','L','\n',0, beginloop(0x7e) diff --git a/src/setup/setup_000000.c b/src/setup/setup_000000.c index 502de7d82..f243aafc7 100644 --- a/src/setup/setup_000000.c +++ b/src/setup/setup_000000.c @@ -13996,7 +13996,7 @@ bool (*command_pointers[])(void) = { /*0x002c*/ ai002c, /*0x002d*/ ai002d, /*0x002e*/ ai002e, - /*0x002f*/ ai002f, + /*0x002f*/ aiGoToChr, /*0x0030*/ ai0030, /*0x0031*/ ai0031, /*0x0032*/ aiIfStopped,