mirror of
https://github.com/MoleskiCoder/EightBit.git
synced 2025-01-14 21:29:42 +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 uint8_t pop() final;
|
||||
|
||||
// Dummy stack push, used during RESET
|
||||
void dummyPush(uint8_t value);
|
||||
|
||||
// Addressing modes
|
||||
|
||||
register16_t Address_Absolute();
|
||||
|
@ -72,17 +72,21 @@ void EightBit::MOS6502::handleIRQ() {
|
||||
}
|
||||
|
||||
void EightBit::MOS6502::interrupt() {
|
||||
uint8_t vector = RSTvector;
|
||||
if (!m_handlingRESET) {
|
||||
const bool nmi = m_handlingNMI;
|
||||
const bool irq = m_handlingIRQ;
|
||||
const bool hardware = nmi || irq;
|
||||
const bool software = !hardware;
|
||||
const bool reset = m_handlingRESET;
|
||||
const bool nmi = m_handlingNMI;
|
||||
const bool irq = m_handlingIRQ;
|
||||
const bool hardware = nmi || irq || reset;
|
||||
const bool software = !hardware;
|
||||
if (reset) {
|
||||
dummyPush(PC().high);
|
||||
dummyPush(PC().low);
|
||||
dummyPush(P());
|
||||
} else {
|
||||
pushWord(PC());
|
||||
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));
|
||||
m_handlingRESET = m_handlingNMI = m_handlingIRQ = false;
|
||||
}
|
||||
@ -392,6 +396,12 @@ uint8_t EightBit::MOS6502::pop() {
|
||||
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() {
|
||||
|
Loading…
x
Reference in New Issue
Block a user