From 9f0e5ccada2dccaccd7d08ec6b85a421e7fb950a Mon Sep 17 00:00:00 2001 From: Ryan Dwyer Date: Mon, 30 Dec 2019 21:10:42 +1000 Subject: [PATCH] Decompile optionsGetShowGunFunction and optionsSetShowGunFunction --- src/game/game_097a50.c | 2 +- src/game/game_102240.c | 4 +-- src/game/game_10ccd0.c | 8 +++--- src/game/game_152710.c | 50 ++++++++-------------------------- src/include/constants.h | 3 +- src/include/game/game_152710.h | 4 +-- 6 files changed, 23 insertions(+), 48 deletions(-) diff --git a/src/game/game_097a50.c b/src/game/game_097a50.c index ef966fd1d..f21cbe194 100644 --- a/src/game/game_097a50.c +++ b/src/game/game_097a50.c @@ -22497,7 +22497,7 @@ glabel func0f0aa86c /* f0aad0c: 3c0e800a */ lui $t6,0x800a /* f0aad10: 8dcea248 */ lw $t6,-0x5db8($t6) /* f0aad14: afa20130 */ sw $v0,0x130($sp) -/* f0aad18: 0fc54a16 */ jal func0f152858 +/* f0aad18: 0fc54a16 */ jal optionsGetShowGunFunction /* f0aad1c: 8dc40070 */ lw $a0,0x70($t6) /* f0aad20: 10400163 */ beqz $v0,.L0f0ab2b0 /* f0aad24: 8faa0058 */ lw $t2,0x58($sp) diff --git a/src/game/game_102240.c b/src/game/game_102240.c index 9b7cf0033..8dcc684b1 100644 --- a/src/game/game_102240.c +++ b/src/game/game_102240.c @@ -1062,9 +1062,9 @@ s32 menuhandlerShowGunFunction(u32 operation, struct menu_item *item, bool *enab } break; case MENUOP_GET: - return func0f152858(optionsindex); + return optionsGetShowGunFunction(optionsindex); case MENUOP_SET: - func0f152b58(optionsindex, *enable); + optionsSetShowGunFunction(optionsindex, *enable); g_Vars.unk000458 |= 1; } diff --git a/src/game/game_10ccd0.c b/src/game/game_10ccd0.c index 1eb5fa607..8efddd0e2 100644 --- a/src/game/game_10ccd0.c +++ b/src/game/game_10ccd0.c @@ -2825,7 +2825,7 @@ glabel func0f10f204 /* f10f310: 0fc47961 */ jal func0f11e584 /* f10f314: 02002825 */ or $a1,$s0,$zero /* f10f318: 8fa40024 */ lw $a0,0x24($sp) -/* f10f31c: 0fc54ad6 */ jal func0f152b58 +/* f10f31c: 0fc54ad6 */ jal optionsSetShowGunFunction /* f10f320: 00402825 */ or $a1,$v0,$zero /* f10f324: 24040015 */ addiu $a0,$zero,0x15 /* f10f328: 0fc47961 */ jal func0f11e584 @@ -2897,7 +2897,7 @@ glabel func0f10f204 /* f10f430: 0fc47961 */ jal func0f11e584 /* f10f434: 02002825 */ or $a1,$s0,$zero /* f10f438: 8fa40020 */ lw $a0,0x20($sp) -/* f10f43c: 0fc54ad6 */ jal func0f152b58 +/* f10f43c: 0fc54ad6 */ jal optionsSetShowGunFunction /* f10f440: 00402825 */ or $a1,$v0,$zero /* f10f444: 24040016 */ addiu $a0,$zero,0x16 /* f10f448: 0fc47961 */ jal func0f11e584 @@ -3703,7 +3703,7 @@ glabel func0f10feac /* f10ffcc: 02002825 */ or $a1,$s0,$zero /* f10ffd0: 0fc4794c */ jal func0f11e530 /* f10ffd4: 00403025 */ or $a2,$v0,$zero -/* f10ffd8: 0fc54a16 */ jal func0f152858 +/* f10ffd8: 0fc54a16 */ jal optionsGetShowGunFunction /* f10ffdc: 02602025 */ or $a0,$s3,$zero /* f10ffe0: 2404000a */ addiu $a0,$zero,0xa /* f10ffe4: 02002825 */ or $a1,$s0,$zero @@ -3775,7 +3775,7 @@ glabel func0f10feac /* f1100ec: 02002825 */ or $a1,$s0,$zero /* f1100f0: 0fc4794c */ jal func0f11e530 /* f1100f4: 00403025 */ or $a2,$v0,$zero -/* f1100f8: 0fc54a16 */ jal func0f152858 +/* f1100f8: 0fc54a16 */ jal optionsGetShowGunFunction /* f1100fc: 02202025 */ or $a0,$s1,$zero /* f110100: 24040013 */ addiu $a0,$zero,0x13 /* f110104: 02002825 */ or $a1,$s0,$zero diff --git a/src/game/game_152710.c b/src/game/game_152710.c index 9090fccc2..70bb0ed6b 100644 --- a/src/game/game_152710.c +++ b/src/game/game_152710.c @@ -121,18 +121,10 @@ s32 optionsGetAmmoOnScreen(s32 optionsindex) return (g_Options[optionsindex].unk48 & OPTION_AMMOONSCREEN) != 0; } -GLOBAL_ASM( -glabel func0f152858 -/* f152858: 00047080 */ sll $t6,$a0,0x2 -/* f15285c: 01c47021 */ addu $t6,$t6,$a0 -/* f152860: 000e7140 */ sll $t6,$t6,0x5 -/* f152864: 3c02800b */ lui $v0,0x800b -/* f152868: 004e1021 */ addu $v0,$v0,$t6 -/* f15286c: 9442c800 */ lhu $v0,-0x3800($v0) -/* f152870: 304f0040 */ andi $t7,$v0,0x40 -/* f152874: 03e00008 */ jr $ra -/* f152878: 000f102b */ sltu $v0,$zero,$t7 -); +s32 optionsGetShowGunFunction(s32 optionsindex) +{ + return (g_Options[optionsindex].unk48 & OPTION_SHOWGUNFUNCTION) != 0; +} GLOBAL_ASM( glabel func0f15287c @@ -357,32 +349,14 @@ void optionsSetAmmoOnScreen(s32 optionsindex, bool enable) } } -GLOBAL_ASM( -glabel func0f152b58 -/* f152b58: 10a0000b */ beqz $a1,.L0f152b88 -/* f152b5c: 00044080 */ sll $t0,$a0,0x2 -/* f152b60: 00047080 */ sll $t6,$a0,0x2 -/* f152b64: 01c47021 */ addu $t6,$t6,$a0 -/* f152b68: 3c0f800b */ lui $t7,%hi(g_Options) -/* f152b6c: 25efc7b8 */ addiu $t7,$t7,%lo(g_Options) -/* f152b70: 000e7140 */ sll $t6,$t6,0x5 -/* f152b74: 01cf1021 */ addu $v0,$t6,$t7 -/* f152b78: 94580048 */ lhu $t8,0x48($v0) -/* f152b7c: 37190040 */ ori $t9,$t8,0x40 -/* f152b80: 03e00008 */ jr $ra -/* f152b84: a4590048 */ sh $t9,0x48($v0) -.L0f152b88: -/* f152b88: 01044021 */ addu $t0,$t0,$a0 -/* f152b8c: 3c09800b */ lui $t1,%hi(g_Options) -/* f152b90: 2529c7b8 */ addiu $t1,$t1,%lo(g_Options) -/* f152b94: 00084140 */ sll $t0,$t0,0x5 -/* f152b98: 01091021 */ addu $v0,$t0,$t1 -/* f152b9c: 944a0048 */ lhu $t2,0x48($v0) -/* f152ba0: 314bffbf */ andi $t3,$t2,0xffbf -/* f152ba4: a44b0048 */ sh $t3,0x48($v0) -/* f152ba8: 03e00008 */ jr $ra -/* f152bac: 00000000 */ sll $zero,$zero,0x0 -); +void optionsSetShowGunFunction(s32 optionsindex, bool enable) +{ + if (enable) { + g_Options[optionsindex].unk48 |= OPTION_SHOWGUNFUNCTION; + } else { + g_Options[optionsindex].unk48 &= ~OPTION_SHOWGUNFUNCTION; + } +} GLOBAL_ASM( glabel func0f152bb0 diff --git a/src/include/constants.h b/src/include/constants.h index 1bce7dde1..7793f09b4 100644 --- a/src/include/constants.h +++ b/src/include/constants.h @@ -658,7 +658,8 @@ #define OPERATOR_LESS_THAN 0 #define OPERATOR_GREATER_THAN 1 -#define OPTION_AMMOONSCREEN 0x0020 +#define OPTION_AMMOONSCREEN 0x0020 +#define OPTION_SHOWGUNFUNCTION 0x0040 #define OUTFIT_DEFAULT 0x00 #define OUTFIT_ELVIS 0x01 diff --git a/src/include/game/game_152710.h b/src/include/game/game_152710.h index afd3ea457..1a39b5c59 100644 --- a/src/include/game/game_152710.h +++ b/src/include/game/game_152710.h @@ -13,7 +13,7 @@ u32 func0f1527c8(void); u32 func0f1527ec(void); u32 func0f152810(void); s32 optionsGetAmmoOnScreen(s32 optionsindex); -s32 func0f152858(s32 optionsindex); +s32 optionsGetShowGunFunction(s32 optionsindex); u32 func0f15287c(void); u32 func0f1528a0(void); u32 func0f1528c4(void); @@ -27,7 +27,7 @@ u32 func0f1529f8(void); u32 func0f152a50(void); u32 func0f152aa8(void); void optionsSetAmmoOnScreen(s32 optionsindex, bool enable); -void func0f152b58(s32 optionsindex, bool enable); +void optionsSetShowGunFunction(s32 optionsindex, bool enable); u32 func0f152bb0(void); u32 func0f152c08(void); u32 func0f152c60(void);