Timers: Minor fixes

This commit is contained in:
Connor McLaughlin 2019-09-27 00:03:28 +10:00
parent 792ec27b1a
commit 7ec3343ee6
4 changed files with 21 additions and 18 deletions

View File

@ -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)

View File

@ -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()

View File

@ -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)

View File

@ -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);
}