From b7c978e078f499f5b90c19344696e5860e559ccb Mon Sep 17 00:00:00 2001 From: Thomas Harte Date: Thu, 22 Jun 2017 20:11:19 -0400 Subject: [PATCH] Added getters for most of the input lines, and attempted to round out the ZX81's wait logic. --- Machines/ZX8081/ZX8081.cpp | 7 ++++--- Processors/Z80/Z80.hpp | 20 +++++++++++++++++++- 2 files changed, 23 insertions(+), 4 deletions(-) diff --git a/Machines/ZX8081/ZX8081.cpp b/Machines/ZX8081/ZX8081.cpp index 4af76c948..184434791 100644 --- a/Machines/ZX8081/ZX8081.cpp +++ b/Machines/ZX8081/ZX8081.cpp @@ -36,9 +36,6 @@ int Machine::perform_machine_cycle(const CPU::Z80::PartialMachineCycle &cycle) { set_hsync(true); if(nmi_is_enabled_) { set_non_maskable_interrupt_line(true); - if(!get_halt_line()) { - set_wait_line(true); - } } video_->run_for_cycles(horizontal_counter_ - vsync_start_cycle_); } else if(previous_counter < vsync_end_cycle_ && horizontal_counter_ >= vsync_end_cycle_) { @@ -56,6 +53,10 @@ int Machine::perform_machine_cycle(const CPU::Z80::PartialMachineCycle &cycle) { if(is_zx81_) horizontal_counter_ %= 207; tape_player_.run_for_cycles(cycle.length); + if(nmi_is_enabled_ && !get_halt_line() && get_non_maskable_interrupt_line()) { + set_wait_line(true); + } + if(!cycle.is_terminal()) { return 0; } diff --git a/Processors/Z80/Z80.hpp b/Processors/Z80/Z80.hpp index 44579d94c..ce9c9bb46 100644 --- a/Processors/Z80/Z80.hpp +++ b/Processors/Z80/Z80.hpp @@ -192,7 +192,7 @@ template class Processor { }; uint8_t request_status_; uint8_t last_request_status_; - bool irq_line_; + bool irq_line_, nmi_line_; bool bus_request_line_; bool wait_line_; @@ -771,6 +771,7 @@ template class Processor { request_status_(Interrupt::PowerOn), last_request_status_(Interrupt::PowerOn), irq_line_(false), + nmi_line_(false), bus_request_line_(false), pc_increment_(1), scheduled_program_counter_(nullptr) { @@ -1888,6 +1889,10 @@ template class Processor { } } + bool get_interrupt_line() { + return irq_line_; + } + /*! Sets the logical value of the non-maskable interrupt line. @@ -1895,6 +1900,7 @@ template class Processor { */ void set_non_maskable_interrupt_line(bool value, int offset = 0) { // NMIs are edge triggered and cannot be masked. + nmi_line_ = value; if(value) { request_status_ |= Interrupt::NMI; if(offset < 0) { @@ -1903,6 +1909,10 @@ template class Processor { } } + bool get_non_maskable_interrupt_line() { + return nmi_line_; + } + /*! Sets the logical value of the bus request line. */ @@ -1910,6 +1920,10 @@ template class Processor { bus_request_line_ = value; } + bool get_bus_request_line() { + return bus_request_line_; + } + /*! Sets the logical value of the reset line. */ @@ -1935,6 +1949,10 @@ template class Processor { wait_line_ = value; } + bool get_wait_line() { + return wait_line_; + } + /*! For receivers of perform_machine_cycle only. Temporarily rejects the current machine cycle, causing time to be rewinded to its beginning.