From 55ab305dbfc62ec57af12444340c4c681876e9d8 Mon Sep 17 00:00:00 2001 From: Thomas Harte Date: Sat, 23 Jun 2018 22:11:39 -0400 Subject: [PATCH] Introduces equalisation pulses for the Apple II. --- Machines/AppleII/Video.hpp | 18 ++++++++++++++++-- 1 file changed, 16 insertions(+), 2 deletions(-) diff --git a/Machines/AppleII/Video.hpp b/Machines/AppleII/Video.hpp index e5d2f97df..470ed5bee 100644 --- a/Machines/AppleII/Video.hpp +++ b/Machines/AppleII/Video.hpp @@ -88,11 +88,25 @@ template class Video: public VideoBase { int int_cycles = cycles.as_int(); while(int_cycles) { const int cycles_this_line = std::min(65 - column_, int_cycles); + const int ending_column = column_ + cycles_this_line; if(row_ >= first_sync_line && row_ < first_sync_line + 3) { - crt_->output_sync(static_cast(cycles_this_line) * 14); + // In effect apply an XOR to HSYNC and VSYNC flags in order to include equalising + // pulses (and hencce keep hsync approximately where it should be during vsync). + const int blank_start = std::max(first_sync_column, column_); + const int blank_end = std::min(first_sync_column + 4, ending_column); + if(blank_end > blank_start) { + if(blank_start > column_) { + crt_->output_sync(static_cast(blank_start - column_) * 14); + } + crt_->output_blank(static_cast(blank_end - blank_start) * 14); + if(blank_end < ending_column) { + crt_->output_sync(static_cast(ending_column - blank_end) * 14); + } + } else { + crt_->output_sync(static_cast(cycles_this_line) * 14); + } } else { - const int ending_column = column_ + cycles_this_line; const GraphicsMode line_mode = use_graphics_mode_ ? graphics_mode_ : GraphicsMode::Text; // The first 40 columns are submitted to the CRT only upon completion;