From 5412046c462de55714219a4c1e92f71acb22490b Mon Sep 17 00:00:00 2001 From: Ryan Dwyer Date: Tue, 31 Dec 2019 01:04:16 +1000 Subject: [PATCH] Decompile optionsGetAimControl and optionsSetAimControl --- src/game/game_0c79f0.c | 12 ++++---- src/game/game_0dcdb0.c | 2 +- src/game/game_102240.c | 8 ++--- src/game/game_10ccd0.c | 8 ++--- src/game/game_152710.c | 50 ++++++++------------------------ src/game/game_176d70.c | 4 +-- src/include/constants.h | 6 ++++ src/include/game/game_102240.h | 2 +- src/include/game/game_152710.h | 4 +-- src/include/setup/setup_0160b0.h | 2 +- src/setup/setup_0160b0.c | 2 +- 11 files changed, 40 insertions(+), 60 deletions(-) diff --git a/src/game/game_0c79f0.c b/src/game/game_0c79f0.c index 13d375141..eee13a8f3 100644 --- a/src/game/game_0c79f0.c +++ b/src/game/game_0c79f0.c @@ -1843,7 +1843,7 @@ glabel func0f0c8b90 /* f0c916c: a7ae00ea */ sh $t6,0xea($sp) .L0f0c9170: /* f0c9170: 8e4f0288 */ lw $t7,0x288($s2) -/* f0c9174: 0fc549fb */ jal func0f1527ec +/* f0c9174: 0fc549fb */ jal optionsGetAimControl /* f0c9178: 8de40070 */ lw $a0,0x70($t7) /* f0c917c: 1440001f */ bnez $v0,.L0f0c91fc /* f0c9180: 00000000 */ sll $zero,$zero,0x0 @@ -1886,7 +1886,7 @@ glabel func0f0c8b90 /* f0c9204: 54400243 */ bnezl $v0,.L0f0c9b14 /* f0c9208: 8e450284 */ lw $a1,0x284($s2) /* f0c920c: 8e4d0288 */ lw $t5,0x288($s2) -/* f0c9210: 0fc549fb */ jal func0f1527ec +/* f0c9210: 0fc549fb */ jal optionsGetAimControl /* f0c9214: 8da40070 */ lw $a0,0x70($t5) /* f0c9218: 1040001f */ beqz $v0,.L0f0c9298 /* f0c921c: 00000000 */ sll $zero,$zero,0x0 @@ -2392,7 +2392,7 @@ glabel func0f0c8b90 .L0f0c9924: /* f0c9924: 8e4a0288 */ lw $t2,0x288($s2) .L0f0c9928: -/* f0c9928: 0fc549fb */ jal func0f1527ec +/* f0c9928: 0fc549fb */ jal optionsGetAimControl /* f0c992c: 8d440070 */ lw $a0,0x70($t2) /* f0c9930: 14400019 */ bnez $v0,.L0f0c9998 /* f0c9934: 00105880 */ sll $t3,$s0,0x2 @@ -2627,7 +2627,7 @@ glabel func0f0c8b90 /* f0c9c5c: a7aa00ca */ sh $t2,0xca($sp) .L0f0c9c60: /* f0c9c60: 8e4b0288 */ lw $t3,0x288($s2) -/* f0c9c64: 0fc549fb */ jal func0f1527ec +/* f0c9c64: 0fc549fb */ jal optionsGetAimControl /* f0c9c68: 8d640070 */ lw $a0,0x70($t3) /* f0c9c6c: 14400021 */ bnez $v0,.L0f0c9cf4 /* f0c9c70: 00000000 */ sll $zero,$zero,0x0 @@ -2672,7 +2672,7 @@ glabel func0f0c8b90 /* f0c9cfc: 544002ba */ bnezl $v0,.L0f0ca7e8 /* f0c9d00: 8e450284 */ lw $a1,0x284($s2) /* f0c9d04: 8e490288 */ lw $t1,0x288($s2) -/* f0c9d08: 0fc549fb */ jal func0f1527ec +/* f0c9d08: 0fc549fb */ jal optionsGetAimControl /* f0c9d0c: 8d240070 */ lw $a0,0x70($t1) /* f0c9d10: 10400021 */ beqz $v0,.L0f0c9d98 /* f0c9d14: 00000000 */ sll $zero,$zero,0x0 @@ -3300,7 +3300,7 @@ glabel func0f0c8b90 .L0f0ca5f0: /* f0ca5f0: 8e4e0288 */ lw $t6,0x288($s2) .L0f0ca5f4: -/* f0ca5f4: 0fc549fb */ jal func0f1527ec +/* f0ca5f4: 0fc549fb */ jal optionsGetAimControl /* f0ca5f8: 8dc40070 */ lw $a0,0x70($t6) /* f0ca5fc: 14400019 */ bnez $v0,.L0f0ca664 /* f0ca600: 00107880 */ sll $t7,$s0,0x2 diff --git a/src/game/game_0dcdb0.c b/src/game/game_0dcdb0.c index ebe97049e..87e6a3e52 100644 --- a/src/game/game_0dcdb0.c +++ b/src/game/game_0dcdb0.c @@ -25038,7 +25038,7 @@ glabel func0f0efa90 /* f0efae4: 01194023 */ subu $t0,$t0,$t9 /* f0efae8: 00084100 */ sll $t0,$t0,0x4 /* f0efaec: 00882021 */ addu $a0,$a0,$t0 -/* f0efaf0: 0fc549fb */ jal func0f1527ec +/* f0efaf0: 0fc549fb */ jal optionsGetAimControl /* f0efaf4: 8c84ee24 */ lw $a0,-0x11dc($a0) /* f0efaf8: 24010001 */ addiu $at,$zero,0x1 /* f0efafc: 14410002 */ bne $v0,$at,.L0f0efb08 diff --git a/src/game/game_102240.c b/src/game/game_102240.c index 9930e6a41..e6338f565 100644 --- a/src/game/game_102240.c +++ b/src/game/game_102240.c @@ -381,8 +381,8 @@ glabel menuhandlerAimControl /* f1025e4: 8f040070 */ lw $a0,0x70($t8) /* f1025e8: 8ca4000c */ lw $a0,0xc($a1) .L0f1025ec: -/* f1025ec: 3c198007 */ lui $t9,%hi(options_aimcontrol) -/* f1025f0: 273919e4 */ addiu $t9,$t9,%lo(options_aimcontrol) +/* f1025ec: 3c198007 */ lui $t9,%hi(g_AimControlOptions) +/* f1025f0: 273919e4 */ addiu $t9,$t9,%lo(g_AimControlOptions) /* f1025f4: 8f210000 */ lw $at,0x0($t9) /* f1025f8: 27a30020 */ addiu $v1,$sp,0x20 /* f1025fc: 240a0002 */ addiu $t2,$zero,0x2 @@ -410,7 +410,7 @@ glabel menuhandlerAimControl /* f10264c: 1000000f */ beqz $zero,.L0f10268c /* f102650: 8fbf0014 */ lw $ra,0x14($sp) .L0f102654: -/* f102654: 0fc54a94 */ jal func0f152a50 +/* f102654: 0fc54a94 */ jal optionsSetAimControl /* f102658: 8cc50000 */ lw $a1,0x0($a2) /* f10265c: 3c02800a */ lui $v0,%hi(g_Vars) /* f102660: 24429fc0 */ addiu $v0,$v0,%lo(g_Vars) @@ -419,7 +419,7 @@ glabel menuhandlerAimControl /* f10266c: 10000005 */ beqz $zero,.L0f102684 /* f102670: ac4f0458 */ sw $t7,0x458($v0) .L0f102674: -/* f102674: 0fc549fb */ jal func0f1527ec +/* f102674: 0fc549fb */ jal optionsGetAimControl /* f102678: afa60030 */ sw $a2,0x30($sp) /* f10267c: 8fa60030 */ lw $a2,0x30($sp) /* f102680: acc20000 */ sw $v0,0x0($a2) diff --git a/src/game/game_10ccd0.c b/src/game/game_10ccd0.c index a624e5e4c..4ee559524 100644 --- a/src/game/game_10ccd0.c +++ b/src/game/game_10ccd0.c @@ -2795,7 +2795,7 @@ glabel func0f10f204 /* f10f298: 0fc47961 */ jal func0f11e584 /* f10f29c: 02002825 */ or $a1,$s0,$zero /* f10f2a0: 8fa40024 */ lw $a0,0x24($sp) -/* f10f2a4: 0fc54a94 */ jal func0f152a50 +/* f10f2a4: 0fc54a94 */ jal optionsSetAimControl /* f10f2a8: 00402825 */ or $a1,$v0,$zero /* f10f2ac: 24040003 */ addiu $a0,$zero,0x3 /* f10f2b0: 0fc47961 */ jal func0f11e584 @@ -2867,7 +2867,7 @@ glabel func0f10f204 /* f10f3b8: 0fc47961 */ jal func0f11e584 /* f10f3bc: 02002825 */ or $a1,$s0,$zero /* f10f3c0: 8fa40020 */ lw $a0,0x20($sp) -/* f10f3c4: 0fc54a94 */ jal func0f152a50 +/* f10f3c4: 0fc54a94 */ jal optionsSetAimControl /* f10f3c8: 00402825 */ or $a1,$v0,$zero /* f10f3cc: 2404000f */ addiu $a0,$zero,0xf /* f10f3d0: 0fc47961 */ jal func0f11e584 @@ -3673,7 +3673,7 @@ glabel func0f10feac /* f10ff54: 02002825 */ or $a1,$s0,$zero /* f10ff58: 0fc4794c */ jal func0f11e530 /* f10ff5c: 00403025 */ or $a2,$v0,$zero -/* f10ff60: 0fc549fb */ jal func0f1527ec +/* f10ff60: 0fc549fb */ jal optionsGetAimControl /* f10ff64: 02602025 */ or $a0,$s3,$zero /* f10ff68: 24040002 */ addiu $a0,$zero,0x2 /* f10ff6c: 02002825 */ or $a1,$s0,$zero @@ -3745,7 +3745,7 @@ glabel func0f10feac /* f110074: 02002825 */ or $a1,$s0,$zero /* f110078: 0fc4794c */ jal func0f11e530 /* f11007c: 00403025 */ or $a2,$v0,$zero -/* f110080: 0fc549fb */ jal func0f1527ec +/* f110080: 0fc549fb */ jal optionsGetAimControl /* f110084: 02202025 */ or $a0,$s1,$zero /* f110088: 2404000e */ addiu $a0,$zero,0xe /* f11008c: 02002825 */ or $a1,$s0,$zero diff --git a/src/game/game_152710.c b/src/game/game_152710.c index a1b7cee66..b7c18d429 100644 --- a/src/game/game_152710.c +++ b/src/game/game_152710.c @@ -66,18 +66,10 @@ s32 optionsGetLookAhead(s32 optionsindex) return (g_Options[optionsindex].unk48 & OPTION_LOOKAHEAD) != 0; } -GLOBAL_ASM( -glabel func0f1527ec -/* f1527ec: 00047080 */ sll $t6,$a0,0x2 -/* f1527f0: 01c47021 */ addu $t6,$t6,$a0 -/* f1527f4: 000e7140 */ sll $t6,$t6,0x5 -/* f1527f8: 3c02800b */ lui $v0,0x800b -/* f1527fc: 004e1021 */ addu $v0,$v0,$t6 -/* f152800: 9442c800 */ lhu $v0,-0x3800($v0) -/* f152804: 304f0010 */ andi $t7,$v0,0x10 -/* f152808: 03e00008 */ jr $ra -/* f15280c: 000f102b */ sltu $v0,$zero,$t7 -); +s32 optionsGetAimControl(s32 optionsindex) +{ + return (g_Options[optionsindex].unk48 & OPTION_AIMCONTROL) != 0; +} s32 optionsGetSightOnScreen(s32 optionsindex) { @@ -160,32 +152,14 @@ void optionsSetLookAhead(s32 optionsindex, bool enable) } } -GLOBAL_ASM( -glabel func0f152a50 -/* f152a50: 10a0000b */ beqz $a1,.L0f152a80 -/* f152a54: 00044080 */ sll $t0,$a0,0x2 -/* f152a58: 00047080 */ sll $t6,$a0,0x2 -/* f152a5c: 01c47021 */ addu $t6,$t6,$a0 -/* f152a60: 3c0f800b */ lui $t7,%hi(g_Options) -/* f152a64: 25efc7b8 */ addiu $t7,$t7,%lo(g_Options) -/* f152a68: 000e7140 */ sll $t6,$t6,0x5 -/* f152a6c: 01cf1021 */ addu $v0,$t6,$t7 -/* f152a70: 94580048 */ lhu $t8,0x48($v0) -/* f152a74: 37190010 */ ori $t9,$t8,0x10 -/* f152a78: 03e00008 */ jr $ra -/* f152a7c: a4590048 */ sh $t9,0x48($v0) -.L0f152a80: -/* f152a80: 01044021 */ addu $t0,$t0,$a0 -/* f152a84: 3c09800b */ lui $t1,%hi(g_Options) -/* f152a88: 2529c7b8 */ addiu $t1,$t1,%lo(g_Options) -/* f152a8c: 00084140 */ sll $t0,$t0,0x5 -/* f152a90: 01091021 */ addu $v0,$t0,$t1 -/* f152a94: 944a0048 */ lhu $t2,0x48($v0) -/* f152a98: 314bffef */ andi $t3,$t2,0xffef -/* f152a9c: a44b0048 */ sh $t3,0x48($v0) -/* f152aa0: 03e00008 */ jr $ra -/* f152aa4: 00000000 */ sll $zero,$zero,0x0 -); +void optionsSetAimControl(s32 optionsindex, s32 index) +{ + if (index) { + g_Options[optionsindex].unk48 |= OPTION_AIMCONTROL; + } else { + g_Options[optionsindex].unk48 &= ~OPTION_AIMCONTROL; + } +} void optionsSetSightOnScreen(s32 optionsindex, bool enable) { diff --git a/src/game/game_176d70.c b/src/game/game_176d70.c index 82683e5f9..2259bffc0 100644 --- a/src/game/game_176d70.c +++ b/src/game/game_176d70.c @@ -3629,14 +3629,14 @@ glabel menuhandlerMpAimControl .L0f179854: /* f179854: 3c048007 */ lui $a0,0x8007 /* f179858: 8c841448 */ lw $a0,0x1448($a0) -/* f17985c: 0fc54a94 */ jal func0f152a50 +/* f17985c: 0fc54a94 */ jal optionsSetAimControl /* f179860: 8cc50000 */ lw $a1,0x0($a2) /* f179864: 10000008 */ beqz $zero,.L0f179888 /* f179868: 00001025 */ or $v0,$zero,$zero .L0f17986c: /* f17986c: 3c048007 */ lui $a0,0x8007 /* f179870: 8c841448 */ lw $a0,0x1448($a0) -/* f179874: 0fc549fb */ jal func0f1527ec +/* f179874: 0fc549fb */ jal optionsGetAimControl /* f179878: afa60028 */ sw $a2,0x28($sp) /* f17987c: 8fa60028 */ lw $a2,0x28($sp) /* f179880: acc20000 */ sw $v0,0x0($a2) diff --git a/src/include/constants.h b/src/include/constants.h index 846e050ff..b7c4dae85 100644 --- a/src/include/constants.h +++ b/src/include/constants.h @@ -44,6 +44,9 @@ #define ACT_PUNCH 36 #define ACT_CUTFIRE 37 +#define AIMCONTROL_HOLD 0 +#define AIMCONTROL_TOGGLE 1 + #define AMMOTYPE_PISTOL 0x01 #define AMMOTYPE_SMG 0x02 #define AMMOTYPE_CROSSBOW 0x03 @@ -480,6 +483,8 @@ #define MA_FACING 53 #define MA_PUNCHING 54 +#define MENUOP_GETOPTIONCOUNT 1 +#define MENUOP_GETOPTIONTEXT 3 #define MENUOP_SET 6 #define MENUOP_GET 8 #define MENUOP_CHECKDISABLED 12 @@ -662,6 +667,7 @@ #define OPTION_LOOKAHEAD 0x0002 #define OPTION_SIGHTONSCREEN 0x0004 #define OPTION_AUTOAIM 0x0008 +#define OPTION_AIMCONTROL 0x0010 #define OPTION_AMMOONSCREEN 0x0020 #define OPTION_SHOWGUNFUNCTION 0x0040 #define OPTION_HEADROLL 0x0080 diff --git a/src/include/game/game_102240.h b/src/include/game/game_102240.h index 783d68d19..91f03f100 100644 --- a/src/include/game/game_102240.h +++ b/src/include/game/game_102240.h @@ -46,7 +46,7 @@ s32 menuhandler00106028(u32 operation, struct menu_item *item, bool *enable); s32 menuhandler00106178(u32 operation, struct menu_item *item, bool *enable); s32 menuhandler00106394(u32 operation, struct menu_item *item, bool *enable); s32 menuhandler00106644(u32 operation, struct menu_item *item, bool *enable); -s32 menuhandlerAimControl(u32 operation, struct menu_item *item, bool *enable); +char *menuhandlerAimControl(u32 operation, struct menu_item *item, bool *value); s32 menuhandlerAlternativeTitle(u32 operation, struct menu_item *item, bool *enable); s32 menuhandlerAlwaysShowTarget(u32 operation, struct menu_item *item, bool *enable); s32 menuhandlerAmmoOnScreen(u32 operation, struct menu_item *item, bool *enable); diff --git a/src/include/game/game_152710.h b/src/include/game/game_152710.h index c9b60b3ee..e3c1da756 100644 --- a/src/include/game/game_152710.h +++ b/src/include/game/game_152710.h @@ -10,7 +10,7 @@ u32 func0f152764(void); s32 optionsGetForwardPitch(s32 optionsindex); s32 optionsGetAutoAim(s32 optionsindex); s32 optionsGetLookAhead(s32 optionsindex); -u32 func0f1527ec(void); +s32 optionsGetAimControl(s32 optionsindex); s32 optionsGetSightOnScreen(s32 optionsindex); s32 optionsGetAmmoOnScreen(s32 optionsindex); s32 optionsGetShowGunFunction(s32 optionsindex); @@ -25,7 +25,7 @@ s32 optionsGetHeadRoll(s32 optionsindex); void optionsSetForwardPitch(s32 optionsindex, bool enable); void optionsSetAutoAim(s32 optionsindex, bool enable); void optionsSetLookAhead(s32 optionsindex, bool enable); -u32 func0f152a50(void); +void optionsSetAimControl(s32 optionsindex, s32 index); void optionsSetSightOnScreen(s32 optionsindex, bool enable); void optionsSetAmmoOnScreen(s32 optionsindex, bool enable); void optionsSetShowGunFunction(s32 optionsindex, bool enable); diff --git a/src/include/setup/setup_0160b0.h b/src/include/setup/setup_0160b0.h index 7da918f0a..d8ab977d2 100644 --- a/src/include/setup/setup_0160b0.h +++ b/src/include/setup/setup_0160b0.h @@ -174,7 +174,7 @@ extern u32 var800719b8; extern u32 var800719bc; extern u32 var800719c0; extern u16 options_controlmode[]; -extern u16 options_aimcontrol[]; +extern u16 g_AimControlOptions[]; extern u16 options_soundmode[]; extern u16 options_screenmode[]; extern u16 options_screenratio[]; diff --git a/src/setup/setup_0160b0.c b/src/setup/setup_0160b0.c index e9698011e..4a38e8baf 100644 --- a/src/setup/setup_0160b0.c +++ b/src/setup/setup_0160b0.c @@ -1549,7 +1549,7 @@ u16 options_controlmode[] = { }; // 17a04 -u16 options_aimcontrol[] = { +u16 g_AimControlOptions[] = { 0x56c9, // "Hold" 0x56ca, // "Toggle" };