diff --git a/src/core/hw/gpu.cpp b/src/core/hw/gpu.cpp index 4f6a31441..e31ea4e5c 100644 --- a/src/core/hw/gpu.cpp +++ b/src/core/hw/gpu.cpp @@ -30,8 +30,6 @@ namespace GPU { Regs g_regs; Memory::MemorySystem* g_memory; -/// 268MHz CPU clocks / 60Hz frames per second -const u64 frame_ticks = static_cast(BASE_CLOCK_RATE_ARM11 / SCREEN_REFRESH_RATE); /// Event id for CoreTiming static Core::TimingEventType* vblank_event; diff --git a/src/core/hw/gpu.h b/src/core/hw/gpu.h index 4e1c92289..1e49967e9 100644 --- a/src/core/hw/gpu.h +++ b/src/core/hw/gpu.h @@ -12,6 +12,7 @@ #include "common/bit_field.h" #include "common/common_funcs.h" #include "common/common_types.h" +#include "core/core_timing.h" namespace Memory { class MemorySystem; @@ -19,10 +20,12 @@ class MemorySystem; namespace GPU { -// TODO(xperia64): This should be defined by the number of -// ARM11 cycles per vblank interval once that value is measured -// and not the other way around -constexpr double SCREEN_REFRESH_RATE = 59.833997376556916; +// Measured on hardware to be 2240568 timer cycles or 4481136 ARM11 cycles +constexpr u64 frame_ticks = 4481136ull; + +// Refresh rate defined by ratio of ARM11 frequency to ARM11 ticks per frame +// (268,111,856) / (4,481,136) = 59.83122493939037Hz +constexpr double SCREEN_REFRESH_RATE = BASE_CLOCK_RATE_ARM11 / static_cast(frame_ticks); // Returns index corresponding to the Regs member labeled by field_name #define GPU_REG_INDEX(field_name) (offsetof(GPU::Regs, field_name) / sizeof(u32))