mirror of
https://github.com/MoleskiCoder/EightBit.git
synced 2025-07-22 22:24:11 +00:00
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:
@@ -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();
|
||||||
|
@@ -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; }
|
||||||
|
@@ -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);
|
||||||
|
@@ -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; }
|
||||||
|
@@ -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);
|
||||||
|
@@ -10,8 +10,6 @@ namespace EightBit {
|
|||||||
public:
|
public:
|
||||||
mc6850();
|
mc6850();
|
||||||
|
|
||||||
void raisePOWER() final;
|
|
||||||
|
|
||||||
// +--------+----------------------------------------------------------------------------------+
|
// +--------+----------------------------------------------------------------------------------+
|
||||||
// | | Buffer address |
|
// | | Buffer address |
|
||||||
// | +------------------+------------------+--------------------+-----------------------+
|
// | +------------------+------------------+--------------------+-----------------------+
|
||||||
|
Binary file not shown.
@@ -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;
|
||||||
|
@@ -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();
|
||||||
|
16
inc/Device.h
16
inc/Device.h
@@ -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) \
|
||||||
|
@@ -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:
|
||||||
|
@@ -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;
|
||||||
|
Reference in New Issue
Block a user