From fff96a85280a008e200a959b1e23965495d4ee37 Mon Sep 17 00:00:00 2001 From: "Skyth (Asilkan)" <19259897+blueskythlikesclouds@users.noreply.github.com> Date: Sat, 8 Feb 2025 20:45:14 +0300 Subject: [PATCH] Implement fix for Sparkle locus particle vertex corruption. (#317) --- UnleashedRecomp/patches/fps_patches.cpp | 8 ++++++++ UnleashedRecompLib/config/SWA.toml | 5 +++++ 2 files changed, 13 insertions(+) diff --git a/UnleashedRecomp/patches/fps_patches.cpp b/UnleashedRecomp/patches/fps_patches.cpp index 33f4ca2c..9bdb8e9d 100644 --- a/UnleashedRecomp/patches/fps_patches.cpp +++ b/UnleashedRecomp/patches/fps_patches.cpp @@ -159,3 +159,11 @@ PPC_FUNC(sub_82B00D00) *pElapsedTime = std::max(*pElapsedTime, 0.0f); } + +bool SparkleLocusMidAsmHook() +{ + // There is an epsilon check in sparkle locus particle code that seems to never pass at high frame rates, which causes vertex corruption. + // Checking for equality doesn't fix it either, so we can fix it by forcing it to always execute instead. + // This has the side effect of the locus particle eventually snapping to the rest position during pause, but it's better than vertices exploding. + return App::s_deltaTime < (1.0 / 60.0); +} diff --git a/UnleashedRecompLib/config/SWA.toml b/UnleashedRecompLib/config/SWA.toml index 10434e6f..79341805 100644 --- a/UnleashedRecompLib/config/SWA.toml +++ b/UnleashedRecompLib/config/SWA.toml @@ -957,3 +957,8 @@ registers = ["r3"] name = "EvilHudGuideUpdateMidAsmHook" address = 0x82449800 registers = ["r30", "f30"] + +[[midasm_hook]] +name = "SparkleLocusMidAsmHook" +address = 0x82E96804 +jump_address_on_true = 0x82E96808