mirror of
https://github.com/MoleskiCoder/EightBit.git
synced 2025-02-08 03:30:36 +00:00
Add support for emulated SYNC and RDY lines. Untested, but feel close.
Signed-off-by: Adrian Conlon <Adrian.conlon@gmail.com>
This commit is contained in:
parent
047babbe7c
commit
01175cf9eb
@ -43,7 +43,9 @@ namespace EightBit {
|
||||
const auto& P() const { return p; }
|
||||
|
||||
auto& NMI() { return m_nmiLine; } // In
|
||||
auto& SO() { return m_soLine; } // In
|
||||
auto& SO() { return m_soLine; } // In
|
||||
auto& SYNC() { return m_syncLine; } // Out
|
||||
auto& RDY() { return m_rdyLine; } // In
|
||||
|
||||
protected:
|
||||
virtual void handleRESET() final;
|
||||
@ -185,8 +187,10 @@ namespace EightBit {
|
||||
uint8_t s = 0; // stack pointer
|
||||
uint8_t p = 0; // processor status
|
||||
|
||||
PinLevel m_nmiLine = PinLevel::Low;
|
||||
PinLevel m_soLine = PinLevel::Low;
|
||||
PinLevel m_nmiLine = PinLevel::Low; // Active low
|
||||
PinLevel m_soLine = PinLevel::Low; // Active low
|
||||
PinLevel m_syncLine = PinLevel::Low; // Active high
|
||||
PinLevel m_rdyLine = PinLevel::Low; // Active high
|
||||
|
||||
register16_t m_intermediate;
|
||||
|
||||
|
@ -21,13 +21,12 @@ void EightBit::MOS6502::powerOn() {
|
||||
int EightBit::MOS6502::step() {
|
||||
resetCycles();
|
||||
ExecutingInstruction.fire(*this);
|
||||
if (LIKELY(powered())) {
|
||||
if (LIKELY(powered() && raised(RDY()))) {
|
||||
if (UNLIKELY(lowered(SO())))
|
||||
handleSO();
|
||||
lower(SYNC()); // Instruction fetch beginning
|
||||
opcode() = fetchByte();
|
||||
if (UNLIKELY(lowered(HALT())))
|
||||
handleHALT();
|
||||
else if (UNLIKELY(lowered(RESET())))
|
||||
if (UNLIKELY(lowered(RESET())))
|
||||
handleRESET();
|
||||
else if (UNLIKELY(lowered(NMI())))
|
||||
handleNMI();
|
||||
@ -46,10 +45,6 @@ void EightBit::MOS6502::handleSO() {
|
||||
P() |= VF;
|
||||
}
|
||||
|
||||
void EightBit::MOS6502::handleHALT() {
|
||||
opcode() = 0xea; // NOP
|
||||
}
|
||||
|
||||
void EightBit::MOS6502::handleRESET() {
|
||||
raise(RESET());
|
||||
m_handlingRESET = true;
|
||||
@ -58,14 +53,12 @@ void EightBit::MOS6502::handleRESET() {
|
||||
|
||||
|
||||
void EightBit::MOS6502::handleNMI() {
|
||||
raise(HALT());
|
||||
raise(NMI());
|
||||
m_handlingNMI = true;
|
||||
opcode() = 0x00; // BRK
|
||||
}
|
||||
|
||||
void EightBit::MOS6502::handleIRQ() {
|
||||
raise(HALT());
|
||||
raise(INT());
|
||||
m_handlingIRQ = true;
|
||||
opcode() = 0x00; // BRK
|
||||
@ -107,6 +100,8 @@ uint8_t EightBit::MOS6502::busRead() {
|
||||
|
||||
int EightBit::MOS6502::execute() {
|
||||
|
||||
raise(SYNC()); // Instruction fetch has now completed
|
||||
|
||||
switch (opcode()) {
|
||||
|
||||
case 0x00: fetchByte(); interrupt(); break; // BRK (implied)
|
||||
|
Loading…
x
Reference in New Issue
Block a user