From 5b43cefb8582371da32a2af1b0b261c51441f540 Mon Sep 17 00:00:00 2001 From: Thomas Harte Date: Thu, 1 Jun 2017 20:34:52 -0400 Subject: [PATCH] Started filling an appropriate mask variable with the interrupt request status right now. Which is step one towards implementing interrupts. --- Processors/Z80/Z80.hpp | 34 ++++++++++++++++++++++++++++------ 1 file changed, 28 insertions(+), 6 deletions(-) diff --git a/Processors/Z80/Z80.hpp b/Processors/Z80/Z80.hpp index 66ac4c2b3..d1a41d315 100644 --- a/Processors/Z80/Z80.hpp +++ b/Processors/Z80/Z80.hpp @@ -182,6 +182,14 @@ template class Processor: public MicroOpScheduler { int number_of_cycles_; + enum Interrupt: uint8_t { + IRQ = 0x01, + NMI = 0x02, + BUSREQ = 0x04, + }; + uint8_t request_status_; + bool irq_line_; + uint8_t operation_; RegisterPair temp16_; uint8_t temp8_; @@ -1337,10 +1345,12 @@ template class Processor: public MicroOpScheduler { case MicroOp::EI: iff1_ = iff2_ = true; + if(irq_line_) request_status_ |= Interrupt::IRQ; break; case MicroOp::DI: iff1_ = iff2_ = false; + request_status_ &= ~Interrupt::IRQ; break; case MicroOp::IM: @@ -1570,21 +1580,33 @@ template class Processor: public MicroOpScheduler { } /*! - Sets the logical value of the interrupt line at @c time_offset cycles from now. + Sets the logical value of the interrupt line. */ - void set_interrupt_line(bool value, int time_offset) { + void set_interrupt_line(bool value) { + // IRQ requests are level triggered and masked. + irq_line_ = value; + if(irq_line_ && iff1_) { + request_status_ |= Interrupt::IRQ; + } else { + request_status_ &= ~Interrupt::IRQ; + } } /*! - Sets the logical value of the non-maskable interrupt line at @c time_offset cycles from now. + Sets the logical value of the non-maskable interrupt line. */ - void set_non_maskable_interrupt_line(bool value, int time_offset) { + void set_non_maskable_interrupt_line(bool value) { + // NMIs are edge triggered and cannot be masked. + if(value) request_status_ |= Interrupt::NMI; } /*! - Sets the logical value of the bus request line at @c time_offset cycles from now. + Sets the logical value of the bus request line. */ - void set_bus_request_line(bool value, int time_offset) { + void set_bus_request_line(bool value) { + // Bus requests are level triggered and cannot be masked. + if(value) request_status_ |= Interrupt::BUSREQ; + else request_status_ &= ~Interrupt::BUSREQ; } /*!