diff --git a/src/core/gpu.cpp b/src/core/gpu.cpp index 7b3595350..de8b77f24 100644 --- a/src/core/gpu.cpp +++ b/src/core/gpu.cpp @@ -449,6 +449,7 @@ void GPU::UpdateCRTCConfig() cs.vertical_total = PAL_TOTAL_LINES; cs.current_scanline %= PAL_TOTAL_LINES; cs.horizontal_total = PAL_TICKS_PER_LINE; + cs.horizontal_sync_start = PAL_HSYNC_TICKS; cs.current_tick_in_scanline %= PAL_TICKS_PER_LINE; } else @@ -456,9 +457,12 @@ void GPU::UpdateCRTCConfig() cs.vertical_total = NTSC_TOTAL_LINES; cs.current_scanline %= NTSC_TOTAL_LINES; cs.horizontal_total = NTSC_TICKS_PER_LINE; + cs.horizontal_sync_start = NTSC_HSYNC_TICKS; cs.current_tick_in_scanline %= NTSC_TICKS_PER_LINE; } + cs.in_hblank = (cs.current_tick_in_scanline >= cs.horizontal_sync_start); + const u8 horizontal_resolution_index = m_GPUSTAT.horizontal_resolution_1 | (m_GPUSTAT.horizontal_resolution_2 << 2); cs.dot_clock_divider = dot_clock_dividers[horizontal_resolution_index]; cs.horizontal_display_start = std::min(cs.regs.X1, cs.horizontal_total); @@ -682,8 +686,8 @@ void GPU::CRTCTickEvent(TickCount ticks) { // short path when we execute <1 line.. this shouldn't occur often. const bool old_hblank = m_crtc_state.in_hblank; - const bool new_hblank = m_crtc_state.current_tick_in_scanline < m_crtc_state.horizontal_display_start || - m_crtc_state.current_tick_in_scanline >= m_crtc_state.horizontal_display_end; + const bool new_hblank = (m_crtc_state.current_tick_in_scanline >= m_crtc_state.horizontal_sync_start); + m_crtc_state.in_hblank = new_hblank; if (!old_hblank && new_hblank && g_timers.IsUsingExternalClock(HBLANK_TIMER_INDEX)) g_timers.AddTicks(HBLANK_TIMER_INDEX, 1); @@ -699,8 +703,7 @@ void GPU::CRTCTickEvent(TickCount ticks) #endif const bool old_hblank = m_crtc_state.in_hblank; - const bool new_hblank = m_crtc_state.current_tick_in_scanline < m_crtc_state.horizontal_display_start || - m_crtc_state.current_tick_in_scanline >= m_crtc_state.horizontal_display_end; + const bool new_hblank = (m_crtc_state.current_tick_in_scanline >= m_crtc_state.horizontal_sync_start); m_crtc_state.in_hblank = new_hblank; if (g_timers.IsUsingExternalClock(HBLANK_TIMER_INDEX)) { diff --git a/src/core/gpu.h b/src/core/gpu.h index 15ec797bb..3ebe49898 100644 --- a/src/core/gpu.h +++ b/src/core/gpu.h @@ -102,8 +102,10 @@ public: enum : u16 { NTSC_TICKS_PER_LINE = 3413, + NTSC_HSYNC_TICKS = 200, NTSC_TOTAL_LINES = 263, PAL_TICKS_PER_LINE = 3406, + PAL_HSYNC_TICKS = 200, // actually one more on odd lines PAL_TOTAL_LINES = 314, }; @@ -683,6 +685,7 @@ protected: u16 display_vram_height; u16 horizontal_total; + u16 horizontal_sync_start; // <- not currently saved to state, so we don't have to bump the version u16 horizontal_active_start; u16 horizontal_active_end; u16 horizontal_display_start;