From 1f399e37afeb0423c2593c8cd64455c160e38f74 Mon Sep 17 00:00:00 2001 From: Alex Date: Sat, 24 Dec 2022 05:51:01 +0200 Subject: [PATCH] Wrong value for HPET --- Core/Timer.cpp | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) diff --git a/Core/Timer.cpp b/Core/Timer.cpp index b74ab0a..3c46bff 100644 --- a/Core/Timer.cpp +++ b/Core/Timer.cpp @@ -15,9 +15,18 @@ namespace Time void time::Sleep(uint64_t Milliseconds) { #if defined(__amd64__) || defined(__i386__) - uintptr_t Target = mminq(&((HPET *)hpet)->MainCounterValue) + (Milliseconds * 1000000000) / clk; + uintptr_t Target = mminq(&((HPET *)hpet)->MainCounterValue) + (Milliseconds * 1000000000000) / clk; +#ifdef DEBUG + uint64_t Counter = mminq(&((HPET *)hpet)->MainCounterValue); + while (Counter < Target) + { + Counter = mminq(&((HPET *)hpet)->MainCounterValue); + CPU::Pause(); + } +#else while (mminq(&((HPET *)hpet)->MainCounterValue) < Target) CPU::Pause(); +#endif #elif defined(__aarch64__) #endif }