diff --git a/Intel8080/src/Intel8080.cpp b/Intel8080/src/Intel8080.cpp index 3c70265..0292307 100644 --- a/Intel8080/src/Intel8080.cpp +++ b/Intel8080/src/Intel8080.cpp @@ -29,7 +29,6 @@ void EightBit::Intel8080::handleRESET() { tick(3); } - void EightBit::Intel8080::handleINT() { IntelProcessor::handleINT(); raiseHALT(); diff --git a/M6502/inc/mos6502.h b/M6502/inc/mos6502.h index 86257a0..a04696b 100644 --- a/M6502/inc/mos6502.h +++ b/M6502/inc/mos6502.h @@ -33,7 +33,6 @@ namespace EightBit { int execute() final; int step() final; - void raisePOWER() final; auto& X() { return x; } auto& Y() { return y; } diff --git a/M6502/src/mos6502.cpp b/M6502/src/mos6502.cpp index 13a7a67..9091fc8 100644 --- a/M6502/src/mos6502.cpp +++ b/M6502/src/mos6502.cpp @@ -2,23 +2,22 @@ #include "mos6502.h" EightBit::MOS6502::MOS6502(Bus& bus) -: LittleEndianProcessor(bus) {} +: LittleEndianProcessor(bus) { + RaisedPOWER.connect([this](EventArgs) { + X() = Bit7; + Y() = 0; + A() = 0; + P() = RF; + S() = Mask8; + lowerSYNC(); + }); +} DEFINE_PIN_LEVEL_CHANGERS(NMI, MOS6502); DEFINE_PIN_LEVEL_CHANGERS(SO, MOS6502); DEFINE_PIN_LEVEL_CHANGERS(SYNC, MOS6502); DEFINE_PIN_LEVEL_CHANGERS(RDY, MOS6502); -void EightBit::MOS6502::raisePOWER() { - LittleEndianProcessor::raisePOWER(); - X() = Bit7; - Y() = 0; - A() = 0; - P() = RF; - S() = Mask8; - lowerSYNC(); -} - int EightBit::MOS6502::step() { resetCycles(); ExecutingInstruction.fire(*this); diff --git a/MC6809/inc/mc6809.h b/MC6809/inc/mc6809.h index 7c5e595..a14edd3 100644 --- a/MC6809/inc/mc6809.h +++ b/MC6809/inc/mc6809.h @@ -60,8 +60,6 @@ namespace EightBit { virtual int execute() final; virtual int step() final; - virtual void raisePOWER() final; - auto& D() { return m_d; } auto& A() { return D().high; } auto& B() { return D().low; } diff --git a/MC6809/src/mc6809.cpp b/MC6809/src/mc6809.cpp index 91361aa..a62a654 100644 --- a/MC6809/src/mc6809.cpp +++ b/MC6809/src/mc6809.cpp @@ -5,7 +5,12 @@ #include EightBit::mc6809::mc6809(Bus& bus) -: BigEndianProcessor(bus) {} +: BigEndianProcessor(bus) { + RaisedPOWER.connect([this](EventArgs) { + lowerBA(); + lowerBS(); + }); +} DEFINE_PIN_LEVEL_CHANGERS(NMI, mc6809); DEFINE_PIN_LEVEL_CHANGERS(FIRQ, mc6809); @@ -13,12 +18,6 @@ DEFINE_PIN_LEVEL_CHANGERS(HALT, mc6809); DEFINE_PIN_LEVEL_CHANGERS(BA, mc6809); DEFINE_PIN_LEVEL_CHANGERS(BS, mc6809); -void EightBit::mc6809::raisePOWER() { - BigEndianProcessor::raisePOWER(); - lowerBA(); - lowerBS(); -} - int EightBit::mc6809::step() { resetCycles(); ExecutingInstruction.fire(*this); diff --git a/MC6850/inc/MC6850.h b/MC6850/inc/MC6850.h index a5f7c08..bac5d78 100644 --- a/MC6850/inc/MC6850.h +++ b/MC6850/inc/MC6850.h @@ -10,8 +10,6 @@ namespace EightBit { public: mc6850(); - void raisePOWER() final; - // +--------+----------------------------------------------------------------------------------+ // | | Buffer address | // | +------------------+------------------+--------------------+-----------------------+ diff --git a/MC6850/src/MC6850.cpp b/MC6850/src/MC6850.cpp index a9d5194..3645f2d 100644 Binary files a/MC6850/src/MC6850.cpp and b/MC6850/src/MC6850.cpp differ diff --git a/Z80/inc/Z80.h b/Z80/inc/Z80.h index de9cbdc..599404f 100644 --- a/Z80/inc/Z80.h +++ b/Z80/inc/Z80.h @@ -56,8 +56,6 @@ namespace EightBit { int execute() final; int step() final; - void raisePOWER() final; - [[nodiscard]] register16_t& AF() final; [[nodiscard]] register16_t& BC() final; [[nodiscard]] register16_t& DE() final; diff --git a/Z80/src/Z80.cpp b/Z80/src/Z80.cpp index 4244868..145c501 100644 --- a/Z80/src/Z80.cpp +++ b/Z80/src/Z80.cpp @@ -6,6 +6,22 @@ EightBit::Z80::Z80(Bus& bus, InputOutput& ports) : IntelProcessor(bus), m_ports(ports) { + RaisedPOWER.connect([this](EventArgs) { + raiseM1(); + + di(); + IM() = 0; + + REFRESH() = 0; + IV() = Mask8; + + AF() = IX() = IY() = BC() = DE() = HL() = Mask16; + + exxAF(); + exx(); + + m_prefixCB = m_prefixDD = m_prefixED = m_prefixFD = false; + }); } DEFINE_PIN_LEVEL_CHANGERS(NMI, Z80); @@ -27,27 +43,6 @@ EightBit::register16_t& EightBit::Z80::HL() { return m_registers[m_registerSet][HL_IDX]; } -void EightBit::Z80::raisePOWER() { - - IntelProcessor::raisePOWER(); - - raiseM1(); - - di(); - IM() = 0; - - REFRESH() = 0; - IV() = Mask8; - - exxAF(); - AF() = Mask16; - - exx(); - IX() = IY() = BC() = DE() = HL() = Mask16; - - m_prefixCB = m_prefixDD = m_prefixED = m_prefixFD = false; -} - void EightBit::Z80::handleRESET() { IntelProcessor::handleRESET(); di(); diff --git a/inc/Device.h b/inc/Device.h index e438f42..27a1501 100644 --- a/inc/Device.h +++ b/inc/Device.h @@ -21,16 +21,20 @@ #define DEFINE_PIN_LEVEL_RAISE(name, within) \ void EightBit:: within ::raise ## name() { \ - Raising ## name.fire(EventArgs::empty()); \ - raise( name ()); \ - Raised ## name.fire(EventArgs::empty()); \ + if (lowered( name ())) { \ + Raising ## name.fire(EventArgs::empty()); \ + raise( name ()); \ + Raised ## name.fire(EventArgs::empty()); \ + } \ } #define DEFINE_PIN_LEVEL_LOWER(name, within) \ void EightBit:: within ::lower ## name() { \ - Lowering ## name.fire(EventArgs::empty()); \ - lower( name ()); \ - Lowered ## name.fire(EventArgs::empty()); \ + if (raised( name ())) { \ + Lowering ## name.fire(EventArgs::empty()); \ + lower( name ()); \ + Lowered ## name.fire(EventArgs::empty()); \ + } \ } #define DEFINE_PIN_LEVEL_CHANGERS(name, within) \ diff --git a/inc/IntelProcessor.h b/inc/IntelProcessor.h index c035eca..381df2f 100644 --- a/inc/IntelProcessor.h +++ b/inc/IntelProcessor.h @@ -58,8 +58,6 @@ namespace EightBit { [[nodiscard]] auto& H() { return HL().high; } [[nodiscard]] auto& L() { return HL().low; } - void raisePOWER() override; - DECLARE_PIN_INPUT(HALT) protected: diff --git a/src/IntelProcessor.cpp b/src/IntelProcessor.cpp index ed7cb7d..6e8e65f 100644 --- a/src/IntelProcessor.cpp +++ b/src/IntelProcessor.cpp @@ -5,16 +5,18 @@ EightBit::IntelProcessor::IntelProcessor(Bus& bus) : LittleEndianProcessor(bus) { for (int i = 0; i < 0x100; ++i) m_decodedOpcodes[i] = i; + + LoweredHALT.connect([this](EventArgs) { --PC(); }); + RaisedHALT.connect([this](EventArgs) { ++PC(); }); + + RaisedPOWER.connect([this](EventArgs) { + raiseHALT(); + SP() = AF() = BC() = DE() = HL() = Mask16; + }); } DEFINE_PIN_LEVEL_CHANGERS(HALT, IntelProcessor); -void EightBit::IntelProcessor::raisePOWER() { - Processor::raisePOWER(); - raiseHALT(); - SP() = AF() = BC() = DE() = HL() = Mask16; -} - void EightBit::IntelProcessor::handleRESET() { Processor::handleRESET(); PC() = 0;