Fix loading screen speed at high frame rates

This commit is contained in:
Hyper 2024-11-12 19:55:00 +00:00
parent 3080412dc0
commit c9b6a6913f
3 changed files with 21 additions and 0 deletions

View file

@ -3,6 +3,9 @@
#include "ui/window.h"
#include "config.h"
float m_lastLoadingFrameDelta = 0.0f;
std::chrono::steady_clock::time_point m_lastLoadingFrameTime;
void HighFrameRateDeltaTimeFixMidAsmHook(PPCRegister& f1)
{
// Having 60 FPS threshold ensures we still retain
@ -58,3 +61,15 @@ void Camera2DSlopeLerpFixMidAsmHook(PPCRegister& t, PPCRegister& deltaTime)
{
t.f64 = ComputeLerpFactor(t.f64, deltaTime.f64 / 60.0);
}
void LoadingScreenSpeedFixMidAsmHook(PPCRegister& r4)
{
auto now = std::chrono::high_resolution_clock::now();
m_lastLoadingFrameDelta = std::min(std::chrono::duration<float>(now - m_lastLoadingFrameTime).count(), 1.0f / 15.0f);
m_lastLoadingFrameTime = now;
auto pDeltaTime = (be<float>*)g_memory.Translate(r4.u32);
*pDeltaTime = m_lastLoadingFrameDelta;
}

View file

@ -12,6 +12,7 @@
#include <vector>
#include <string>
#include <cassert>
#include <chrono>
#include <xbox.h>
#include <xxhash.h>
#include <ankerl/unordered_dense.h>

View file

@ -417,3 +417,8 @@ jump_address_on_true = 0x827D20EC
name = "ParticleTestDrawIndexedPrimitiveMidAsmHook"
address = 0x827D25AC
registers = ["r7"]
[[midasm_hook]]
name = "LoadingScreenSpeedFixMidAsmHook"
address = 0x824DAB60
registers = ["r4"]