Decompile aibotGetAmmoQty

This commit is contained in:
Ryan Dwyer 2020-05-19 17:08:29 +10:00
parent c26ab49275
commit 044551035d
4 changed files with 28 additions and 62 deletions

View File

@ -317,7 +317,7 @@ glabel mpChrReset
//
// func0f197c00(chr);
//
// aibot->unk04c_02 = 0;
// aibot->gunfunc = 0;
// aibot->unk04c_01 = 1;
// aibot->unk09c_00 = 0;
// aibot->cloakdeviceenabled = false;
@ -821,7 +821,7 @@ glabel var7f1b8ea8
/* f190e64: 8fae008c */ lw $t6,0x8c($sp)
/* f190e68: 00003025 */ or $a2,$zero,$zero
/* f190e6c: 8e05005c */ lw $a1,0x5c($s0)
/* f190e70: 0fc6672e */ jal func0f199cb8
/* f190e70: 0fc6672e */ jal aibotGetAmmoQty
/* f190e74: 8dc402d4 */ lw $a0,0x2d4($t6)
/* f190e78: 8e04005c */ lw $a0,0x5c($s0)
/* f190e7c: 0fc2a63d */ jal ammotypeGetMaxCapacity
@ -863,7 +863,7 @@ glabel var7f1b8ea8
/* f190f00: 5b20001d */ blezl $t9,.L0f190f78
/* f190f04: 24010013 */ addiu $at,$zero,0x13
/* f190f08: 8d0402d4 */ lw $a0,0x2d4($t0)
/* f190f0c: 0fc6672e */ jal func0f199cb8
/* f190f0c: 0fc6672e */ jal aibotGetAmmoQty
/* f190f10: afa30028 */ sw $v1,0x28($sp)
/* f190f14: 02002025 */ or $a0,$s0,$zero
/* f190f18: 0fc2a63d */ jal ammotypeGetMaxCapacity
@ -4530,7 +4530,7 @@ glabel var7f1b8f50
/* f194404: 02e08825 */ or $s1,$s7,$zero
.L0f194408:
/* f194408: 02402825 */ or $a1,$s2,$zero
/* f19440c: 0fc6672e */ jal func0f199cb8
/* f19440c: 0fc6672e */ jal aibotGetAmmoQty
/* f194410: 02803025 */ or $a2,$s4,$zero
/* f194414: 0051082a */ slt $at,$v0,$s1
/* f194418: 10200008 */ beqz $at,.L0f19443c
@ -4658,7 +4658,7 @@ glabel var7f1b8f50
/* f1945c4: 00408025 */ or $s0,$v0,$zero
/* f1945c8: 8fa40274 */ lw $a0,0x274($sp)
/* f1945cc: 00402825 */ or $a1,$v0,$zero
/* f1945d0: 0fc6672e */ jal func0f199cb8
/* f1945d0: 0fc6672e */ jal aibotGetAmmoQty
/* f1945d4: 00003025 */ or $a2,$zero,$zero
/* f1945d8: 00409025 */ or $s2,$v0,$zero
/* f1945dc: 0fc2a63d */ jal ammotypeGetMaxCapacity

View File

@ -224,59 +224,25 @@ glabel func0f199be4
/* f199cb4: 00601025 */ or $v0,$v1,$zero
);
GLOBAL_ASM(
glabel func0f199cb8
/* f199cb8: 27bdffe0 */ addiu $sp,$sp,-32
/* f199cbc: afbf0014 */ sw $ra,0x14($sp)
/* f199cc0: afa50024 */ sw $a1,0x24($sp)
/* f199cc4: afa60028 */ sw $a2,0x28($sp)
/* f199cc8: 00803825 */ or $a3,$a0,$zero
/* f199ccc: 10800023 */ beqz $a0,.L0f199d5c
/* f199cd0: 00001825 */ or $v1,$zero,$zero
/* f199cd4: 948e0064 */ lhu $t6,0x64($a0)
/* f199cd8: 00a02025 */ or $a0,$a1,$zero
/* f199cdc: 8fb90024 */ lw $t9,0x24($sp)
/* f199ce0: 31cf0001 */ andi $t7,$t6,0x1
/* f199ce4: 51e00007 */ beqzl $t7,.L0f199d04
/* f199ce8: 8cf8001c */ lw $t8,0x1c($a3)
/* f199cec: 0fc2a63d */ jal ammotypeGetMaxCapacity
/* f199cf0: afa70020 */ sw $a3,0x20($sp)
/* f199cf4: 8fa70020 */ lw $a3,0x20($sp)
/* f199cf8: 10000005 */ beqz $zero,.L0f199d10
/* f199cfc: 00401825 */ or $v1,$v0,$zero
/* f199d00: 8cf8001c */ lw $t8,0x1c($a3)
.L0f199d04:
/* f199d04: 00194080 */ sll $t0,$t9,0x2
/* f199d08: 03084821 */ addu $t1,$t8,$t0
/* f199d0c: 8d230000 */ lw $v1,0x0($t1)
.L0f199d10:
/* f199d10: 8faa0028 */ lw $t2,0x28($sp)
/* f199d14: 51400012 */ beqzl $t2,.L0f199d60
/* f199d18: 8fbf0014 */ lw $ra,0x14($sp)
/* f199d1c: 8ce5004c */ lw $a1,0x4c($a3)
/* f199d20: 8ce40020 */ lw $a0,0x20($a3)
/* f199d24: afa70020 */ sw $a3,0x20($sp)
/* f199d28: 00055880 */ sll $t3,$a1,0x2
/* f199d2c: 000b2fc2 */ srl $a1,$t3,0x1f
/* f199d30: 0fc6666c */ jal weaponGetAmmoTypeByFunction
/* f199d34: afa3001c */ sw $v1,0x1c($sp)
/* f199d38: 8fad0024 */ lw $t5,0x24($sp)
/* f199d3c: 8fa3001c */ lw $v1,0x1c($sp)
/* f199d40: 8fa70020 */ lw $a3,0x20($sp)
/* f199d44: 544d0006 */ bnel $v0,$t5,.L0f199d60
/* f199d48: 8fbf0014 */ lw $ra,0x14($sp)
/* f199d4c: 8cee0028 */ lw $t6,0x28($a3)
/* f199d50: 8cf90024 */ lw $t9,0x24($a3)
/* f199d54: 006e7821 */ addu $t7,$v1,$t6
/* f199d58: 01f91821 */ addu $v1,$t7,$t9
.L0f199d5c:
/* f199d5c: 8fbf0014 */ lw $ra,0x14($sp)
.L0f199d60:
/* f199d60: 27bd0020 */ addiu $sp,$sp,0x20
/* f199d64: 00601025 */ or $v0,$v1,$zero
/* f199d68: 03e00008 */ jr $ra
/* f199d6c: 00000000 */ sll $zero,$zero,0x0
);
u32 aibotGetAmmoQty(struct aibot *aibot, s32 ammotype, bool include_equipped)
{
u32 qty = 0;
if (aibot) {
if (aibot->unk064 & 1) {
qty = ammotypeGetMaxCapacity(ammotype);
} else {
qty = aibot->ammotypes->quantities[ammotype];
}
if (include_equipped
&& weaponGetAmmoTypeByFunction(aibot->weaponnum, aibot->gunfunc) == ammotype) {
qty += aibot->unk028 + aibot->unk024;
}
}
return qty;
}
GLOBAL_ASM(
glabel func0f199d70

View File

@ -7,7 +7,7 @@ s32 weaponGetAmmoTypeByFunction(s32 weaponnum, u32 funcnum);
s32 weaponGetClipSizeByFunction(s32 weaponnum, u32 funcnum);
u32 func0f199a40(void);
s32 func0f199be4(struct aibot *aibot, u32 weaponnum, u32 arg2, u32 arg3);
u32 func0f199cb8(void);
u32 aibotGetAmmoQty(struct aibot *aibot, s32 ammotype, bool include_equipped);
u32 func0f199d70(void);
void aibotGiveAmmoByWeapon(struct aibot *aibot, s32 weaponnum, s32 funcnum, s32 qty);
void aibotGiveAmmoByType(struct aibot *aibot, u32 ammotype, s32 quantity);

View File

@ -166,8 +166,8 @@ struct aibot {
/*0x018*/ u32 unk018;
/*0x01c*/ struct aibotammotype *ammotypes;
/*0x020*/ u32 weaponnum;
/*0x024*/ s32 unk024;
/*0x028*/ u32 unk028;
/*0x024*/ s32 unk024; // probably current clip count or reserve count
/*0x028*/ u32 unk028; // probably current clip count or reserve count
/*0x02c*/ u16 unk02c;
/*0x02e*/ u16 unk02e;
/*0x030*/ u32 unk030; // timer of some sort
@ -181,7 +181,7 @@ struct aibot {
/*0x04a*/ s16 unk04a;
/*0x04c*/ u8 unk04c_00 : 1;
/*0x04c*/ u8 unk04c_01 : 1;
/*0x04c*/ u8 unk04c_02 : 1;
/*0x04c*/ u8 gunfunc : 1;
/*0x04c*/ u8 unk04c_03 : 1;
/*0x04c*/ u8 unk04c_04 : 1;
/*0x04c*/ u8 unk04c_05 : 1;