From 57de503a23837cdd43dbf414b4c5b1ba74840a42 Mon Sep 17 00:00:00 2001 From: Ryan Dwyer Date: Thu, 10 Oct 2019 19:04:04 +1000 Subject: [PATCH] Decompile aiSetRoomToSearch --- src/game/chr/chraicommands.c | 42 +++++++++------------------- src/include/commands.h | 3 +- src/include/game/chr/chraicommands.h | 2 +- src/include/types.h | 4 +-- src/setup/setup_000000.c | 2 +- 5 files changed, 19 insertions(+), 34 deletions(-) diff --git a/src/game/chr/chraicommands.c b/src/game/chr/chraicommands.c index fa04b28fb..c734906ce 100644 --- a/src/game/chr/chraicommands.c +++ b/src/game/chr/chraicommands.c @@ -1813,7 +1813,7 @@ bool ai0045(void) u8 *cmd = g_Vars.ailist + g_Vars.aioffset; struct chrdata *chr = chrFindById(g_Vars.chrdata, cmd[2]); - if (chr && chr->pos && func0f0393b4(g_Vars.chrdata, &chr->pos->coord, &chr->pos->unk28)) { + if (chr && chr->pos && func0f0393b4(g_Vars.chrdata, &chr->pos->coord, &chr->pos->room)) { g_Vars.aioffset = chraiGoToLabel(g_Vars.ailist, g_Vars.aioffset, cmd[3]); } else { g_Vars.aioffset += 4; @@ -18369,34 +18369,18 @@ bool aiSetChrSpecialDeathAnimation(void) /** * @cmd 01a1 */ -GLOBAL_ASM( -glabel ai01a1 -/* f05daac: 27bdffe8 */ addiu $sp,$sp,-24 -/* f05dab0: 3c06800a */ lui $a2,0x800a -/* f05dab4: 24c69fc0 */ addiu $a2,$a2,-24640 -/* f05dab8: afbf0014 */ sw $ra,0x14($sp) -/* f05dabc: 8cc40424 */ lw $a0,0x424($a2) -/* f05dac0: 0fc126d1 */ jal chrFindById -/* f05dac4: 240500f6 */ addiu $a1,$zero,0xf6 -/* f05dac8: 3c06800a */ lui $a2,0x800a -/* f05dacc: 10400007 */ beqz $v0,.L0f05daec -/* f05dad0: 24c69fc0 */ addiu $a2,$a2,-24640 -/* f05dad4: 8c43001c */ lw $v1,0x1c($v0) -/* f05dad8: 50600005 */ beqzl $v1,.L0f05daf0 -/* f05dadc: 8cd80438 */ lw $t8,0x438($a2) -/* f05dae0: 846e0028 */ lh $t6,0x28($v1) -/* f05dae4: 8ccf0424 */ lw $t7,0x424($a2) -/* f05dae8: a5ee0330 */ sh $t6,0x330($t7) -.L0f05daec: -/* f05daec: 8cd80438 */ lw $t8,0x438($a2) -.L0f05daf0: -/* f05daf0: 8fbf0014 */ lw $ra,0x14($sp) -/* f05daf4: 27bd0018 */ addiu $sp,$sp,0x18 -/* f05daf8: 27190002 */ addiu $t9,$t8,0x2 -/* f05dafc: acd90438 */ sw $t9,0x438($a2) -/* f05db00: 03e00008 */ jr $ra -/* f05db04: 00001025 */ or $v0,$zero,$zero -); +bool aiSetRoomToSearch(void) +{ + struct chrdata *target = chrFindById(g_Vars.chrdata, TARGET_CHR); + + if (target && target->pos) { + g_Vars.chrdata->roomtosearch = target->pos->room; + } + + g_Vars.aioffset += 2; + + return false; +} /** * @cmd 01a2 diff --git a/src/include/commands.h b/src/include/commands.h index 1de7acfd7..4c25acb7e 100644 --- a/src/include/commands.h +++ b/src/include/commands.h @@ -1574,7 +1574,8 @@ chr, \ anim, -// Copies the room from the chr's position struct into the chr struct itself +// Sets the chr's roomtosearch field +// to the same room that the chr's target is in. #define set_chr_roomtosearch \ mkshort(0x01a1), diff --git a/src/include/game/chr/chraicommands.h b/src/include/game/chr/chraicommands.h index b1cbc7be0..667a0c11a 100644 --- a/src/include/game/chr/chraicommands.h +++ b/src/include/game/chr/chraicommands.h @@ -384,7 +384,7 @@ /*0x019e*/ bool aiIfObjHealthLessThan(void); /*0x019f*/ bool aiSetObjHealth(void); /*0x01a0*/ bool aiSetChrSpecialDeathAnimation(void); -/*0x01a1*/ bool ai01a1(void); +/*0x01a1*/ bool aiSetRoomToSearch(void); /*0x01a2*/ bool ai01a2(void); /*0x01a3*/ bool ai01a3(void); /*0x01a4*/ bool ai01a4(void); diff --git a/src/include/types.h b/src/include/types.h index e886352af..2868052fd 100644 --- a/src/include/types.h +++ b/src/include/types.h @@ -14,7 +14,7 @@ struct coord { struct position { u8 unk00; u8 flags; - u16 room; + u16 unk02; u32 unk04; struct coord coord; u32 unk14; @@ -22,7 +22,7 @@ struct position { u32 unk1c; u32 unk20; u32 unk24; - u32 unk28; + s16 room; }; struct chrdata { diff --git a/src/setup/setup_000000.c b/src/setup/setup_000000.c index 21441de57..662afc2da 100644 --- a/src/setup/setup_000000.c +++ b/src/setup/setup_000000.c @@ -14366,7 +14366,7 @@ bool (*command_pointers[])(void) = { /*0x019e*/ aiIfObjHealthLessThan, /*0x019f*/ aiSetObjHealth, /*0x01a0*/ aiSetChrSpecialDeathAnimation, - /*0x01a1*/ ai01a1, + /*0x01a1*/ aiSetRoomToSearch, /*0x01a2*/ ai01a2, /*0x01a3*/ ai01a3, /*0x01a4*/ ai01a4,