From a9b8a6fffc870f344878e21e1c2164290bc148d7 Mon Sep 17 00:00:00 2001 From: Ryan Dwyer Date: Sat, 19 Oct 2019 16:19:21 +1000 Subject: [PATCH] Decompile aiIfChannelIdle --- src/game/chr/chraicommands.c | 48 ++++++++-------------------- src/include/game/chr/chraicommands.h | 2 +- src/setup/setup_000000.c | 2 +- 3 files changed, 15 insertions(+), 37 deletions(-) diff --git a/src/game/chr/chraicommands.c b/src/game/chr/chraicommands.c index d39fcde7f..d740d39a2 100644 --- a/src/game/chr/chraicommands.c +++ b/src/game/chr/chraicommands.c @@ -8237,41 +8237,19 @@ bool aiAudioMuteChannel(void) /** * @cmd 0138 */ -GLOBAL_ASM( -glabel ai0138 -/* f056324: 3c03800a */ lui $v1,0x800a -/* f056328: 24639fc0 */ addiu $v1,$v1,-24640 -/* f05632c: 8c6e0434 */ lw $t6,0x434($v1) -/* f056330: 8c6f0438 */ lw $t7,0x438($v1) -/* f056334: 27bdffe0 */ addiu $sp,$sp,-32 -/* f056338: afbf0014 */ sw $ra,0x14($sp) -/* f05633c: 01cf3821 */ addu $a3,$t6,$t7 -/* f056340: 80e40002 */ lb $a0,0x2($a3) -/* f056344: 0fc250ef */ jal func0f0943bc -/* f056348: afa7001c */ sw $a3,0x1c($sp) -/* f05634c: 3c03800a */ lui $v1,0x800a -/* f056350: 24639fc0 */ addiu $v1,$v1,-24640 -/* f056354: 10400009 */ beqz $v0,.L0f05637c -/* f056358: 8fa7001c */ lw $a3,0x1c($sp) -/* f05635c: 8c640434 */ lw $a0,0x434($v1) -/* f056360: 8c650438 */ lw $a1,0x438($v1) -/* f056364: 0fc13583 */ jal chraiGoToLabel -/* f056368: 90e60003 */ lbu $a2,0x3($a3) -/* f05636c: 3c03800a */ lui $v1,0x800a -/* f056370: 24639fc0 */ addiu $v1,$v1,-24640 -/* f056374: 10000004 */ beqz $zero,.L0f056388 -/* f056378: ac620438 */ sw $v0,0x438($v1) -.L0f05637c: -/* f05637c: 8c780438 */ lw $t8,0x438($v1) -/* f056380: 27190004 */ addiu $t9,$t8,0x4 -/* f056384: ac790438 */ sw $t9,0x438($v1) -.L0f056388: -/* f056388: 8fbf0014 */ lw $ra,0x14($sp) -/* f05638c: 27bd0020 */ addiu $sp,$sp,0x20 -/* f056390: 00001025 */ or $v0,$zero,$zero -/* f056394: 03e00008 */ jr $ra -/* f056398: 00000000 */ sll $zero,$zero,0x0 -); +bool aiIfChannelIdle(void) +{ + u8 *cmd = g_Vars.ailist + g_Vars.aioffset; + s8 channel = (s8) cmd[2]; + + if (func0f0943bc(channel)) { + g_Vars.aioffset = chraiGoToLabel(g_Vars.ailist, g_Vars.aioffset, cmd[3]); + } else { + g_Vars.aioffset += 4; + } + + return false; +} /** * @cmd 00d1 diff --git a/src/include/game/chr/chraicommands.h b/src/include/game/chr/chraicommands.h index 22713bfbc..4fc107e4f 100644 --- a/src/include/game/chr/chraicommands.h +++ b/src/include/game/chr/chraicommands.h @@ -310,7 +310,7 @@ /*0x0135*/ bool ai0135(void); /*0x0136*/ bool ai0136(void); /*0x0137*/ bool ai0137(void); -/*0x0138*/ bool ai0138(void); +/*0x0138*/ bool aiIfChannelIdle(void); /*0x0139*/ bool ai0139(void); /*0x013a*/ bool ai013a(void); /*0x013b*/ bool ai013b(void); diff --git a/src/setup/setup_000000.c b/src/setup/setup_000000.c index 94a69e4d0..5b59d8c99 100644 --- a/src/setup/setup_000000.c +++ b/src/setup/setup_000000.c @@ -14265,7 +14265,7 @@ bool (*command_pointers[])(void) = { /*0x0135*/ ai0135, /*0x0136*/ ai0136, /*0x0137*/ ai0137, - /*0x0138*/ ai0138, + /*0x0138*/ aiIfChannelIdle, /*0x0139*/ ai0139, /*0x013a*/ ai013a, /*0x013b*/ ai013b,