From 63a622740ccd2f188403c7391bf5ec7265efba05 Mon Sep 17 00:00:00 2001 From: Skyth <19259897+blueskythlikesclouds@users.noreply.github.com> Date: Fri, 10 Jan 2025 16:42:35 +0300 Subject: [PATCH] Fix world map 3D to 2D projection. --- UnleashedRecomp/patches/csd_patches.cpp | 6 ++++++ UnleashedRecompLib/config/SWA.toml | 5 +++++ 2 files changed, 11 insertions(+) diff --git a/UnleashedRecomp/patches/csd_patches.cpp b/UnleashedRecomp/patches/csd_patches.cpp index e5202a4d..e7009663 100644 --- a/UnleashedRecomp/patches/csd_patches.cpp +++ b/UnleashedRecomp/patches/csd_patches.cpp @@ -941,3 +941,9 @@ PPC_FUNC(sub_826906A8) ctx.f1.f64 = 0.25; } } + +void WorldMapProjectionMidAsmHook(PPCVRegister& v63, PPCVRegister& v62) +{ + v63.f32[3] *= std::max(NARROW_ASPECT_RATIO, g_aspectRatio) / WIDE_ASPECT_RATIO; + v62.f32[2] *= NARROW_ASPECT_RATIO / std::min(NARROW_ASPECT_RATIO, g_aspectRatio); +} diff --git a/UnleashedRecompLib/config/SWA.toml b/UnleashedRecompLib/config/SWA.toml index a39470f2..25527b21 100644 --- a/UnleashedRecompLib/config/SWA.toml +++ b/UnleashedRecompLib/config/SWA.toml @@ -628,3 +628,8 @@ registers = ["r3"] name = "ObjGetItemFieldOfViewMidAsmHook" address = 0x82692934 registers = ["r1", "f1"] + +[[midasm_hook]] +name = "WorldMapProjectionMidAsmHook" +address = 0x82574E00 +registers = ["v63", "v62"]