mirror of
https://github.com/MoleskiCoder/EightBit.git
synced 2025-01-03 09:29:50 +00:00
Rearrange the RESET handler for cycle accuracy. Use more of the general interrupt handler, but with "dummy" stack write access.
Signed-off-by: Adrian Conlon <Adrian.conlon@gmail.com>
This commit is contained in:
parent
25321e78e7
commit
047babbe7c
@ -76,6 +76,9 @@ namespace EightBit {
|
|||||||
virtual void push(uint8_t value) final;
|
virtual void push(uint8_t value) final;
|
||||||
virtual uint8_t pop() final;
|
virtual uint8_t pop() final;
|
||||||
|
|
||||||
|
// Dummy stack push, used during RESET
|
||||||
|
void dummyPush(uint8_t value);
|
||||||
|
|
||||||
// Addressing modes
|
// Addressing modes
|
||||||
|
|
||||||
register16_t Address_Absolute();
|
register16_t Address_Absolute();
|
||||||
|
@ -72,17 +72,21 @@ void EightBit::MOS6502::handleIRQ() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
void EightBit::MOS6502::interrupt() {
|
void EightBit::MOS6502::interrupt() {
|
||||||
uint8_t vector = RSTvector;
|
const bool reset = m_handlingRESET;
|
||||||
if (!m_handlingRESET) {
|
const bool nmi = m_handlingNMI;
|
||||||
const bool nmi = m_handlingNMI;
|
const bool irq = m_handlingIRQ;
|
||||||
const bool irq = m_handlingIRQ;
|
const bool hardware = nmi || irq || reset;
|
||||||
const bool hardware = nmi || irq;
|
const bool software = !hardware;
|
||||||
const bool software = !hardware;
|
if (reset) {
|
||||||
|
dummyPush(PC().high);
|
||||||
|
dummyPush(PC().low);
|
||||||
|
dummyPush(P());
|
||||||
|
} else {
|
||||||
pushWord(PC());
|
pushWord(PC());
|
||||||
push(P() | (software ? BF : 0));
|
push(P() | (software ? BF : 0));
|
||||||
setFlag(P(), IF); // Disable IRQ
|
|
||||||
vector = nmi ? NMIvector : IRQvector;
|
|
||||||
}
|
}
|
||||||
|
setFlag(P(), IF); // Disable IRQ
|
||||||
|
const uint8_t vector = reset ? RSTvector : (nmi ? NMIvector : IRQvector);
|
||||||
jump(getWordPaged(0xff, vector));
|
jump(getWordPaged(0xff, vector));
|
||||||
m_handlingRESET = m_handlingNMI = m_handlingIRQ = false;
|
m_handlingRESET = m_handlingNMI = m_handlingIRQ = false;
|
||||||
}
|
}
|
||||||
@ -392,6 +396,12 @@ uint8_t EightBit::MOS6502::pop() {
|
|||||||
return getBytePaged(1, ++S());
|
return getBytePaged(1, ++S());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void EightBit::MOS6502::dummyPush(const uint8_t value) {
|
||||||
|
addCycle();
|
||||||
|
BUS().DATA() = value;
|
||||||
|
BUS().ADDRESS() = register16_t(S()--, 1);
|
||||||
|
}
|
||||||
|
|
||||||
////
|
////
|
||||||
|
|
||||||
EightBit::register16_t EightBit::MOS6502::Address_Absolute() {
|
EightBit::register16_t EightBit::MOS6502::Address_Absolute() {
|
||||||
|
Loading…
Reference in New Issue
Block a user