From 6b9c6d3750d3bc666f03e208a267534eb0c65f1c Mon Sep 17 00:00:00 2001 From: Connor McLaughlin Date: Sun, 1 Mar 2020 17:04:36 +1000 Subject: [PATCH] GPU: Add a helper function to determine how many GPU ticks are pending --- src/core/gpu.cpp | 10 ++++++++-- src/core/gpu.h | 3 +++ 2 files changed, 11 insertions(+), 2 deletions(-) diff --git a/src/core/gpu.cpp b/src/core/gpu.cpp index 81fa208d7..8dd91d7d0 100644 --- a/src/core/gpu.cpp +++ b/src/core/gpu.cpp @@ -408,10 +408,16 @@ void GPU::UpdateCRTCConfig() cs.visible_display_height - cs.active_display_height - cs.active_display_top); } -static TickCount GPUTicksToSystemTicks(u32 gpu_ticks) +static TickCount GPUTicksToSystemTicks(TickCount gpu_ticks) { // convert to master clock, rounding up as we want to overshoot not undershoot - return (gpu_ticks * 7 + 10) / 11; + return static_cast((static_cast(gpu_ticks) * 7u + 10u) / 11u); +} + +TickCount GPU::GetPendingGPUTicks() const +{ + const TickCount pending_sysclk_ticks = m_tick_event->GetTicksSinceLastExecution(); + return ((pending_sysclk_ticks * 11) + m_crtc_state.fractional_ticks) / 7; } void GPU::UpdateSliceTicks() diff --git a/src/core/gpu.h b/src/core/gpu.h index 974bc2453..4761bfde4 100644 --- a/src/core/gpu.h +++ b/src/core/gpu.h @@ -307,6 +307,9 @@ protected: // Ticks for hblank/vblank. void Execute(TickCount ticks); + /// Returns the number of pending GPU ticks. + TickCount GetPendingGPUTicks() const; + /// Returns true if scanout should be interlaced. bool IsDisplayInterlaced() const { return !m_force_progressive_scan && m_GPUSTAT.In480iMode(); }