From 039aed1bd12409e0c6736ee658d5ca5c81997412 Mon Sep 17 00:00:00 2001 From: Thomas Harte Date: Fri, 25 Aug 2017 21:26:01 -0400 Subject: [PATCH 1/2] Switches the two sync counters to upward-going rather than downward, as a more likely match to the way the rest of the 6845 implementation. --- Components/6845/CRTC6845.hpp | 25 +++++++++++-------------- 1 file changed, 11 insertions(+), 14 deletions(-) diff --git a/Components/6845/CRTC6845.hpp b/Components/6845/CRTC6845.hpp index 011b00b13..e75a61c7f 100644 --- a/Components/6845/CRTC6845.hpp +++ b/Components/6845/CRTC6845.hpp @@ -79,17 +79,15 @@ template class CRTC6845 { int cyles_remaining = cycles.as_int(); while(cyles_remaining--) { // check for end of horizontal sync - if(hsync_down_counter_) { - hsync_down_counter_--; - if(!hsync_down_counter_) { - bus_state_.hsync = false; - } + if(bus_state_.hsync) { + hsync_counter_++; + bus_state_.hsync = hsync_counter_ != (registers_[3] & 15); } // check for start of horizontal sync if(character_counter_ == registers_[2]) { - hsync_down_counter_ = registers_[3] & 15; - if(hsync_down_counter_) bus_state_.hsync = true; + hsync_counter_ = 0; + if(registers_[3] & 15) bus_state_.hsync = true; } // check for end of visible characters @@ -123,9 +121,9 @@ template class CRTC6845 { inline void do_end_of_line() { // check for end of vertical sync - if(vsync_down_counter_) { - vsync_down_counter_--; - if(!vsync_down_counter_) { + if(bus_state_.vsync) { + vsync_counter_++; + if(vsync_counter_ == (registers_[3] >> 4)) { bus_state_.vsync = false; } } @@ -156,8 +154,7 @@ template class CRTC6845 { // check for start of vertical sync if(line_counter_ == registers_[7]) { bus_state_.vsync = true; - vsync_down_counter_ = registers_[3] >> 4; - if(!vsync_down_counter_) vsync_down_counter_ = 16; + vsync_counter_ = 0; } // check for end of visible lines @@ -194,8 +191,8 @@ template class CRTC6845 { bool character_is_visible_, line_is_visible_; - int hsync_down_counter_; - int vsync_down_counter_; + int hsync_counter_; + int vsync_counter_; bool is_in_adjustment_period_; uint16_t line_address_; From 3caa4705cae22bc9115d9649f5ddfae107a3050b Mon Sep 17 00:00:00 2001 From: Thomas Harte Date: Sat, 26 Aug 2017 12:31:19 -0400 Subject: [PATCH 2/2] Limits sync counter size. --- Components/6845/CRTC6845.hpp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/Components/6845/CRTC6845.hpp b/Components/6845/CRTC6845.hpp index e75a61c7f..44eee1f80 100644 --- a/Components/6845/CRTC6845.hpp +++ b/Components/6845/CRTC6845.hpp @@ -80,7 +80,7 @@ template class CRTC6845 { while(cyles_remaining--) { // check for end of horizontal sync if(bus_state_.hsync) { - hsync_counter_++; + hsync_counter_ = (hsync_counter_ + 1) & 15; bus_state_.hsync = hsync_counter_ != (registers_[3] & 15); } @@ -122,7 +122,7 @@ template class CRTC6845 { inline void do_end_of_line() { // check for end of vertical sync if(bus_state_.vsync) { - vsync_counter_++; + vsync_counter_ = (vsync_counter_ + 1) & 15; if(vsync_counter_ == (registers_[3] >> 4)) { bus_state_.vsync = false; }