From cd738463d60490d0830f7f5f19437b51eea1434c Mon Sep 17 00:00:00 2001 From: Crementif <26669564+Crementif@users.noreply.github.com> Date: Wed, 27 Jul 2022 01:08:29 +0200 Subject: [PATCH] [XCX] Fix QTE bug for real! --- .../Mods/60FPS/patch_Cutscene.asm | 2 +- .../Mods/60FPS/patch_GameSpeed.asm | 6 +- .../Mods/60FPS/patch_Overdrive.asm | 8 +- .../Mods/60FPS/patch_QTE.asm | 83 ++++++++++++++++--- src/XenobladeChroniclesX/Mods/60FPS/rules.txt | 2 +- 5 files changed, 79 insertions(+), 22 deletions(-) diff --git a/src/XenobladeChroniclesX/Mods/60FPS/patch_Cutscene.asm b/src/XenobladeChroniclesX/Mods/60FPS/patch_Cutscene.asm index 22081150..98edd128 100644 --- a/src/XenobladeChroniclesX/Mods/60FPS/patch_Cutscene.asm +++ b/src/XenobladeChroniclesX/Mods/60FPS/patch_Cutscene.asm @@ -1,5 +1,5 @@ [XCX_FPS++_Cutscene] -moduleMatches = 0x218F6E07, 0xF882D5CF, 0x30B6E091, 0x7672271D ; 1.0.0E, 1.0.1E, 1.0.2U, 1.0.2J +moduleMatches = 0xF882D5CF, 0x30B6E091, 0x7672271D ; 1.0.1E, 1.0.2U, 1.0.2J .origin = codecave diff --git a/src/XenobladeChroniclesX/Mods/60FPS/patch_GameSpeed.asm b/src/XenobladeChroniclesX/Mods/60FPS/patch_GameSpeed.asm index 25158ae6..476805cc 100644 --- a/src/XenobladeChroniclesX/Mods/60FPS/patch_GameSpeed.asm +++ b/src/XenobladeChroniclesX/Mods/60FPS/patch_GameSpeed.asm @@ -1,5 +1,5 @@ [XCX_FPS++_GameSpeed] -moduleMatches = 0x218F6E07, 0xF882D5CF, 0x30B6E091, 0x7672271D ; 1.0.0E, 1.0.1E, 1.0.2U, 1.0.2J +moduleMatches = 0xF882D5CF, 0x30B6E091, 0x7672271D ; 1.0.1E, 1.0.2U, 1.0.2J .origin = codecave @@ -258,8 +258,8 @@ lwz r10, 0x14(r1) blr -[XCX_FPS++_GameSpeed_V100E_V101E] -moduleMatches = 0x218F6E07, 0xF882D5CF +[XCX_FPS++_GameSpeed_V101E] +moduleMatches = 0xF882D5CF ; Global data patch 0x10171980 = havokHalfSpeed: diff --git a/src/XenobladeChroniclesX/Mods/60FPS/patch_Overdrive.asm b/src/XenobladeChroniclesX/Mods/60FPS/patch_Overdrive.asm index d2e6ff86..031bddc0 100644 --- a/src/XenobladeChroniclesX/Mods/60FPS/patch_Overdrive.asm +++ b/src/XenobladeChroniclesX/Mods/60FPS/patch_Overdrive.asm @@ -1,5 +1,5 @@ [XCX_FPS++_Overdrive_General] ; ######################################################## -moduleMatches = 0xF882D5CF, 0x30B6E091, 0xAB97DE6B, 0x7672271D ; 1.0.1E, 1.0.2U, 1.0.1U, 1.0.2J +moduleMatches = 0xF882D5CF, 0x30B6E091, 0x7672271D ; 1.0.1E, 1.0.2U, 1.0.2J .origin = codecave @@ -11,13 +11,13 @@ _over: blr -[XCX_FPS++_Overdrive_NonJ] ; ######################################################## -moduleMatches = 0xF882D5CF, 0x30B6E091, 0xAB97DE6B ; 1.0.1E, 1.0.2U, 1.0.1U +[XCX_FPS++_Overdrive_V101E_102U] ; ######################################################## +moduleMatches = 0xF882D5CF, 0x30B6E091 ; 1.0.1E, 1.0.2U 0x021BC904 = bla _over 0x021E2020 = bla _over ; Skell Overdrive -[XCX_FPS++_Overdrive_2J] ; ######################################################## +[XCX_FPS++_Overdrive_V102J] ; ######################################################## moduleMatches = 0x7672271D ; 1.0.2J 0x021BC3D0 = bla _over diff --git a/src/XenobladeChroniclesX/Mods/60FPS/patch_QTE.asm b/src/XenobladeChroniclesX/Mods/60FPS/patch_QTE.asm index 7c6aaea0..cee5ca13 100644 --- a/src/XenobladeChroniclesX/Mods/60FPS/patch_QTE.asm +++ b/src/XenobladeChroniclesX/Mods/60FPS/patch_QTE.asm @@ -1,23 +1,80 @@ [XCX_FPS++_QTE_General] ; ######################################################## -moduleMatches = 0x218F6E07, 0xF882D5CF, 0x30B6E091, 0x7672271D ; 1.0.1E, 1.0.2U, 1.0.1U, 1.0.2J +moduleMatches = 0xF882D5CF, 0x30B6E091, 0x7672271D ; 1.0.1E, 1.0.2U, 1.0.2J .origin = codecave +timingFloatConv: +timingFloatConvHa: +.uint 0 +timingFloatConvL: +.uint 0 + +correctedTimingTemp: +correctedTimingTempHa: +.uint 0 +correctedTimingTempL: +.uint 1 + + _justFrame1: - lwz r12, 0x47C(r29) - lis r10, averageFPS1IntInv@ha - lbz r10, averageFPS1IntInv@l(r10) - mullw r12, r12, r10 - ; mr r12, r10 - blr + lwz r12, 0x47C(r29) + + ; Convert timing to floating point for multiplication + xoris r12, r12, 0x8000 + lis r27, timingFloatConv@ha + stw r12, timingFloatConv@l+0x4(r27) + lis r12, 0x4330 + stw r12, timingFloatConv@l+0x0(r27) + lfd f13, timingFloatConv@l+0x0(r27) + lis r27, convSub@ha + lfd f0, convSub@l(r27) + fsub f13, f13, f0 + frsp f13, f13 + + ; Multiply timing + lis r27, averageFPS1@ha + lfs f0, averageFPS1@l(r27) + fmuls f13, f13, f0 + + ; Convert and load corrected timing back + fctiwz f13, f13 + lis r27, correctedTimingTemp@ha + stfd f13, correctedTimingTemp@l(r27) + lis r27, correctedTimingTempL@ha + lwz r12, correctedTimingTempL@l(r27) + + blr _justFrame2: - lwz r0, 0x478(r29) - lis r8, averageFPS1IntInv@ha - lbz r8, averageFPS1IntInv@l(r8) - mullw r0, r0, r8 - ; mr r0, r8 - blr + lwz r0, 0x478(r29) + cmpwi r0, 0 + beqlr + + ; Convert timing to floating point for multiplication + xoris r0, r0, 0x8000 + lis r8, timingFloatConv@ha + stw r0, timingFloatConv@l+0x4(r8) + lis r0, 0x4330 + stw r0, timingFloatConv@l+0x0(r8) + lfd f13, timingFloatConv@l+0x0(r8) + lis r8, convSub@ha + lfd f0, convSub@l(r8) + fsub f13, f13, f0 + frsp f13, f13 + + ; Multiply timing + lis r8, averageFPS1@ha + lfs f0, averageFPS1@l(r8) + fmuls f13, f13, f0 + + ; Convert corrected timing back + fctiwz f13, f13 + lis r8, correctedTimingTemp@ha + stfd f13, correctedTimingTemp@l(r8) + lis r8, correctedTimingTempL@ha + lwz r0, correctedTimingTempL@l(r8) + + blr [XCX_FPS++_QTE_1E] ; ######################################################## moduleMatches = 0xF882D5CF ; 1.0.1E diff --git a/src/XenobladeChroniclesX/Mods/60FPS/rules.txt b/src/XenobladeChroniclesX/Mods/60FPS/rules.txt index bf0aeb5b..c6755ad8 100644 --- a/src/XenobladeChroniclesX/Mods/60FPS/rules.txt +++ b/src/XenobladeChroniclesX/Mods/60FPS/rules.txt @@ -2,7 +2,7 @@ titleIds = 0005000010116100,00050000101C4C00,00050000101C4D00 name = FPS++ For Xenoblade Chronicles X path = "Xenoblade Chronicles X/Mods/FPS++ For XCX" -description = Allows you to change the FPS and the speed that most things run at.|Some bugs might still occur if you run games at 60FPS. +description = Allows you to change the FPS and the speed that most things run at.|Some bugs might still occur if you run games at 60FPS.|Only supports the latest update! version = 6 [Default]