diff --git a/UnleashedRecomp/game.cpp b/UnleashedRecomp/game.cpp index 1ae3d0f..acdd2f0 100644 --- a/UnleashedRecomp/game.cpp +++ b/UnleashedRecomp/game.cpp @@ -43,3 +43,31 @@ void CameraBoostAspectRatioMidAsmHook(PPCRegister& r31, PPCRegister& f0) f0.f32 = pCamera->m_VertFieldOfView; } } + +void CSDAspectRatioMidAsmHook(PPCRegister& f1, PPCRegister& f2) +{ + auto newAspectRatio = (float)Window::s_width / (float)Window::s_height; + + if (newAspectRatio > m_baseAspectRatio) + { + f1.f64 = 1280.0f / ((newAspectRatio * 720.0f) / 1280.0f); + } + else if (newAspectRatio < m_baseAspectRatio) + { + f2.f64 = 720.0f / ((1280.0f / newAspectRatio) / 720.0f); + } +} + +void CSDOffsetMidAsmHook(PPCRegister& f1, PPCRegister& f2) +{ + auto newAspectRatio = (float)Window::s_width / (float)Window::s_height; + + if (newAspectRatio > m_baseAspectRatio) + { + *(be*)g_memory.Translate(0x8339C5D0) = ((newAspectRatio * 720.0f) - 1280.0f) / 2.0f / 1280.0f; + } + else + { + *(be*)g_memory.Translate(0x8339C5D4) = ((1280.0f / newAspectRatio) - 720.0f) / 2.0f / 720.0f; + } +} diff --git a/UnleashedRecompLib/config/SWA.toml b/UnleashedRecompLib/config/SWA.toml index 820dd50..8646af7 100644 --- a/UnleashedRecompLib/config/SWA.toml +++ b/UnleashedRecompLib/config/SWA.toml @@ -119,4 +119,15 @@ jump_address_on_false = 0x82468EE0 [[midasm_hook]] name = "CameraBoostAspectRatioMidAsmHook" address = 0x8246BDA8 -registers = ["r31", "f0"] \ No newline at end of file +registers = ["r31", "f0"] + +[[midasm_hook]] +name = "CSDAspectRatioMidAsmHook" +address = 0x830C0A28 +registers = ["f1", "f2"] + +[[midasm_hook]] +name = "CSDOffsetMidAsmHook" +address = 0x830C0A78 +registers = ["f1", "f2"] +return = true \ No newline at end of file