From 0551c0e8083fae27bb692764989bfa9d14bafa36 Mon Sep 17 00:00:00 2001 From: Ryan Dwyer Date: Mon, 2 Nov 2020 00:03:14 +1000 Subject: [PATCH] Decompile currentPlayerSetGunSightVisible --- src/game/bondmove.c | 4 ++-- src/game/chr/chraicommands.c | 4 ++-- src/game/game_097ba0.c | 28 +++++++++------------------- src/game/game_0b63b0.c | 8 ++++---- src/include/constants.h | 4 ++++ src/include/game/game_097ba0.h | 2 +- src/include/types.h | 2 +- 7 files changed, 23 insertions(+), 29 deletions(-) diff --git a/src/game/bondmove.c b/src/game/bondmove.c index b9ad16f97..756855a59 100644 --- a/src/game/bondmove.c +++ b/src/game/bondmove.c @@ -2964,7 +2964,7 @@ glabel var7f1ad8e4 /* f0ca9f0: c7ac00b4 */ lwc1 $f12,0xb4($sp) /* f0ca9f4: 24040002 */ addiu $a0,$zero,0x2 .L0f0ca9f8: -/* f0ca9f8: 0fc2af1d */ jal func0f0abc74 +/* f0ca9f8: 0fc2af1d */ jal currentPlayerSetGunSightVisible /* f0ca9fc: 8fa50208 */ lw $a1,0x208($sp) /* f0caa00: c7ac0210 */ lwc1 $f12,0x210($sp) /* f0caa04: 44808000 */ mtc1 $zero,$f16 @@ -4885,7 +4885,7 @@ glabel var7f1ad8e4 // func0f028590(spb4); // } // -// func0f0abc74(2, movedata.unk54); +// currentPlayerSetGunSightVisible(GUNSIGHTREASON_AIMING, movedata.unk54); // // if (movedata.zoomoutfovpersec > 0) { // currentPlayerZoomOut(movedata.zoomoutfovpersec); diff --git a/src/game/chr/chraicommands.c b/src/game/chr/chraicommands.c index 77953be88..dcc55be3c 100644 --- a/src/game/chr/chraicommands.c +++ b/src/game/chr/chraicommands.c @@ -5275,7 +5275,7 @@ bool aiRevokeControl(void) u32 prevplayernum = g_Vars.currentplayernum; u32 playernum = propGetPlayerNum(chr->prop); setCurrentPlayerNum(playernum); - func0f0abc74(4, false); + currentPlayerSetGunSightVisible(GUNSIGHTREASON_NOCONTROL, false); func0f0a95ec(2, false); if ((cmd[3] & 2) == 0) { @@ -5306,7 +5306,7 @@ bool aiGrantControl(void) if (chr && chr->prop && chr->prop->type == PROPTYPE_PLAYER) { u32 prevplayernum = g_Vars.currentplayernum; setCurrentPlayerNum(propGetPlayerNum(chr->prop)); - func0f0abc74(4, true); + currentPlayerSetGunSightVisible(GUNSIGHTREASON_NOCONTROL, true); func0f0a95ec(2, true); currentPlayerUnsetFlag(PLAYERFLAG_NOCONTROL); countdownTimerSetVisible(16, true); diff --git a/src/game/game_097ba0.c b/src/game/game_097ba0.c index 0ba636ea2..697ba61ff 100644 --- a/src/game/game_097ba0.c +++ b/src/game/game_097ba0.c @@ -23659,25 +23659,15 @@ void speedpillTick(void) } } -GLOBAL_ASM( -glabel func0f0abc74 -/* f0abc74: 10a00008 */ beqz $a1,.L0f0abc98 -/* f0abc78: 3c02800a */ lui $v0,%hi(g_Menus+0x37a4) -/* f0abc7c: 3c02800a */ lui $v0,%hi(g_Vars+0x284) -/* f0abc80: 8c42a244 */ lw $v0,%lo(g_Vars+0x284)($v0) -/* f0abc84: 00807827 */ nor $t7,$a0,$zero -/* f0abc88: 8c4e17a4 */ lw $t6,%lo(g_Menus+0x37a4)($v0) -/* f0abc8c: 01cfc024 */ and $t8,$t6,$t7 -/* f0abc90: 03e00008 */ jr $ra -/* f0abc94: ac5817a4 */ sw $t8,0x17a4($v0) -.L0f0abc98: -/* f0abc98: 8c42a244 */ lw $v0,-0x5dbc($v0) -/* f0abc9c: 8c5917a4 */ lw $t9,0x17a4($v0) -/* f0abca0: 03244025 */ or $t0,$t9,$a0 -/* f0abca4: ac4817a4 */ sw $t0,0x17a4($v0) -/* f0abca8: 03e00008 */ jr $ra -/* f0abcac: 00000000 */ nop -); +void currentPlayerSetGunSightVisible(u32 reason, bool visible) +{ + if (visible) { + g_Vars.currentplayer->gunsightoff &= ~reason; + return; + } + + g_Vars.currentplayer->gunsightoff |= reason; +} GLOBAL_ASM( glabel func0f0abcb0 diff --git a/src/game/game_0b63b0.c b/src/game/game_0b63b0.c index dbebff545..6c7ba03fc 100644 --- a/src/game/game_0b63b0.c +++ b/src/game/game_0b63b0.c @@ -5702,7 +5702,7 @@ glabel var7f1ad674 /* f0bb84c: 00000000 */ nop /* f0bb850: 4502001d */ bc1fl .L0f0bb8c8 /* f0bb854: 8c4900d8 */ lw $t1,0xd8($v0) -/* f0bb858: 0fc2af1d */ jal func0f0abc74 +/* f0bb858: 0fc2af1d */ jal currentPlayerSetGunSightVisible /* f0bb85c: 00002825 */ or $a1,$zero,$zero /* f0bb860: 0fc30865 */ jal currentPlayerGetHealth /* f0bb864: 00000000 */ nop @@ -5821,7 +5821,7 @@ glabel var7f1ad674 /* f0bba08: 8f1900d8 */ lw $t9,0xd8($t8) /* f0bba0c: 17200003 */ bnez $t9,.L0f0bba1c /* f0bba10: 00000000 */ nop -/* f0bba14: 0fc2af1d */ jal func0f0abc74 +/* f0bba14: 0fc2af1d */ jal currentPlayerSetGunSightVisible /* f0bba18: 24050001 */ addiu $a1,$zero,0x1 .L0f0bba1c: /* f0bba1c: 0fc305f3 */ jal currentPlayerIsHealthVisible @@ -8236,7 +8236,7 @@ glabel var7f1ad6ac /* f0bdc84: 0fc2a57b */ jal func0f0a95ec /* f0bdc88: 00402825 */ or $a1,$v0,$zero /* f0bdc8c: 02a02025 */ or $a0,$s5,$zero -/* f0bdc90: 0fc2af1d */ jal func0f0abc74 +/* f0bdc90: 0fc2af1d */ jal currentPlayerSetGunSightVisible /* f0bdc94: 24050001 */ addiu $a1,$zero,0x1 /* f0bdc98: 8e6302ac */ lw $v1,0x2ac($s3) /* f0bdc9c: 10600002 */ beqz $v1,.L0f0bdca8 @@ -10431,7 +10431,7 @@ glabel var7f1ad6ac // currentPlayerSetAutoAimX(optionsGetAutoAim(g_Vars.currentplayerstats->mpindex)); // currentPlayerSetAutoMoveCentreEnabled(optionsGetLookAhead(g_Vars.currentplayerstats->mpindex)); // func0f0a95ec(1, optionsGetAmmoOnScreen(g_Vars.currentplayerstats->mpindex)); -// func0f0abc74(1, 1); +// currentPlayerSetGunSightVisible(GUNSIGHTREASON_1, true); // // // dc9c // if ((g_Vars.tickmode == TICKMODE_0 || g_Vars.tickmode == TICKMODE_1) diff --git a/src/include/constants.h b/src/include/constants.h index 808cc6089..464818ffd 100644 --- a/src/include/constants.h +++ b/src/include/constants.h @@ -735,6 +735,10 @@ #define GOPOSFLAG_DUCK 0x40 #define GOPOSFLAG_80 0x80 +#define GUNSIGHTREASON_1 1 +#define GUNSIGHTREASON_AIMING 2 +#define GUNSIGHTREASON_NOCONTROL 4 + #define HANGARBIO_INSTITUTE 0 #define HANGARBIO_DDTOWER 1 #define HANGARBIO_LABBASEMENT 2 diff --git a/src/include/game/game_097ba0.h b/src/include/game/game_097ba0.h index 6492b4775..5899ba0ff 100644 --- a/src/include/game/game_097ba0.h +++ b/src/include/game/game_097ba0.h @@ -172,7 +172,7 @@ void speedpillRevert(s32 arg0); void func0f0abba8(void); void func0f0abbe8(void); void speedpillTick(void); -void func0f0abc74(u32 arg0, s32 arg1); +void currentPlayerSetGunSightVisible(u32 bits, bool visible); Gfx *func0f0abcb0(Gfx *gdl); u32 func0f0abd30(void); u32 getCurrentPlayerWeaponIdWrapper(u32 arg0); diff --git a/src/include/types.h b/src/include/types.h index 1e456fa4b..66da3f8b9 100644 --- a/src/include/types.h +++ b/src/include/types.h @@ -2621,7 +2621,7 @@ struct player { /*0x1798*/ f32 screenyminf; /*0x179c*/ f32 screenxmaxf; /*0x17a0*/ f32 screenymaxf; - /*0x17a4*/ s32 gunsightoff; + /*0x17a4*/ u32 gunsightoff; /*0x17a8*/ s32 ammoheldarr[33]; // ammo quantities not loaded into a gun /*0x182c*/ u32 unk182c; /*0x1830*/ u32 unk1830;