add High Resolution Timer switch

add WARN for experimental function
This commit is contained in:
ptmaster
2024-12-08 22:32:02 +08:00
parent cb0d4692ff
commit 703982937d
6 changed files with 23 additions and 19 deletions
+1 -3
View File
@@ -135,6 +135,4 @@ cmake -B build -S . -G "Visual Studio 17 2022" -A x64 -DCMAKE_BUILD_TYPE=Release
cmake --build build --config Release --target bnusio
```
The compiled dll of TaikoArcadeLoader will be written in the `dist` folder.
(experimental) To enable `async update` / `async io`, you can add `-DASYNC_UPDATE` or `-DASYNC_IO` into add_definitions in CMakeLists.txt
The compiled dll of TaikoArcadeLoader will be written in the `dist` folder.
+1 -1
View File
@@ -15,7 +15,7 @@ version = "auto" # Patch version
# | - JPN39: For use with Taiko JPN 39.06
# | - CHN00: For use with Taiko CHN 00.32
unlock_songs = true
high_res_timer = true # (experimental) Enable High Resolution Timer, which might improve judgement timing
[patches.chn00] # These patches are only available for version CHN00
fix_language = false # Sync test mode language to attract etc
+1 -1
View File
@@ -248,7 +248,7 @@ std::condition_variable syncCV;
void
UpdateLoop () {
LogMessage (LogLevel::WARN, "Using Async Update (experimental)!");
LogMessage (LogLevel::WARN, "(experimental) Using Async Update!");
std::unique_lock<std::mutex> syncLock(syncMtx);
while (exited < 120) {
syncCV.wait (syncLock);
+9 -3
View File
@@ -22,6 +22,7 @@ char accessCode1[21] = "00000000000000000001";
char accessCode2[21] = "00000000000000000002";
char chipId1[33] = "00000000000000000000000000000001";
char chipId2[33] = "00000000000000000000000000000002";
bool highResTimer = true;
bool windowed = false;
bool autoIme = false;
bool jpLayout = false;
@@ -150,7 +151,7 @@ DllMain (HMODULE module, const DWORD reason, LPVOID reserved) {
LogMessage (LogLevel::INFO, "Loading config...");
#ifdef ASYNC_IO
LogMessage (LogLevel::WARN, "Using Async IO (experimental)!");
LogMessage (LogLevel::WARN, "(experimental) Using Async IO!");
InitializeKeyboard ();
#endif
@@ -176,7 +177,10 @@ DllMain (HMODULE module, const DWORD reason, LPVOID reserved) {
std::strcat (placeId, countryCode.c_str ());
std::strcat (placeId, "0FF0");
}
if (const auto patches = openConfigSection (config, "patches")) version = readConfigString (patches, "version", version);
if (const auto patches = openConfigSection (config, "patches")) {
version = readConfigString (patches, "version", version);
highResTimer = readConfigBool (patches, "high_res_timer", highResTimer);
}
if (const auto emulation = openConfigSection (config, "emulation")) {
emulateUsio = readConfigBool (emulation, "usio", emulateUsio);
emulateCardReader = readConfigBool (emulation, "card_reader", emulateCardReader);
@@ -266,7 +270,9 @@ DllMain (HMODULE module, const DWORD reason, LPVOID reserved) {
patches::LayeredFs::Init ();
patches::TestMode::Init ();
patches::Timer::Init ();
if (highResTimer) {
patches::Timer::Init ();
}
LogMessage (LogLevel::INFO, "==== Finished Loading patches!");
}
+4 -4
View File
@@ -29,17 +29,17 @@ namespace patches::Timer {
NTSTATUS queryStatus = NtQueryTimerResolution(&currentResolution, &minimumResolution, &maximumResolution);
if (queryStatus == 0) {
bool setHighResolutionTimer = currentResolution > maximumResolution;
LogMessage (LogLevel::INFO, "Timer Resolution current: {}ms maximum: {}ms", currentResolution / 10000.0, maximumResolution / 10000.0);
LogMessage (LogLevel::WARN, "(experimental) Timer Resolution current: {}ms maximum: {}ms", currentResolution / 10000.0, maximumResolution / 10000.0);
if (setHighResolutionTimer) {
NTSTATUS status = NtSetTimerResolution(maximumResolution, TRUE, &currentResolution);
if (status == 0) {
LogMessage (LogLevel::INFO, "Successfully change Timer resolution to {}ms", maximumResolution / 10000.0);
LogMessage (LogLevel::WARN, "(experimental) Successfully change Timer resolution to {}ms", maximumResolution / 10000.0);
} else {
LogMessage (LogLevel::ERROR, "Failed to change Timer resolution, status={}", status);
LogMessage (LogLevel::ERROR, "(experimental) Failed to change Timer resolution, status={}", status);
}
atexit (Release);
}
} else LogMessage (LogLevel::ERROR, "Failed to query Timer resolution, status={}", queryStatus);
} else LogMessage (LogLevel::ERROR, "(experimental) Failed to query Timer resolution, status={}", queryStatus);
}
}
+7 -7
View File
@@ -450,12 +450,12 @@ HOOK (u64, EnsoGameManagerChechEnsoEnd, ASLR (0x1400E2A10), u64 a1, u64 a2, u64
return result;
}
HOOK (DWORD*, AcquireMostCompatibleDisplayMode, ASLR (0x14064C870), i64 a1, DWORD *a2, DWORD *a3) {
LogMessage (LogLevel::DEBUG, "AcquireMostCompatibleDisplayMode {:d} {:d} {:f} {:f}", a3[0], a3[1], (float)(int)a3[2], (float)(int)a3[3]);
a3[2] = (DWORD)(int)120.0f;
LogMessage (LogLevel::DEBUG, "AcquireMostCompatibleDisplayMode {:d} {:d} {:f} {:f}", a3[0], a3[1], (float)(int)a3[2], (float)(int)a3[3]);
return originalAcquireMostCompatibleDisplayMode (a1, a2, a3);
}
// HOOK (DWORD*, AcquireMostCompatibleDisplayMode, ASLR (0x14064C870), i64 a1, DWORD *a2, DWORD *a3) {
// LogMessage (LogLevel::DEBUG, "AcquireMostCompatibleDisplayMode {:d} {:d} {:f} {:f}", a3[0], a3[1], (float)(int)a3[2], (float)(int)a3[3]);
// a3[2] = (DWORD)(int)120.0f;
// LogMessage (LogLevel::DEBUG, "AcquireMostCompatibleDisplayMode {:d} {:d} {:f} {:f}", a3[0], a3[1], (float)(int)a3[2], (float)(int)a3[3]);
// return originalAcquireMostCompatibleDisplayMode (a1, a2, a3);
// }
HOOK (char, SceneTestModeLoading, ASLR (0x1404793D0), u64 a1, u64 a2, u64 a3) {
LogMessage (LogLevel::DEBUG, "Begin SceneTestModeLoading");
@@ -534,7 +534,7 @@ Init () {
INSTALL_HOOK (EnsoGraphicManagerPreparing);
INSTALL_HOOK (EnsoGameManagerStart);
INSTALL_HOOK (EnsoGameManagerChechEnsoEnd);
INSTALL_HOOK (AcquireMostCompatibleDisplayMode);
// INSTALL_HOOK (AcquireMostCompatibleDisplayMode);
INSTALL_HOOK (SceneTestModeLoading);
// Apply common config patch