From 2cb5004c47f016387c69bbc531d5c6ee01731e60 Mon Sep 17 00:00:00 2001 From: somewhatlurker <52014015+somewhatlurker@users.noreply.github.com> Date: Fri, 6 Sep 2019 02:37:38 +1000 Subject: [PATCH 01/11] replace FrameRateManager with new approach -- now keeps sync much better, but makes wind effects and some stuff outside PVs run at the wrong speed --- .../TLAC/Components/FrameRateManager.cpp | 198 ++++++++++++++---- .../TLAC/Components/FrameRateManager.h | 12 +- 2 files changed, 160 insertions(+), 50 deletions(-) diff --git a/source-code/source/plugins/TLAC/Components/FrameRateManager.cpp b/source-code/source/plugins/TLAC/Components/FrameRateManager.cpp index c902a2f..d011719 100644 --- a/source-code/source/plugins/TLAC/Components/FrameRateManager.cpp +++ b/source-code/source/plugins/TLAC/Components/FrameRateManager.cpp @@ -1,4 +1,4 @@ -#include "FrameRateManager.h" +#include "FrameRateManager.h" #include "../Constants.h" #include "GameState.h" #include @@ -30,57 +30,177 @@ namespace TLAC::Components defaultAetFrameDuration = *aetFrameDuration; // This const variable is stored inside a data segment so we don't want to throw any access violations - DWORD oldProtect; + DWORD oldProtect, bck; VirtualProtect((void*)AET_FRAME_DURATION_ADDRESS, sizeof(float), PAGE_EXECUTE_READWRITE, &oldProtect); + + + // fix auto speed for high fps + VirtualProtect((BYTE*)0x140192d7b, 3, PAGE_EXECUTE_READWRITE, &oldProtect); + *((BYTE*)0x140192d7b + 0) = 0x90; + *((BYTE*)0x140192d7b + 1) = 0x90; + *((BYTE*)0x140192d7b + 2) = 0x90; + VirtualProtect((BYTE*)0x140192d7b, 3, oldProtect, &bck); + + + // fix edit PV AETs (thanks lyb) + VirtualProtect((BYTE*)0x140192D30, 8, PAGE_EXECUTE_READWRITE, &oldProtect); // MOVSS XMM0, dword ptr [0x140192f94] + *((BYTE*)0x140192D30 + 0) = 0xF3; + *((BYTE*)0x140192D30 + 1) = 0x0F; + *((BYTE*)0x140192D30 + 2) = 0x10; + *((BYTE*)0x140192D30 + 3) = 0x05; + *((BYTE*)0x140192D30 + 4) = 0x5C; + *((BYTE*)0x140192D30 + 5) = 0x02; + *((BYTE*)0x140192D30 + 6) = 0x00; + *((BYTE*)0x140192D30 + 7) = 0x00; + VirtualProtect((BYTE*)0x140192D30, 8, oldProtect, &bck); + + + // fix ageage hair effect + VirtualProtect((BYTE*)0x14054352f, 5, PAGE_EXECUTE_READWRITE, &oldProtect); // CALL 0x140192d50 (getFrameSpeed) + *((BYTE*)0x14054352f + 0) = 0xE8; + *((BYTE*)0x14054352f + 1) = 0x1C; + *((BYTE*)0x14054352f + 2) = 0xF8; + *((BYTE*)0x14054352f + 3) = 0xC4; + *((BYTE*)0x14054352f + 4) = 0xFF; + VirtualProtect((BYTE*)0x14054352f, 5, oldProtect, &bck); + + VirtualProtect((BYTE*)0x140543534, 4, PAGE_EXECUTE_READWRITE, &oldProtect); // MULSS XMM3, XMM0 + *((BYTE*)0x140543534 + 0) = 0xF3; + *((BYTE*)0x140543534 + 1) = 0x0F; + *((BYTE*)0x140543534 + 2) = 0x59; + *((BYTE*)0x140543534 + 3) = 0xD8; + VirtualProtect((BYTE*)0x140543534, 4, oldProtect, &bck); + + VirtualProtect((BYTE*)0x140543538, 2, PAGE_EXECUTE_READWRITE, &oldProtect); // JMP 0x1405434f0 + *((BYTE*)0x140543538 + 0) = 0xEB; + *((BYTE*)0x140543538 + 1) = 0xB6; + VirtualProtect((BYTE*)0x140543538, 2, oldProtect, &bck); + + + + // below are patches for the alternate method (breaks physics) + + //// run motions at motionSpeedMultiplier x rate + // // skip unncessary code to free code space + // VirtualProtect((BYTE*)0x140194b2b, 2, PAGE_EXECUTE_READWRITE, &oldProtect); // JMP 0x140194b51 + // *((BYTE*)0x140194b2b + 0) = 0xEB; + // *((BYTE*)0x140194b2b + 1) = 0x24; + // VirtualProtect((BYTE*)0x140194b2b, 2, oldProtect, &bck); + + + // VirtualProtect((BYTE*)0x140194b2d, 5, PAGE_EXECUTE_READWRITE, &oldProtect); // CALL 0x140192d50 + // *((BYTE*)0x140194b2d + 0) = 0xE8; + // *((BYTE*)0x140194b2d + 1) = 0x1E; + // *((BYTE*)0x140194b2d + 2) = 0xE2; + // *((BYTE*)0x140194b2d + 3) = 0xFF; + // *((BYTE*)0x140194b2d + 4) = 0xFF; + // VirtualProtect((BYTE*)0x140194b2d, 5, oldProtect, &bck); + + // VirtualProtect((BYTE*)0x140194b32, 10, PAGE_EXECUTE_READWRITE, &oldProtect); // MOV ECX, &motionSpeedMultiplier + // *((BYTE*)0x140194b32 + 0) = 0x48; + // *((BYTE*)0x140194b32 + 1) = 0xB9; + // *((BYTE*)0x140194b32 + 2) = (uint64_t)&motionSpeedMultiplier & 0xFF; + // *((BYTE*)0x140194b32 + 3) = ((uint64_t)&motionSpeedMultiplier >> 8) & 0xFF; + // *((BYTE*)0x140194b32 + 4) = ((uint64_t)&motionSpeedMultiplier >> 16) & 0xFF; + // *((BYTE*)0x140194b32 + 5) = ((uint64_t)&motionSpeedMultiplier >> 24) & 0xFF; + // *((BYTE*)0x140194b32 + 6) = ((uint64_t)&motionSpeedMultiplier >> 32) & 0xFF; + // *((BYTE*)0x140194b32 + 7) = ((uint64_t)&motionSpeedMultiplier >> 40) & 0xFF; + // *((BYTE*)0x140194b32 + 8) = ((uint64_t)&motionSpeedMultiplier >> 48) & 0xFF; + // *((BYTE*)0x140194b32 + 9) = ((uint64_t)&motionSpeedMultiplier >> 56) & 0xFF; + // VirtualProtect((BYTE*)0x140194b32, 10, oldProtect, &bck); + + // VirtualProtect((BYTE*)0x140194b3c, 5, PAGE_EXECUTE_READWRITE, &oldProtect); // MOVD XMM1, dword ptr [ECX] + // *((BYTE*)0x140194b3c + 0) = 0x66; + // *((BYTE*)0x140194b3c + 1) = 0x67; + // *((BYTE*)0x140194b3c + 2) = 0x0F; + // *((BYTE*)0x140194b3c + 3) = 0x6E; + // *((BYTE*)0x140194b3c + 4) = 0x09; + // VirtualProtect((BYTE*)0x140194b3c, 5, oldProtect, &bck); + + // VirtualProtect((BYTE*)0x140194b41, 4, PAGE_EXECUTE_READWRITE, &oldProtect); // MULSS XMM0, XMM1 + // *((BYTE*)0x140194b41 + 0) = 0xF3; + // *((BYTE*)0x140194b41 + 1) = 0x0F; + // *((BYTE*)0x140194b41 + 2) = 0x59; + // *((BYTE*)0x140194b41 + 3) = 0xC1; + // VirtualProtect((BYTE*)0x140194b41, 4, oldProtect, &bck); + + // VirtualProtect((BYTE*)0x140194b45, 2, PAGE_EXECUTE_READWRITE, &oldProtect); // JMP 0x140194ae8 + // *((BYTE*)0x140194b45 + 0) = 0xEB; + // *((BYTE*)0x140194b45 + 1) = 0xA1; + // VirtualProtect((BYTE*)0x140194b45, 2, oldProtect, &bck); + + + // // jump to new code + // VirtualProtect((BYTE*)0x140194ae3, 2, PAGE_EXECUTE_READWRITE, &oldProtect); // JMP 0x140194b2d + // *((BYTE*)0x140194ae3 + 0) = 0xEB; + // *((BYTE*)0x140194ae3 + 1) = 0x48; + // VirtualProtect((BYTE*)0x140194ae3, 2, oldProtect, &bck); + + + //// // trying to fix physics (fail) + //// VirtualProtect((BYTE*)0x14011d537, 9, PAGE_EXECUTE_READWRITE, &oldProtect); // change source to dword ptr [0x140b0d4f0] + //// *((BYTE*)0x14011d537 + 0) = 0xF3; + //// *((BYTE*)0x14011d537 + 1) = 0x0F; + //// *((BYTE*)0x14011d537 + 2) = 0x10; + //// *((BYTE*)0x14011d537 + 3) = 0x05; + //// *((BYTE*)0x14011d537 + 4) = 0xB1; + //// *((BYTE*)0x14011d537 + 5) = 0xFF; + //// *((BYTE*)0x14011d537 + 6) = 0x9E; + //// *((BYTE*)0x14011d537 + 7) = 0x00; + //// *((BYTE*)0x14011d537 + 8) = 0x90; + //// VirtualProtect((BYTE*)0x14011d537, 9, oldProtect, &bck); } void FrameRateManager::Update() { - float frameRate = 0.0f; - frameRate = RoundFrameRate(GetGameFrameRate()); + // this alterante way makes physics slowmo, but overall may be better if that's fixed - *aetFrameDuration = 1.0f / frameRate; - *pvFrameRate = frameRate; + //// target framerate + //*(float*)0x140eda6cc = 60.0f; + + //// enable dynamic framerate + //*(bool*)0x140eda79c = true; + + //*pvFrameRate = 60.0f; + + //*aetFrameDuration = 1.0f / GetGameFrameRate(); + + //bool inGame = *(GameState*)CURRENT_GAME_STATE_ADDRESS == GS_GAME; + //if (inGame) + //{ + // // This PV struct creates a copy of the PvFrameRate & PvFrameSpeed during the loading screen + // // so we'll make sure to keep updating it as well. + // // Each new motion also creates its own copy of these values but keeping track of the active motions is annoying + // // and they usually change multiple times per PV anyway so this should suffice for now + // float* pvStructPvFrameRate = (float*)(0x0000000140CDD978 + 0x2BF98); + // float* pvStructPvFrameSpeed = (float*)(0x0000000140CDD978 + 0x2BF9C); + + // *pvStructPvFrameRate = 60.0; // ? + // *pvStructPvFrameSpeed = 1.0 / motionSpeedMultiplier; + //} + + + + + // this way breaks some anim speeds, but they're fixable + + *pvFrameRate = 60.0f * motionSpeedMultiplier; + + // target framerate + *(float*)0x140eda6cc = *pvFrameRate; + + *aetFrameDuration = 1.0f / GetGameFrameRate(); bool inGame = *(GameState*)CURRENT_GAME_STATE_ADDRESS == GS_GAME; - if (inGame) { - // During the GAME state the frame rate will be handled by the PvFrameRate instead - - constexpr float defaultFrameSpeed = 1.0f; - constexpr float defaultFrameRate = 60.0f; - - // This PV struct creates a copy of the PvFrameRate & PvFrameSpeed during the loading screen - // so we'll make sure to keep updating it as well. - // Each new motion also creates its own copy of these values but keeping track of the active motions is annoying - // and they usually change multiple times per PV anyway so this should suffice for now - float* pvStructPvFrameRate = (float*)(0x0000000140CDD978 + 0x2BF98); - float* pvStructPvFrameSpeed = (float*)(0x0000000140CDD978 + 0x2BF9C); - - *pvStructPvFrameRate = *pvFrameRate; - *pvStructPvFrameSpeed = (defaultFrameRate / *pvFrameRate); - - *frameSpeed = defaultFrameSpeed; + // enable dynamic framerate + *(bool*)0x140eda79c = true; } else { - *frameSpeed = *aetFrameDuration / defaultAetFrameDuration; + // disable dynamic framerate + *(bool*)0x140eda79c = false; } } - - float FrameRateManager::RoundFrameRate(float frameRate) - { - constexpr float roundingThreshold = 4.0f; - - for (int i = 0; i < sizeof(commonRefreshRates) / sizeof(float); i++) - { - float refreshRate = commonRefreshRates[i]; - - if (frameRate > refreshRate - roundingThreshold && frameRate < refreshRate + roundingThreshold) - frameRate = refreshRate; - } - - return frameRate; - } } diff --git a/source-code/source/plugins/TLAC/Components/FrameRateManager.h b/source-code/source/plugins/TLAC/Components/FrameRateManager.h index f6a6600..512f49c 100644 --- a/source-code/source/plugins/TLAC/Components/FrameRateManager.h +++ b/source-code/source/plugins/TLAC/Components/FrameRateManager.h @@ -19,16 +19,6 @@ namespace TLAC::Components float *frameSpeed; float *aetFrameDuration; float defaultAetFrameDuration; - - float commonRefreshRates[5] - { - 60.0f, - 75.0f, - 120.0f, - 144.0f, - 240.0f, - }; - - float RoundFrameRate(float frameRate); + float motionSpeedMultiplier = 3.0; }; } From 7b35907406a7d212e3eeca1155a8e5e85877d34a Mon Sep 17 00:00:00 2001 From: somewhatlurker <52014015+somewhatlurker@users.noreply.github.com> Date: Fri, 6 Sep 2019 03:24:04 +1000 Subject: [PATCH 02/11] restrict frame rate adjustments to in-pv and attract demos only --- source-code/source/plugins/TLAC/Components/FrameRateManager.cpp | 2 +- source-code/source/plugins/TLAC/Constants.h | 1 + 2 files changed, 2 insertions(+), 1 deletion(-) diff --git a/source-code/source/plugins/TLAC/Components/FrameRateManager.cpp b/source-code/source/plugins/TLAC/Components/FrameRateManager.cpp index d011719..b26620c 100644 --- a/source-code/source/plugins/TLAC/Components/FrameRateManager.cpp +++ b/source-code/source/plugins/TLAC/Components/FrameRateManager.cpp @@ -191,7 +191,7 @@ namespace TLAC::Components *aetFrameDuration = 1.0f / GetGameFrameRate(); - bool inGame = *(GameState*)CURRENT_GAME_STATE_ADDRESS == GS_GAME; + bool inGame = *(SubGameState*)CURRENT_GAME_SUB_STATE_ADDRESS == SUB_GAME_MAIN || *(SubGameState*)CURRENT_GAME_SUB_STATE_ADDRESS == SUB_DEMO; if (inGame) { // enable dynamic framerate diff --git a/source-code/source/plugins/TLAC/Constants.h b/source-code/source/plugins/TLAC/Constants.h index 304f737..fc8c7ff 100644 --- a/source-code/source/plugins/TLAC/Constants.h +++ b/source-code/source/plugins/TLAC/Constants.h @@ -10,6 +10,7 @@ constexpr uint8_t JNE_OPCODE = 0x85; constexpr uint64_t ENGINE_UPDATE_INPUT_ADDRESS = 0x000000014018CBB0; constexpr uint64_t CURRENT_GAME_STATE_ADDRESS = 0x0000000140EDA810; +constexpr uint64_t CURRENT_GAME_SUB_STATE_ADDRESS = 0x0000000140EDA82C; constexpr uint64_t RESOLUTION_WIDTH_ADDRESS = 0x0000000140EDA8BC; constexpr uint64_t RESOLUTION_HEIGHT_ADDRESS = 0x0000000140EDA8C0; From 82f5d35e0a87d786e8a329c0832cf7550541e3ac Mon Sep 17 00:00:00 2001 From: somewhatlurker <52014015+somewhatlurker@users.noreply.github.com> Date: Fri, 6 Sep 2019 08:35:58 +1000 Subject: [PATCH 03/11] frm: fix speed in data test modes --- .../plugins/TLAC/Components/FrameRateManager.cpp | 16 ++++++++++++---- 1 file changed, 12 insertions(+), 4 deletions(-) diff --git a/source-code/source/plugins/TLAC/Components/FrameRateManager.cpp b/source-code/source/plugins/TLAC/Components/FrameRateManager.cpp index b26620c..6e761b6 100644 --- a/source-code/source/plugins/TLAC/Components/FrameRateManager.cpp +++ b/source-code/source/plugins/TLAC/Components/FrameRateManager.cpp @@ -186,16 +186,24 @@ namespace TLAC::Components *pvFrameRate = 60.0f * motionSpeedMultiplier; - // target framerate - *(float*)0x140eda6cc = *pvFrameRate; *aetFrameDuration = 1.0f / GetGameFrameRate(); - bool inGame = *(SubGameState*)CURRENT_GAME_SUB_STATE_ADDRESS == SUB_GAME_MAIN || *(SubGameState*)CURRENT_GAME_SUB_STATE_ADDRESS == SUB_DEMO; - if (inGame) + if (*(SubGameState*)CURRENT_GAME_SUB_STATE_ADDRESS == SUB_GAME_MAIN || *(SubGameState*)CURRENT_GAME_SUB_STATE_ADDRESS == SUB_DEMO) { // enable dynamic framerate *(bool*)0x140eda79c = true; + + // target framerate + *(float*)0x140eda6cc = *pvFrameRate; + } + else if (*(GameState*)CURRENT_GAME_STATE_ADDRESS == GS_DATA_TEST) + { + // enable dynamic framerate + *(bool*)0x140eda79c = true; + + // target framerate + *(float*)0x140eda6cc = 60.0f; } else { From 4ae24cea39871efeaf4aa4ac001db75eef17751b Mon Sep 17 00:00:00 2001 From: somewhatlurker <52014015+somewhatlurker@users.noreply.github.com> Date: Fri, 6 Sep 2019 10:35:02 +1000 Subject: [PATCH 04/11] frm: fix wind effect(?), increase motionSpeedMultiplier to 5 --- .../TLAC/Components/FrameRateManager.cpp | 45 +++++++++++++++++++ .../TLAC/Components/FrameRateManager.h | 2 +- 2 files changed, 46 insertions(+), 1 deletion(-) diff --git a/source-code/source/plugins/TLAC/Components/FrameRateManager.cpp b/source-code/source/plugins/TLAC/Components/FrameRateManager.cpp index 6e761b6..1629cdd 100644 --- a/source-code/source/plugins/TLAC/Components/FrameRateManager.cpp +++ b/source-code/source/plugins/TLAC/Components/FrameRateManager.cpp @@ -76,6 +76,51 @@ namespace TLAC::Components *((BYTE*)0x140543538 + 1) = 0xB6; VirtualProtect((BYTE*)0x140543538, 2, oldProtect, &bck); + + // fix wind effect + VirtualProtect((BYTE*)0x14053ca71, 2, PAGE_EXECUTE_READWRITE, &oldProtect); // JMP 0x14053cab2 + *((BYTE*)0x14053ca71 + 0) = 0xEB; + *((BYTE*)0x14053ca71 + 1) = 0x3F; + VirtualProtect((BYTE*)0x14053ca71, 2, oldProtect, &bck); + + VirtualProtect((BYTE*)0x14053cab2, 8, PAGE_EXECUTE_READWRITE, &oldProtect); // MOVSS XMM0, dword ptr [0x1409a1eb4] (60.0f) + *((BYTE*)0x14053cab2 + 0) = 0xF3; + *((BYTE*)0x14053cab2 + 1) = 0x0F; + *((BYTE*)0x14053cab2 + 2) = 0x10; + *((BYTE*)0x14053cab2 + 3) = 0x05; + *((BYTE*)0x14053cab2 + 4) = 0xFA; + *((BYTE*)0x14053cab2 + 5) = 0x53; + *((BYTE*)0x14053cab2 + 6) = 0x46; + *((BYTE*)0x14053cab2 + 7) = 0x00; + VirtualProtect((BYTE*)0x14053cab2, 8, oldProtect, &bck); + + VirtualProtect((BYTE*)0x14053caba, 5, PAGE_EXECUTE_READWRITE, &oldProtect); // JMP 0x14053c901 + *((BYTE*)0x14053caba + 0) = 0xE9; + *((BYTE*)0x14053caba + 1) = 0x42; + *((BYTE*)0x14053caba + 2) = 0xFE; + *((BYTE*)0x14053caba + 3) = 0xFF; + *((BYTE*)0x14053caba + 4) = 0xFF; + VirtualProtect((BYTE*)0x14053caba, 5, oldProtect, &bck); + + VirtualProtect((BYTE*)0x14053c901, 8, PAGE_EXECUTE_READWRITE, &oldProtect); // DIVSS XMM0, dword ptr [0x140eda6d0] (framerate) + *((BYTE*)0x14053c901 + 0) = 0xF3; + *((BYTE*)0x14053c901 + 1) = 0x0F; + *((BYTE*)0x14053c901 + 2) = 0x5E; + *((BYTE*)0x14053c901 + 3) = 0x05; + *((BYTE*)0x14053c901 + 4) = 0xC7; + *((BYTE*)0x14053c901 + 5) = 0xDD; + *((BYTE*)0x14053c901 + 6) = 0x99; + *((BYTE*)0x14053c901 + 7) = 0x00; + VirtualProtect((BYTE*)0x14053c901, 8, oldProtect, &bck); + + VirtualProtect((BYTE*)0x14053c909, 5, PAGE_EXECUTE_READWRITE, &oldProtect); // JMP 0x14053ca76 + *((BYTE*)0x14053c909 + 0) = 0xE9; + *((BYTE*)0x14053c909 + 1) = 0x68; + *((BYTE*)0x14053c909 + 2) = 0x01; + *((BYTE*)0x14053c909 + 3) = 0x00; + *((BYTE*)0x14053c909 + 4) = 0x00; + VirtualProtect((BYTE*)0x14053c909, 5, oldProtect, &bck); + // below are patches for the alternate method (breaks physics) diff --git a/source-code/source/plugins/TLAC/Components/FrameRateManager.h b/source-code/source/plugins/TLAC/Components/FrameRateManager.h index 512f49c..54f67fc 100644 --- a/source-code/source/plugins/TLAC/Components/FrameRateManager.h +++ b/source-code/source/plugins/TLAC/Components/FrameRateManager.h @@ -19,6 +19,6 @@ namespace TLAC::Components float *frameSpeed; float *aetFrameDuration; float defaultAetFrameDuration; - float motionSpeedMultiplier = 3.0; + float motionSpeedMultiplier = 5.0; }; } From dafeef79364c6314fb428e31b684888e5e56b437 Mon Sep 17 00:00:00 2001 From: somewhatlurker <52014015+somewhatlurker@users.noreply.github.com> Date: Fri, 6 Sep 2019 22:16:05 +1000 Subject: [PATCH 05/11] frm: use InjectCode for readability, add fix for snow effect, fix module menu framerate --- .../TLAC/Components/FrameRateManager.cpp | 189 ++++-------------- .../TLAC/Components/FrameRateManager.h | 2 + 2 files changed, 46 insertions(+), 145 deletions(-) diff --git a/source-code/source/plugins/TLAC/Components/FrameRateManager.cpp b/source-code/source/plugins/TLAC/Components/FrameRateManager.cpp index 1629cdd..af73e43 100644 --- a/source-code/source/plugins/TLAC/Components/FrameRateManager.cpp +++ b/source-code/source/plugins/TLAC/Components/FrameRateManager.cpp @@ -4,6 +4,7 @@ #include #include #include "../framework.h" +#include namespace TLAC::Components { @@ -30,96 +31,31 @@ namespace TLAC::Components defaultAetFrameDuration = *aetFrameDuration; // This const variable is stored inside a data segment so we don't want to throw any access violations - DWORD oldProtect, bck; + DWORD oldProtect; VirtualProtect((void*)AET_FRAME_DURATION_ADDRESS, sizeof(float), PAGE_EXECUTE_READWRITE, &oldProtect); // fix auto speed for high fps - VirtualProtect((BYTE*)0x140192d7b, 3, PAGE_EXECUTE_READWRITE, &oldProtect); - *((BYTE*)0x140192d7b + 0) = 0x90; - *((BYTE*)0x140192d7b + 1) = 0x90; - *((BYTE*)0x140192d7b + 2) = 0x90; - VirtualProtect((BYTE*)0x140192d7b, 3, oldProtect, &bck); + InjectCode((void*)0x140192d7b, { 0x90, 0x90, 0x90 }); // fix edit PV AETs (thanks lyb) - VirtualProtect((BYTE*)0x140192D30, 8, PAGE_EXECUTE_READWRITE, &oldProtect); // MOVSS XMM0, dword ptr [0x140192f94] - *((BYTE*)0x140192D30 + 0) = 0xF3; - *((BYTE*)0x140192D30 + 1) = 0x0F; - *((BYTE*)0x140192D30 + 2) = 0x10; - *((BYTE*)0x140192D30 + 3) = 0x05; - *((BYTE*)0x140192D30 + 4) = 0x5C; - *((BYTE*)0x140192D30 + 5) = 0x02; - *((BYTE*)0x140192D30 + 6) = 0x00; - *((BYTE*)0x140192D30 + 7) = 0x00; - VirtualProtect((BYTE*)0x140192D30, 8, oldProtect, &bck); - + InjectCode((void*)0x140192d30, { 0xF3, 0x0F, 0x10, 0x05, 0x5C, 0x02, 0x00, 0x00 }); // MOVSS XMM0, dword ptr [0x140192f94] // fix ageage hair effect - VirtualProtect((BYTE*)0x14054352f, 5, PAGE_EXECUTE_READWRITE, &oldProtect); // CALL 0x140192d50 (getFrameSpeed) - *((BYTE*)0x14054352f + 0) = 0xE8; - *((BYTE*)0x14054352f + 1) = 0x1C; - *((BYTE*)0x14054352f + 2) = 0xF8; - *((BYTE*)0x14054352f + 3) = 0xC4; - *((BYTE*)0x14054352f + 4) = 0xFF; - VirtualProtect((BYTE*)0x14054352f, 5, oldProtect, &bck); - - VirtualProtect((BYTE*)0x140543534, 4, PAGE_EXECUTE_READWRITE, &oldProtect); // MULSS XMM3, XMM0 - *((BYTE*)0x140543534 + 0) = 0xF3; - *((BYTE*)0x140543534 + 1) = 0x0F; - *((BYTE*)0x140543534 + 2) = 0x59; - *((BYTE*)0x140543534 + 3) = 0xD8; - VirtualProtect((BYTE*)0x140543534, 4, oldProtect, &bck); - - VirtualProtect((BYTE*)0x140543538, 2, PAGE_EXECUTE_READWRITE, &oldProtect); // JMP 0x1405434f0 - *((BYTE*)0x140543538 + 0) = 0xEB; - *((BYTE*)0x140543538 + 1) = 0xB6; - VirtualProtect((BYTE*)0x140543538, 2, oldProtect, &bck); - + InjectCode((void*)0x14054352f, { 0xE8, 0x1C, 0xF8, 0xC4, 0xFF }); // CALL 0x140192d50 (getFrameSpeed) + InjectCode((void*)0x140543534, { 0xF3, 0x0F, 0x59, 0xD8 }); // MULSS XMM3, XMM0 + InjectCode((void*)0x140543538, { 0xEB, 0xB6 }); // JMP 0x1405434f0 // fix wind effect - VirtualProtect((BYTE*)0x14053ca71, 2, PAGE_EXECUTE_READWRITE, &oldProtect); // JMP 0x14053cab2 - *((BYTE*)0x14053ca71 + 0) = 0xEB; - *((BYTE*)0x14053ca71 + 1) = 0x3F; - VirtualProtect((BYTE*)0x14053ca71, 2, oldProtect, &bck); + InjectCode((void*)0x14053ca71, { 0xEB, 0x3F }); // JMP 0x14053cab2 + InjectCode((void*)0x14053cab2, { 0xF3, 0x0F, 0x10, 0x05, 0xFA, 0x53, 0x46, 0x00 }); // MOVSS XMM0, dword ptr [0x1409a1eb4] (60.0f) + InjectCode((void*)0x14053caba, { 0xE9, 0x42, 0xFE, 0xFF, 0xFF }); // JMP 0x14053c901 + InjectCode((void*)0x14053c901, { 0xF3, 0x0F, 0x5E, 0x05, 0xC7, 0xDD, 0x99, 0x00 }); // DIVSS XMM0, dword ptr [0x140eda6d0] (framerate) + InjectCode((void*)0x14053c909, { 0xE9, 0x68, 0x01, 0x00, 0x00 }); // JMP 0x14053ca76 - VirtualProtect((BYTE*)0x14053cab2, 8, PAGE_EXECUTE_READWRITE, &oldProtect); // MOVSS XMM0, dword ptr [0x1409a1eb4] (60.0f) - *((BYTE*)0x14053cab2 + 0) = 0xF3; - *((BYTE*)0x14053cab2 + 1) = 0x0F; - *((BYTE*)0x14053cab2 + 2) = 0x10; - *((BYTE*)0x14053cab2 + 3) = 0x05; - *((BYTE*)0x14053cab2 + 4) = 0xFA; - *((BYTE*)0x14053cab2 + 5) = 0x53; - *((BYTE*)0x14053cab2 + 6) = 0x46; - *((BYTE*)0x14053cab2 + 7) = 0x00; - VirtualProtect((BYTE*)0x14053cab2, 8, oldProtect, &bck); - - VirtualProtect((BYTE*)0x14053caba, 5, PAGE_EXECUTE_READWRITE, &oldProtect); // JMP 0x14053c901 - *((BYTE*)0x14053caba + 0) = 0xE9; - *((BYTE*)0x14053caba + 1) = 0x42; - *((BYTE*)0x14053caba + 2) = 0xFE; - *((BYTE*)0x14053caba + 3) = 0xFF; - *((BYTE*)0x14053caba + 4) = 0xFF; - VirtualProtect((BYTE*)0x14053caba, 5, oldProtect, &bck); - - VirtualProtect((BYTE*)0x14053c901, 8, PAGE_EXECUTE_READWRITE, &oldProtect); // DIVSS XMM0, dword ptr [0x140eda6d0] (framerate) - *((BYTE*)0x14053c901 + 0) = 0xF3; - *((BYTE*)0x14053c901 + 1) = 0x0F; - *((BYTE*)0x14053c901 + 2) = 0x5E; - *((BYTE*)0x14053c901 + 3) = 0x05; - *((BYTE*)0x14053c901 + 4) = 0xC7; - *((BYTE*)0x14053c901 + 5) = 0xDD; - *((BYTE*)0x14053c901 + 6) = 0x99; - *((BYTE*)0x14053c901 + 7) = 0x00; - VirtualProtect((BYTE*)0x14053c901, 8, oldProtect, &bck); - - VirtualProtect((BYTE*)0x14053c909, 5, PAGE_EXECUTE_READWRITE, &oldProtect); // JMP 0x14053ca76 - *((BYTE*)0x14053c909 + 0) = 0xE9; - *((BYTE*)0x14053c909 + 1) = 0x68; - *((BYTE*)0x14053c909 + 2) = 0x01; - *((BYTE*)0x14053c909 + 3) = 0x00; - *((BYTE*)0x14053c909 + 4) = 0x00; - VirtualProtect((BYTE*)0x14053c909, 5, oldProtect, &bck); + // fix snow effect + InjectCode((void*)0x14035ca68, { 0xF3, 0x0F, 0x5E, 0x05, 0x44, 0x54, 0x64, 0x00 }); // DIVSS XMM0, dword ptr [0x1409a1eb4] (60.0f) @@ -127,73 +63,31 @@ namespace TLAC::Components //// run motions at motionSpeedMultiplier x rate // // skip unncessary code to free code space - // VirtualProtect((BYTE*)0x140194b2b, 2, PAGE_EXECUTE_READWRITE, &oldProtect); // JMP 0x140194b51 - // *((BYTE*)0x140194b2b + 0) = 0xEB; - // *((BYTE*)0x140194b2b + 1) = 0x24; - // VirtualProtect((BYTE*)0x140194b2b, 2, oldProtect, &bck); - - - // VirtualProtect((BYTE*)0x140194b2d, 5, PAGE_EXECUTE_READWRITE, &oldProtect); // CALL 0x140192d50 - // *((BYTE*)0x140194b2d + 0) = 0xE8; - // *((BYTE*)0x140194b2d + 1) = 0x1E; - // *((BYTE*)0x140194b2d + 2) = 0xE2; - // *((BYTE*)0x140194b2d + 3) = 0xFF; - // *((BYTE*)0x140194b2d + 4) = 0xFF; - // VirtualProtect((BYTE*)0x140194b2d, 5, oldProtect, &bck); - - // VirtualProtect((BYTE*)0x140194b32, 10, PAGE_EXECUTE_READWRITE, &oldProtect); // MOV ECX, &motionSpeedMultiplier - // *((BYTE*)0x140194b32 + 0) = 0x48; - // *((BYTE*)0x140194b32 + 1) = 0xB9; - // *((BYTE*)0x140194b32 + 2) = (uint64_t)&motionSpeedMultiplier & 0xFF; - // *((BYTE*)0x140194b32 + 3) = ((uint64_t)&motionSpeedMultiplier >> 8) & 0xFF; - // *((BYTE*)0x140194b32 + 4) = ((uint64_t)&motionSpeedMultiplier >> 16) & 0xFF; - // *((BYTE*)0x140194b32 + 5) = ((uint64_t)&motionSpeedMultiplier >> 24) & 0xFF; - // *((BYTE*)0x140194b32 + 6) = ((uint64_t)&motionSpeedMultiplier >> 32) & 0xFF; - // *((BYTE*)0x140194b32 + 7) = ((uint64_t)&motionSpeedMultiplier >> 40) & 0xFF; - // *((BYTE*)0x140194b32 + 8) = ((uint64_t)&motionSpeedMultiplier >> 48) & 0xFF; - // *((BYTE*)0x140194b32 + 9) = ((uint64_t)&motionSpeedMultiplier >> 56) & 0xFF; - // VirtualProtect((BYTE*)0x140194b32, 10, oldProtect, &bck); - - // VirtualProtect((BYTE*)0x140194b3c, 5, PAGE_EXECUTE_READWRITE, &oldProtect); // MOVD XMM1, dword ptr [ECX] - // *((BYTE*)0x140194b3c + 0) = 0x66; - // *((BYTE*)0x140194b3c + 1) = 0x67; - // *((BYTE*)0x140194b3c + 2) = 0x0F; - // *((BYTE*)0x140194b3c + 3) = 0x6E; - // *((BYTE*)0x140194b3c + 4) = 0x09; - // VirtualProtect((BYTE*)0x140194b3c, 5, oldProtect, &bck); - - // VirtualProtect((BYTE*)0x140194b41, 4, PAGE_EXECUTE_READWRITE, &oldProtect); // MULSS XMM0, XMM1 - // *((BYTE*)0x140194b41 + 0) = 0xF3; - // *((BYTE*)0x140194b41 + 1) = 0x0F; - // *((BYTE*)0x140194b41 + 2) = 0x59; - // *((BYTE*)0x140194b41 + 3) = 0xC1; - // VirtualProtect((BYTE*)0x140194b41, 4, oldProtect, &bck); - - // VirtualProtect((BYTE*)0x140194b45, 2, PAGE_EXECUTE_READWRITE, &oldProtect); // JMP 0x140194ae8 - // *((BYTE*)0x140194b45 + 0) = 0xEB; - // *((BYTE*)0x140194b45 + 1) = 0xA1; - // VirtualProtect((BYTE*)0x140194b45, 2, oldProtect, &bck); + // InjectCode((void*)0x140194b2b, { 0xEB, 0x24 }); // JMP 0x140194b51 + // InjectCode((void*)0x140194b2d, { 0xE8, 0x1E, 0xE2, 0xFF, 0xFF }); // CALL 0x140192d50 + // InjectCode((void*)0x140194b32, { // MOV ECX, &motionSpeedMultiplier + // 0x48, + // 0xB9, + // (uint8_t)((uint64_t)&motionSpeedMultiplier & 0xFF), + // (uint8_t)(((uint64_t)&motionSpeedMultiplier >> 8) & 0xFF), + // (uint8_t)(((uint64_t)&motionSpeedMultiplier >> 16) & 0xFF), + // (uint8_t)(((uint64_t)&motionSpeedMultiplier >> 24) & 0xFF), + // (uint8_t)(((uint64_t)&motionSpeedMultiplier >> 32) & 0xFF), + // (uint8_t)(((uint64_t)&motionSpeedMultiplier >> 40) & 0xFF), + // (uint8_t)(((uint64_t)&motionSpeedMultiplier >> 48) & 0xFF), + // (uint8_t)(((uint64_t)&motionSpeedMultiplier >> 56) & 0xFF), + // }); + // InjectCode((void*)0x140194b3c, { 0x66, 0x67, 0x0F, 0x6E, 0x09 }); // MOVD XMM1, dword ptr [ECX] + // InjectCode((void*)0x140194b41, { 0xF3, 0x0F, 0x59, 0xC1 }); // MULSS XMM0, XMM1 + // InjectCode((void*)0x140194b45, { 0xEB, 0xA1 }); // JMP 0x140194ae8 // // jump to new code - // VirtualProtect((BYTE*)0x140194ae3, 2, PAGE_EXECUTE_READWRITE, &oldProtect); // JMP 0x140194b2d - // *((BYTE*)0x140194ae3 + 0) = 0xEB; - // *((BYTE*)0x140194ae3 + 1) = 0x48; - // VirtualProtect((BYTE*)0x140194ae3, 2, oldProtect, &bck); + // InjectCode((void*)0x140194ae3, { 0xEB, 0x48 }); // JMP 0x140194b2d //// // trying to fix physics (fail) - //// VirtualProtect((BYTE*)0x14011d537, 9, PAGE_EXECUTE_READWRITE, &oldProtect); // change source to dword ptr [0x140b0d4f0] - //// *((BYTE*)0x14011d537 + 0) = 0xF3; - //// *((BYTE*)0x14011d537 + 1) = 0x0F; - //// *((BYTE*)0x14011d537 + 2) = 0x10; - //// *((BYTE*)0x14011d537 + 3) = 0x05; - //// *((BYTE*)0x14011d537 + 4) = 0xB1; - //// *((BYTE*)0x14011d537 + 5) = 0xFF; - //// *((BYTE*)0x14011d537 + 6) = 0x9E; - //// *((BYTE*)0x14011d537 + 7) = 0x00; - //// *((BYTE*)0x14011d537 + 8) = 0x90; - //// VirtualProtect((BYTE*)0x14011d537, 9, oldProtect, &bck); + //// InjectCode((void*)0x14011d537, { 0xF3, 0x0F, 0x10, 0x05, 0xB1, 0xFF, 0x9E, 0x00, 0x90 }); // change source to dword ptr [0x140b0d4f0] } void FrameRateManager::Update() @@ -242,7 +136,7 @@ namespace TLAC::Components // target framerate *(float*)0x140eda6cc = *pvFrameRate; } - else if (*(GameState*)CURRENT_GAME_STATE_ADDRESS == GS_DATA_TEST) + else { // enable dynamic framerate *(bool*)0x140eda79c = true; @@ -250,10 +144,15 @@ namespace TLAC::Components // target framerate *(float*)0x140eda6cc = 60.0f; } - else - { - // disable dynamic framerate - *(bool*)0x140eda79c = false; - } + } + + void FrameRateManager::InjectCode(void* address, const std::vector data) + { + const size_t byteCount = data.size() * sizeof(uint8_t); + + DWORD oldProtect; + VirtualProtect(address, byteCount, PAGE_EXECUTE_READWRITE, &oldProtect); + memcpy(address, data.data(), byteCount); + VirtualProtect(address, byteCount, oldProtect, nullptr); } } diff --git a/source-code/source/plugins/TLAC/Components/FrameRateManager.h b/source-code/source/plugins/TLAC/Components/FrameRateManager.h index 54f67fc..2d46181 100644 --- a/source-code/source/plugins/TLAC/Components/FrameRateManager.h +++ b/source-code/source/plugins/TLAC/Components/FrameRateManager.h @@ -1,5 +1,6 @@ #pragma once #include "EmulatorComponent.h" +#include namespace TLAC::Components { @@ -20,5 +21,6 @@ namespace TLAC::Components float *aetFrameDuration; float defaultAetFrameDuration; float motionSpeedMultiplier = 5.0; + void InjectCode(void* address, const std::vector data); }; } From 23a391fc75690c474bdf01d2115e6c4d28793347 Mon Sep 17 00:00:00 2001 From: somewhatlurker <52014015+somewhatlurker@users.noreply.github.com> Date: Sun, 8 Sep 2019 03:59:28 +1000 Subject: [PATCH 06/11] frm: ensure correct speed in test modes, stop modifying "aetFrameDuration" because it breaks some effects (actual aet code is patched) --- .../TLAC/Components/FrameRateManager.cpp | 26 ++++++++++++------- 1 file changed, 17 insertions(+), 9 deletions(-) diff --git a/source-code/source/plugins/TLAC/Components/FrameRateManager.cpp b/source-code/source/plugins/TLAC/Components/FrameRateManager.cpp index af73e43..6b07d3e 100644 --- a/source-code/source/plugins/TLAC/Components/FrameRateManager.cpp +++ b/source-code/source/plugins/TLAC/Components/FrameRateManager.cpp @@ -39,6 +39,9 @@ namespace TLAC::Components InjectCode((void*)0x140192d7b, { 0x90, 0x90, 0x90 }); + // fix AETs + InjectCode((void*)0x140170394, { 0xF3, 0x0F, 0x5E, 0x05, 0x34, 0xA3, 0xD6, 0x00 }); // DIVSS XMM0, dword ptr [0x140eda6d0] (framerate) + // fix edit PV AETs (thanks lyb) InjectCode((void*)0x140192d30, { 0xF3, 0x0F, 0x10, 0x05, 0x5C, 0x02, 0x00, 0x00 }); // MOVSS XMM0, dword ptr [0x140192f94] @@ -53,10 +56,6 @@ namespace TLAC::Components InjectCode((void*)0x14053caba, { 0xE9, 0x42, 0xFE, 0xFF, 0xFF }); // JMP 0x14053c901 InjectCode((void*)0x14053c901, { 0xF3, 0x0F, 0x5E, 0x05, 0xC7, 0xDD, 0x99, 0x00 }); // DIVSS XMM0, dword ptr [0x140eda6d0] (framerate) InjectCode((void*)0x14053c909, { 0xE9, 0x68, 0x01, 0x00, 0x00 }); // JMP 0x14053ca76 - - // fix snow effect - InjectCode((void*)0x14035ca68, { 0xF3, 0x0F, 0x5E, 0x05, 0x44, 0x54, 0x64, 0x00 }); // DIVSS XMM0, dword ptr [0x1409a1eb4] (60.0f) - // below are patches for the alternate method (breaks physics) @@ -120,13 +119,17 @@ namespace TLAC::Components - // this way breaks some anim speeds, but they're fixable + // *aetFrameDuration = 1.0f / GetGameFrameRate(); - *pvFrameRate = 60.0f * motionSpeedMultiplier; - - - *aetFrameDuration = 1.0f / GetGameFrameRate(); + if (*(GameState*)CURRENT_GAME_STATE_ADDRESS == GS_GAME) + { + *pvFrameRate = 60.0f * motionSpeedMultiplier; + } + else + { + *pvFrameRate = 60.0f; + } if (*(SubGameState*)CURRENT_GAME_SUB_STATE_ADDRESS == SUB_GAME_MAIN || *(SubGameState*)CURRENT_GAME_SUB_STATE_ADDRESS == SUB_DEMO) { @@ -135,6 +138,11 @@ namespace TLAC::Components // target framerate *(float*)0x140eda6cc = *pvFrameRate; + + // trying to fix meltdown's water + //if ((uint64_t*)0x1411943f8 != nullptr) + //*(float*)(*(uint64_t*)0x1411943f8 + 0x1c) = (60.0f / GetGameFrameRate()) / 15.0f; + //*(float*)(*(uint64_t*)0x1411943f8 + 0x10) = *(float*)(*(uint64_t*)0x1411943f8); } else { From 2239228bb09e0a33e28c750e29958012e49132e0 Mon Sep 17 00:00:00 2001 From: somewhatlurker <52014015+somewhatlurker@users.noreply.github.com> Date: Wed, 11 Sep 2019 10:28:07 +1000 Subject: [PATCH 07/11] add frm motion rate option and fix esm options --- source-code/data/plugins/config.ini | 2 ++ source-code/source/plugins/Launcher/framework.h | 6 ++++-- .../source/plugins/TLAC/Components/FrameRateManager.cpp | 5 +++++ 3 files changed, 11 insertions(+), 2 deletions(-) diff --git a/source-code/data/plugins/config.ini b/source-code/data/plugins/config.ini index cda8351..0b816d3 100644 --- a/source-code/data/plugins/config.ini +++ b/source-code/data/plugins/config.ini @@ -55,6 +55,8 @@ FPS.Limit.Verbose=0 TAA=1 # Morphological Anti-Aliasing MLAA=1 +# FrameRateManager motion rate (multiplier percentage) +FRM.Motion.Rate=500 [Resolution] # 0 = Windowed, 1 = Borderless (Forced to desktop resolution), 2 = Fullscreen diff --git a/source-code/source/plugins/Launcher/framework.h b/source-code/source/plugins/Launcher/framework.h index adfdd7b..9af26cc 100644 --- a/source-code/source/plugins/Launcher/framework.h +++ b/source-code/source/plugins/Launcher/framework.h @@ -162,8 +162,8 @@ ConfigOptionBase* optionsArray[] = { new BooleanOption(L"no_error", PATCHES_SECTION, CONFIG_FILE, L"Disable Error Banner", L"Disable the error banner on the attract screen.", true, false), new BooleanOption(L"hardware_slider", PATCHES_SECTION, CONFIG_FILE, L"Use Hardware Slider", L"Enable this if using a real arcade slider.\n(set the slider to port COM11)", false, false), - new NumericOption(L"Enhanced_Stage_Manager", GRAPHICS_SECTION, CONFIG_FILE, L"Number of stages:", L"Set the number of stages (0 = default).", 0, 0, INT_MAX), - new BooleanOption(L"Enhanced_Stage_Manager_Encore", PATCHES_SECTION, CONFIG_FILE, L"Encore", L"Enable encore stages.", true, false), + new NumericOption(L"Enhanced_Stage_Manager", PATCHES_SECTION, CONFIG_FILE, L"Number of stages:", L"Set the number of stages (0 = default).", 0, 0, INT_MAX), + new BooleanOption(L"Enhanced_Stage_Manager_Encore", PATCHES_SECTION, CONFIG_FILE, L"Encore Stages", L"Enable encore stages.", true, false), new BooleanOption(L"skip", LAUNCHER_SECTION, CONFIG_FILE, L"Skip Launcher", L"Forces the launcher to be skipped, you can also use the --launch parameter instead of this.", false, false), @@ -172,6 +172,8 @@ ConfigOptionBase* optionsArray[] = { new NumericOption(L"FPS.Limit", GRAPHICS_SECTION, CONFIG_FILE, L"FPS Limit:", L"Allows you to set a frame rate cap. Set to -1 to unlock the frame rate.", 60, -1, INT_MAX), new BooleanOption(L"FPS.Limit.LightMode", GRAPHICS_SECTION, CONFIG_FILE, L"Use Lightweight Limiter", L"Makes the FPS limiter use less CPU.\nMay have less consistent performance.", true, false), + new NumericOption(L"frm.motion.rate", GRAPHICS_SECTION, CONFIG_FILE, L"FRM Motion Rate:", L"Sets the motion rate (multiplier percentage) for the FrameRateManager component.\nLarger=smoother, but more CPU intensive.", 500, 1, INT_MAX), + new StringOption(L"command_line", LAUNCHER_SECTION, CONFIG_FILE, L"Command Line:", L"Allows setting command line parameters for the game when using the launcher.\nDisabling the launcher will bypass this.", L"", false), }; diff --git a/source-code/source/plugins/TLAC/Components/FrameRateManager.cpp b/source-code/source/plugins/TLAC/Components/FrameRateManager.cpp index 6b07d3e..b760948 100644 --- a/source-code/source/plugins/TLAC/Components/FrameRateManager.cpp +++ b/source-code/source/plugins/TLAC/Components/FrameRateManager.cpp @@ -5,11 +5,16 @@ #include #include "../framework.h" #include +#include namespace TLAC::Components { FrameRateManager::FrameRateManager() { + std::wstring_convert> converter; + std::wstring configPath = converter.from_bytes((TLAC::framework::GetModuleDirectory() + "/config.ini").c_str()); + float nMotionRate = GetPrivateProfileIntW(L"graphics", L"frm.motion.rate", 500, configPath.c_str()); + motionSpeedMultiplier = nMotionRate / 100.0f; } FrameRateManager::~FrameRateManager() From a28a6bece3482ed23ea3196f1a8b1f1271d46dc0 Mon Sep 17 00:00:00 2001 From: somewhatlurker <52014015+somewhatlurker@users.noreply.github.com> Date: Wed, 11 Sep 2019 10:49:42 +1000 Subject: [PATCH 08/11] launcher: rearrange and add spacers to options section --- .../source/plugins/Launcher/framework.h | 39 ++++++++++--------- 1 file changed, 21 insertions(+), 18 deletions(-) diff --git a/source-code/source/plugins/Launcher/framework.h b/source-code/source/plugins/Launcher/framework.h index 9af26cc..5c5a15d 100644 --- a/source-code/source/plugins/Launcher/framework.h +++ b/source-code/source/plugins/Launcher/framework.h @@ -145,34 +145,37 @@ ConfigOptionBase* internalResolutionArray[] = { }; ConfigOptionBase* optionsArray[] = { - new BooleanOption(L"cursor", PATCHES_SECTION, CONFIG_FILE, L"Cursor", L"Enable or disable the mouse cursor.", true, false), - - new BooleanOption(L"TAA", GRAPHICS_SECTION, CONFIG_FILE, L"TAA", L"Temporal Anti-Aliasing", true, false), - new BooleanOption(L"MLAA", GRAPHICS_SECTION, CONFIG_FILE, L"MLAA", L"Morphological Anti-Aliasing", true, false), - new BooleanOption(L"hide_freeplay", PATCHES_SECTION, CONFIG_FILE, L"Hide \"FREE PLAY\"/\"CREDIT(S)\"", L"Hide the \"FREE PLAY\"/\"CREDIT(S)\" text.", false, false), new BooleanOption(L"freeplay", PATCHES_SECTION, CONFIG_FILE, L"FREE PLAY", L"Show \"FREE PLAY\" instead of \"CREDIT(S)\".", true, false), new BooleanOption(L"pdloadertext", PATCHES_SECTION, CONFIG_FILE, L"PD Loader FREE PLAY", L"Show the version of PD Loader instead of \"FREE PLAY\".", true, false), - new BooleanOption(L"hide_volume", PATCHES_SECTION, CONFIG_FILE, L"Hide Volume Buttons", L"Hide the volume and SE control buttons.", false, false), + new OptionMetaSpacer(8), + new BooleanOption(L"no_movies", PATCHES_SECTION, CONFIG_FILE, L"Disable Movies", L"Disable movies (enable this if the game hangs when loading certain PVs).", false, false), new BooleanOption(L"mp4_movies", PATCHES_SECTION, CONFIG_FILE, L"Custom MP4 Adv Movies", L"Enable MP4 (instead of WMV) advertise/attract movies.", false, false), + new OptionMetaSpacer(8), + + new BooleanOption(L"cursor", PATCHES_SECTION, CONFIG_FILE, L"Cursor", L"Enable or disable the mouse cursor.", true, false), + new BooleanOption(L"hide_volume", PATCHES_SECTION, CONFIG_FILE, L"Hide Volume Buttons", L"Hide the volume and SE control buttons.", false, false), new BooleanOption(L"no_pv_ui", PATCHES_SECTION, CONFIG_FILE, L"Disable PV UI", L"Remove the photo controls during PV playback.", false, false), - new BooleanOption(L"no_lyrics", PATCHES_SECTION, CONFIG_FILE, L"Disable Lyrics", L"Disable showing lyrics.", false, false), new BooleanOption(L"hide_pv_watermark", PATCHES_SECTION, CONFIG_FILE, L"Hide PV Watermark", L"Hide the watermark that's usually shown in PV viewing mode.", false, false), + new BooleanOption(L"no_lyrics", PATCHES_SECTION, CONFIG_FILE, L"Disable Lyrics", L"Disable showing lyrics.", false, false), new BooleanOption(L"no_error", PATCHES_SECTION, CONFIG_FILE, L"Disable Error Banner", L"Disable the error banner on the attract screen.", true, false), - new BooleanOption(L"hardware_slider", PATCHES_SECTION, CONFIG_FILE, L"Use Hardware Slider", L"Enable this if using a real arcade slider.\n(set the slider to port COM11)", false, false), - - new NumericOption(L"Enhanced_Stage_Manager", PATCHES_SECTION, CONFIG_FILE, L"Number of stages:", L"Set the number of stages (0 = default).", 0, 0, INT_MAX), - new BooleanOption(L"Enhanced_Stage_Manager_Encore", PATCHES_SECTION, CONFIG_FILE, L"Encore Stages", L"Enable encore stages.", true, false), - - new BooleanOption(L"skip", LAUNCHER_SECTION, CONFIG_FILE, L"Skip Launcher", L"Forces the launcher to be skipped, you can also use the --launch parameter instead of this.", false, false), - new DropdownOption(L"status_icons", PATCHES_SECTION, CONFIG_FILE, L"Status Icons:", L"Set the state of card reader and network status icons.", 3, std::vector({ L"Default", L"Hidden", L"Error", L"OK", L"Partial OK" })), - - new NumericOption(L"FPS.Limit", GRAPHICS_SECTION, CONFIG_FILE, L"FPS Limit:", L"Allows you to set a frame rate cap. Set to -1 to unlock the frame rate.", 60, -1, INT_MAX), - new BooleanOption(L"FPS.Limit.LightMode", GRAPHICS_SECTION, CONFIG_FILE, L"Use Lightweight Limiter", L"Makes the FPS limiter use less CPU.\nMay have less consistent performance.", true, false), + new OptionMetaSpacer(8), - new NumericOption(L"frm.motion.rate", GRAPHICS_SECTION, CONFIG_FILE, L"FRM Motion Rate:", L"Sets the motion rate (multiplier percentage) for the FrameRateManager component.\nLarger=smoother, but more CPU intensive.", 500, 1, INT_MAX), + new BooleanOption(L"Enhanced_Stage_Manager_Encore", PATCHES_SECTION, CONFIG_FILE, L"Encore Stages", L"Enable encore stages.", true, false), + new NumericOption(L"Enhanced_Stage_Manager", PATCHES_SECTION, CONFIG_FILE, L"Number of stages:", L"Set the number of stages (0 = default).", 0, 0, INT_MAX), + new OptionMetaSpacer(8), + + new BooleanOption(L"hardware_slider", PATCHES_SECTION, CONFIG_FILE, L"Use Hardware Slider", L"Enable this if using a real arcade slider.\n(set the slider to port COM11)", false, false), + new OptionMetaSpacer(8), + + new BooleanOption(L"TAA", GRAPHICS_SECTION, CONFIG_FILE, L"TAA", L"Temporal Anti-Aliasing", true, false), + new BooleanOption(L"MLAA", GRAPHICS_SECTION, CONFIG_FILE, L"MLAA", L"Morphological Anti-Aliasing", true, false), + new BooleanOption(L"FPS.Limit.LightMode", GRAPHICS_SECTION, CONFIG_FILE, L"Use Lightweight Limiter", L"Makes the FPS limiter use less CPU.\nMay have less consistent performance.", true, false), + new NumericOption(L"FPS.Limit", GRAPHICS_SECTION, CONFIG_FILE, L"FPS Limit:", L"Allows you to set a frame rate cap. Set to -1 to unlock the frame rate.", 60, -1, INT_MAX), + new NumericOption(L"frm.motion.rate", GRAPHICS_SECTION, CONFIG_FILE, L"FRM Motion Rate:", L"Sets the motion rate (multiplier percentage) for the Frame Rate Manager component.\nLarger=smoother, but more CPU intensive.", 500, 1, INT_MAX), + new OptionMetaSpacer(8), new StringOption(L"command_line", LAUNCHER_SECTION, CONFIG_FILE, L"Command Line:", L"Allows setting command line parameters for the game when using the launcher.\nDisabling the launcher will bypass this.", L"", false), }; From d266dd0542d59c55a43b7b792a654b8fb7040adf Mon Sep 17 00:00:00 2001 From: somewhatlurker <52014015+somewhatlurker@users.noreply.github.com> Date: Wed, 11 Sep 2019 11:01:14 +1000 Subject: [PATCH 09/11] make USE_AUTO_FRAMESPEED_ADDRESS and AUTO_FRAMESPEED_TARGET_FRAMERATE_ADDRESS constants --- .../plugins/TLAC/Components/FrameRateManager.cpp | 12 ++++++------ source-code/source/plugins/TLAC/Constants.h | 2 ++ 2 files changed, 8 insertions(+), 6 deletions(-) diff --git a/source-code/source/plugins/TLAC/Components/FrameRateManager.cpp b/source-code/source/plugins/TLAC/Components/FrameRateManager.cpp index b760948..4359584 100644 --- a/source-code/source/plugins/TLAC/Components/FrameRateManager.cpp +++ b/source-code/source/plugins/TLAC/Components/FrameRateManager.cpp @@ -99,10 +99,10 @@ namespace TLAC::Components // this alterante way makes physics slowmo, but overall may be better if that's fixed //// target framerate - //*(float*)0x140eda6cc = 60.0f; + //*(float*)AUTO_FRAMESPEED_TARGET_FRAMERATE_ADDRESS = 60.0f; //// enable dynamic framerate - //*(bool*)0x140eda79c = true; + //*(bool*)USE_AUTO_FRAMESPEED_ADDRESS = true; //*pvFrameRate = 60.0f; @@ -139,10 +139,10 @@ namespace TLAC::Components if (*(SubGameState*)CURRENT_GAME_SUB_STATE_ADDRESS == SUB_GAME_MAIN || *(SubGameState*)CURRENT_GAME_SUB_STATE_ADDRESS == SUB_DEMO) { // enable dynamic framerate - *(bool*)0x140eda79c = true; + *(bool*)USE_AUTO_FRAMESPEED_ADDRESS = true; // target framerate - *(float*)0x140eda6cc = *pvFrameRate; + *(float*)AUTO_FRAMESPEED_TARGET_FRAMERATE_ADDRESS = *pvFrameRate; // trying to fix meltdown's water //if ((uint64_t*)0x1411943f8 != nullptr) @@ -152,10 +152,10 @@ namespace TLAC::Components else { // enable dynamic framerate - *(bool*)0x140eda79c = true; + *(bool*)USE_AUTO_FRAMESPEED_ADDRESS = true; // target framerate - *(float*)0x140eda6cc = 60.0f; + *(float*)AUTO_FRAMESPEED_TARGET_FRAMERATE_ADDRESS = 60.0f; } } diff --git a/source-code/source/plugins/TLAC/Constants.h b/source-code/source/plugins/TLAC/Constants.h index fc8c7ff..4fdaf06 100644 --- a/source-code/source/plugins/TLAC/Constants.h +++ b/source-code/source/plugins/TLAC/Constants.h @@ -21,6 +21,8 @@ constexpr uint64_t AET_FRAME_DURATION_ADDRESS = 0x00000001409A0A58; constexpr uint64_t PV_FRAME_RATE_ADDRESS = 0x0000000140EDA7CC; constexpr uint64_t FRAME_SPEED_ADDRESS = 0x0000000140EDA798; constexpr uint64_t FRAME_RATE_ADDRESS = 0x0000000140EDA6D0; +constexpr uint64_t USE_AUTO_FRAMESPEED_ADDRESS = 0x0000000140EDA79C; +constexpr uint64_t AUTO_FRAMESPEED_TARGET_FRAMERATE_ADDRESS = 0x0000000140EDA6CC; constexpr uint64_t DW_GUI_DISPLAY_INSTANCE_PTR_ADDRESS = 0x0000000141190108; constexpr uint64_t INPUT_STATE_PTR_ADDRESS = 0x0000000140EDA330; From 3223d80666501acbae67b87b56cbd5d1263cfbda Mon Sep 17 00:00:00 2001 From: somewhatlurker <52014015+somewhatlurker@users.noreply.github.com> Date: Wed, 11 Sep 2019 13:01:46 +1000 Subject: [PATCH 10/11] fix frame speed slider initial value (should ignore effect of auto speed) --- .../source/plugins/TLAC/Components/FrameRateManager.cpp | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/source-code/source/plugins/TLAC/Components/FrameRateManager.cpp b/source-code/source/plugins/TLAC/Components/FrameRateManager.cpp index 4359584..fef8f1b 100644 --- a/source-code/source/plugins/TLAC/Components/FrameRateManager.cpp +++ b/source-code/source/plugins/TLAC/Components/FrameRateManager.cpp @@ -43,6 +43,14 @@ namespace TLAC::Components // fix auto speed for high fps InjectCode((void*)0x140192d7b, { 0x90, 0x90, 0x90 }); + // fix frame speed slider initial value (should ignore effect of auto speed) + InjectCode((void*)0x140338f2f, { 0xf3, 0x0f, 0x10, 0x0d, 0x61, 0x18, 0xba, 0x00 }); // MOVSS XMM1, dword ptr [0x140eda798] (raw framespeed) + InjectCode((void*)0x140338f37, { 0x48, 0x8b, 0x8f, 0x80, 0x01, 0x00, 0x00 }); // MOV RCX, qword ptr [0x180 + RDI] + + InjectCode((void*)0x140338ebe, { 0xf3, 0x0f, 0x10, 0x0d, 0xd2, 0x18, 0xba, 0x00 }); // MOVSS XMM1, dword ptr [0x140eda798] (raw framespeed) + InjectCode((void*)0x140338ec6, { 0x48, 0x8b, 0x05, 0xfb, 0xb1, 0xe5, 0x00 }); // MOV RAX, qword ptr [0x1411940c8] + InjectCode((void*)0x140338ecd, { 0x48, 0x8b, 0x88, 0x80, 0x01, 0x00, 0x00 }); // MOV RCX, qword ptr [0x180 + RAX] + // fix AETs InjectCode((void*)0x140170394, { 0xF3, 0x0F, 0x5E, 0x05, 0x34, 0xA3, 0xD6, 0x00 }); // DIVSS XMM0, dword ptr [0x140eda6d0] (framerate) From 4025d8b821231fbd46b7432556448fbd052577ea Mon Sep 17 00:00:00 2001 From: somewhatlurker <52014015+somewhatlurker@users.noreply.github.com> Date: Sat, 14 Sep 2019 14:42:19 +1000 Subject: [PATCH 11/11] frm: use fps for motion rate --- source-code/data/plugins/config.ini | 4 ++-- source-code/source/plugins/Launcher/framework.h | 2 +- .../source/plugins/TLAC/Components/FrameRateManager.cpp | 4 ++-- 3 files changed, 5 insertions(+), 5 deletions(-) diff --git a/source-code/data/plugins/config.ini b/source-code/data/plugins/config.ini index 0b816d3..93925c1 100644 --- a/source-code/data/plugins/config.ini +++ b/source-code/data/plugins/config.ini @@ -55,8 +55,8 @@ FPS.Limit.Verbose=0 TAA=1 # Morphological Anti-Aliasing MLAA=1 -# FrameRateManager motion rate (multiplier percentage) -FRM.Motion.Rate=500 +# FrameRateManager motion rate (fps) +FRM.Motion.Rate=300 [Resolution] # 0 = Windowed, 1 = Borderless (Forced to desktop resolution), 2 = Fullscreen diff --git a/source-code/source/plugins/Launcher/framework.h b/source-code/source/plugins/Launcher/framework.h index 5c5a15d..c23adaa 100644 --- a/source-code/source/plugins/Launcher/framework.h +++ b/source-code/source/plugins/Launcher/framework.h @@ -174,7 +174,7 @@ ConfigOptionBase* optionsArray[] = { new BooleanOption(L"MLAA", GRAPHICS_SECTION, CONFIG_FILE, L"MLAA", L"Morphological Anti-Aliasing", true, false), new BooleanOption(L"FPS.Limit.LightMode", GRAPHICS_SECTION, CONFIG_FILE, L"Use Lightweight Limiter", L"Makes the FPS limiter use less CPU.\nMay have less consistent performance.", true, false), new NumericOption(L"FPS.Limit", GRAPHICS_SECTION, CONFIG_FILE, L"FPS Limit:", L"Allows you to set a frame rate cap. Set to -1 to unlock the frame rate.", 60, -1, INT_MAX), - new NumericOption(L"frm.motion.rate", GRAPHICS_SECTION, CONFIG_FILE, L"FRM Motion Rate:", L"Sets the motion rate (multiplier percentage) for the Frame Rate Manager component.\nLarger=smoother, but more CPU intensive.", 500, 1, INT_MAX), + new NumericOption(L"frm.motion.rate", GRAPHICS_SECTION, CONFIG_FILE, L"FRM Motion Rate:", L"Sets the motion rate (fps) for the Frame Rate Manager component.\nLarger values should be smoother, but more CPU intensive and possibly buggier.", 300, 1, INT_MAX), new OptionMetaSpacer(8), new StringOption(L"command_line", LAUNCHER_SECTION, CONFIG_FILE, L"Command Line:", L"Allows setting command line parameters for the game when using the launcher.\nDisabling the launcher will bypass this.", L"", false), diff --git a/source-code/source/plugins/TLAC/Components/FrameRateManager.cpp b/source-code/source/plugins/TLAC/Components/FrameRateManager.cpp index fef8f1b..174dede 100644 --- a/source-code/source/plugins/TLAC/Components/FrameRateManager.cpp +++ b/source-code/source/plugins/TLAC/Components/FrameRateManager.cpp @@ -13,8 +13,8 @@ namespace TLAC::Components { std::wstring_convert> converter; std::wstring configPath = converter.from_bytes((TLAC::framework::GetModuleDirectory() + "/config.ini").c_str()); - float nMotionRate = GetPrivateProfileIntW(L"graphics", L"frm.motion.rate", 500, configPath.c_str()); - motionSpeedMultiplier = nMotionRate / 100.0f; + float nMotionRate = GetPrivateProfileIntW(L"graphics", L"frm.motion.rate", 300, configPath.c_str()); + motionSpeedMultiplier = nMotionRate / 60.0f; } FrameRateManager::~FrameRateManager()