From a9f0f6930307154b578f06a01cc92fbd58940265 Mon Sep 17 00:00:00 2001 From: Ryan Dwyer Date: Wed, 6 May 2020 17:49:52 +1000 Subject: [PATCH] Decompile currentPlayerZoomOut --- src/game/bondmove.c | 8 +-- src/game/game_0b0420.c | 116 +++++++++------------------------ src/include/game/game_0b0420.h | 4 +- 3 files changed, 36 insertions(+), 92 deletions(-) diff --git a/src/game/bondmove.c b/src/game/bondmove.c index 1c9962063..ec1b25ef0 100644 --- a/src/game/bondmove.c +++ b/src/game/bondmove.c @@ -2988,7 +2988,7 @@ glabel var7f1ad8e4 /* f0caa10: 00000000 */ sll $zero,$zero,0x0 /* f0caa14: 45020004 */ bc1fl .L0f0caa28 /* f0caa18: c7ac0214 */ lwc1 $f12,0x214($sp) -/* f0caa1c: 0fc2c562 */ jal func0f0b1588 +/* f0caa1c: 0fc2c562 */ jal currentPlayerZoomOut /* f0caa20: e7ac0210 */ swc1 $f12,0x210($sp) /* f0caa24: c7ac0214 */ lwc1 $f12,0x214($sp) .L0f0caa28: @@ -2998,7 +2998,7 @@ glabel var7f1ad8e4 /* f0caa34: 00000000 */ sll $zero,$zero,0x0 /* f0caa38: 45020004 */ bc1fl .L0f0caa4c /* f0caa3c: 8e590284 */ lw $t9,0x284($s2) -/* f0caa40: 0fc2c5a9 */ jal currentPlayerUpdateGunZoomFovs +/* f0caa40: 0fc2c5a9 */ jal currentPlayerZoomIn /* f0caa44: e7ac0214 */ swc1 $f12,0x214($sp) /* f0caa48: 8e590284 */ lw $t9,0x284($s2) .L0f0caa4c: @@ -4831,11 +4831,11 @@ glabel var7f1ad8e4 // func0f0abc74(2, uStack88); // // if (fStack80 > 0) { -// func0f0b1588(); +// currentPlayerZoomOut(); // } // // if (fStack76 > 0) { -// currentPlayerUpdateGunZoomFovs(); +// currentPlayerZoomIn(); // } // // if (g_Vars.currentplayer->pausemode == PAUSEMODE_UNPAUSED && var8005d9d0 == 0) { diff --git a/src/game/game_0b0420.c b/src/game/game_0b0420.c index 7fad33942..5f5c9971f 100644 --- a/src/game/game_0b0420.c +++ b/src/game/game_0b0420.c @@ -30,7 +30,7 @@ const char var7f1acdbc[] = "%s %s"; const char var7f1acdc4[] = "%s %s"; const u32 var7f1acdcc[] = {0x00000000}; -const u32 var7f1acdd0[] = {0x3dcccccd}; +//const u32 var7f1acdd0[] = {0x3dcccccd}; GLOBAL_ASM( glabel func0f0b0420 @@ -1037,88 +1037,7 @@ f32 currentPlayerGetGunZoomFov(void) return 0; } -GLOBAL_ASM( -glabel func0f0b1588 -/* f0b1588: 27bdffe0 */ addiu $sp,$sp,-32 -/* f0b158c: afbf0014 */ sw $ra,0x14($sp) -/* f0b1590: 2405ffff */ addiu $a1,$zero,-1 -/* f0b1594: e7ac0020 */ swc1 $f12,0x20($sp) -/* f0b1598: afa5001c */ sw $a1,0x1c($sp) -/* f0b159c: 0fc2867c */ jal getCurrentPlayerWeaponIdWrapper -/* f0b15a0: 00002025 */ or $a0,$zero,$zero -/* f0b15a4: 24010015 */ addiu $at,$zero,0x15 -/* f0b15a8: 10410008 */ beq $v0,$at,.L0f0b15cc -/* f0b15ac: 8fa5001c */ lw $a1,0x1c($sp) -/* f0b15b0: 24010016 */ addiu $at,$zero,0x16 -/* f0b15b4: 10410007 */ beq $v0,$at,.L0f0b15d4 -/* f0b15b8: 24010032 */ addiu $at,$zero,0x32 -/* f0b15bc: 50410008 */ beql $v0,$at,.L0f0b15e0 -/* f0b15c0: 24050002 */ addiu $a1,$zero,0x2 -/* f0b15c4: 10000006 */ beqz $zero,.L0f0b15e0 -/* f0b15c8: 00000000 */ sll $zero,$zero,0x0 -.L0f0b15cc: -/* f0b15cc: 10000004 */ beqz $zero,.L0f0b15e0 -/* f0b15d0: 00002825 */ or $a1,$zero,$zero -.L0f0b15d4: -/* f0b15d4: 10000002 */ beqz $zero,.L0f0b15e0 -/* f0b15d8: 24050001 */ addiu $a1,$zero,0x1 -/* f0b15dc: 24050002 */ addiu $a1,$zero,0x2 -.L0f0b15e0: -/* f0b15e0: 04a0002c */ bltz $a1,.L0f0b1694 -/* f0b15e4: c7a40020 */ lwc1 $f4,0x20($sp) -/* f0b15e8: 3c013e80 */ lui $at,0x3e80 -/* f0b15ec: 44813000 */ mtc1 $at,$f6 -/* f0b15f0: 3c01800a */ lui $at,0x800a -/* f0b15f4: c42aa004 */ lwc1 $f10,-0x5ffc($at) -/* f0b15f8: 46062202 */ mul.s $f8,$f4,$f6 -/* f0b15fc: 00002025 */ or $a0,$zero,$zero -/* f0b1600: afa5001c */ sw $a1,0x1c($sp) -/* f0b1604: 460a4002 */ mul.s $f0,$f8,$f10 -/* f0b1608: 0fc2867c */ jal getCurrentPlayerWeaponIdWrapper -/* f0b160c: e7a00018 */ swc1 $f0,0x18($sp) -/* f0b1610: 3c04800a */ lui $a0,%hi(g_Vars) -/* f0b1614: 24010016 */ addiu $at,$zero,0x16 -/* f0b1618: 24849fc0 */ addiu $a0,$a0,%lo(g_Vars) -/* f0b161c: 8fa5001c */ lw $a1,0x1c($sp) -/* f0b1620: 14410006 */ bne $v0,$at,.L0f0b163c -/* f0b1624: c7a00018 */ lwc1 $f0,0x18($sp) -/* f0b1628: 3c013f00 */ lui $at,0x3f00 -/* f0b162c: 44818000 */ mtc1 $at,$f16 -/* f0b1630: 00000000 */ sll $zero,$zero,0x0 -/* f0b1634: 46100002 */ mul.s $f0,$f0,$f16 -/* f0b1638: 00000000 */ sll $zero,$zero,0x0 -.L0f0b163c: -/* f0b163c: 3c014270 */ lui $at,0x4270 -/* f0b1640: 44811000 */ mtc1 $at,$f2 -/* f0b1644: 3c013f80 */ lui $at,0x3f80 -/* f0b1648: 44819000 */ mtc1 $at,$f18 -/* f0b164c: 3c017f1b */ lui $at,%hi(var7f1acdd0) -/* f0b1650: c424cdd0 */ lwc1 $f4,%lo(var7f1acdd0)($at) -/* f0b1654: 8c8e0284 */ lw $t6,0x284($a0) -/* f0b1658: 00051080 */ sll $v0,$a1,0x2 -/* f0b165c: 46040182 */ mul.s $f6,$f0,$f4 -/* f0b1660: 01c21821 */ addu $v1,$t6,$v0 -/* f0b1664: c46a16f4 */ lwc1 $f10,0x16f4($v1) -/* f0b1668: 46069200 */ add.s $f8,$f18,$f6 -/* f0b166c: 46085402 */ mul.s $f16,$f10,$f8 -/* f0b1670: e47016f4 */ swc1 $f16,0x16f4($v1) -/* f0b1674: 8c8f0284 */ lw $t7,0x284($a0) -/* f0b1678: 01e21821 */ addu $v1,$t7,$v0 -/* f0b167c: c46416f4 */ lwc1 $f4,0x16f4($v1) -/* f0b1680: 4604103c */ c.lt.s $f2,$f4 -/* f0b1684: 00000000 */ sll $zero,$zero,0x0 -/* f0b1688: 45020003 */ bc1fl .L0f0b1698 -/* f0b168c: 8fbf0014 */ lw $ra,0x14($sp) -/* f0b1690: e46216f4 */ swc1 $f2,0x16f4($v1) -.L0f0b1694: -/* f0b1694: 8fbf0014 */ lw $ra,0x14($sp) -.L0f0b1698: -/* f0b1698: 27bd0020 */ addiu $sp,$sp,0x20 -/* f0b169c: 03e00008 */ jr $ra -/* f0b16a0: 00000000 */ sll $zero,$zero,0x0 -); - -void currentPlayerUpdateGunZoomFovs(f32 arg0) +void currentPlayerZoomOut(f32 fovpersec) { s32 index = -1; @@ -1129,13 +1048,38 @@ void currentPlayerUpdateGunZoomFovs(f32 arg0) } if (index >= 0) { - f32 value = arg0 * 0.25f * g_Vars.lvupdate240f; + f32 amount = fovpersec * 0.25f * g_Vars.lvupdate240f; if (getCurrentPlayerWeaponIdWrapper(0) == WEAPON_FARSIGHTXR20) { - value *= 0.5f; + amount *= 0.5f; } - g_Vars.currentplayer->gunzoomfovs[index] /= 1 + value * 0.1f; + g_Vars.currentplayer->gunzoomfovs[index] *= 1.0f + amount * 0.1f; + + if (g_Vars.currentplayer->gunzoomfovs[index] > 60) { + g_Vars.currentplayer->gunzoomfovs[index] = 60; + } + } +} + +void currentPlayerZoomIn(f32 fovpersec) +{ + s32 index = -1; + + switch (getCurrentPlayerWeaponIdWrapper(0)) { + case WEAPON_SNIPERRIFLE: index = 0; break; + case WEAPON_FARSIGHTXR20: index = 1; break; + case WEAPON_HORIZONSCANNER: index = 2; break; + } + + if (index >= 0) { + f32 amount = fovpersec * 0.25f * g_Vars.lvupdate240f; + + if (getCurrentPlayerWeaponIdWrapper(0) == WEAPON_FARSIGHTXR20) { + amount *= 0.5f; + } + + g_Vars.currentplayer->gunzoomfovs[index] /= 1 + amount * 0.1f; if (g_Vars.currentplayer->gunzoomfovs[index] < 2) { g_Vars.currentplayer->gunzoomfovs[index] = 2; diff --git a/src/include/game/game_0b0420.h b/src/include/game/game_0b0420.h index 9cb256080..9ca85d201 100644 --- a/src/include/game/game_0b0420.h +++ b/src/include/game/game_0b0420.h @@ -28,8 +28,8 @@ struct inventory_ammo *weaponGetAmmoByFunction(u32 weaponnum, u32 funcnum); f32 handGetXOffset(u32 arg0); f32 func0f0b131c(u32 hand); f32 currentPlayerGetGunZoomFov(void); -u32 func0f0b1588(void); -void currentPlayerUpdateGunZoomFovs(f32 arg0); +void currentPlayerZoomOut(f32 fovpersec); +void currentPlayerZoomIn(f32 fovpersec); bool weaponHasFlag(s32 itemid, u32 flag); u32 func0f0b1804(void); u32 func0f0b184c(void);