From 6c5a03187b0c24cfdf1b7c5554ee811be226a56e Mon Sep 17 00:00:00 2001 From: Thomas Harte Date: Sat, 26 Aug 2017 17:22:48 -0400 Subject: [PATCH 1/3] Relocates the HSYNC start test, in order to pass Arnold's cpctest HSYNC start position conformance test. --- Components/6845/CRTC6845.hpp | 26 +++++++++++++------------- 1 file changed, 13 insertions(+), 13 deletions(-) diff --git a/Components/6845/CRTC6845.hpp b/Components/6845/CRTC6845.hpp index ecc468da1..fea89eeb1 100644 --- a/Components/6845/CRTC6845.hpp +++ b/Components/6845/CRTC6845.hpp @@ -87,19 +87,6 @@ template class CRTC6845 { void run_for(Cycles cycles) { int cyles_remaining = cycles.as_int(); while(cyles_remaining--) { - // check for start of horizontal sync - if(character_counter_ == registers_[2]) { - hsync_counter_ = 0; - bus_state_.hsync = true; - } - - // check for end of horizontal sync; note that a sync time of zero will result in an immediate - // cancellation of the plan to perform sync - if(bus_state_.hsync) { - bus_state_.hsync = hsync_counter_ != (registers_[3] & 15); - hsync_counter_ = (hsync_counter_ + 1) & 15; - } - // check for end of visible characters if(character_counter_ == registers_[1]) { // TODO: consider skew in character_is_visible_. Or maybe defer until perform_bus_cycle? @@ -120,6 +107,19 @@ template class CRTC6845 { character_counter_++; } + // check for start of horizontal sync + if(character_counter_ == registers_[2]) { + hsync_counter_ = 0; + bus_state_.hsync = true; + } + + // check for end of horizontal sync; note that a sync time of zero will result in an immediate + // cancellation of the plan to perform sync + if(bus_state_.hsync) { + bus_state_.hsync = hsync_counter_ != (registers_[3] & 15); + hsync_counter_ = (hsync_counter_ + 1) & 15; + } + perform_bus_cycle_phase2(); } } From 487fe83dcad098310fcb15d5cea72630c74e8aae Mon Sep 17 00:00:00 2001 From: Thomas Harte Date: Sat, 26 Aug 2017 17:54:54 -0400 Subject: [PATCH 2/3] Ensures that vertical sync and end-of-visible-lines conditions potentially trigger whenever line_counter_ changes, not only when it increments. --- Components/6845/CRTC6845.hpp | 25 +++++++++++++------------ 1 file changed, 13 insertions(+), 12 deletions(-) diff --git a/Components/6845/CRTC6845.hpp b/Components/6845/CRTC6845.hpp index fea89eeb1..88c3f81c6 100644 --- a/Components/6845/CRTC6845.hpp +++ b/Components/6845/CRTC6845.hpp @@ -75,8 +75,9 @@ template class CRTC6845 { 0xff, 0x1f, 0x7f, 0x1f, 0x3f, 0xff, 0x3f, 0xff }; - if(selected_register_ < 16) + if(selected_register_ < 16) { registers_[selected_register_] = value & masks[selected_register_]; + } } void trigger_light_pen() { @@ -170,21 +171,21 @@ template class CRTC6845 { } } else { line_counter_ = (line_counter_ + 1) & 0x7f; - - // check for start of vertical sync - if(line_counter_ == registers_[7]) { - bus_state_.vsync = true; - vsync_counter_ = 0; - } - - // check for end of visible lines - if(line_counter_ == registers_[6]) { - line_is_visible_ = false; - } } } else { bus_state_.row_address = (bus_state_.row_address + 1) & 0x1f; } + + // check for start of vertical sync + if(line_counter_ == registers_[7]) { + bus_state_.vsync = true; + vsync_counter_ = 0; + } + + // check for end of visible lines + if(line_counter_ == registers_[6]) { + line_is_visible_ = false; + } } bus_state_.refresh_address = line_address_; From bdda7012078a83eb904d6b3f05b5d58a87e6b80a Mon Sep 17 00:00:00 2001 From: Thomas Harte Date: Sat, 26 Aug 2017 22:58:16 -0400 Subject: [PATCH 3/3] Reverts previous unevidenced change. --- Components/6845/CRTC6845.hpp | 22 +++++++++++----------- 1 file changed, 11 insertions(+), 11 deletions(-) diff --git a/Components/6845/CRTC6845.hpp b/Components/6845/CRTC6845.hpp index 88c3f81c6..5ec321611 100644 --- a/Components/6845/CRTC6845.hpp +++ b/Components/6845/CRTC6845.hpp @@ -171,21 +171,21 @@ template class CRTC6845 { } } else { line_counter_ = (line_counter_ + 1) & 0x7f; + + // check for start of vertical sync + if(line_counter_ == registers_[7]) { + bus_state_.vsync = true; + vsync_counter_ = 0; + } + + // check for end of visible lines + if(line_counter_ == registers_[6]) { + line_is_visible_ = false; + } } } else { bus_state_.row_address = (bus_state_.row_address + 1) & 0x1f; } - - // check for start of vertical sync - if(line_counter_ == registers_[7]) { - bus_state_.vsync = true; - vsync_counter_ = 0; - } - - // check for end of visible lines - if(line_counter_ == registers_[6]) { - line_is_visible_ = false; - } } bus_state_.refresh_address = line_address_;