diff --git a/src/game/game_0b28d0.c b/src/game/game_0b28d0.c index bc762c9bf..026c98af9 100644 --- a/src/game/game_0b28d0.c +++ b/src/game/game_0b28d0.c @@ -12935,12 +12935,12 @@ glabel func0f0bd904 /* f0bdc30: 0fc2ed7b */ jal func0f0bb5ec /* f0bdc34: 00000000 */ sll $zero,$zero,0x0 /* f0bdc38: 8e6b0288 */ lw $t3,0x288($s3) -/* f0bdc3c: 0fc549e9 */ jal func0f1527a4 +/* f0bdc3c: 0fc549e9 */ jal optionsGetAutoAim /* f0bdc40: 8d640070 */ lw $a0,0x70($t3) /* f0bdc44: 0fc31e88 */ jal func0f0c7a20 /* f0bdc48: 00402025 */ or $a0,$v0,$zero /* f0bdc4c: 8e6c0288 */ lw $t4,0x288($s3) -/* f0bdc50: 0fc549e9 */ jal func0f1527a4 +/* f0bdc50: 0fc549e9 */ jal optionsGetAutoAim /* f0bdc54: 8d840070 */ lw $a0,0x70($t4) /* f0bdc58: 0fc31ed9 */ jal func0f0c7b64 /* f0bdc5c: 00402025 */ or $a0,$v0,$zero diff --git a/src/game/game_0c79f0.c b/src/game/game_0c79f0.c index 4bcde723a..13d375141 100644 --- a/src/game/game_0c79f0.c +++ b/src/game/game_0c79f0.c @@ -198,7 +198,7 @@ glabel func0f0c7a30 /* f0c7a6c: 00001025 */ or $v0,$zero,$zero /* f0c7a70: 8c680288 */ lw $t0,0x288($v1) .L0f0c7a74: -/* f0c7a74: 0fc549e9 */ jal func0f1527a4 +/* f0c7a74: 0fc549e9 */ jal optionsGetAutoAim /* f0c7a78: 8d040070 */ lw $a0,0x70($t0) .L0f0c7a7c: /* f0c7a7c: 8fbf0014 */ lw $ra,0x14($sp) @@ -307,7 +307,7 @@ glabel func0f0c7b74 /* f0c7bb0: 00001025 */ or $v0,$zero,$zero /* f0c7bb4: 8c680288 */ lw $t0,0x288($v1) .L0f0c7bb8: -/* f0c7bb8: 0fc549e9 */ jal func0f1527a4 +/* f0c7bb8: 0fc549e9 */ jal optionsGetAutoAim /* f0c7bbc: 8d040070 */ lw $a0,0x70($t0) .L0f0c7bc0: /* f0c7bc0: 8fbf0014 */ lw $ra,0x14($sp) diff --git a/src/game/game_102240.c b/src/game/game_102240.c index bd181649b..9930e6a41 100644 --- a/src/game/game_102240.c +++ b/src/game/game_102240.c @@ -1115,49 +1115,26 @@ s32 menuhandlerSightOnScreen(u32 operation, struct menu_item *item, bool *enable return 0; } -GLOBAL_ASM( -glabel menuhandlerAutoAim -/* f103204: 3c02800a */ lui $v0,%hi(g_Vars) -/* f103208: 24429fc0 */ addiu $v0,$v0,%lo(g_Vars) -/* f10320c: 8c4e0298 */ lw $t6,0x298($v0) -/* f103210: 27bdffe8 */ addiu $sp,$sp,-24 -/* f103214: afbf0014 */ sw $ra,0x14($sp) -/* f103218: 05c10004 */ bgez $t6,.L0f10322c -/* f10321c: 00803825 */ or $a3,$a0,$zero -/* f103220: 8c4f029c */ lw $t7,0x29c($v0) -/* f103224: 05e20005 */ bltzl $t7,.L0f10323c -/* f103228: 8ca4000c */ lw $a0,0xc($a1) -.L0f10322c: -/* f10322c: 8c580288 */ lw $t8,0x288($v0) -/* f103230: 10000002 */ beqz $zero,.L0f10323c -/* f103234: 8f040070 */ lw $a0,0x70($t8) -/* f103238: 8ca4000c */ lw $a0,0xc($a1) -.L0f10323c: -/* f10323c: 24010006 */ addiu $at,$zero,0x6 -/* f103240: 10e10007 */ beq $a3,$at,.L0f103260 -/* f103244: 24010008 */ addiu $at,$zero,0x8 -/* f103248: 54e1000d */ bnel $a3,$at,.L0f103280 -/* f10324c: 00001025 */ or $v0,$zero,$zero -/* f103250: 0fc549e9 */ jal func0f1527a4 -/* f103254: 00000000 */ sll $zero,$zero,0x0 -/* f103258: 1000000a */ beqz $zero,.L0f103284 -/* f10325c: 8fbf0014 */ lw $ra,0x14($sp) -.L0f103260: -/* f103260: 0fc54a68 */ jal func0f1529a0 -/* f103264: 8cc50000 */ lw $a1,0x0($a2) -/* f103268: 3c02800a */ lui $v0,%hi(g_Vars) -/* f10326c: 24429fc0 */ addiu $v0,$v0,%lo(g_Vars) -/* f103270: 8c590458 */ lw $t9,0x458($v0) -/* f103274: 37280001 */ ori $t0,$t9,0x1 -/* f103278: ac480458 */ sw $t0,0x458($v0) -/* f10327c: 00001025 */ or $v0,$zero,$zero -.L0f103280: -/* f103280: 8fbf0014 */ lw $ra,0x14($sp) -.L0f103284: -/* f103284: 27bd0018 */ addiu $sp,$sp,0x18 -/* f103288: 03e00008 */ jr $ra -/* f10328c: 00000000 */ sll $zero,$zero,0x0 -); +s32 menuhandlerAutoAim(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 optionsGetAutoAim(optionsindex); + case MENUOP_SET: + optionsSetAutoAim(optionsindex, *enable); + g_Vars.unk000458 |= 1; + } + + return 0; +} GLOBAL_ASM( glabel menuhandlerMusicVolume diff --git a/src/game/game_10ccd0.c b/src/game/game_10ccd0.c index 2713e175e..a624e5e4c 100644 --- a/src/game/game_10ccd0.c +++ b/src/game/game_10ccd0.c @@ -2789,7 +2789,7 @@ glabel func0f10f204 /* f10f280: 0fc47961 */ jal func0f11e584 /* f10f284: 02002825 */ or $a1,$s0,$zero /* f10f288: 8fa40024 */ lw $a0,0x24($sp) -/* f10f28c: 0fc54a68 */ jal func0f1529a0 +/* f10f28c: 0fc54a68 */ jal optionsSetAutoAim /* f10f290: 00402825 */ or $a1,$v0,$zero /* f10f294: 24040002 */ addiu $a0,$zero,0x2 /* f10f298: 0fc47961 */ jal func0f11e584 @@ -2861,7 +2861,7 @@ glabel func0f10f204 /* f10f3a0: 0fc47961 */ jal func0f11e584 /* f10f3a4: 02002825 */ or $a1,$s0,$zero /* f10f3a8: 8fa40020 */ lw $a0,0x20($sp) -/* f10f3ac: 0fc54a68 */ jal func0f1529a0 +/* f10f3ac: 0fc54a68 */ jal optionsSetAutoAim /* f10f3b0: 00402825 */ or $a1,$v0,$zero /* f10f3b4: 2404000e */ addiu $a0,$zero,0xe /* f10f3b8: 0fc47961 */ jal func0f11e584 @@ -3667,7 +3667,7 @@ glabel func0f10feac /* f10ff3c: 00002025 */ or $a0,$zero,$zero /* f10ff40: 0fc4794c */ jal func0f11e530 /* f10ff44: 00403025 */ or $a2,$v0,$zero -/* f10ff48: 0fc549e9 */ jal func0f1527a4 +/* f10ff48: 0fc549e9 */ jal optionsGetAutoAim /* f10ff4c: 02602025 */ or $a0,$s3,$zero /* f10ff50: 02402025 */ or $a0,$s2,$zero /* f10ff54: 02002825 */ or $a1,$s0,$zero @@ -3739,7 +3739,7 @@ glabel func0f10feac /* f11005c: 02002825 */ or $a1,$s0,$zero /* f110060: 0fc4794c */ jal func0f11e530 /* f110064: 00403025 */ or $a2,$v0,$zero -/* f110068: 0fc549e9 */ jal func0f1527a4 +/* f110068: 0fc549e9 */ jal optionsGetAutoAim /* f11006c: 02202025 */ or $a0,$s1,$zero /* f110070: 2404000d */ addiu $a0,$zero,0xd /* f110074: 02002825 */ or $a1,$s0,$zero diff --git a/src/game/game_152710.c b/src/game/game_152710.c index e2dfef806..a1b7cee66 100644 --- a/src/game/game_152710.c +++ b/src/game/game_152710.c @@ -56,18 +56,10 @@ s32 optionsGetForwardPitch(s32 optionsindex) return (g_Options[optionsindex].unk48 & OPTION_FORWARDPITCH) != 0; } -GLOBAL_ASM( -glabel func0f1527a4 -/* f1527a4: 00047080 */ sll $t6,$a0,0x2 -/* f1527a8: 01c47021 */ addu $t6,$t6,$a0 -/* f1527ac: 000e7140 */ sll $t6,$t6,0x5 -/* f1527b0: 3c02800b */ lui $v0,0x800b -/* f1527b4: 004e1021 */ addu $v0,$v0,$t6 -/* f1527b8: 9442c800 */ lhu $v0,-0x3800($v0) -/* f1527bc: 304f0008 */ andi $t7,$v0,0x8 -/* f1527c0: 03e00008 */ jr $ra -/* f1527c4: 000f102b */ sltu $v0,$zero,$t7 -); +s32 optionsGetAutoAim(s32 optionsindex) +{ + return (g_Options[optionsindex].unk48 & OPTION_AUTOAIM) != 0; +} s32 optionsGetLookAhead(s32 optionsindex) { @@ -150,32 +142,14 @@ void optionsSetForwardPitch(s32 optionsindex, bool enable) } } -GLOBAL_ASM( -glabel func0f1529a0 -/* f1529a0: 10a0000b */ beqz $a1,.L0f1529d0 -/* f1529a4: 00044080 */ sll $t0,$a0,0x2 -/* f1529a8: 00047080 */ sll $t6,$a0,0x2 -/* f1529ac: 01c47021 */ addu $t6,$t6,$a0 -/* f1529b0: 3c0f800b */ lui $t7,%hi(g_Options) -/* f1529b4: 25efc7b8 */ addiu $t7,$t7,%lo(g_Options) -/* f1529b8: 000e7140 */ sll $t6,$t6,0x5 -/* f1529bc: 01cf1021 */ addu $v0,$t6,$t7 -/* f1529c0: 94580048 */ lhu $t8,0x48($v0) -/* f1529c4: 37190008 */ ori $t9,$t8,0x8 -/* f1529c8: 03e00008 */ jr $ra -/* f1529cc: a4590048 */ sh $t9,0x48($v0) -.L0f1529d0: -/* f1529d0: 01044021 */ addu $t0,$t0,$a0 -/* f1529d4: 3c09800b */ lui $t1,%hi(g_Options) -/* f1529d8: 2529c7b8 */ addiu $t1,$t1,%lo(g_Options) -/* f1529dc: 00084140 */ sll $t0,$t0,0x5 -/* f1529e0: 01091021 */ addu $v0,$t0,$t1 -/* f1529e4: 944a0048 */ lhu $t2,0x48($v0) -/* f1529e8: 314bfff7 */ andi $t3,$t2,0xfff7 -/* f1529ec: a44b0048 */ sh $t3,0x48($v0) -/* f1529f0: 03e00008 */ jr $ra -/* f1529f4: 00000000 */ sll $zero,$zero,0x0 -); +void optionsSetAutoAim(s32 optionsindex, bool enable) +{ + if (enable) { + g_Options[optionsindex].unk48 |= OPTION_AUTOAIM; + } else { + g_Options[optionsindex].unk48 &= ~OPTION_AUTOAIM; + } +} void optionsSetLookAhead(s32 optionsindex, bool enable) { diff --git a/src/include/constants.h b/src/include/constants.h index abd416f04..846e050ff 100644 --- a/src/include/constants.h +++ b/src/include/constants.h @@ -661,6 +661,7 @@ #define OPTION_FORWARDPITCH 0x0001 #define OPTION_LOOKAHEAD 0x0002 #define OPTION_SIGHTONSCREEN 0x0004 +#define OPTION_AUTOAIM 0x0008 #define OPTION_AMMOONSCREEN 0x0020 #define OPTION_SHOWGUNFUNCTION 0x0040 #define OPTION_HEADROLL 0x0080 diff --git a/src/include/game/game_152710.h b/src/include/game/game_152710.h index 2f342ab32..c9b60b3ee 100644 --- a/src/include/game/game_152710.h +++ b/src/include/game/game_152710.h @@ -8,7 +8,7 @@ u32 func0f15272c(void); u32 func0f152748(void); u32 func0f152764(void); s32 optionsGetForwardPitch(s32 optionsindex); -u32 func0f1527a4(void); +s32 optionsGetAutoAim(s32 optionsindex); s32 optionsGetLookAhead(s32 optionsindex); u32 func0f1527ec(void); s32 optionsGetSightOnScreen(s32 optionsindex); @@ -23,7 +23,7 @@ u32 func0f152918(void); s32 optionsGetHeadRoll(s32 optionsindex); void optionsSetForwardPitch(s32 optionsindex, bool enable); -u32 func0f1529a0(void); +void optionsSetAutoAim(s32 optionsindex, bool enable); void optionsSetLookAhead(s32 optionsindex, bool enable); u32 func0f152a50(void); void optionsSetSightOnScreen(s32 optionsindex, bool enable);