From 9f573c2aeac41f5ebbb1011fbce6be41e5d0e5dc Mon Sep 17 00:00:00 2001 From: Ryan Dwyer Date: Sun, 20 Oct 2019 13:33:16 +1000 Subject: [PATCH] Decompile aiIfKillCountGreaterThan --- src/game/chr/chraicommands.c | 41 ++++++++-------------------- src/include/game/chr/chraicommands.h | 2 +- src/include/gvars/gvars.h | 2 +- src/setup/setup_000000.c | 2 +- 4 files changed, 15 insertions(+), 32 deletions(-) diff --git a/src/game/chr/chraicommands.c b/src/game/chr/chraicommands.c index 192eb1c2a..bb3646f56 100644 --- a/src/game/chr/chraicommands.c +++ b/src/game/chr/chraicommands.c @@ -10420,35 +10420,18 @@ bool aiChrExplosions(void) /** * @cmd 00fc */ -GLOBAL_ASM( -glabel ai00fc -/* f058788: 3c03800a */ lui $v1,0x800a -/* f05878c: 24639fc0 */ addiu $v1,$v1,-24640 -/* f058790: 8c640434 */ lw $a0,0x434($v1) -/* f058794: 8c650438 */ lw $a1,0x438($v1) -/* f058798: 27bdffe8 */ addiu $sp,$sp,-24 -/* f05879c: afbf0014 */ sw $ra,0x14($sp) -/* f0587a0: 00851021 */ addu $v0,$a0,$a1 -/* f0587a4: 904e0002 */ lbu $t6,0x2($v0) -/* f0587a8: 8c6f02b0 */ lw $t7,0x2b0($v1) -/* f0587ac: 24b80004 */ addiu $t8,$a1,0x4 -/* f0587b0: 01cf082a */ slt $at,$t6,$t7 -/* f0587b4: 50200008 */ beqzl $at,.L0f0587d8 -/* f0587b8: ac780438 */ sw $t8,0x438($v1) -/* f0587bc: 0fc13583 */ jal chraiGoToLabel -/* f0587c0: 90460003 */ lbu $a2,0x3($v0) -/* f0587c4: 3c03800a */ lui $v1,0x800a -/* f0587c8: 24639fc0 */ addiu $v1,$v1,-24640 -/* f0587cc: 10000002 */ beqz $zero,.L0f0587d8 -/* f0587d0: ac620438 */ sw $v0,0x438($v1) -/* f0587d4: ac780438 */ sw $t8,0x438($v1) -.L0f0587d8: -/* f0587d8: 8fbf0014 */ lw $ra,0x14($sp) -/* f0587dc: 27bd0018 */ addiu $sp,$sp,0x18 -/* f0587e0: 00001025 */ or $v0,$zero,$zero -/* f0587e4: 03e00008 */ jr $ra -/* f0587e8: 00000000 */ sll $zero,$zero,0x0 -); +bool aiIfKillCountGreaterThan(void) +{ + u8 *cmd = g_Vars.ailist + g_Vars.aioffset; + + if (g_Vars.killcount > cmd[2]) { + g_Vars.aioffset = chraiGoToLabel(g_Vars.ailist, g_Vars.aioffset, cmd[3]); + } else { + g_Vars.aioffset += 4; + } + + return false; +} /** * @cmd 01ab diff --git a/src/include/game/chr/chraicommands.h b/src/include/game/chr/chraicommands.h index 2be94d2b1..96f620c94 100644 --- a/src/include/game/chr/chraicommands.h +++ b/src/include/game/chr/chraicommands.h @@ -252,7 +252,7 @@ /*0x00f9*/ bool aiAudioPlayXMusic(void); /*0x00fa*/ bool aiAudioStopChannel(void); /*0x00fb*/ bool aiChrExplosions(void); -/*0x00fc*/ bool ai00fc(void); +/*0x00fc*/ bool aiIfKillCountGreaterThan(void); /*0x00fd*/ bool ai00fd(void); /*0x00fe*/ bool ai00fe(void); /*0x00ff*/ bool ai00ff(void); diff --git a/src/include/gvars/gvars.h b/src/include/gvars/gvars.h index afbbf41e5..89fda27ff 100644 --- a/src/include/gvars/gvars.h +++ b/src/include/gvars/gvars.h @@ -187,7 +187,7 @@ struct g_vars { /*0002a4*/ struct player *coop; // Co-op buddy when controlled by human /*0002a8*/ struct player *anti; // Counter-op /*0002ac*/ u32 unk0002ac; - /*0002b0*/ u32 unk0002b0; + /*0002b0*/ s32 killcount; /*0002b4*/ u32 unk0002b4; /*0002b8*/ u32 unk0002b8; /*0002bc*/ u32 unk0002bc; diff --git a/src/setup/setup_000000.c b/src/setup/setup_000000.c index 664af9c36..fc7a1a0a9 100644 --- a/src/setup/setup_000000.c +++ b/src/setup/setup_000000.c @@ -14205,7 +14205,7 @@ bool (*command_pointers[])(void) = { /*0x00f9*/ aiAudioPlayXMusic, /*0x00fa*/ aiAudioStopChannel, /*0x00fb*/ aiChrExplosions, - /*0x00fc*/ ai00fc, + /*0x00fc*/ aiIfKillCountGreaterThan, /*0x00fd*/ ai00fd, /*0x00fe*/ ai00fe, /*0x00ff*/ ai00ff,