From 1cce73bc3992523795d2f2d9d19b8eeef73c209b Mon Sep 17 00:00:00 2001 From: Ryan Dwyer Date: Wed, 6 May 2020 00:00:11 +1000 Subject: [PATCH] Decompile currentPlayerGetGunZoomFov --- src/game/bondmove.c | 8 ++-- src/game/data/inventory.c | 26 ++++++------ src/game/game_097ba0.c | 2 +- src/game/game_0b0420.c | 77 +++++++++++----------------------- src/game/game_0d7070.c | 2 +- src/game/game_0dcdb0.c | 2 +- src/game/wallhit.c | 2 +- src/include/game/game_0b0420.h | 2 +- src/include/types.h | 4 +- 9 files changed, 48 insertions(+), 77 deletions(-) diff --git a/src/game/bondmove.c b/src/game/bondmove.c index ccb96556c..1c9962063 100644 --- a/src/game/bondmove.c +++ b/src/game/bondmove.c @@ -3164,7 +3164,7 @@ glabel var7f1ad8e4 .L0f0cacac: /* f0cacac: 13000004 */ beqz $t8,.L0f0cacc0 /* f0cacb0: 00000000 */ sll $zero,$zero,0x0 -/* f0cacb4: 0fc2c536 */ jal func0f0b14d8 +/* f0cacb4: 0fc2c536 */ jal currentPlayerGetGunZoomFov /* f0cacb8: 00000000 */ sll $zero,$zero,0x0 /* f0cacbc: e7a000b0 */ swc1 $f0,0xb0($sp) .L0f0cacc0: @@ -3178,7 +3178,7 @@ glabel var7f1ad8e4 /* f0cacdc: 9328063b */ lbu $t0,0x63b($t9) /* f0cace0: 55010005 */ bnel $t0,$at,.L0f0cacf8 /* f0cace4: c7ac00b0 */ lwc1 $f12,0xb0($sp) -/* f0cace8: 0fc2c536 */ jal func0f0b14d8 +/* f0cace8: 0fc2c536 */ jal currentPlayerGetGunZoomFov /* f0cacec: 00000000 */ sll $zero,$zero,0x0 /* f0cacf0: e7a000b0 */ swc1 $f0,0xb0($sp) /* f0cacf4: c7ac00b0 */ lwc1 $f12,0xb0($sp) @@ -4881,12 +4881,12 @@ glabel var7f1ad8e4 // } // // if (iStack84) { -// fStack432 = func0f0b14d8(); +// fStack432 = currentPlayerGetGunZoomFov(); // } // // if (getCurrentPlayerWeaponId(0) == WEAPON_AR34 // && g_Vars.currentplayer->hands[0].weaponfunc == FUNC_SECONDARY) { -// fStack432 = func0f0b14d8(); +// fStack432 = currentPlayerGetGunZoomFov(); // } // // func0f0ba8b0(fStack432 > 0 ? fStack432 : 0); diff --git a/src/game/data/inventory.c b/src/game/data/inventory.c index b245be11f..86bc15d6a 100644 --- a/src/game/data/inventory.c +++ b/src/game/data/inventory.c @@ -68,7 +68,7 @@ struct inventory_menupos invmenupos_000110ac = { // 110c0 struct inventory_typee inve_000110c0 = { - 0x00000000, + 0, 0x40400000, 0x41000000, 0x41700000, @@ -80,7 +80,7 @@ struct inventory_typee inve_000110c0 = { // 110e0 struct inventory_typee inve_000110e0 = { - 0x00000000, + 0, 0x40400000, 0x41000000, 0x41700000, @@ -92,7 +92,7 @@ struct inventory_typee inve_000110e0 = { // 11100 struct inventory_typee inve_00011100 = { - 0x00000000, + 0, 0x40400000, 0x41000000, 0x41700000, @@ -104,7 +104,7 @@ struct inventory_typee inve_00011100 = { // 11120 struct inventory_typee inve_00011120 = { - 0x41f00000, + 30, 0x40400000, 0x41000000, 0x41700000, @@ -116,7 +116,7 @@ struct inventory_typee inve_00011120 = { // 11140 struct inventory_typee inve_00011140 = { - 0x41f00000, + 30, 0x40400000, 0x41000000, 0x41700000, @@ -730,7 +730,7 @@ u32 invanim_magsec_equiporshoot[] = { // 11970 struct inventory_typee inve_00011970 = { - 0x41c80000, + 25, 0x40400000, 0x41000000, 0x41700000, @@ -1404,7 +1404,7 @@ u32 invanim_cmp150_equiporshoot[] = { // 12308 struct inventory_typee inve_00012308 = { - 0x00000000, + 0, 0x40400000, 0x41000000, 0x41700000, @@ -2185,7 +2185,7 @@ u32 invanim_ar34_equiporreload[] = { // 12cc4 struct inventory_typee inve_00012cc4 = { - 0x41a00000, + 20, 0x40400000, 0x41000000, 0x41700000, @@ -2333,7 +2333,7 @@ u32 var8006ce78 = 0x00000000; // 12e9c struct inventory_typee inve_00012e9c = { - 0x41a00000, + 20, 0x40400000, 0x41000000, 0x41700000, @@ -2893,7 +2893,7 @@ u32 invanim_rockerlauncher_equiporshoot[] = { // 135f0 struct inventory_typee inve_000135f0 = { - 0x00000000, + 0, 0x40400000, 0x41000000, 0x41700000, @@ -3752,7 +3752,7 @@ u32 invanim_farsight_equiporshoot[] = { // 13ff8 struct inventory_typee inve_00013ff8 = { - 0x00000000, + 0, 0x40400000, 0x41000000, 0x41700000, @@ -4223,7 +4223,7 @@ u32 invanim_sniperrifle_reload[] = { // 1460c struct inventory_typee inve_0001460c = { - 0x00000000, + 0, 0x40400000, 0x41000000, 0x41700000, @@ -5386,7 +5386,7 @@ struct weaponfunc invfunc_horizonscanner_primary = { // 15348 struct inventory_typee inve_00015348 = { - 0x00000000, + 0, 0x40400000, 0x41000000, 0x41700000, diff --git a/src/game/game_097ba0.c b/src/game/game_097ba0.c index 7e9cf437e..247ac37ac 100644 --- a/src/game/game_097ba0.c +++ b/src/game/game_097ba0.c @@ -14968,7 +14968,7 @@ glabel func0f0a3eac /* f0a3f08: 00808025 */ or $s0,$a0,$zero /* f0a3f0c: 00a0b825 */ or $s7,$a1,$zero /* f0a3f10: adc8000c */ sw $t0,0xc($t6) -/* f0a3f14: 0fc2c536 */ jal func0f0b14d8 +/* f0a3f14: 0fc2c536 */ jal currentPlayerGetGunZoomFov /* f0a3f18: adc10008 */ sw $at,0x8($t6) /* f0a3f1c: 3c014000 */ lui $at,0x4000 /* f0a3f20: 44812000 */ mtc1 $at,$f4 diff --git a/src/game/game_0b0420.c b/src/game/game_0b0420.c index 2a313476b..7fad33942 100644 --- a/src/game/game_0b0420.c +++ b/src/game/game_0b0420.c @@ -1012,59 +1012,30 @@ f32 func0f0b131c(u32 hand) return x; } -GLOBAL_ASM( -glabel func0f0b14d8 -/* f0b14d8: 27bdffe0 */ addiu $sp,$sp,-32 -/* f0b14dc: afbf0014 */ sw $ra,0x14($sp) -/* f0b14e0: 2403ffff */ addiu $v1,$zero,-1 -/* f0b14e4: afa3001c */ sw $v1,0x1c($sp) -/* f0b14e8: 0fc2867c */ jal getCurrentPlayerWeaponIdWrapper -/* f0b14ec: 00002025 */ or $a0,$zero,$zero -/* f0b14f0: 24010015 */ addiu $at,$zero,0x15 -/* f0b14f4: 10410008 */ beq $v0,$at,.L0f0b1518 -/* f0b14f8: 8fa3001c */ lw $v1,0x1c($sp) -/* f0b14fc: 24010016 */ addiu $at,$zero,0x16 -/* f0b1500: 10410007 */ beq $v0,$at,.L0f0b1520 -/* f0b1504: 24010032 */ addiu $at,$zero,0x32 -/* f0b1508: 50410008 */ beql $v0,$at,.L0f0b152c -/* f0b150c: 24030002 */ addiu $v1,$zero,0x2 -/* f0b1510: 10000006 */ beqz $zero,.L0f0b152c -/* f0b1514: 00000000 */ sll $zero,$zero,0x0 -.L0f0b1518: -/* f0b1518: 10000004 */ beqz $zero,.L0f0b152c -/* f0b151c: 00001825 */ or $v1,$zero,$zero -.L0f0b1520: -/* f0b1520: 10000002 */ beqz $zero,.L0f0b152c -/* f0b1524: 24030001 */ addiu $v1,$zero,0x1 -/* f0b1528: 24030002 */ addiu $v1,$zero,0x2 -.L0f0b152c: -/* f0b152c: 04600006 */ bltz $v1,.L0f0b1548 -/* f0b1530: 3c0e800a */ lui $t6,%hi(g_Vars+0x284) -/* f0b1534: 8dcea244 */ lw $t6,%lo(g_Vars+0x284)($t6) -/* f0b1538: 00037880 */ sll $t7,$v1,0x2 -/* f0b153c: 01cfc021 */ addu $t8,$t6,$t7 -/* f0b1540: 1000000d */ beqz $zero,.L0f0b1578 -/* f0b1544: c70016f4 */ lwc1 $f0,0x16f4($t8) -.L0f0b1548: -/* f0b1548: 0fc2867c */ jal getCurrentPlayerWeaponIdWrapper -/* f0b154c: 00002025 */ or $a0,$zero,$zero -/* f0b1550: 0fc2c3f4 */ jal weaponFindById -/* f0b1554: 00402025 */ or $a0,$v0,$zero -/* f0b1558: 50400006 */ beqzl $v0,.L0f0b1574 -/* f0b155c: 44800000 */ mtc1 $zero,$f0 -/* f0b1560: 8c590024 */ lw $t9,0x24($v0) -/* f0b1564: c7220000 */ lwc1 $f2,0x0($t9) -/* f0b1568: 10000003 */ beqz $zero,.L0f0b1578 -/* f0b156c: 46001006 */ mov.s $f0,$f2 -/* f0b1570: 44800000 */ mtc1 $zero,$f0 -.L0f0b1574: -/* f0b1574: 00000000 */ sll $zero,$zero,0x0 -.L0f0b1578: -/* f0b1578: 8fbf0014 */ lw $ra,0x14($sp) -/* f0b157c: 27bd0020 */ addiu $sp,$sp,0x20 -/* f0b1580: 03e00008 */ jr $ra -/* f0b1584: 00000000 */ sll $zero,$zero,0x0 -); +f32 currentPlayerGetGunZoomFov(void) +{ + s32 index = -1; + struct weapon *weapon; + + switch (getCurrentPlayerWeaponIdWrapper(0)) { + case WEAPON_SNIPERRIFLE: index = 0; break; + case WEAPON_FARSIGHTXR20: index = 1; break; + case WEAPON_HORIZONSCANNER: index = 2; break; + } + + if (index >= 0) { + return g_Vars.currentplayer->gunzoomfovs[index]; + } + + weapon = weaponFindById(getCurrentPlayerWeaponIdWrapper(0)); + + if (weapon) { + f32 fov = weapon->eptr->zoomfov; + return fov; + } + + return 0; +} GLOBAL_ASM( glabel func0f0b1588 diff --git a/src/game/game_0d7070.c b/src/game/game_0d7070.c index 1769e3014..893ee5176 100644 --- a/src/game/game_0d7070.c +++ b/src/game/game_0d7070.c @@ -3705,7 +3705,7 @@ glabel var7f1ade54 .L0f0da420: /* f0da420: a3a400af */ sb $a0,0xaf($sp) /* f0da424: afa60100 */ sw $a2,0x100($sp) -/* f0da428: 0fc2c536 */ jal func0f0b14d8 +/* f0da428: 0fc2c536 */ jal currentPlayerGetGunZoomFov /* f0da42c: afad00b4 */ sw $t5,0xb4($sp) /* f0da430: 44803000 */ mtc1 $zero,$f6 /* f0da434: 3c0f800a */ lui $t7,%hi(g_Vars+0x284) diff --git a/src/game/game_0dcdb0.c b/src/game/game_0dcdb0.c index 8306d60ee..0b1dfbf81 100644 --- a/src/game/game_0dcdb0.c +++ b/src/game/game_0dcdb0.c @@ -512,7 +512,7 @@ glabel func0f0dd2ac /* f0dd4a0: 00000000 */ sll $zero,$zero,0x0 /* f0dd4a4: 26100008 */ addiu $s0,$s0,0x8 .L0f0dd4a8: -/* f0dd4a8: 0fc2c536 */ jal func0f0b14d8 +/* f0dd4a8: 0fc2c536 */ jal currentPlayerGetGunZoomFov /* f0dd4ac: 00000000 */ sll $zero,$zero,0x0 /* f0dd4b0: 44803000 */ mtc1 $zero,$f6 /* f0dd4b4: 3c06800a */ lui $a2,%hi(g_Vars) diff --git a/src/game/wallhit.c b/src/game/wallhit.c index 34dc709fb..e58cbf3a7 100644 --- a/src/game/wallhit.c +++ b/src/game/wallhit.c @@ -891,7 +891,7 @@ glabel var7f1b5d18 /* f13eba4: f7ba0030 */ sdc1 $f26,0x30($sp) /* f13eba8: f7b80028 */ sdc1 $f24,0x28($sp) /* f13ebac: f7b60020 */ sdc1 $f22,0x20($sp) -/* f13ebb0: 0fc2c536 */ jal func0f0b14d8 +/* f13ebb0: 0fc2c536 */ jal currentPlayerGetGunZoomFov /* f13ebb4: f7b40018 */ sdc1 $f20,0x18($sp) /* f13ebb8: 3c047f1b */ lui $a0,%hi(var7f1b5a54) /* f13ebbc: 3c058008 */ lui $a1,%hi(var8007f750) diff --git a/src/include/game/game_0b0420.h b/src/include/game/game_0b0420.h index 8145b6fe6..9cb256080 100644 --- a/src/include/game/game_0b0420.h +++ b/src/include/game/game_0b0420.h @@ -27,7 +27,7 @@ u32 func0f0b11bc(void); struct inventory_ammo *weaponGetAmmoByFunction(u32 weaponnum, u32 funcnum); f32 handGetXOffset(u32 arg0); f32 func0f0b131c(u32 hand); -f32 func0f0b14d8(void); +f32 currentPlayerGetGunZoomFov(void); u32 func0f0b1588(void); void currentPlayerUpdateGunZoomFovs(f32 arg0); bool weaponHasFlag(s32 itemid, u32 flag); diff --git a/src/include/types.h b/src/include/types.h index 2b18fa776..27fdd1aa7 100644 --- a/src/include/types.h +++ b/src/include/types.h @@ -2071,7 +2071,7 @@ struct player { /*0x16e8*/ u32 unk16e8; /*0x16ec*/ u32 unk16ec; /*0x16f0*/ u32 unk16f0; - /*0x16f4*/ f32 gunzoomfovs[3]; + /*0x16f4*/ f32 gunzoomfovs[3]; // saved zoom levels/fovs for sniper, farsight and horizon scanner /*0x1700*/ u32 lastroomforoffset; /*0x1704*/ f32 c_screenwidth; /*0x1708*/ f32 c_screenheight; @@ -2577,7 +2577,7 @@ struct inventory_menupos { }; struct inventory_typee { - u32 unk00; + f32 zoomfov; u32 unk04; u32 unk08; u32 unk0c;