From 4e68fb74796d257329839980a00d9d871995ae6c Mon Sep 17 00:00:00 2001 From: Ryan Dwyer Date: Tue, 8 Oct 2019 20:13:35 +1000 Subject: [PATCH] Decompile aiIfSeesPlayer --- src/game/chr/chraicommands.c | 57 ++++++---------------------- src/include/game/chr/chraicommands.h | 2 +- src/setup/setup_000000.c | 2 +- 3 files changed, 14 insertions(+), 47 deletions(-) diff --git a/src/game/chr/chraicommands.c b/src/game/chr/chraicommands.c index 1a894a6a1..7ce6046a1 100644 --- a/src/game/chr/chraicommands.c +++ b/src/game/chr/chraicommands.c @@ -1596,51 +1596,18 @@ bool aiIfSawDeath(void) /** * @cmd 003f */ -GLOBAL_ASM( -glabel ai003f -/* f04fdc8: 27bdffe0 */ addiu $sp,$sp,-32 -/* f04fdcc: afb00018 */ sw $s0,0x18($sp) -/* f04fdd0: 3c10800a */ lui $s0,0x800a -/* f04fdd4: 26109fc0 */ addiu $s0,$s0,-24640 -/* f04fdd8: 8e040424 */ lw $a0,0x424($s0) -/* f04fddc: afbf001c */ sw $ra,0x1c($sp) -/* f04fde0: 50800006 */ beqzl $a0,.L0f04fdfc -/* f04fde4: 8e040430 */ lw $a0,0x430($s0) -/* f04fde8: 0fc0e4da */ jal func0f039368 -/* f04fdec: 00000000 */ sll $zero,$zero,0x0 -/* f04fdf0: 5440000d */ bnezl $v0,.L0f04fe28 -/* f04fdf4: 8e040434 */ lw $a0,0x434($s0) -/* f04fdf8: 8e040430 */ lw $a0,0x430($s0) -.L0f04fdfc: -/* f04fdfc: 50800011 */ beqzl $a0,.L0f04fe44 -/* f04fe00: 8e0e0438 */ lw $t6,0x438($s0) -/* f04fe04: 0fc1eb86 */ jal func0f07ae18 -/* f04fe08: 24050040 */ addiu $a1,$zero,0x40 -/* f04fe0c: 5040000d */ beqzl $v0,.L0f04fe44 -/* f04fe10: 8e0e0438 */ lw $t6,0x438($s0) -/* f04fe14: 0fc1ebcd */ jal func0f07af34 -/* f04fe18: 8e040430 */ lw $a0,0x430($s0) -/* f04fe1c: 50400009 */ beqzl $v0,.L0f04fe44 -/* f04fe20: 8e0e0438 */ lw $t6,0x438($s0) -/* f04fe24: 8e040434 */ lw $a0,0x434($s0) -.L0f04fe28: -/* f04fe28: 8e050438 */ lw $a1,0x438($s0) -/* f04fe2c: 00851021 */ addu $v0,$a0,$a1 -/* f04fe30: 0fc13583 */ jal chraiGoToLabel -/* f04fe34: 90460002 */ lbu $a2,0x2($v0) -/* f04fe38: 10000004 */ beqz $zero,.L0f04fe4c -/* f04fe3c: ae020438 */ sw $v0,0x438($s0) -/* f04fe40: 8e0e0438 */ lw $t6,0x438($s0) -.L0f04fe44: -/* f04fe44: 25cf0003 */ addiu $t7,$t6,0x3 -/* f04fe48: ae0f0438 */ sw $t7,0x438($s0) -.L0f04fe4c: -/* f04fe4c: 8fbf001c */ lw $ra,0x1c($sp) -/* f04fe50: 8fb00018 */ lw $s0,0x18($sp) -/* f04fe54: 27bd0020 */ addiu $sp,$sp,0x20 -/* f04fe58: 03e00008 */ jr $ra -/* f04fe5c: 00001025 */ or $v0,$zero,$zero -); +bool aiIfSeesPlayer(void) +{ + if ((g_Vars.chrdata && func0f039368(g_Vars.chrdata)) || + (g_Vars.aiddata && func0f07ae18(g_Vars.aiddata, 0x40) && func0f07af34(g_Vars.aiddata))) { + 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 017a diff --git a/src/include/game/chr/chraicommands.h b/src/include/game/chr/chraicommands.h index 0e201a876..e06c39d40 100644 --- a/src/include/game/chr/chraicommands.h +++ b/src/include/game/chr/chraicommands.h @@ -66,7 +66,7 @@ /*0x003c*/ bool ai003c(void); /*0x003d*/ bool ai003d(void); /*0x003e*/ bool aiIfSawDeath(void); -/*0x003f*/ bool ai003f(void); +/*0x003f*/ bool aiIfSeesPlayer(void); /*0x0040*/ bool ai0040(void); /*0x0041*/ bool ai0041(void); /*0x0042*/ bool ai0042(void); diff --git a/src/setup/setup_000000.c b/src/setup/setup_000000.c index 11eed0936..b9216a3b3 100644 --- a/src/setup/setup_000000.c +++ b/src/setup/setup_000000.c @@ -14012,7 +14012,7 @@ bool (*command_pointers[])(void) = { /*0x003c*/ ai003c, /*0x003d*/ ai003d, /*0x003e*/ aiIfSawDeath, - /*0x003f*/ ai003f, + /*0x003f*/ aiIfSeesPlayer, /*0x0040*/ ai0040, /*0x0041*/ ai0041, /*0x0042*/ ai0042,