diff options
Diffstat (limited to 'src/core')
| -rw-r--r-- | src/core/arm/dynarmic/arm_dynarmic.cpp | 2 | ||||
| -rw-r--r-- | src/core/core_timing_util.cpp | 8 | ||||
| -rw-r--r-- | src/core/core_timing_util.h | 2 |
3 files changed, 6 insertions, 6 deletions
diff --git a/src/core/arm/dynarmic/arm_dynarmic.cpp b/src/core/arm/dynarmic/arm_dynarmic.cpp index d36538257..25f76259b 100644 --- a/src/core/arm/dynarmic/arm_dynarmic.cpp +++ b/src/core/arm/dynarmic/arm_dynarmic.cpp | |||
| @@ -120,7 +120,7 @@ public: | |||
| 120 | return std::max(parent.core_timing.GetDowncount(), 0); | 120 | return std::max(parent.core_timing.GetDowncount(), 0); |
| 121 | } | 121 | } |
| 122 | u64 GetCNTPCT() override { | 122 | u64 GetCNTPCT() override { |
| 123 | return CpuCyclesToClockCycles(parent.core_timing.GetTicks()); | 123 | return Timing::CpuCyclesToClockCycles(parent.core_timing.GetTicks()); |
| 124 | } | 124 | } |
| 125 | 125 | ||
| 126 | ARM_Dynarmic& parent; | 126 | ARM_Dynarmic& parent; |
diff --git a/src/core/core_timing_util.cpp b/src/core/core_timing_util.cpp index 8fc92560a..aab4aa697 100644 --- a/src/core/core_timing_util.cpp +++ b/src/core/core_timing_util.cpp | |||
| @@ -7,6 +7,7 @@ | |||
| 7 | #include <cinttypes> | 7 | #include <cinttypes> |
| 8 | #include <limits> | 8 | #include <limits> |
| 9 | #include "common/logging/log.h" | 9 | #include "common/logging/log.h" |
| 10 | #include "common/uint128.h" | ||
| 10 | 11 | ||
| 11 | namespace Core::Timing { | 12 | namespace Core::Timing { |
| 12 | 13 | ||
| @@ -61,10 +62,9 @@ s64 nsToCycles(u64 ns) { | |||
| 61 | } | 62 | } |
| 62 | 63 | ||
| 63 | u64 CpuCyclesToClockCycles(u64 ticks) { | 64 | u64 CpuCyclesToClockCycles(u64 ticks) { |
| 64 | u64 result = ticks; | 65 | u128 temporal = Common::Multiply64Into128(ticks, CNTFREQ); |
| 65 | result *= CNTFREQ; | 66 | std::pair<u64, u64> result = Common::Divide128On64(temporal, BASE_CLOCK_RATE); |
| 66 | result /= BASE_CLOCK_RATE; | 67 | return result.first; |
| 67 | return static_cast<u64>(result); | ||
| 68 | } | 68 | } |
| 69 | 69 | ||
| 70 | } // namespace Core::Timing | 70 | } // namespace Core::Timing |
diff --git a/src/core/core_timing_util.h b/src/core/core_timing_util.h index 545d3a260..679aa3123 100644 --- a/src/core/core_timing_util.h +++ b/src/core/core_timing_util.h | |||
| @@ -11,7 +11,7 @@ namespace Core::Timing { | |||
| 11 | // The below clock rate is based on Switch's clockspeed being widely known as 1.020GHz | 11 | // The below clock rate is based on Switch's clockspeed being widely known as 1.020GHz |
| 12 | // The exact value used is of course unverified. | 12 | // The exact value used is of course unverified. |
| 13 | constexpr u64 BASE_CLOCK_RATE = 1019215872; // Switch clock speed is 1020MHz un/docked | 13 | constexpr u64 BASE_CLOCK_RATE = 1019215872; // Switch clock speed is 1020MHz un/docked |
| 14 | constexpr u64 CNTFREQ = 19200000; // Value from fusee. | 14 | constexpr u64 CNTFREQ = 19200000; // Value from fusee. |
| 15 | 15 | ||
| 16 | inline s64 msToCycles(int ms) { | 16 | inline s64 msToCycles(int ms) { |
| 17 | // since ms is int there is no way to overflow | 17 | // since ms is int there is no way to overflow |