Use u128 on Clock Cycles calculation.
This commit is contained in:
parent
3ea48e8ebe
commit
ecccfe0337
5 changed files with 32 additions and 27 deletions
|
@ -120,7 +120,7 @@ public:
|
|||
return std::max(parent.core_timing.GetDowncount(), 0);
|
||||
}
|
||||
u64 GetCNTPCT() override {
|
||||
return CpuCyclesToClockCycles(parent.core_timing.GetTicks());
|
||||
return Timing::CpuCyclesToClockCycles(parent.core_timing.GetTicks());
|
||||
}
|
||||
|
||||
ARM_Dynarmic& parent;
|
||||
|
|
|
@ -7,6 +7,7 @@
|
|||
#include <cinttypes>
|
||||
#include <limits>
|
||||
#include "common/logging/log.h"
|
||||
#include "common/uint128.h"
|
||||
|
||||
namespace Core::Timing {
|
||||
|
||||
|
@ -61,10 +62,9 @@ s64 nsToCycles(u64 ns) {
|
|||
}
|
||||
|
||||
u64 CpuCyclesToClockCycles(u64 ticks) {
|
||||
u64 result = ticks;
|
||||
result *= CNTFREQ;
|
||||
result /= BASE_CLOCK_RATE;
|
||||
return static_cast<u64>(result);
|
||||
u128 temporal = Common::Multiply64Into128(ticks, CNTFREQ);
|
||||
std::pair<u64, u64> result = Common::Divide128On64(temporal, BASE_CLOCK_RATE);
|
||||
return result.first;
|
||||
}
|
||||
|
||||
} // namespace Core::Timing
|
||||
|
|
|
@ -11,7 +11,7 @@ namespace Core::Timing {
|
|||
// The below clock rate is based on Switch's clockspeed being widely known as 1.020GHz
|
||||
// The exact value used is of course unverified.
|
||||
constexpr u64 BASE_CLOCK_RATE = 1019215872; // Switch clock speed is 1020MHz un/docked
|
||||
constexpr u64 CNTFREQ = 19200000; // Value from fusee.
|
||||
constexpr u64 CNTFREQ = 19200000; // Value from fusee.
|
||||
|
||||
inline s64 msToCycles(int ms) {
|
||||
// since ms is int there is no way to overflow
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue