From 4cedf70192e20044fb662f8fe13b8b5f4951791e Mon Sep 17 00:00:00 2001 From: Ryan Dwyer Date: Sun, 20 Oct 2019 14:17:09 +1000 Subject: [PATCH] Decompile ai00fd --- src/game/chr/chraicommands.c | 60 +++++++++--------------------------- src/include/constants.h | 10 +++--- 2 files changed, 19 insertions(+), 51 deletions(-) diff --git a/src/game/chr/chraicommands.c b/src/game/chr/chraicommands.c index 0e121b864..a686aa4cb 100644 --- a/src/game/chr/chraicommands.c +++ b/src/game/chr/chraicommands.c @@ -10454,52 +10454,20 @@ bool aiIfNumKnockedOutChrs(void) /** * @cmd 00fd */ -GLOBAL_ASM( -glabel ai00fd -/* f0588b0: 3c03800a */ lui $v1,0x800a -/* f0588b4: 24639fc0 */ addiu $v1,$v1,-24640 -/* f0588b8: 8c6e0434 */ lw $t6,0x434($v1) -/* f0588bc: 8c6f0438 */ lw $t7,0x438($v1) -/* f0588c0: 27bdffe0 */ addiu $sp,$sp,-32 -/* f0588c4: afbf0014 */ sw $ra,0x14($sp) -/* f0588c8: 01cf3821 */ addu $a3,$t6,$t7 -/* f0588cc: 90e50002 */ lbu $a1,0x2($a3) -/* f0588d0: afa7001c */ sw $a3,0x1c($sp) -/* f0588d4: 0fc126d1 */ jal chrFindById -/* f0588d8: 8c640424 */ lw $a0,0x424($v1) -/* f0588dc: 3c03800a */ lui $v1,0x800a -/* f0588e0: 24639fc0 */ addiu $v1,$v1,-24640 -/* f0588e4: 10400012 */ beqz $v0,.L0f058930 -/* f0588e8: 8fa7001c */ lw $a3,0x1c($sp) -/* f0588ec: 8c580018 */ lw $t8,0x18($v0) -/* f0588f0: 0018ca80 */ sll $t9,$t8,0xa -/* f0588f4: 0723000f */ bgezl $t9,.L0f058934 -/* f0588f8: 8c6b0438 */ lw $t3,0x438($v1) -/* f0588fc: 8c490018 */ lw $t1,0x18($v0) -/* f058900: 3c01ffdf */ lui $at,0xffdf -/* f058904: 3421ffff */ ori $at,$at,0xffff -/* f058908: 01215024 */ and $t2,$t1,$at -/* f05890c: ac4a0018 */ sw $t2,0x18($v0) -/* f058910: 90e60003 */ lbu $a2,0x3($a3) -/* f058914: 8c650438 */ lw $a1,0x438($v1) -/* f058918: 0fc13583 */ jal chraiGoToLabel -/* f05891c: 8c640434 */ lw $a0,0x434($v1) -/* f058920: 3c03800a */ lui $v1,0x800a -/* f058924: 24639fc0 */ addiu $v1,$v1,-24640 -/* f058928: 10000004 */ beqz $zero,.L0f05893c -/* f05892c: ac620438 */ sw $v0,0x438($v1) -.L0f058930: -/* f058930: 8c6b0438 */ lw $t3,0x438($v1) -.L0f058934: -/* f058934: 256c0004 */ addiu $t4,$t3,0x4 -/* f058938: ac6c0438 */ sw $t4,0x438($v1) -.L0f05893c: -/* f05893c: 8fbf0014 */ lw $ra,0x14($sp) -/* f058940: 27bd0020 */ addiu $sp,$sp,0x20 -/* f058944: 00001025 */ or $v0,$zero,$zero -/* f058948: 03e00008 */ jr $ra -/* f05894c: 00000000 */ sll $zero,$zero,0x0 -); +bool ai00fd(void) +{ + u8 *cmd = g_Vars.ailist + g_Vars.aioffset; + struct chrdata *chr = chrFindById(g_Vars.chrdata, cmd[2]); + + if (chr && (chr->chrflags & 0x00200000)) { + chr->chrflags &= 0xffdfffff; + g_Vars.aioffset = chraiGoToLabel(g_Vars.ailist, g_Vars.aioffset, cmd[3]); + } else { + g_Vars.aioffset += 4; + } + + return false; +} /** * @cmd 00fe diff --git a/src/include/constants.h b/src/include/constants.h index 4a1356b32..d3c86b4ce 100644 --- a/src/include/constants.h +++ b/src/include/constants.h @@ -91,7 +91,7 @@ #define FOLLOW_CHR 0xfc #define CHR_SELF 0xfd -// Character flags - bank 0 (chr struct offset 0x114) +// Character flags - bank 0 (chr struct offset 0x114 - chr->flags) #define CHRFLAG0_CANT_ALERT_GROUP 0x00000001 // Don't set group alertness when becoming aware #define CHRFLAG0_00000002 0x00000002 // Not used in scripts #define CHRFLAG0_00000004 0x00000004 // Can search for player when heard? @@ -125,7 +125,7 @@ #define CHRFLAG0_NOHEAR 0x40000000 // Globals, Villa #define CHRFLAG0_80000000 0x80000000 // Globals, Villa, Chicago, CI Training -// Character flags - bank 1 (chr struct offset 0x118) +// Character flags - bank 1 (chr struct offset 0x118 - chr->flags2) #define CHRFLAG1_00000001 0x00000001 // Globals, Extraction, Air Base, Deep Sea #define CHRFLAG1_00000002 0x00000002 // Globals #define CHRFLAG1_00000004 0x00000004 // Globals - If set, avoids cmd0184 @@ -159,7 +159,7 @@ #define CHRFLAG1_40000000 0x40000000 // Globals #define CHRFLAG1_80000000 0x80000000 // Globals -// Character flags - bank 2 (chr struct offset 0x14 - "hidden") +// Character flags - bank 2 (chr struct offset 0x14 - chr->hidden) #define CHRFLAG2_00000001 0x00000001 // Not used in scripts - sunglasses? #define CHRFLAG2_00000002 0x00000002 // Not used in scripts #define CHRFLAG2_00000004 0x00000004 // Not used in scripts @@ -193,7 +193,7 @@ #define CHRFLAG2_40000000 0x40000000 // Air Base and AF1 #define CHRFLAG2_PSYCHOSISED 0x80000000 -// Character flags - bank 3 (chr struct offset 0x18) +// Character flags - bank 3 (chr struct offset 0x18 - chr->chrflags) #define CHRFLAG3_00000001 0x00000001 // Villa takers, Attack Ship Cass and skedar - both set at end of intros #define CHRFLAG3_00000002 0x00000002 // Seems to be set on guards who can spawn clones? #define CHRFLAG3_00000004 0x00000004 // Not used in scripts @@ -215,7 +215,7 @@ #define CHRFLAG3_00040000 0x00040000 // Used a lot #define CHRFLAG3_00080000 0x00080000 #define CHRFLAG3_KILLCOUNTABLE 0x00100000 -#define CHRFLAG3_00200000 0x00200000 // Not used in scripts +#define CHRFLAG3_00200000 0x00200000 // Unset by cmd 00fd #define CHRFLAG3_00400000 0x00400000 // Not used in scripts #define CHRFLAG3_UNPLAYABLE 0x00800000 #define CHRFLAG3_01000000 0x01000000 // Typically set on allies during init