From a95f70bf3392628d090ef63ebe28178d08f93cbd Mon Sep 17 00:00:00 2001 From: Ryan Dwyer Date: Sat, 10 Apr 2021 21:49:03 +1000 Subject: [PATCH] Decompile weaponGetAmmoCapacity --- src/game/game_097ba0.c | 37 ++++++++++------------------------ src/game/propobj.c | 4 ++-- src/include/game/game_097ba0.h | 2 +- 3 files changed, 14 insertions(+), 29 deletions(-) diff --git a/src/game/game_097ba0.c b/src/game/game_097ba0.c index 41d1e91bf..1f0519fe5 100644 --- a/src/game/game_097ba0.c +++ b/src/game/game_097ba0.c @@ -34639,32 +34639,17 @@ void currentPlayerGiveAmmoForWeapon(u32 weaponnum, u32 func, u32 quantity) } } -GLOBAL_ASM( -glabel func0f0a9b10 -/* f0a9b10: 27bdffe8 */ addiu $sp,$sp,-24 -/* f0a9b14: afbf0014 */ sw $ra,0x14($sp) -/* f0a9b18: 0fc2c3f4 */ jal weaponFindById -/* f0a9b1c: afa5001c */ sw $a1,0x1c($sp) -/* f0a9b20: 8fae001c */ lw $t6,0x1c($sp) -/* f0a9b24: 8fbf0014 */ lw $ra,0x14($sp) -/* f0a9b28: 000e7880 */ sll $t7,$t6,0x2 -/* f0a9b2c: 004fc021 */ addu $t8,$v0,$t7 -/* f0a9b30: 8f03001c */ lw $v1,0x1c($t8) -/* f0a9b34: 00001025 */ or $v0,$zero,$zero -/* f0a9b38: 10600009 */ beqz $v1,.L0f0a9b60 -/* f0a9b3c: 00000000 */ nop -/* f0a9b40: 8c790000 */ lw $t9,0x0($v1) -/* f0a9b44: 3c028007 */ lui $v0,%hi(g_AmmoTypes) -/* f0a9b48: 00194080 */ sll $t0,$t9,0x2 -/* f0a9b4c: 01194023 */ subu $t0,$t0,$t9 -/* f0a9b50: 00084080 */ sll $t0,$t0,0x2 -/* f0a9b54: 00481021 */ addu $v0,$v0,$t0 -/* f0a9b58: 10000001 */ b .L0f0a9b60 -/* f0a9b5c: 8c420368 */ lw $v0,%lo(g_AmmoTypes)($v0) -.L0f0a9b60: -/* f0a9b60: 03e00008 */ jr $ra -/* f0a9b64: 27bd0018 */ addiu $sp,$sp,0x18 -); +s32 weaponGetAmmoCapacity(s32 weaponnum, s32 func) +{ + struct weapon *weapon = weaponFindById(weaponnum); + struct inventory_ammo *ammo = weapon->ammos[func]; + + if (ammo) { + return g_AmmoTypes[ammo->type].capacity; + } + + return 0; +} GLOBAL_ASM( glabel func0f0a9b68 diff --git a/src/game/propobj.c b/src/game/propobj.c index ad2d4b71d..c50681dd0 100644 --- a/src/game/propobj.c +++ b/src/game/propobj.c @@ -65982,7 +65982,7 @@ glabel var7f1aae84 /* f0892a0: 8fa70080 */ lw $a3,0x80($sp) /* f0892a4: 00002825 */ or $a1,$zero,$zero /* f0892a8: 90e4005c */ lbu $a0,0x5c($a3) -/* f0892ac: 0fc2a6c4 */ jal func0f0a9b10 +/* f0892ac: 0fc2a6c4 */ jal weaponGetAmmoCapacity /* f0892b0: afa20030 */ sw $v0,0x30($sp) /* f0892b4: 8fa30030 */ lw $v1,0x30($sp) /* f0892b8: 8fa70080 */ lw $a3,0x80($sp) @@ -65999,7 +65999,7 @@ glabel var7f1aae84 /* f0892e0: 8fa70080 */ lw $a3,0x80($sp) /* f0892e4: 24050001 */ addiu $a1,$zero,0x1 /* f0892e8: 90e4005c */ lbu $a0,0x5c($a3) -/* f0892ec: 0fc2a6c4 */ jal func0f0a9b10 +/* f0892ec: 0fc2a6c4 */ jal weaponGetAmmoCapacity /* f0892f0: afa20030 */ sw $v0,0x30($sp) /* f0892f4: 8fa30030 */ lw $v1,0x30($sp) /* f0892f8: 8fa70080 */ lw $a3,0x80($sp) diff --git a/src/include/game/game_097ba0.h b/src/include/game/game_097ba0.h index 7161c4865..df6659fb4 100644 --- a/src/include/game/game_097ba0.h +++ b/src/include/game/game_097ba0.h @@ -161,7 +161,7 @@ void currentPlayerGiveUnlimitedAmmo(bool force); u32 weaponGetAmmoType(u32 weaponnum, u32 func); s32 currentPlayerGetAmmoQuantityForWeapon(u32 weaponnum, u32 func); void currentPlayerGiveAmmoForWeapon(u32 weaponnum, u32 func, u32 quantity); -u32 func0f0a9b10(void); +s32 weaponGetAmmoCapacity(s32 weaponnum, s32 func); u32 func0f0a9b68(void); u32 func0f0a9d2c(void); void abmagReset(struct abmag *abmag);