From c5c8628617bfc0bc61ffd1c8473ca4b5d7b18139 Mon Sep 17 00:00:00 2001 From: Ryan Dwyer Date: Sat, 19 Oct 2019 21:08:29 +1000 Subject: [PATCH] Decompile aiShowObj --- src/game/chr/chraicommands.c | 75 ++----- src/gvars/gvars.c | 10 +- src/include/constants.h | 1 + src/include/game/chr/chraicommands.h | 2 +- src/include/gvars/gvars.h | 145 +++++++++++- src/include/types.h | 325 ++++++++++++++++++++++++++- src/setup/setup_000000.c | 2 +- 7 files changed, 490 insertions(+), 70 deletions(-) diff --git a/src/game/chr/chraicommands.c b/src/game/chr/chraicommands.c index d4bd75417..a6272e2f4 100644 --- a/src/game/chr/chraicommands.c +++ b/src/game/chr/chraicommands.c @@ -9279,59 +9279,28 @@ bool aiHideChr(void) /** * @cmd 0116 */ -GLOBAL_ASM( -glabel ai0116 -/* f0572e4: 3c03800a */ lui $v1,0x800a -/* f0572e8: 24639fc0 */ addiu $v1,$v1,-24640 -/* f0572ec: 8c6e0434 */ lw $t6,0x434($v1) -/* f0572f0: 8c6f0438 */ lw $t7,0x438($v1) -/* f0572f4: 27bdffe0 */ addiu $sp,$sp,-32 -/* f0572f8: afbf0014 */ sw $ra,0x14($sp) -/* f0572fc: 01cf1021 */ addu $v0,$t6,$t7 -/* f057300: 0fc2556c */ jal objFindByTagId -/* f057304: 90440002 */ lbu $a0,0x2($v0) -/* f057308: 1040001e */ beqz $v0,.L0f057384 -/* f05730c: 00000000 */ sll $zero,$zero,0x0 -/* f057310: 8c580014 */ lw $t8,0x14($v0) -/* f057314: 1300001b */ beqz $t8,.L0f057384 -/* f057318: 00000000 */ sll $zero,$zero,0x0 -/* f05731c: 8c590018 */ lw $t9,0x18($v0) -/* f057320: 13200018 */ beqz $t9,.L0f057384 -/* f057324: 00000000 */ sll $zero,$zero,0x0 -/* f057328: 8c440014 */ lw $a0,0x14($v0) -/* f05732c: 0fc1812f */ jal func0f0604bc -/* f057330: afa20018 */ sw $v0,0x18($sp) -/* f057334: 8fa30018 */ lw $v1,0x18($sp) -/* f057338: 0fc180bc */ jal func0f0602f0 -/* f05733c: 8c640014 */ lw $a0,0x14($v1) -/* f057340: 3c04800a */ lui $a0,0x800a -/* f057344: 24849fc0 */ addiu $a0,$a0,-24640 -/* f057348: 8c880284 */ lw $t0,0x284($a0) -/* f05734c: 8fa30018 */ lw $v1,0x18($sp) -/* f057350: 8d090480 */ lw $t1,0x480($t0) -/* f057354: 1520000b */ bnez $t1,.L0f057384 -/* f057358: 00000000 */ sll $zero,$zero,0x0 -/* f05735c: 906a0003 */ lbu $t2,0x3($v1) -/* f057360: 24010008 */ addiu $at,$zero,0x8 -/* f057364: 15410007 */ bne $t2,$at,.L0f057384 -/* f057368: 00000000 */ sll $zero,$zero,0x0 -/* f05736c: 906b005c */ lbu $t3,0x5c($v1) -/* f057370: 2401002e */ addiu $at,$zero,0x2e -/* f057374: 15610003 */ bne $t3,$at,.L0f057384 -/* f057378: 00000000 */ sll $zero,$zero,0x0 -/* f05737c: 0fc0458c */ jal func0f011630 -/* f057380: 00000000 */ sll $zero,$zero,0x0 -.L0f057384: -/* f057384: 3c04800a */ lui $a0,0x800a -/* f057388: 24849fc0 */ addiu $a0,$a0,-24640 -/* f05738c: 8c8c0438 */ lw $t4,0x438($a0) -/* f057390: 8fbf0014 */ lw $ra,0x14($sp) -/* f057394: 27bd0020 */ addiu $sp,$sp,0x20 -/* f057398: 258d0003 */ addiu $t5,$t4,0x3 -/* f05739c: ac8d0438 */ sw $t5,0x438($a0) -/* f0573a0: 03e00008 */ jr $ra -/* f0573a4: 00001025 */ or $v0,$zero,$zero -); +bool aiShowObj(void) +{ + u8 *cmd = g_Vars.ailist + g_Vars.aioffset; + struct defaultobj *obj = objFindByTagId(cmd[2]); + + if (obj && obj->pos && obj->unk18) { + func0f0604bc(obj->pos); + func0f0602f0(obj->pos); + + if (g_Vars.unk000284->unk480 == 0 && obj->type == OBJTYPE_WEAPON) { + struct weaponobj *weapon = (struct weaponobj *) obj; + + if (weapon->weapon_id == WEAPON_CAMSPY) { + func0f011630(); + } + } + } + + g_Vars.aioffset += 3; + + return false; +} /** * @cmd 0117 diff --git a/src/gvars/gvars.c b/src/gvars/gvars.c index 43cdaf4a9..a8cae12e9 100644 --- a/src/gvars/gvars.c +++ b/src/gvars/gvars.c @@ -9,15 +9,9 @@ u8 padding8009ae20[0xf1a0]; // 80099fc0 -struct g_vars g_Vars; +struct g_vars g_Vars; // ends at 8009a6c8 -// 8009a4a0 -u8 var8009a4a0; -u8 var8009a4a1; -u8 var8009a4a2; -u8 g_LangFilterActive; - -u8 padding8009a4a4[0x2c1c]; +u8 padding8009a6c8[0x29fc]; // 8009d0c4 s32 g_NumTags; diff --git a/src/include/constants.h b/src/include/constants.h index 64d93070c..4a1356b32 100644 --- a/src/include/constants.h +++ b/src/include/constants.h @@ -446,6 +446,7 @@ #define OBJECTFLAG2_80000000 0x80000000 // Not used in scripts #define OBJTYPE_DOOR 0x01 +#define OBJTYPE_WEAPON 0x08 #define OBJTYPE_SINGLEMONITOR 0x0a #define OBJTYPE_MULTIMONITOR 0x0b diff --git a/src/include/game/chr/chraicommands.h b/src/include/game/chr/chraicommands.h index 459f18ddd..ef0e4b006 100644 --- a/src/include/game/chr/chraicommands.h +++ b/src/include/game/chr/chraicommands.h @@ -278,7 +278,7 @@ /*0x0113*/ bool aiIfInCutscene(void); /*0x0114*/ bool aiShowChr(void); /*0x0115*/ bool aiHideChr(void); -/*0x0116*/ bool ai0116(void); +/*0x0116*/ bool aiShowObj(void); /*0x0117*/ bool ai0117(void); /*0x0118*/ bool ai0118(void); /*0x0119*/ bool ai0119(void); diff --git a/src/include/gvars/gvars.h b/src/include/gvars/gvars.h index 830dfc450..a246cf849 100644 --- a/src/include/gvars/gvars.h +++ b/src/include/gvars/gvars.h @@ -176,7 +176,7 @@ struct g_vars { /*000278*/ u32 unk000278; /*00027c*/ u32 unk00027c; /*000280*/ u32 unk000280; - /*000284*/ u32 unk000284; + /*000284*/ struct gvars284 *unk000284; /*000288*/ u32 unk000288; /*00028c*/ u32 unk00028c; /*000290*/ u32 unk000290; @@ -327,12 +327,151 @@ struct g_vars { /*0004d4*/ u32 unk0004d4; /*0004d8*/ u32 unk0004d8; /*0004dc*/ u32 unk0004dc; + /*0004e0*/ u8 unk0004e0; + /*0004e1*/ u8 unk0004e1; + /*0004e2*/ u8 unk0004e2; + /*0004e3*/ u8 langFilterActive; + /*0004e4*/ u32 unk0004e4; + /*0004e8*/ u32 unk0004e8; + /*0004ec*/ u32 unk0004ec; + /*0004f0*/ u32 unk0004f0; + /*0004f4*/ u32 unk0004f4; + /*0004f8*/ u32 unk0004f8; + /*0004fc*/ u32 unk0004fc; + /*0004e0*/ u32 unk000500; + /*000504*/ u32 unk000504; + /*000508*/ u32 unk000508; + /*00050c*/ u32 unk00050c; + /*000510*/ u32 unk000510; + /*000514*/ u32 unk000514; + /*000518*/ u32 unk000518; + /*00051c*/ u32 unk00051c; + /*000520*/ u32 unk000520; + /*000524*/ u32 unk000524; + /*000528*/ u32 unk000528; + /*00052c*/ u32 unk00052c; + /*000530*/ u32 unk000530; + /*000534*/ u32 unk000534; + /*000538*/ u32 unk000538; + /*00053c*/ u32 unk00053c; + /*000540*/ u32 unk000540; + /*000544*/ u32 unk000544; + /*000548*/ u32 unk000548; + /*00054c*/ u32 unk00054c; + /*000550*/ u32 unk000550; + /*000554*/ u32 unk000554; + /*000558*/ u32 unk000558; + /*00055c*/ u32 unk00055c; + /*000560*/ u32 unk000560; + /*000564*/ u32 unk000564; + /*000568*/ u32 unk000568; + /*00056c*/ u32 unk00056c; + /*000570*/ u32 unk000570; + /*000574*/ u32 unk000574; + /*000578*/ u32 unk000578; + /*00057c*/ u32 unk00057c; + /*000580*/ u32 unk000580; + /*000584*/ u32 unk000584; + /*000588*/ u32 unk000588; + /*00058c*/ u32 unk00058c; + /*000590*/ u32 unk000590; + /*000594*/ u32 unk000594; + /*000598*/ u32 unk000598; + /*00059c*/ u32 unk00059c; + /*0005a0*/ u32 unk0005a0; + /*0005a4*/ u32 unk0005a4; + /*0005a8*/ u32 unk0005a8; + /*0005ac*/ u32 unk0005ac; + /*0005b0*/ u32 unk0005b0; + /*0005b4*/ u32 unk0005b4; + /*0005b8*/ u32 unk0005b8; + /*0005bc*/ u32 unk0005bc; + /*0005c0*/ u32 unk0005c0; + /*0005c4*/ u32 unk0005c4; + /*0005c8*/ u32 unk0005c8; + /*0005cc*/ u32 unk0005cc; + /*0005d0*/ u32 unk0005d0; + /*0005d4*/ u32 unk0005d4; + /*0005d8*/ u32 unk0005d8; + /*0005dc*/ u32 unk0005dc; + /*0005e0*/ u32 unk0005e0; + /*0005e4*/ u32 unk0005e4; + /*0005e8*/ u32 unk0005e8; + /*0005ec*/ u32 unk0005ec; + /*0005f0*/ u32 unk0005f0; + /*0005f4*/ u32 unk0005f4; + /*0005f8*/ u32 unk0005f8; + /*0005fc*/ u32 unk0005fc; + /*000600*/ u32 unk000600; + /*000604*/ u32 unk000604; + /*000608*/ u32 unk000608; + /*00060c*/ u32 unk00060c; + /*000610*/ u32 unk000610; + /*000614*/ u32 unk000614; + /*000618*/ u32 unk000618; + /*00061c*/ u32 unk00061c; + /*000620*/ u32 unk000620; + /*000624*/ u32 unk000624; + /*000628*/ u32 unk000628; + /*00062c*/ u32 unk00062c; + /*000630*/ u32 unk000630; + /*000634*/ u32 unk000634; + /*000638*/ u32 unk000638; + /*00063c*/ u32 unk00063c; + /*000640*/ u32 unk000640; + /*000644*/ u32 unk000644; + /*000648*/ u32 unk000648; + /*00064c*/ u32 unk00064c; + /*000650*/ u32 unk000650; + /*000654*/ u32 unk000654; + /*000658*/ u32 unk000658; + /*00065c*/ u32 unk00065c; + /*000660*/ u32 unk000660; + /*000664*/ u32 unk000664; + /*000668*/ u32 unk000668; + /*00066c*/ u32 unk00066c; + /*000670*/ u32 unk000670; + /*000674*/ u32 unk000674; + /*000678*/ u32 unk000678; + /*00067c*/ u32 unk00067c; + /*000680*/ u32 unk000680; + /*000684*/ u32 unk000684; + /*000688*/ u32 unk000688; + /*00068c*/ u32 unk00068c; + /*000690*/ u32 unk000690; + /*000694*/ u32 unk000694; + /*000698*/ u32 unk000698; + /*00069c*/ u32 unk00069c; + /*0006a0*/ u32 unk0006a0; + /*0006a4*/ u32 unk0006a4; + /*0006a8*/ u32 unk0006a8; + /*0006ac*/ u32 unk0006ac; + /*0006b0*/ u32 unk0006b0; + /*0006b4*/ u32 unk0006b4; + /*0006b8*/ u32 unk0006b8; + /*0006bc*/ u32 unk0006bc; + /*0006c0*/ u32 unk0006c0; + /*0006c4*/ u32 unk0006c4; + /*0006c8*/ u32 unk0006c8; + /*0006cc*/ u32 unk0006cc; + /*0006d0*/ u32 unk0006d0; + /*0006d4*/ u32 unk0006d4; + /*0006d8*/ u32 unk0006d8; + /*0006dc*/ u32 unk0006dc; + /*0006e0*/ u32 unk0006e0; + /*0006e4*/ u32 unk0006e4; + /*0006e8*/ u32 unk0006e8; + /*0006ec*/ u32 unk0006ec; + /*0006f0*/ u32 unk0006f0; + /*0006f4*/ u32 unk0006f4; + /*0006f8*/ u32 unk0006f8; + /*0006fc*/ u32 unk0006fc; + /*000700*/ u32 unk000700; + /*000704*/ u32 unk000704; }; extern struct g_vars g_Vars; -extern u8 g_LangFilterActive; - extern s32 g_NumTags; extern struct tag **g_TagPtrs; diff --git a/src/include/types.h b/src/include/types.h index 1faf35559..3fda08474 100644 --- a/src/include/types.h +++ b/src/include/types.h @@ -254,7 +254,7 @@ struct defaultobj { /*0x0c*/ u32 flags2; /*0x10*/ u32 flags3; /*0x14*/ struct position *pos; - /*0x18*/ u32 unk18; + /*0x18*/ void *unk18; // probably same struct as chrdata->unk020 /*0x1c*/ float realrot[9]; /*0x40*/ u32 hidden; /*0x44*/ u32 unk44; @@ -273,7 +273,7 @@ struct defaultobj { /*0x62*/ u16 aireturnlist; }; -struct doorobj { +struct doorobj { // objtype 0x01 struct defaultobj base; /*0x64*/ u32 unk64; /*0x68*/ u32 unk68; @@ -295,7 +295,32 @@ struct image { /*0x14*/ u32 unk14; }; -struct singlemonitorobj { +struct weaponobj { // objtype 0x08 + /*0x00*/ u16 extrascale; + /*0x02*/ u8 hidden2; + /*0x03*/ u8 type; + /*0x04*/ u16 obj; + /*0x06*/ u16 pad; + /*0x08*/ u32 flags; + /*0x0c*/ u32 flags2; + /*0x10*/ u32 flags3; + /*0x14*/ struct position *pos; + /*0x18*/ u32 unk18; + /*0x1c*/ float realrot[9]; + /*0x40*/ u32 hidden; + /*0x44*/ u32 unk44; + /*0x48*/ u32 unk48; + /*0x4c*/ s16 damage; + /*0x4e*/ u16 maxdamage; + /*0x50*/ u32 shadecol; + /*0x54*/ u32 nextcol; + /*0x58*/ u16 floorcol; + /*0x5a*/ u8 numtiles; + /*0x5b*/ u8 unk5b; + /*0x5c*/ u8 weapon_id; +}; + +struct singlemonitorobj { // objtype 0x0a /*0x00*/ u16 extrascale; /*0x02*/ u8 hidden2; /*0x03*/ u8 type; @@ -319,7 +344,7 @@ struct singlemonitorobj { /*0x5c*/ struct image image; }; -struct multimonitorobj { +struct multimonitorobj { // objtype 0b struct singlemonitorobj subobjs[4]; }; @@ -808,4 +833,296 @@ struct audioconfig { u32 unk1c; }; +struct gvars284 { + u32 unk000; + u32 unk004; + u32 unk008; + u32 unk00c; + u32 unk010; + u32 unk014; + u32 unk018; + u32 unk01c; + u32 unk020; + u32 unk024; + u32 unk028; + u32 unk02c; + u32 unk030; + u32 unk034; + u32 unk038; + u32 unk03c; + u32 unk040; + u32 unk044; + u32 unk048; + u32 unk04c; + u32 unk050; + u32 unk054; + u32 unk058; + u32 unk05c; + u32 unk060; + u32 unk064; + u32 unk068; + u32 unk06c; + u32 unk070; + u32 unk074; + u32 unk078; + u32 unk07c; + u32 unk080; + u32 unk084; + u32 unk088; + u32 unk08c; + u32 unk090; + u32 unk094; + u32 unk098; + u32 unk09c; + u32 unk0a0; + u32 unk0a4; + u32 unk0a8; + u32 unk0ac; + u32 unk0b0; + u32 unk0b4; + u32 unk0b8; + u32 unk0bc; + u32 unk0c0; + u32 unk0c4; + u32 unk0c8; + u32 unk0cc; + u32 unk0d0; + u32 unk0d4; + u32 unk0d8; + u32 unk0dc; + u32 unk0e0; + u32 unk0e4; + u32 unk0e8; + u32 unk0ec; + u32 unk0f0; + u32 unk0f4; + u32 unk0f8; + u32 unk0fc; + u32 unk100; + u32 unk104; + u32 unk108; + u32 unk10c; + u32 unk110; + u32 unk114; + u32 unk118; + u32 unk11c; + u32 unk120; + u32 unk124; + u32 unk128; + u32 unk12c; + u32 unk130; + u32 unk134; + u32 unk138; + u32 unk13c; + u32 unk140; + u32 unk144; + u32 unk148; + u32 unk14c; + u32 unk150; + u32 unk154; + u32 unk158; + u32 unk15c; + u32 unk160; + u32 unk164; + u32 unk168; + u32 unk16c; + u32 unk170; + u32 unk174; + u32 unk178; + u32 unk17c; + u32 unk180; + u32 unk184; + u32 unk188; + u32 unk18c; + u32 unk190; + u32 unk194; + u32 unk198; + u32 unk19c; + u32 unk1a0; + u32 unk1a4; + u32 unk1a8; + u32 unk1ac; + u32 unk1b0; + u32 unk1b4; + u32 unk1b8; + u32 unk1bc; + u32 unk1c0; + u32 unk1c4; + u32 unk1c8; + u32 unk1cc; + u32 unk1d0; + u32 unk1d4; + u32 unk1d8; + u32 unk1dc; + u32 unk1e0; + u32 unk1e4; + u32 unk1e8; + u32 unk1ec; + u32 unk1f0; + u32 unk1f4; + u32 unk1f8; + u32 unk1fc; + u32 unk200; + u32 unk204; + u32 unk208; + u32 unk20c; + u32 unk210; + u32 unk214; + u32 unk218; + u32 unk21c; + u32 unk220; + u32 unk224; + u32 unk228; + u32 unk22c; + u32 unk230; + u32 unk234; + u32 unk238; + u32 unk23c; + u32 unk240; + u32 unk244; + u32 unk248; + u32 unk24c; + u32 unk250; + u32 unk254; + u32 unk258; + u32 unk25c; + u32 unk260; + u32 unk264; + u32 unk268; + u32 unk26c; + u32 unk270; + u32 unk274; + u32 unk278; + u32 unk27c; + u32 unk280; + u32 unk284; + u32 unk288; + u32 unk28c; + u32 unk290; + u32 unk294; + u32 unk298; + u32 unk29c; + u32 unk2a0; + u32 unk2a4; + u32 unk2a8; + u32 unk2ac; + u32 unk2b0; + u32 unk2b4; + u32 unk2b8; + u32 unk2bc; + u32 unk2c0; + u32 unk2c4; + u32 unk2c8; + u32 unk2cc; + u32 unk2d0; + u32 unk2d4; + u32 unk2d8; + u32 unk2dc; + u32 unk2e0; + u32 unk2e4; + u32 unk2e8; + u32 unk2ec; + u32 unk2f0; + u32 unk2f4; + u32 unk2f8; + u32 unk2fc; + u32 unk300; + u32 unk304; + u32 unk308; + u32 unk30c; + u32 unk310; + u32 unk314; + u32 unk318; + u32 unk31c; + u32 unk320; + u32 unk324; + u32 unk328; + u32 unk32c; + u32 unk330; + u32 unk334; + u32 unk338; + u32 unk33c; + u32 unk340; + u32 unk344; + u32 unk348; + u32 unk34c; + u32 unk350; + u32 unk354; + u32 unk358; + u32 unk35c; + u32 unk360; + u32 unk364; + u32 unk368; + u32 unk36c; + u32 unk370; + u32 unk374; + u32 unk378; + u32 unk37c; + u32 unk380; + u32 unk384; + u32 unk388; + u32 unk38c; + u32 unk390; + u32 unk394; + u32 unk398; + u32 unk39c; + u32 unk3a0; + u32 unk3a4; + u32 unk3a8; + u32 unk3ac; + u32 unk3b0; + u32 unk3b4; + u32 unk3b8; + u32 unk3bc; + u32 unk3c0; + u32 unk3c4; + u32 unk3c8; + u32 unk3cc; + u32 unk3d0; + u32 unk3d4; + u32 unk3d8; + u32 unk3dc; + u32 unk3e0; + u32 unk3e4; + u32 unk3e8; + u32 unk3ec; + u32 unk3f0; + u32 unk3f4; + u32 unk3f8; + u32 unk3fc; + u32 unk400; + u32 unk404; + u32 unk408; + u32 unk40c; + u32 unk410; + u32 unk414; + u32 unk418; + u32 unk41c; + u32 unk420; + u32 unk424; + u32 unk428; + u32 unk42c; + u32 unk430; + u32 unk434; + u32 unk438; + u32 unk43c; + u32 unk440; + u32 unk444; + u32 unk448; + u32 unk44c; + u32 unk450; + u32 unk454; + u32 unk458; + u32 unk45c; + u32 unk460; + u32 unk464; + u32 unk468; + u32 unk46c; + u32 unk470; + u32 unk474; + u32 unk478; + u32 unk47c; + u32 unk480; +}; + #endif diff --git a/src/setup/setup_000000.c b/src/setup/setup_000000.c index cf1e29819..14a6052e7 100644 --- a/src/setup/setup_000000.c +++ b/src/setup/setup_000000.c @@ -14231,7 +14231,7 @@ bool (*command_pointers[])(void) = { /*0x0113*/ aiIfInCutscene, /*0x0114*/ aiShowChr, /*0x0115*/ aiHideChr, - /*0x0116*/ ai0116, + /*0x0116*/ aiShowObj, /*0x0117*/ ai0117, /*0x0118*/ ai0118, /*0x0119*/ ai0119,