From 7ec3343ee6e4fbaedd115b40a2902d9036c6366c Mon Sep 17 00:00:00 2001 From: Connor McLaughlin Date: Fri, 27 Sep 2019 00:03:28 +1000 Subject: [PATCH] Timers: Minor fixes --- src/pse/gpu.cpp | 32 ++++++++++++++++---------------- src/pse/gpu_hw_opengl.cpp | 4 +++- src/pse/system.cpp | 2 +- src/pse/timers.cpp | 1 + 4 files changed, 21 insertions(+), 18 deletions(-) diff --git a/src/pse/gpu.cpp b/src/pse/gpu.cpp index b469e3fda..721f68d71 100644 --- a/src/pse/gpu.cpp +++ b/src/pse/gpu.cpp @@ -266,7 +266,7 @@ void GPU::UpdateCRTCConfig() void GPU::UpdateSliceTicks() { // the next event is at the end of the next scanline -#if 0 +#if 1 const TickCount ticks_until_next_event = m_crtc_state.ticks_per_scanline - m_crtc_state.current_tick_in_scanline; #else // or at vblank. this will depend on the timer config.. @@ -296,6 +296,21 @@ void GPU::Execute(TickCount ticks) if (m_timers->IsUsingExternalClock(HBLANK_TIMER_INDEX)) m_timers->AddTicks(HBLANK_TIMER_INDEX, 1); + // past the end of vblank? + if (m_crtc_state.current_scanline >= m_crtc_state.total_scanlines_per_frame) + { + // flush any pending draws and "scan out" the image + FlushRender(); + UpdateDisplay(); + + // start the new frame + m_system->IncrementFrameNumber(); + m_crtc_state.current_scanline = 0; + + if (m_GPUSTAT.vertical_resolution) + m_GPUSTAT.drawing_even_line ^= true; + } + const bool old_vblank = m_crtc_state.in_vblank; const bool new_vblank = m_crtc_state.current_scanline >= m_crtc_state.visible_vertical_resolution; if (new_vblank != old_vblank) @@ -311,22 +326,7 @@ void GPU::Execute(TickCount ticks) m_timers->SetGate(HBLANK_TIMER_INDEX, new_vblank); } - // past the end of vblank? - if (m_crtc_state.current_scanline >= m_crtc_state.total_scanlines_per_frame) - { - // flush any pending draws and "scan out" the image - FlushRender(); - UpdateDisplay(); - // start the new frame - m_system->IncrementFrameNumber(); - m_crtc_state.current_scanline = 0; - m_crtc_state.in_hblank = false; - m_crtc_state.in_vblank = false; - - if (m_GPUSTAT.vertical_resolution) - m_GPUSTAT.drawing_even_line ^= true; - } // alternating even line bit in 240-line mode if (!m_crtc_state.vertical_resolution) diff --git a/src/pse/gpu_hw_opengl.cpp b/src/pse/gpu_hw_opengl.cpp index 5fabe395b..0e40d0557 100644 --- a/src/pse/gpu_hw_opengl.cpp +++ b/src/pse/gpu_hw_opengl.cpp @@ -61,7 +61,9 @@ void GPU_HW_OpenGL::RenderUI() ImGui::End(); - m_stats = {}; + // skip update when no batches were drawn in that frame.. for now + if (m_stats.num_batches > 0) + m_stats = {}; } void GPU_HW_OpenGL::InvalidateVRAMReadCache() diff --git a/src/pse/system.cpp b/src/pse/system.cpp index 3c4390e90..c5fc11412 100644 --- a/src/pse/system.cpp +++ b/src/pse/system.cpp @@ -262,11 +262,11 @@ void System::Synchronize() const TickCount pending_ticks = m_cpu->GetPendingTicks(); m_cpu->ResetPendingTicks(); - m_dma->Execute(pending_ticks); m_gpu->Execute(pending_ticks); m_timers->AddSystemTicks(pending_ticks); m_cdrom->Execute(pending_ticks); m_pad->Execute(pending_ticks); + m_dma->Execute(pending_ticks); } void System::SetDowncount(TickCount downcount) diff --git a/src/pse/timers.cpp b/src/pse/timers.cpp index 2e6693847..9045c4fff 100644 --- a/src/pse/timers.cpp +++ b/src/pse/timers.cpp @@ -37,6 +37,7 @@ bool Timers::DoState(StateWrapper& sw) sw.Do(&cs.counter); sw.Do(&cs.target); sw.Do(&cs.gate); + sw.Do(&cs.use_external_clock); sw.Do(&cs.external_counting_enabled); sw.Do(&cs.counting_enabled); }