mirror of
https://github.com/MoleskiCoder/EightBit.git
synced 2025-01-30 03:32:13 +00:00
M6502: Unify accumulator write page boundary fixup code
This commit is contained in:
parent
e4fbeebfa7
commit
93088b355c
@ -190,6 +190,11 @@ namespace EightBit {
|
||||
void sta_AbsoluteY() noexcept;
|
||||
void sta_IndirectIndexedY() noexcept;
|
||||
|
||||
void write_A_with_fixup(const register16_t& address, uint8_t unfixed_page) noexcept {
|
||||
getBytePaged(unfixed_page, address.low); // Possible fixup for page boundary crossing
|
||||
memoryWrite(address, A());
|
||||
}
|
||||
|
||||
uint8_t x = 0; // index register X
|
||||
uint8_t y = 0; // index register Y
|
||||
uint8_t a = 0; // accumulator
|
||||
|
@ -73,14 +73,14 @@ void EightBit::MOS6502::handleINT() noexcept {
|
||||
void EightBit::MOS6502::interrupt() noexcept {
|
||||
const bool reset = m_handlingRESET;
|
||||
const bool nmi = m_handlingNMI;
|
||||
const bool irq = m_handlingINT;
|
||||
const bool hardware = nmi || irq || reset;
|
||||
const bool software = !hardware;
|
||||
if (reset) {
|
||||
dummyPush(PC().high);
|
||||
dummyPush(PC().low);
|
||||
dummyPush(P());
|
||||
} else {
|
||||
const bool irq = m_handlingINT;
|
||||
const bool hardware = nmi || irq || reset;
|
||||
const bool software = !hardware;
|
||||
pushWord(PC());
|
||||
push(P() | (software ? BF : 0));
|
||||
}
|
||||
@ -748,18 +748,15 @@ void EightBit::MOS6502::sre(const uint8_t value) noexcept {
|
||||
|
||||
void EightBit::MOS6502::sta_AbsoluteX() noexcept {
|
||||
const auto [address, page] = Address_AbsoluteX();
|
||||
getBytePaged(page, address.low);
|
||||
memoryWrite(address, A());
|
||||
write_A_with_fixup(address, page);
|
||||
}
|
||||
|
||||
void EightBit::MOS6502::sta_AbsoluteY() noexcept {
|
||||
const auto [address, page] = Address_AbsoluteY();
|
||||
getBytePaged(page, address.low);
|
||||
memoryWrite(address, A());
|
||||
write_A_with_fixup(address, page);
|
||||
}
|
||||
|
||||
void EightBit::MOS6502::sta_IndirectIndexedY() noexcept {
|
||||
const auto [address, page] = Address_IndirectIndexedY();
|
||||
getBytePaged(page, address.low); // Possible fixup for page boundary crossing
|
||||
memoryWrite(address, A());
|
||||
write_A_with_fixup(address, page);
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user