Tidied up pin management to be synchronised with the .Net code.

Signed-off-by: Adrian Conlon <Adrian.conlon@gmail.com>
This commit is contained in:
Adrian Conlon
2019-09-06 23:55:57 +01:00
parent e1f22f6903
commit 254cfbe342
12 changed files with 50 additions and 61 deletions

View File

@@ -29,7 +29,6 @@ void EightBit::Intel8080::handleRESET() {
tick(3); tick(3);
} }
void EightBit::Intel8080::handleINT() { void EightBit::Intel8080::handleINT() {
IntelProcessor::handleINT(); IntelProcessor::handleINT();
raiseHALT(); raiseHALT();

View File

@@ -33,7 +33,6 @@ namespace EightBit {
int execute() final; int execute() final;
int step() final; int step() final;
void raisePOWER() final;
auto& X() { return x; } auto& X() { return x; }
auto& Y() { return y; } auto& Y() { return y; }

View File

@@ -2,23 +2,22 @@
#include "mos6502.h" #include "mos6502.h"
EightBit::MOS6502::MOS6502(Bus& bus) 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(NMI, MOS6502);
DEFINE_PIN_LEVEL_CHANGERS(SO, MOS6502); DEFINE_PIN_LEVEL_CHANGERS(SO, MOS6502);
DEFINE_PIN_LEVEL_CHANGERS(SYNC, MOS6502); DEFINE_PIN_LEVEL_CHANGERS(SYNC, MOS6502);
DEFINE_PIN_LEVEL_CHANGERS(RDY, 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() { int EightBit::MOS6502::step() {
resetCycles(); resetCycles();
ExecutingInstruction.fire(*this); ExecutingInstruction.fire(*this);

View File

@@ -60,8 +60,6 @@ namespace EightBit {
virtual int execute() final; virtual int execute() final;
virtual int step() final; virtual int step() final;
virtual void raisePOWER() final;
auto& D() { return m_d; } auto& D() { return m_d; }
auto& A() { return D().high; } auto& A() { return D().high; }
auto& B() { return D().low; } auto& B() { return D().low; }

View File

@@ -5,7 +5,12 @@
#include <cassert> #include <cassert>
EightBit::mc6809::mc6809(Bus& bus) 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(NMI, mc6809);
DEFINE_PIN_LEVEL_CHANGERS(FIRQ, 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(BA, mc6809);
DEFINE_PIN_LEVEL_CHANGERS(BS, mc6809); DEFINE_PIN_LEVEL_CHANGERS(BS, mc6809);
void EightBit::mc6809::raisePOWER() {
BigEndianProcessor::raisePOWER();
lowerBA();
lowerBS();
}
int EightBit::mc6809::step() { int EightBit::mc6809::step() {
resetCycles(); resetCycles();
ExecutingInstruction.fire(*this); ExecutingInstruction.fire(*this);

View File

@@ -10,8 +10,6 @@ namespace EightBit {
public: public:
mc6850(); mc6850();
void raisePOWER() final;
// +--------+----------------------------------------------------------------------------------+ // +--------+----------------------------------------------------------------------------------+
// | | Buffer address | // | | Buffer address |
// | +------------------+------------------+--------------------+-----------------------+ // | +------------------+------------------+--------------------+-----------------------+

Binary file not shown.

View File

@@ -56,8 +56,6 @@ namespace EightBit {
int execute() final; int execute() final;
int step() final; int step() final;
void raisePOWER() final;
[[nodiscard]] register16_t& AF() final; [[nodiscard]] register16_t& AF() final;
[[nodiscard]] register16_t& BC() final; [[nodiscard]] register16_t& BC() final;
[[nodiscard]] register16_t& DE() final; [[nodiscard]] register16_t& DE() final;

View File

@@ -6,6 +6,22 @@
EightBit::Z80::Z80(Bus& bus, InputOutput& ports) EightBit::Z80::Z80(Bus& bus, InputOutput& ports)
: IntelProcessor(bus), : IntelProcessor(bus),
m_ports(ports) { 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); DEFINE_PIN_LEVEL_CHANGERS(NMI, Z80);
@@ -27,27 +43,6 @@ EightBit::register16_t& EightBit::Z80::HL() {
return m_registers[m_registerSet][HL_IDX]; 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() { void EightBit::Z80::handleRESET() {
IntelProcessor::handleRESET(); IntelProcessor::handleRESET();
di(); di();

View File

@@ -21,16 +21,20 @@
#define DEFINE_PIN_LEVEL_RAISE(name, within) \ #define DEFINE_PIN_LEVEL_RAISE(name, within) \
void EightBit:: within ::raise ## name() { \ void EightBit:: within ::raise ## name() { \
Raising ## name.fire(EventArgs::empty()); \ if (lowered( name ())) { \
raise( name ()); \ Raising ## name.fire(EventArgs::empty()); \
Raised ## name.fire(EventArgs::empty()); \ raise( name ()); \
Raised ## name.fire(EventArgs::empty()); \
} \
} }
#define DEFINE_PIN_LEVEL_LOWER(name, within) \ #define DEFINE_PIN_LEVEL_LOWER(name, within) \
void EightBit:: within ::lower ## name() { \ void EightBit:: within ::lower ## name() { \
Lowering ## name.fire(EventArgs::empty()); \ if (raised( name ())) { \
lower( name ()); \ Lowering ## name.fire(EventArgs::empty()); \
Lowered ## name.fire(EventArgs::empty()); \ lower( name ()); \
Lowered ## name.fire(EventArgs::empty()); \
} \
} }
#define DEFINE_PIN_LEVEL_CHANGERS(name, within) \ #define DEFINE_PIN_LEVEL_CHANGERS(name, within) \

View File

@@ -58,8 +58,6 @@ namespace EightBit {
[[nodiscard]] auto& H() { return HL().high; } [[nodiscard]] auto& H() { return HL().high; }
[[nodiscard]] auto& L() { return HL().low; } [[nodiscard]] auto& L() { return HL().low; }
void raisePOWER() override;
DECLARE_PIN_INPUT(HALT) DECLARE_PIN_INPUT(HALT)
protected: protected:

View File

@@ -5,16 +5,18 @@ EightBit::IntelProcessor::IntelProcessor(Bus& bus)
: LittleEndianProcessor(bus) { : LittleEndianProcessor(bus) {
for (int i = 0; i < 0x100; ++i) for (int i = 0; i < 0x100; ++i)
m_decodedOpcodes[i] = 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); DEFINE_PIN_LEVEL_CHANGERS(HALT, IntelProcessor);
void EightBit::IntelProcessor::raisePOWER() {
Processor::raisePOWER();
raiseHALT();
SP() = AF() = BC() = DE() = HL() = Mask16;
}
void EightBit::IntelProcessor::handleRESET() { void EightBit::IntelProcessor::handleRESET() {
Processor::handleRESET(); Processor::handleRESET();
PC() = 0; PC() = 0;