Attempt to decompile currentPlayerConsiderToggleGunFunction

This commit is contained in:
Ryan Dwyer 2020-05-12 23:57:37 +10:00
parent 6273a41b5c
commit ef8ae5ad3b
5 changed files with 135 additions and 46 deletions

View File

@ -1587,7 +1587,7 @@ glabel var7f1ad8e4
/* f0c969c: 85a4024e */ lh $a0,0x24e($t5)
/* f0c96a0: 04820009 */ bltzl $a0,.L0f0c96c8
/* f0c96a4: 8e450284 */ lw $a1,0x284($s2)
/* f0c96a8: 0fc2a257 */ jal func0f0a895c
/* f0c96a8: 0fc2a257 */ jal currentPlayerConsiderToggleGunFunction
/* f0c96ac: 00003025 */ or $a2,$zero,$zero
/* f0c96b0: 50400005 */ beqzl $v0,.L0f0c96c8
/* f0c96b4: 8e450284 */ lw $a1,0x284($s2)
@ -1602,7 +1602,7 @@ glabel var7f1ad8e4
/* f0c96d4: 14200016 */ bnez $at,.L0f0c9730
/* f0c96d8: 248b0001 */ addiu $t3,$a0,0x1
/* f0c96dc: 00002825 */ or $a1,$zero,$zero
/* f0c96e0: 0fc2a257 */ jal func0f0a895c
/* f0c96e0: 0fc2a257 */ jal currentPlayerConsiderToggleGunFunction
/* f0c96e4: 00003025 */ or $a2,$zero,$zero
/* f0c96e8: 24010001 */ addiu $at,$zero,0x1
/* f0c96ec: 54410005 */ bnel $v0,$at,.L0f0c9704
@ -1631,7 +1631,7 @@ glabel var7f1ad8e4
.L0f0c973c:
/* f0c973c: 1420000e */ bnez $at,.L0f0c9778
/* f0c9740: 00002825 */ or $a1,$zero,$zero
/* f0c9744: 0fc2a257 */ jal func0f0a895c
/* f0c9744: 0fc2a257 */ jal currentPlayerConsiderToggleGunFunction
/* f0c9748: 00003025 */ or $a2,$zero,$zero
/* f0c974c: 1000000b */ beqz $zero,.L0f0c977c
/* f0c9750: 26100001 */ addiu $s0,$s0,0x1
@ -2519,7 +2519,7 @@ glabel var7f1ad8e4
/* f0ca3c4: 8724024e */ lh $a0,0x24e($t9)
/* f0ca3c8: 04820009 */ bltzl $a0,.L0f0ca3f0
/* f0ca3cc: 8e450284 */ lw $a1,0x284($s2)
/* f0ca3d0: 0fc2a257 */ jal func0f0a895c
/* f0ca3d0: 0fc2a257 */ jal currentPlayerConsiderToggleGunFunction
/* f0ca3d4: 00003025 */ or $a2,$zero,$zero
/* f0ca3d8: 50400005 */ beqzl $v0,.L0f0ca3f0
/* f0ca3dc: 8e450284 */ lw $a1,0x284($s2)
@ -2534,7 +2534,7 @@ glabel var7f1ad8e4
/* f0ca3fc: 14200016 */ bnez $at,.L0f0ca458
/* f0ca400: 248f0001 */ addiu $t7,$a0,0x1
/* f0ca404: 00002825 */ or $a1,$zero,$zero
/* f0ca408: 0fc2a257 */ jal func0f0a895c
/* f0ca408: 0fc2a257 */ jal currentPlayerConsiderToggleGunFunction
/* f0ca40c: 00003025 */ or $a2,$zero,$zero
/* f0ca410: 24010001 */ addiu $at,$zero,0x1
/* f0ca414: 54410005 */ bnel $v0,$at,.L0f0ca42c
@ -2563,7 +2563,7 @@ glabel var7f1ad8e4
/* f0ca460: 2881fffe */ slti $at,$a0,-2
/* f0ca464: 1420000e */ bnez $at,.L0f0ca4a0
/* f0ca468: 00002825 */ or $a1,$zero,$zero
/* f0ca46c: 0fc2a257 */ jal func0f0a895c
/* f0ca46c: 0fc2a257 */ jal currentPlayerConsiderToggleGunFunction
/* f0ca470: 00003025 */ or $a2,$zero,$zero
/* f0ca474: 1000000b */ beqz $zero,.L0f0ca4a4
/* f0ca478: 26100001 */ addiu $s0,$s0,0x1
@ -4250,12 +4250,12 @@ glabel var7f1ad8e4
// } else {
// if (g_Vars.currentplayer->usedowntime < -1) {
// if (g_Vars.currentplayer->usedowntime > -3) {
// func0f0a895c(g_Vars.currentplayer->usedowntime, 0, 0);
// currentPlayerConsiderToggleGunFunction(g_Vars.currentplayer->usedowntime, 0, 0);
// }
// } else {
// if (func00014b50(i,uStack369, uStack374 & Z_TRIG)
// && g_Vars.currentplayer->usedowntime > -1
// && func0f0a895c(g_Vars.currentplayer->usedowntime, 1, 0)) {
// && currentPlayerConsiderToggleGunFunction(g_Vars.currentplayer->usedowntime, 1, 0)) {
// g_Vars.currentplayer->usedowntime = -3;
// }
//
@ -4264,7 +4264,7 @@ glabel var7f1ad8e4
// g_Vars.currentplayer->usedowntime++;
// }
// else {
// lVar8 = func0f0a895c(g_Vars.currentplayer->usedowntime, 0, 0);
// lVar8 = currentPlayerConsiderToggleGunFunction(g_Vars.currentplayer->usedowntime, 0, 0);
//
// if (lVar8 == 1) {
// g_Vars.currentplayer->usedowntime = -1;
@ -4629,12 +4629,12 @@ glabel var7f1ad8e4
// } else {
// if (g_Vars.currentplayer->usedowntime < -1) {
// if (g_Vars.currentplayer->usedowntime > -3) {
// func0f0a895c(g_Vars.currentplayer->usedowntime, 0, 0);
// currentPlayerConsiderToggleGunFunction(g_Vars.currentplayer->usedowntime, 0, 0);
// }
// } else {
// if (func00014b50(i, contpad1, shootbuttons & uStack194)
// && g_Vars.currentplayer->usedowntime >= 0
// && func0f0a895c(g_Vars.currentplayer->usedowntime, 1, 0)) {
// && currentPlayerConsiderToggleGunFunction(g_Vars.currentplayer->usedowntime, 1, 0)) {
// g_Vars.currentplayer->usedowntime = -3;
// }
//
@ -4642,7 +4642,7 @@ glabel var7f1ad8e4
// if (g_Vars.currentplayer->usedowntime <= 25) {
// g_Vars.currentplayer->usedowntime++;
// } else {
// lVar8 = func0f0a895c(g_Vars.currentplayer->usedowntime, 0, 0);
// lVar8 = currentPlayerConsiderToggleGunFunction(g_Vars.currentplayer->usedowntime, 0, 0);
//
// if (lVar8 == 1) {
// g_Vars.currentplayer->usedowntime = -1;

View File

@ -144,7 +144,7 @@ glabel activemenuTick
/* f01b25c: 00002825 */ or $a1,$zero,$zero
/* f01b260: 51e0000f */ beqzl $t7,.L0f01b2a0
/* f01b264: 8ce80318 */ lw $t0,0x318($a3)
/* f01b268: 0fc2a257 */ jal func0f0a895c
/* f01b268: 0fc2a257 */ jal currentPlayerConsiderToggleGunFunction
/* f01b26c: 24060001 */ addiu $a2,$zero,0x1
/* f01b270: 18400009 */ blez $v0,.L0f01b298
/* f01b274: 3c07800a */ lui $a3,%hi(g_Vars)

View File

@ -20384,66 +20384,66 @@ glabel func0f0a8910
);
GLOBAL_ASM(
glabel func0f0a895c
glabel currentPlayerConsiderToggleGunFunction
.late_rodata
glabel var7f1acaa4
.word func0f0a895c+0x104 # f0a8a60
.word currentPlayerConsiderToggleGunFunction+0x104 # f0a8a60
glabel var7f1acaa8
.word func0f0a895c+0x1f4 # f0a8b50
.word currentPlayerConsiderToggleGunFunction+0x1f4 # f0a8b50
glabel var7f1acaac
.word func0f0a895c+0x1f4 # f0a8b50
.word currentPlayerConsiderToggleGunFunction+0x1f4 # f0a8b50
glabel var7f1acab0
.word func0f0a895c+0x1f4 # f0a8b50
.word currentPlayerConsiderToggleGunFunction+0x1f4 # f0a8b50
glabel var7f1acab4
.word func0f0a895c+0x104 # f0a8a60
.word currentPlayerConsiderToggleGunFunction+0x104 # f0a8a60
glabel var7f1acab8
.word func0f0a895c+0x1f4 # f0a8b50
.word currentPlayerConsiderToggleGunFunction+0x1f4 # f0a8b50
glabel var7f1acabc
.word func0f0a895c+0x1f4 # f0a8b50
.word currentPlayerConsiderToggleGunFunction+0x1f4 # f0a8b50
glabel var7f1acac0
.word func0f0a895c+0xb0 # f0a8a0c
.word currentPlayerConsiderToggleGunFunction+0xb0 # f0a8a0c
glabel var7f1acac4
.word func0f0a895c+0xb0 # f0a8a0c
.word currentPlayerConsiderToggleGunFunction+0xb0 # f0a8a0c
glabel var7f1acac8
.word func0f0a895c+0xb0 # f0a8a0c
.word currentPlayerConsiderToggleGunFunction+0xb0 # f0a8a0c
glabel var7f1acacc
.word func0f0a895c+0x104 # f0a8a60
.word currentPlayerConsiderToggleGunFunction+0x104 # f0a8a60
glabel var7f1acad0
.word func0f0a895c+0x104 # f0a8a60
.word currentPlayerConsiderToggleGunFunction+0x104 # f0a8a60
glabel var7f1acad4
.word func0f0a895c+0x1f4 # f0a8b50
.word currentPlayerConsiderToggleGunFunction+0x1f4 # f0a8b50
glabel var7f1acad8
.word func0f0a895c+0x1f4 # f0a8b50
.word currentPlayerConsiderToggleGunFunction+0x1f4 # f0a8b50
glabel var7f1acadc
.word func0f0a895c+0x1f4 # f0a8b50
.word currentPlayerConsiderToggleGunFunction+0x1f4 # f0a8b50
glabel var7f1acae0
.word func0f0a895c+0x44 # f0a89a0
.word currentPlayerConsiderToggleGunFunction+0x44 # f0a89a0
glabel var7f1acae4
.word func0f0a895c+0x104 # f0a8a60
.word currentPlayerConsiderToggleGunFunction+0x104 # f0a8a60
glabel var7f1acae8
.word func0f0a895c+0x1f4 # f0a8b50
.word currentPlayerConsiderToggleGunFunction+0x1f4 # f0a8b50
glabel var7f1acaec
.word func0f0a895c+0x1f4 # f0a8b50
.word currentPlayerConsiderToggleGunFunction+0x1f4 # f0a8b50
glabel var7f1acaf0
.word func0f0a895c+0x1f4 # f0a8b50
.word currentPlayerConsiderToggleGunFunction+0x1f4 # f0a8b50
glabel var7f1acaf4
.word func0f0a895c+0x1f4 # f0a8b50
.word currentPlayerConsiderToggleGunFunction+0x1f4 # f0a8b50
glabel var7f1acaf8
.word func0f0a895c+0x1f4 # f0a8b50
.word currentPlayerConsiderToggleGunFunction+0x1f4 # f0a8b50
glabel var7f1acafc
.word func0f0a895c+0x1f4 # f0a8b50
.word currentPlayerConsiderToggleGunFunction+0x1f4 # f0a8b50
glabel var7f1acb00
.word func0f0a895c+0x1f4 # f0a8b50
.word currentPlayerConsiderToggleGunFunction+0x1f4 # f0a8b50
glabel var7f1acb04
.word func0f0a895c+0x1f4 # f0a8b50
.word currentPlayerConsiderToggleGunFunction+0x1f4 # f0a8b50
glabel var7f1acb08
.word func0f0a895c+0x1f4 # f0a8b50
.word currentPlayerConsiderToggleGunFunction+0x1f4 # f0a8b50
glabel var7f1acb0c
.word func0f0a895c+0x104 # f0a8a60
.word currentPlayerConsiderToggleGunFunction+0x104 # f0a8a60
glabel var7f1acb10
.word func0f0a895c+0x1f4 # f0a8b50
.word currentPlayerConsiderToggleGunFunction+0x1f4 # f0a8b50
glabel var7f1acb14
.word func0f0a895c+0xb0 # f0a8a0c
.word currentPlayerConsiderToggleGunFunction+0xb0 # f0a8a0c
.text
/* f0a895c: 27bdffe8 */ addiu $sp,$sp,-24
/* f0a8960: afbf0014 */ sw $ra,0x14($sp)
@ -20651,6 +20651,95 @@ glabel var7f1acb14
/* f0a8c4c: 00000000 */ sll $zero,$zero,0x0
);
// Mismatch near the first gunfuncs check.
// Goal loads 1 into $t5 while the below uses $at.
//u32 currentPlayerConsiderToggleGunFunction(s32 usedowntime, bool firing, s32 arg2)
//{
// switch (getCurrentPlayerWeaponId(0)) {
// case WEAPON_SNIPERRIFLE: // f0a89a0
// // Setting this allows the sniper rifle to behave somewhat similarly to
// // a temporary function, meaning that it reverts to primary when B is
// // released.
// g_Vars.currentplayer->invertgunfunc = true;
//
// // B+Z immediately triggers crouch or stand.
// if (firing) {
// return 1;
// }
//
// // Don't do anything if B hasn't been held for 50/60ths of a second.
// if (usedowntime < 50) {
// return 0;
// }
//
// // Sanity check - make sure the sniper isn't set to alt function
// // permanently (this is impossible).
// if (g_Vars.currentplayer->hands[0].weaponfunc != 1) {
// return 0;
// }
//
// // Do crouch or stand
// g_Vars.currentplayer->hands[0].unk0d0f_03 = true;
// return 2;
// case WEAPON_RCP120:
// case WEAPON_LAPTOPGUN:
// case WEAPON_DRAGON:
// case WEAPON_REMOTEMINE: // f0a8a0c
// // These guns use temporary alt functions
// g_Vars.currentplayer->invertgunfunc = true;
//
// if (arg2 && currentPlayerIsUsingSecondaryFunction() == true) {
// g_Vars.currentplayer->hands[0].unk0d0f_03 = true;
// }
//
// return 1;
// case WEAPON_MAULER:
// case WEAPON_CMP150:
// case WEAPON_K7AVENGER:
// case WEAPON_AR34:
// case WEAPON_FARSIGHTXR20:
// case WEAPON_TIMEDMINE: // f0a8a60
// // These guns disallow B+Z
// if (firing == false) {
// if (g_Vars.currentplayer->unk1580 >= WEAPON_UNARMED
// && g_Vars.currentplayer->unk1580 <= WEAPON_COMBATBOOST) {
// // A macro is probably used here, hence the duplicate checks
// if ((g_Vars.currentplayer->unk1580 >= WEAPON_UNARMED
// && g_Vars.currentplayer->unk1580 <= WEAPON_COMBATBOOST
// && (g_MpPlayers[g_Vars.currentplayerstats->mpindex].gunfuncs[(g_Vars.currentplayer->unk1580 - 1) >> 3] & (1 << ((g_Vars.currentplayer->unk1580 - 1) & 7)))) != 1) {
// // b24
// g_MpPlayers[g_Vars.currentplayerstats->mpindex].gunfuncs[(g_Vars.currentplayer->unk1580 - 1) >> 3] |= 1 << ((g_Vars.currentplayer->unk1580 - 1) & 7);
// } else {
// // b34
// g_MpPlayers[g_Vars.currentplayerstats->mpindex].gunfuncs[(g_Vars.currentplayer->unk1580 - 1) >> 3] &= ~(1 << ((g_Vars.currentplayer->unk1580 - 1) & 7));
// }
// }
//
// return 1;
// }
//
// return 0;
// default: // b50
// if (firing) {
// // B+Z
// g_Vars.currentplayer->invertgunfunc = true;
// } else {
// if (g_Vars.currentplayer->unk1580 >= WEAPON_UNARMED
// && g_Vars.currentplayer->unk1580 <= WEAPON_COMBATBOOST) {
// if (!(g_Vars.currentplayer->unk1580 >= WEAPON_UNARMED
// && g_Vars.currentplayer->unk1580 <= WEAPON_COMBATBOOST
// && (g_MpPlayers[g_Vars.currentplayerstats->mpindex].gunfuncs[(g_Vars.currentplayer->unk1580 - 1) >> 3] & (1 << ((g_Vars.currentplayer->unk1580 - 1) & 7))))) {
// g_MpPlayers[g_Vars.currentplayerstats->mpindex].gunfuncs[(g_Vars.currentplayer->unk1580 - 1) >> 3] |= 1 << ((g_Vars.currentplayer->unk1580 - 1) & 7);
// } else {
// g_MpPlayers[g_Vars.currentplayerstats->mpindex].gunfuncs[(g_Vars.currentplayer->unk1580 - 1) >> 3] &= ~(1 << ((g_Vars.currentplayer->unk1580 - 1) & 7));
// }
// }
// }
//
// return 1;
// }
//}
void func0f0a8c50(void)
{
if (g_Vars.currentplayer->hands[0].unk0d0f_03 == 0) {

View File

@ -140,7 +140,7 @@ u32 func0f0a7d98(void);
u32 func0f0a8404(void);
u32 func0f0a84c8(void);
u32 func0f0a8910(void);
u32 func0f0a895c(void);
u32 currentPlayerConsiderToggleGunFunction(s32 usedowntime, bool firing, s32 arg2);
void func0f0a8c50(void);
bool currentPlayerIsUsingSecondaryFunction(void);
u32 func0f0a8d34(void);

View File

@ -1611,8 +1611,8 @@ struct hand {
/*0x0cfc*/ struct coord unk0cfc;
/*0x0d08*/ u32 unk0d08;
/*0x0d0c*/ u8 unk0d0c;
/*0x0d0e*/ u8 unk0d0d;
/*0x0d0d*/ u8 unk0d0e;
/*0x0d0d*/ u8 unk0d0d;
/*0x0d0e*/ u8 unk0d0e;
/*0x0d0f*/ u8 unk0d0f_00 : 3;
/*0x0d0f*/ u8 unk0d0f_03 : 1;
/*0x0d0f*/ u8 unk0d0f_04 : 4;