From e71eabedf95caca2ebf65c1adfb5b12298e2cd64 Mon Sep 17 00:00:00 2001 From: Thomas Harte Date: Thu, 3 Aug 2017 21:30:04 -0400 Subject: [PATCH 1/4] Fixed timer clearing tet. --- Machines/AmstradCPC/AmstradCPC.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Machines/AmstradCPC/AmstradCPC.cpp b/Machines/AmstradCPC/AmstradCPC.cpp index de44fea88..00031ed89 100644 --- a/Machines/AmstradCPC/AmstradCPC.cpp +++ b/Machines/AmstradCPC/AmstradCPC.cpp @@ -541,7 +541,7 @@ class ConcreteMachine: read_pointers_[3] = (*cycle.value & 8) ? &ram_[49152] : basic_.data(); // Reset the interrupt timer if requested. - if(*cycle.value & 15) interrupt_timer_.reset_count(); + if(*cycle.value & 0x10) interrupt_timer_.reset_count(); // Post the next mode. crtc_bus_handler_.set_next_mode(*cycle.value & 3); From b9275004879abe4428a026682e75b5fc796e6c81 Mon Sep 17 00:00:00 2001 From: Thomas Harte Date: Thu, 3 Aug 2017 22:00:30 -0400 Subject: [PATCH 2/4] Clarified code a little, but this is mostly fiddling in the margins. --- Machines/AmstradCPC/AmstradCPC.cpp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/Machines/AmstradCPC/AmstradCPC.cpp b/Machines/AmstradCPC/AmstradCPC.cpp index 00031ed89..796d7b4e8 100644 --- a/Machines/AmstradCPC/AmstradCPC.cpp +++ b/Machines/AmstradCPC/AmstradCPC.cpp @@ -504,8 +504,8 @@ class ConcreteMachine: // will do as it's safe to conclude that nobody else has touched video RAM // during that whole window crtc_counter_ += cycle.length; - int crtc_cycles = crtc_counter_.divide(HalfCycles(8)).as_int(); - if(crtc_cycles) crtc_.run_for(Cycles(1)); + Cycles crtc_cycles = crtc_counter_.divide_cycles(Cycles(4)); + if(crtc_cycles > Cycles(0)) crtc_.run_for(crtc_cycles); z80_.set_interrupt_line(interrupt_timer_.get_request()); // TODO (in the player, not here): adapt it to accept an input clock rate and From d9097facf1a9b4ecce4046a93b7be77be90a51b4 Mon Sep 17 00:00:00 2001 From: Thomas Harte Date: Fri, 4 Aug 2017 08:56:09 -0400 Subject: [PATCH 3/4] Found documentation that makes more sense, and in practice seems to be more correct: the test after vertical sync is for greater than 32, not less. Also I decided to chance my arm on counter reset also resetting interrupt request. The raster effects of Ghouls 'n' Ghosts is now pretty much correct but one line off. I think probably either something is off in my wait-two logic on the post-vsync timer event, or possibly the vsync bit exposed via the PPI doesn't mean exactly what I think it means. --- Machines/AmstradCPC/AmstradCPC.cpp | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/Machines/AmstradCPC/AmstradCPC.cpp b/Machines/AmstradCPC/AmstradCPC.cpp index 796d7b4e8..469473243 100644 --- a/Machines/AmstradCPC/AmstradCPC.cpp +++ b/Machines/AmstradCPC/AmstradCPC.cpp @@ -30,9 +30,9 @@ class InterruptTimer { InterruptTimer() : timer_(0), interrupt_request_(false) {} /*! - Indicates that a new hsync pulse has been recognised. Per documentation - difficulties, it is not presently clear to me whether this should be - the leading or trailing edge of horizontal sync. + Indicates that a new hsync pulse has been recognised. This should be + supplied on the falling edge of the CRTC HSYNC signal, which is the + trailing edge because it is active high. */ inline void signal_hsync() { // Increment the timer and if it has hit 52 then reset it and @@ -49,7 +49,7 @@ class InterruptTimer { if(reset_counter_) { reset_counter_--; if(!reset_counter_) { - if(timer_ < 32) { + if(timer_ & 32) { interrupt_request_ = true; } timer_ = 0; @@ -76,6 +76,7 @@ class InterruptTimer { /// Resets the timer. inline void reset_count() { timer_ = 0; + interrupt_request_ = false; } private: From 26ce6cdab2d009183ef122ce921bb761561b5e51 Mon Sep 17 00:00:00 2001 From: Thomas Harte Date: Fri, 4 Aug 2017 08:56:36 -0400 Subject: [PATCH 4/4] Permitted register 3 to dictate vertical sync length. --- Components/6845/CRTC6845.hpp | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/Components/6845/CRTC6845.hpp b/Components/6845/CRTC6845.hpp index 13d1a2ffa..1d0bc25c5 100644 --- a/Components/6845/CRTC6845.hpp +++ b/Components/6845/CRTC6845.hpp @@ -106,7 +106,8 @@ template class CRTC6845 { // check for start of vertical sync if(line_counter_ == registers_[7]) { bus_state_.vsync = true; - vsync_down_counter_ = 16; // TODO + vsync_down_counter_ = registers_[3] >> 4; + if(!vsync_down_counter_) vsync_down_counter_ = 16; } // check for entry into the overflow area