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;
}