From df85ded9f36fa2df2a4b119ae712ef8fac2fd5ea Mon Sep 17 00:00:00 2001 From: Ryan Dwyer Date: Mon, 21 Oct 2019 22:06:01 +1000 Subject: [PATCH] Decompile aiSetAutogunType --- src/game/chr/chraicommands.c | 51 ++++++++-------------------- src/include/constants.h | 1 + src/include/game/chr/chraicommands.h | 2 +- src/include/types.h | 24 +++++++++++++ src/setup/setup_000000.c | 2 +- 5 files changed, 42 insertions(+), 38 deletions(-) diff --git a/src/game/chr/chraicommands.c b/src/game/chr/chraicommands.c index 945eaa517..3f2516340 100644 --- a/src/game/chr/chraicommands.c +++ b/src/game/chr/chraicommands.c @@ -16717,42 +16717,21 @@ glabel ai01b7 /** * @cmd 01b8 */ -GLOBAL_ASM( -glabel ai01b8 -/* f05e914: 3c05800a */ lui $a1,0x800a -/* f05e918: 24a59fc0 */ addiu $a1,$a1,-24640 -/* f05e91c: 8cae0434 */ lw $t6,0x434($a1) -/* f05e920: 8caf0438 */ lw $t7,0x438($a1) -/* f05e924: 27bdffe0 */ addiu $sp,$sp,-32 -/* f05e928: afbf0014 */ sw $ra,0x14($sp) -/* f05e92c: 01cf1821 */ addu $v1,$t6,$t7 -/* f05e930: 90640002 */ lbu $a0,0x2($v1) -/* f05e934: 0fc2556c */ jal objFindByTagId -/* f05e938: afa3001c */ sw $v1,0x1c($sp) -/* f05e93c: 3c05800a */ lui $a1,0x800a -/* f05e940: 24a59fc0 */ addiu $a1,$a1,-24640 -/* f05e944: 1040000b */ beqz $v0,.L0f05e974 -/* f05e948: 8fa3001c */ lw $v1,0x1c($sp) -/* f05e94c: 8c580014 */ lw $t8,0x14($v0) -/* f05e950: 53000009 */ beqzl $t8,.L0f05e978 -/* f05e954: 8ca90438 */ lw $t1,0x438($a1) -/* f05e958: 90590003 */ lbu $t9,0x3($v0) -/* f05e95c: 2401000d */ addiu $at,$zero,0xd -/* f05e960: 57210005 */ bnel $t9,$at,.L0f05e978 -/* f05e964: 8ca90438 */ lw $t1,0x438($a1) -/* f05e968: 90680003 */ lbu $t0,0x3($v1) -/* f05e96c: ac4000a4 */ sw $zero,0xa4($v0) -/* f05e970: a04800a8 */ sb $t0,0xa8($v0) -.L0f05e974: -/* f05e974: 8ca90438 */ lw $t1,0x438($a1) -.L0f05e978: -/* f05e978: 8fbf0014 */ lw $ra,0x14($sp) -/* f05e97c: 27bd0020 */ addiu $sp,$sp,0x20 -/* f05e980: 252a0004 */ addiu $t2,$t1,0x4 -/* f05e984: acaa0438 */ sw $t2,0x438($a1) -/* f05e988: 03e00008 */ jr $ra -/* f05e98c: 00001025 */ or $v0,$zero,$zero -); +bool aiSetAutogunType(void) +{ + u8 *cmd = g_Vars.ailist + g_Vars.aioffset; + struct defaultobj *obj = objFindByTagId(cmd[2]); + + if (obj && obj->pos && obj->type == OBJTYPE_AUTOGUN) { + struct autogunobj *autogun = (struct autogunobj *)obj; + autogun->autogun_type = cmd[3]; + autogun->unka4 = 0; + } + + g_Vars.aioffset += 4; + + return false; +} /** * @cmd 01b9 diff --git a/src/include/constants.h b/src/include/constants.h index 154fdd7f7..271756f61 100644 --- a/src/include/constants.h +++ b/src/include/constants.h @@ -449,6 +449,7 @@ #define OBJTYPE_WEAPON 0x08 #define OBJTYPE_SINGLEMONITOR 0x0a #define OBJTYPE_MULTIMONITOR 0x0b +#define OBJTYPE_AUTOGUN 0x0d #define OBJTYPE_LIFT 0x30 #define OPERATOR_LESS_THAN 0 diff --git a/src/include/game/chr/chraicommands.h b/src/include/game/chr/chraicommands.h index feffece87..147fd2e9e 100644 --- a/src/include/game/chr/chraicommands.h +++ b/src/include/game/chr/chraicommands.h @@ -403,7 +403,7 @@ /*0x01b5*/ bool ai01b5(void); /*0x01b6*/ bool aiConfigureSnow(void); /*0x01b7*/ bool ai01b7(void); -/*0x01b8*/ bool ai01b8(void); +/*0x01b8*/ bool aiSetAutogunType(void); /*0x01b9*/ bool ai01b9(void); /*0x01ba*/ bool ai01ba(void); /*0x01bb*/ bool ai01bb(void); diff --git a/src/include/types.h b/src/include/types.h index 1633f07da..3c9239054 100644 --- a/src/include/types.h +++ b/src/include/types.h @@ -392,6 +392,30 @@ struct multimonitorobj { // objtype 0b struct singlemonitorobj subobjs[4]; }; +struct autogunobj { // objtype 0d + struct defaultobj base; + /*0x5c*/ u32 unk5c; + /*0x60*/ u32 unk60; + /*0x64*/ u32 unk64; + /*0x68*/ u32 unk68; + /*0x6c*/ u32 unk6c; + /*0x70*/ u32 unk70; + /*0x74*/ u32 unk74; + /*0x78*/ u32 unk78; + /*0x7c*/ u32 unk7c; + /*0x80*/ u32 unk80; + /*0x84*/ u32 unk84; + /*0x88*/ u32 unk88; + /*0x8c*/ u32 unk8c; + /*0x90*/ u32 unk90; + /*0x94*/ u32 unk94; + /*0x98*/ u32 unk98; + /*0x9c*/ u32 unk9c; + /*0xa0*/ u32 unka0; + /*0xa4*/ u32 unka4; + /*0xa8*/ u8 autogun_type; +}; + struct liftobj { struct defaultobj base; /*0x5c*/ u32 unk5c; diff --git a/src/setup/setup_000000.c b/src/setup/setup_000000.c index 6b41b5bb0..db25126d8 100644 --- a/src/setup/setup_000000.c +++ b/src/setup/setup_000000.c @@ -14393,7 +14393,7 @@ bool (*command_pointers[])(void) = { /*0x01b5*/ ai01b5, /*0x01b6*/ aiConfigureSnow, /*0x01b7*/ ai01b7, - /*0x01b8*/ ai01b8, + /*0x01b8*/ aiSetAutogunType, /*0x01b9*/ ai01b9, /*0x01ba*/ ai01ba, /*0x01bb*/ ai01bb,