From aa7733851264a8cc2527e3b02bd0203bb480b2c5 Mon Sep 17 00:00:00 2001 From: Ryan Dwyer Date: Mon, 30 Dec 2019 20:10:23 +1000 Subject: [PATCH] Decompile menuhandlerAmmoOnScreen --- src/game/game_102240.c | 63 +++++++++++----------------------- src/include/game/game_102240.h | 2 +- src/include/game/game_152710.h | 4 +-- src/include/types.h | 33 +++++++++++++++++- 4 files changed, 55 insertions(+), 47 deletions(-) diff --git a/src/game/game_102240.c b/src/game/game_102240.c index a1f6a0dd9..aebc68da7 100644 --- a/src/game/game_102240.c +++ b/src/game/game_102240.c @@ -1024,49 +1024,26 @@ glabel menuhandlerHiRes /* f102dcc: 00000000 */ sll $zero,$zero,0x0 ); -GLOBAL_ASM( -glabel menuhandlerAmmoOnScreen -/* f102dd0: 3c02800a */ lui $v0,%hi(g_Vars) -/* f102dd4: 24429fc0 */ addiu $v0,$v0,%lo(g_Vars) -/* f102dd8: 8c4e0298 */ lw $t6,0x298($v0) -/* f102ddc: 27bdffe8 */ addiu $sp,$sp,-24 -/* f102de0: afbf0014 */ sw $ra,0x14($sp) -/* f102de4: 05c10004 */ bgez $t6,.L0f102df8 -/* f102de8: 00803825 */ or $a3,$a0,$zero -/* f102dec: 8c4f029c */ lw $t7,0x29c($v0) -/* f102df0: 05e20005 */ bltzl $t7,.L0f102e08 -/* f102df4: 8ca4000c */ lw $a0,0xc($a1) -.L0f102df8: -/* f102df8: 8c580288 */ lw $t8,0x288($v0) -/* f102dfc: 10000002 */ beqz $zero,.L0f102e08 -/* f102e00: 8f040070 */ lw $a0,0x70($t8) -/* f102e04: 8ca4000c */ lw $a0,0xc($a1) -.L0f102e08: -/* f102e08: 24010006 */ addiu $at,$zero,0x6 -/* f102e0c: 10e10007 */ beq $a3,$at,.L0f102e2c -/* f102e10: 24010008 */ addiu $at,$zero,0x8 -/* f102e14: 54e1000d */ bnel $a3,$at,.L0f102e4c -/* f102e18: 00001025 */ or $v0,$zero,$zero -/* f102e1c: 0fc54a0d */ jal func0f152834 -/* f102e20: 00000000 */ sll $zero,$zero,0x0 -/* f102e24: 1000000a */ beqz $zero,.L0f102e50 -/* f102e28: 8fbf0014 */ lw $ra,0x14($sp) -.L0f102e2c: -/* f102e2c: 0fc54ac0 */ jal func0f152b00 -/* f102e30: 8cc50000 */ lw $a1,0x0($a2) -/* f102e34: 3c02800a */ lui $v0,%hi(g_Vars) -/* f102e38: 24429fc0 */ addiu $v0,$v0,%lo(g_Vars) -/* f102e3c: 8c590458 */ lw $t9,0x458($v0) -/* f102e40: 37280001 */ ori $t0,$t9,0x1 -/* f102e44: ac480458 */ sw $t0,0x458($v0) -/* f102e48: 00001025 */ or $v0,$zero,$zero -.L0f102e4c: -/* f102e4c: 8fbf0014 */ lw $ra,0x14($sp) -.L0f102e50: -/* f102e50: 27bd0018 */ addiu $sp,$sp,0x18 -/* f102e54: 03e00008 */ jr $ra -/* f102e58: 00000000 */ sll $zero,$zero,0x0 -); +s32 menuhandlerAmmoOnScreen(u32 operation, struct menu_item *item, bool *enable) +{ + u32 optionsindex; + + if (g_Vars.coopplayernum >= 0 || g_Vars.antiplayernum >= 0) { + optionsindex = g_Vars.unk000288->optionsindex; + } else { + optionsindex = item->right; + } + + switch (operation) { + case MENUOP_GET: + return func0f152834(optionsindex); + case MENUOP_SET: + func0f152b00(optionsindex, *enable); + g_Vars.unk000458 |= 1; + } + + return 0; +} GLOBAL_ASM( glabel menuhandlerShowGunFunction diff --git a/src/include/game/game_102240.h b/src/include/game/game_102240.h index 8446e3d90..19357aa8f 100644 --- a/src/include/game/game_102240.h +++ b/src/include/game/game_102240.h @@ -49,7 +49,7 @@ s32 menuhandler00106644(u32, u32, u32 *); s32 menuhandlerAimControl(u32, u32, u32 *); s32 menuhandlerAlternativeTitle(u32, u32, u32 *); s32 menuhandlerAlwaysShowTarget(u32, u32, u32 *); -s32 menuhandlerAmmoOnScreen(u32, u32, u32 *); +s32 menuhandlerAmmoOnScreen(u32 operation, struct menu_item *item, bool *enable); s32 menuhandlerAntiPlayer(u32, u32, u32 *); s32 menuhandlerAntiRadar(u32, u32, u32 *); s32 menuhandlerAutoAim(u32, u32, u32 *); diff --git a/src/include/game/game_152710.h b/src/include/game/game_152710.h index 6d5fde88f..6413e7ad4 100644 --- a/src/include/game/game_152710.h +++ b/src/include/game/game_152710.h @@ -12,7 +12,7 @@ u32 func0f1527a4(void); u32 func0f1527c8(void); u32 func0f1527ec(void); u32 func0f152810(void); -u32 func0f152834(void); +s32 func0f152834(s32 optionsindex); u32 func0f152858(void); u32 func0f15287c(void); u32 func0f1528a0(void); @@ -26,7 +26,7 @@ u32 func0f1529a0(void); u32 func0f1529f8(void); u32 func0f152a50(void); u32 func0f152aa8(void); -u32 func0f152b00(void); +void func0f152b00(s32 optionsindex, bool enable); u32 func0f152b58(void); u32 func0f152bb0(void); u32 func0f152c08(void); diff --git a/src/include/types.h b/src/include/types.h index e5433e196..3cb1b414f 100644 --- a/src/include/types.h +++ b/src/include/types.h @@ -2861,7 +2861,38 @@ struct bootbufferthing { }; struct gvars74 { - u8 unk00[0x80]; + /*0x00*/ u32 unk00; + /*0x04*/ u32 unk04; + /*0x08*/ u32 unk08; + /*0x0c*/ u32 unk0c; + /*0x10*/ u32 unk10; + /*0x14*/ u32 unk14; + /*0x18*/ u32 unk18; + /*0x1c*/ u32 unk1c; + /*0x20*/ u32 unk20; + /*0x24*/ u32 unk24; + /*0x28*/ u32 unk28; + /*0x2c*/ u32 unk2c; + /*0x30*/ u32 unk30; + /*0x34*/ u32 unk34; + /*0x38*/ u32 unk38; + /*0x3c*/ u32 unk3c; + /*0x40*/ u32 unk40; + /*0x44*/ u32 unk44; + /*0x48*/ u32 unk48; + /*0x4c*/ u32 unk4c; + /*0x50*/ u32 unk50; + /*0x54*/ u32 unk54; + /*0x58*/ u32 unk58; + /*0x5c*/ u32 unk5c; + /*0x60*/ u32 unk60; + /*0x64*/ u32 unk64; + /*0x68*/ u32 unk68; + /*0x6c*/ u32 unk6c; + /*0x70*/ u32 optionsindex; + /*0x74*/ u32 unk74; + /*0x78*/ u32 unk78; + /*0x7c*/ u32 unk7c; }; struct credit {