From ac135cb4681f6e03127b7661b9638c5e709efbc5 Mon Sep 17 00:00:00 2001 From: Ryan Dwyer Date: Wed, 4 Mar 2020 00:17:51 +1000 Subject: [PATCH] Decompile weaponGetMaxFireRatePerTick --- src/game/chr/chraction.c | 10 ++-- src/game/data/inventory.c | 96 +++++++++++++++++----------------- src/game/game_0b0420.c | 48 ++++++----------- src/game/game_190260.c | 4 +- src/include/game/game_0b0420.h | 2 +- src/include/types.h | 4 +- 6 files changed, 73 insertions(+), 91 deletions(-) diff --git a/src/game/chr/chraction.c b/src/game/chr/chraction.c index 4efef09b0..d66cd2d03 100644 --- a/src/game/chr/chraction.c +++ b/src/game/chr/chraction.c @@ -2804,7 +2804,7 @@ glabel chrAttackWalk /* f030864: 8c430004 */ lw $v1,0x4($v0) /* f030868: 9064005c */ lbu $a0,0x5c($v1) /* f03086c: 9065005f */ lbu $a1,0x5f($v1) -/* f030870: 0fc2c7ba */ jal func0f0b1ee8 +/* f030870: 0fc2c7ba */ jal weaponGetMaxFireRatePerTick /* f030874: afa30044 */ sw $v1,0x44($sp) /* f030878: 8fa30044 */ lw $v1,0x44($sp) /* f03087c: 8fa60034 */ lw $a2,0x34($sp) @@ -3175,7 +3175,7 @@ glabel chrAttackRoll /* f030da0: 8c430004 */ lw $v1,0x4($v0) /* f030da4: 9064005c */ lbu $a0,0x5c($v1) /* f030da8: 9065005f */ lbu $a1,0x5f($v1) -/* f030dac: 0fc2c7ba */ jal func0f0b1ee8 +/* f030dac: 0fc2c7ba */ jal weaponGetMaxFireRatePerTick /* f030db0: afa3006c */ sw $v1,0x6c($sp) /* f030db4: 8fa3006c */ lw $v1,0x6c($sp) /* f030db8: 8fa60038 */ lw $a2,0x38($sp) @@ -3738,7 +3738,7 @@ glabel func0f031384 /* f0315e4: 9065005f */ lbu $a1,0x5f($v1) /* f0315e8: afa80040 */ sw $t0,0x40($sp) /* f0315ec: afa70044 */ sw $a3,0x44($sp) -/* f0315f0: 0fc2c7ba */ jal func0f0b1ee8 +/* f0315f0: 0fc2c7ba */ jal weaponGetMaxFireRatePerTick /* f0315f4: afa30078 */ sw $v1,0x78($sp) /* f0315f8: 8fa30078 */ lw $v1,0x78($sp) /* f0315fc: 8fa70044 */ lw $a3,0x44($sp) @@ -18852,7 +18852,7 @@ glabel var7f1a90b4 /* f03fd3c: 46041082 */ mul.s $f2,$f2,$f4 /* f03fd40: 90440000 */ lbu $a0,0x0($v0) /* f03fd44: 90450003 */ lbu $a1,0x3($v0) -/* f03fd48: 0fc2c7ba */ jal func0f0b1ee8 +/* f03fd48: 0fc2c7ba */ jal weaponGetMaxFireRatePerTick /* f03fd4c: e7a20024 */ swc1 $f2,0x24($sp) /* f03fd50: 1c400002 */ bgtz $v0,.L0f03fd5c /* f03fd54: c7a20024 */ lwc1 $f2,0x24($sp) @@ -19545,7 +19545,7 @@ glabel var7f1a9184 /* f040588: 93a40260 */ lbu $a0,0x260($sp) /* f04058c: 93a50263 */ lbu $a1,0x263($sp) /* f040590: afa00254 */ sw $zero,0x254($sp) -/* f040594: 0fc2c7ba */ jal func0f0b1ee8 +/* f040594: 0fc2c7ba */ jal weaponGetMaxFireRatePerTick /* f040598: afa80258 */ sw $t0,0x258($sp) /* f04059c: 8fa60254 */ lw $a2,0x254($sp) /* f0405a0: 1c400005 */ bgtz $v0,.L0f0405b8 diff --git a/src/game/data/inventory.c b/src/game/data/inventory.c index 4ea87491a..ab2b0268c 100644 --- a/src/game/data/inventory.c +++ b/src/game/data/inventory.c @@ -1448,8 +1448,8 @@ struct weaponfunc_shootauto invfunc_cmp150_rapidfire = { 0x00000000, 0x03008040, 0x01000000, - 0x44610000, - 0x44610000, + 900, + 900, 0x00000000, 0x00000000, 0x00000000, @@ -1475,8 +1475,8 @@ struct weaponfunc_shootauto invfunc_cmp150_followlockon = { 0x00000000, 0x03008040, 0x01000000, - 0x44610000, - 0x44610000, + 900, + 900, 0x00000000, 0x00000000, 0x00000000, @@ -1587,8 +1587,8 @@ struct weaponfunc_shootauto invfunc_cyclone_rapidfire = { 0x40800000, 0x0400805f, 0x01000000, - 0x44610000, - 0x44610000, + 900, + 900, 0x00000000, 0x00000000, 0x00000000, @@ -1614,8 +1614,8 @@ struct weaponfunc_shootauto invfunc_cyclone_magazinedischarge = { 0x40800000, 0x04008075, 0x01000000, - 0x44fa0000, - 0x44fa0000, + 2000, + 2000, 0x00000000, 0x00000000, 0x00000000, @@ -1714,8 +1714,8 @@ struct weaponfunc_shootauto invfunc_rcp120_rapidfire = { 0x00000000, 0x0400806d, 0x01000000, - 0x44898000, - 0x44898000, + 1100, + 1100, 0x00000000, 0x00000000, 0x00000000, @@ -1823,8 +1823,8 @@ struct weaponfunc_shootauto invfunc_callisto_rapidfire = { 0x00000000, 0x03008063, 0x01000000, - 0x44610000, - 0x44610000, + 900, + 900, 0x00000000, 0x00000000, 0x00000000, @@ -1850,8 +1850,8 @@ struct weaponfunc_shootauto invfunc_callisto_highimpactshells = { 0x00000000, 0x03008064, 0x05000000, - 0x43960000, - 0x43960000, + 300, + 300, 0x00000000, 0x00000000, 0x00000000, @@ -1946,8 +1946,8 @@ struct weaponfunc_shootauto invfunc_dragon_rapidfire = { 0x40800000, 0x04008049, 0x01000000, - 0x442f0000, - 0x442f0000, + 700, + 700, 0x00000000, 0x00000000, 0x00000000, @@ -2094,8 +2094,8 @@ struct weaponfunc_shootauto invfunc_superdragon_rapidfire = { 0x40800000, 0x04008049, 0x01000000, - 0x442f0000, - 0x442f0000, + 700, + 700, 0x00000000, 0x00000000, 0x00000000, @@ -2243,8 +2243,8 @@ struct weaponfunc_shootauto invfunc_ar34_burstfire = { 0x40800000, 0x05008059, 0x01000000, - 0x443b8000, - 0x443b8000, + 750, + 750, 0x00000000, 0x00000000, 0x00000000, @@ -2270,8 +2270,8 @@ struct weaponfunc_shootauto invfunc_ar34_usescope = { 0x40800000, 0x05008059, 0x01000000, - 0x443b8000, - 0x443b8000, + 750, + 750, 0x00000000, 0x00000000, 0x00000000, @@ -2393,8 +2393,8 @@ struct weaponfunc_shootauto invfunc_k7avenger_burstfire = { 0x40800000, 0x0400805a, 0x01000000, - 0x446d8000, - 0x446d8000, + 950, + 950, 0x00000000, 0x00000000, 0x00000000, @@ -2420,8 +2420,8 @@ struct weaponfunc_shootauto invfunc_k7avenger_threatdetector = { 0x40800000, 0x0400805a, 0x01000000, - 0x446d8000, - 0x446d8000, + 950, + 950, 0x00000000, 0x00000000, 0x00000000, @@ -2551,8 +2551,8 @@ struct weaponfunc_shootauto invfunc_laptopgun_burstfire = { 0x40800000, 0x04008044, 0x01000000, - 0x447a0000, - 0x447a0000, + 1000, + 1000, 0x00000000, 0x00000000, 0x00000000, @@ -2824,8 +2824,8 @@ struct weaponfunc_shootauto invfunc_reaper_shoot = { 0x40800000, 0x0200803f, 0x01000000, - 0x42700000, - 0x44e10000, + 60, + 1800, (u32) &var8006d33c, (u32) &var8006d36c, 0x58580000, @@ -4428,8 +4428,8 @@ struct weaponfunc_shootauto invfunc_laser_stream = { 0x00000000, 0x03000000, 0x01000000, - 0x45610000, - 0x45610000, + 3600, + 3600, 0x00000000, 0x00000000, 0x00000000, @@ -4626,8 +4626,8 @@ struct weaponfunc_shootauto invfunc_kl01313_shoot = { 0x00000000, 0x0b00806b, 0x01000000, - 0x43e10000, - 0x43e10000, + 450, + 450, 0x00000000, 0x00000000, 0x00000000, @@ -4690,8 +4690,8 @@ struct weaponfunc_shootauto invfunc_kf7special_shoot = { 0x40400000, 0x0400806c, 0x01000000, - 0x43e10000, - 0x43e10000, + 450, + 450, 0x00000000, 0x00000000, 0x00000000, @@ -4754,8 +4754,8 @@ struct weaponfunc_shootauto invfunc_zzt9mm_shoot = { 0x00000000, 0x0400806d, 0x01000000, - 0x44160000, - 0x44160000, + 600, + 600, 0x00000000, 0x00000000, 0x00000000, @@ -4818,8 +4818,8 @@ struct weaponfunc_shootauto invfunc_dmc_shoot = { 0x00000000, 0x0400806e, 0x01000000, - 0x43e10000, - 0x43e10000, + 450, + 450, 0x00000000, 0x00000000, 0x00000000, @@ -4882,8 +4882,8 @@ struct weaponfunc_shootauto invfunc_ar53_shoot = { 0x40800000, 0x0500806f, 0x01000000, - 0x44098000, - 0x44098000, + 550, + 550, 0x00000000, 0x00000000, 0x00000000, @@ -4946,8 +4946,8 @@ struct weaponfunc_shootauto invfunc_rcp45_shoot = { 0x40800000, 0x02008070, 0x01000000, - 0x44160000, - 0x44160000, + 600, + 600, 0x00000000, 0x00000000, 0x00000000, @@ -5053,8 +5053,8 @@ struct weaponfunc_shootauto invfunc_59_rapidfire = { 0x40800000, 0x04008059, 0x02000000, - 0x44610000, - 0x44610000, + 900, + 900, 0x00000000, 0x00000000, 0x00000000, @@ -5117,8 +5117,8 @@ struct weaponfunc_shootauto invfunc_5a_rapidfire = { 0x40800000, 0x0400803f, 0x01000000, - 0x44610000, - 0x44610000, + 900, + 900, 0x00000000, 0x00000000, 0x00000000, diff --git a/src/game/game_0b0420.c b/src/game/game_0b0420.c index 696cfcbab..646680441 100644 --- a/src/game/game_0b0420.c +++ b/src/game/game_0b0420.c @@ -2030,39 +2030,21 @@ glabel func0f0b1ea8 /* f0b1ee4: 00000000 */ sll $zero,$zero,0x0 ); -GLOBAL_ASM( -glabel func0f0b1ee8 -/* f0b1ee8: 27bdffd8 */ addiu $sp,$sp,-40 -/* f0b1eec: afbf0014 */ sw $ra,0x14($sp) -/* f0b1ef0: afa5002c */ sw $a1,0x2c($sp) -/* f0b1ef4: 0fc2c3f4 */ jal weaponFindById -/* f0b1ef8: afa0001c */ sw $zero,0x1c($sp) -/* f0b1efc: 8fae002c */ lw $t6,0x2c($sp) -/* f0b1f00: 8fa6001c */ lw $a2,0x1c($sp) -/* f0b1f04: 8fbf0014 */ lw $ra,0x14($sp) -/* f0b1f08: 000e7880 */ sll $t7,$t6,0x2 -/* f0b1f0c: 004fc021 */ addu $t8,$v0,$t7 -/* f0b1f10: 8f030014 */ lw $v1,0x14($t8) -/* f0b1f14: 27bd0028 */ addiu $sp,$sp,0x28 -/* f0b1f18: 5060000c */ beqzl $v1,.L0f0b1f4c -/* f0b1f1c: 00061600 */ sll $v0,$a2,0x18 -/* f0b1f20: 8c790000 */ lw $t9,0x0($v1) -/* f0b1f24: 24010101 */ addiu $at,$zero,0x101 -/* f0b1f28: 17210007 */ bne $t9,$at,.L0f0b1f48 -/* f0b1f2c: 3c014561 */ lui $at,0x4561 -/* f0b1f30: 44812000 */ mtc1 $at,$f4 -/* f0b1f34: c4660044 */ lwc1 $f6,0x44($v1) -/* f0b1f38: 46062203 */ div.s $f8,$f4,$f6 -/* f0b1f3c: 4600428d */ trunc.w.s $f10,$f8 -/* f0b1f40: 44065000 */ mfc1 $a2,$f10 -/* f0b1f44: 00000000 */ sll $zero,$zero,0x0 -.L0f0b1f48: -/* f0b1f48: 00061600 */ sll $v0,$a2,0x18 -.L0f0b1f4c: -/* f0b1f4c: 00024e03 */ sra $t1,$v0,0x18 -/* f0b1f50: 03e00008 */ jr $ra -/* f0b1f54: 01201025 */ or $v0,$t1,$zero -); +s8 weaponGetMaxFireRatePerTick(u32 weaponnum, u32 funcindex) +{ + u32 stack[2]; + s32 result = 0; + struct weapon *weapon = weaponFindById(weaponnum); + struct weaponfunc *func = weapon->functions[funcindex]; + + if (func && func->type == INVENTORYFUNCTYPE_SHOOT_AUTOMATIC) { + struct weaponfunc_shootauto *autofunc = (struct weaponfunc_shootauto *)func; + + result = 3600.0f / autofunc->maxfirerate; + } + + return result; +} u32 currentPlayerGetSight(void) { diff --git a/src/game/game_190260.c b/src/game/game_190260.c index 85ead8481..0e1e21c42 100644 --- a/src/game/game_190260.c +++ b/src/game/game_190260.c @@ -7608,7 +7608,7 @@ glabel func0f194b40 /* f197198: 00008025 */ or $s0,$zero,$zero /* f19719c: 8e440020 */ lw $a0,0x20($s2) /* f1971a0: 00055880 */ sll $t3,$a1,0x2 -/* f1971a4: 0fc2c7ba */ jal func0f0b1ee8 +/* f1971a4: 0fc2c7ba */ jal weaponGetMaxFireRatePerTick /* f1971a8: 000b2fc2 */ srl $a1,$t3,0x1f /* f1971ac: 5c400030 */ bgtzl $v0,.L0f197270 /* f1971b0: 02e08025 */ or $s0,$s7,$zero @@ -7755,7 +7755,7 @@ glabel func0f194b40 .L0f1973bc: /* f1973bc: 8e440020 */ lw $a0,0x20($s2) /* f1973c0: 00055880 */ sll $t3,$a1,0x2 -/* f1973c4: 0fc2c7ba */ jal func0f0b1ee8 +/* f1973c4: 0fc2c7ba */ jal weaponGetMaxFireRatePerTick /* f1973c8: 000b2fc2 */ srl $a1,$t3,0x1f /* f1973cc: 1c40003f */ bgtz $v0,.L0f1974cc /* f1973d0: 00000000 */ sll $zero,$zero,0x0 diff --git a/src/include/game/game_0b0420.h b/src/include/game/game_0b0420.h index 04682079e..3c35cf828 100644 --- a/src/include/game/game_0b0420.h +++ b/src/include/game/game_0b0420.h @@ -45,7 +45,7 @@ f32 func0f0b1d28(u8 *weapon_id); u32 func0f0b1e28(void); u32 func0f0b1e68(void); u32 func0f0b1ea8(void); -u32 func0f0b1ee8(void); +s8 weaponGetMaxFireRatePerTick(u32 weaponnum, u32 funcindex); u32 currentPlayerGetSight(void); u32 func0f0b201c(void); u32 func0f0b20e8(void); diff --git a/src/include/types.h b/src/include/types.h index c6be16375..dad93970c 100644 --- a/src/include/types.h +++ b/src/include/types.h @@ -2896,8 +2896,8 @@ struct weaponfunc_shootauto { /*0x34*/ u32 unk34; /*0x38*/ u32 unk38; /*0x3c*/ u32 unk3c; - /*0x40*/ u32 unk40; - /*0x44*/ u32 unk44; + /*0x40*/ f32 initialfirerate; // rounds per minute + /*0x44*/ f32 maxfirerate; // rounds per minute /*0x48*/ u32 unk48; /*0x4c*/ u32 unk4c; /*0x50*/ u32 unk50;