Correct problem in page boundary condition for M6502.

This commit is contained in:
Adrian Conlon 2023-12-31 14:32:16 +00:00
parent 84a2d0f952
commit e4fbeebfa7
2 changed files with 8 additions and 1 deletions

View File

@ -188,6 +188,7 @@ namespace EightBit {
void sta_AbsoluteX() noexcept;
void sta_AbsoluteY() noexcept;
void sta_IndirectIndexedY() noexcept;
uint8_t x = 0; // index register X
uint8_t y = 0; // index register Y

View File

@ -266,7 +266,7 @@ int EightBit::MOS6502::execute() noexcept {
case 0x8f: memoryWrite(Address_Absolute(), A() & X()); break; // *SAX (absolute)
case 0x90: branch(!carry()); break; // BCC (relative)
case 0x91: memoryRead(Address_IndirectIndexedY().first); memoryWrite(A()); break; // STA (indirect indexed Y)
case 0x91: sta_IndirectIndexedY(); break; // STA (indirect indexed Y)
case 0x92: break;
case 0x93: break;
case 0x94: memoryWrite(Address_ZeroPageX(), Y()); break; // STY (zero page, X)
@ -757,3 +757,9 @@ void EightBit::MOS6502::sta_AbsoluteY() noexcept {
getBytePaged(page, address.low);
memoryWrite(address, A());
}
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());
}