GPU: Add a helper function to determine how many GPU ticks are pending

This commit is contained in:
Connor McLaughlin 2020-03-01 17:04:36 +10:00
parent 635ab72b37
commit 6b9c6d3750
2 changed files with 11 additions and 2 deletions

View file

@ -408,10 +408,16 @@ void GPU::UpdateCRTCConfig()
cs.visible_display_height - cs.active_display_height - cs.active_display_top); 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 // convert to master clock, rounding up as we want to overshoot not undershoot
return (gpu_ticks * 7 + 10) / 11; return static_cast<TickCount>((static_cast<u32>(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() void GPU::UpdateSliceTicks()

View file

@ -307,6 +307,9 @@ protected:
// Ticks for hblank/vblank. // Ticks for hblank/vblank.
void Execute(TickCount ticks); void Execute(TickCount ticks);
/// Returns the number of pending GPU ticks.
TickCount GetPendingGPUTicks() const;
/// Returns true if scanout should be interlaced. /// Returns true if scanout should be interlaced.
bool IsDisplayInterlaced() const { return !m_force_progressive_scan && m_GPUSTAT.In480iMode(); } bool IsDisplayInterlaced() const { return !m_force_progressive_scan && m_GPUSTAT.In480iMode(); }