From e4fbeebfa7c47d8ab6192c397f3e04c8705657b3 Mon Sep 17 00:00:00 2001 From: Adrian Conlon <98398945+AdrianConlon@users.noreply.github.com> Date: Sun, 31 Dec 2023 14:32:16 +0000 Subject: [PATCH] Correct problem in page boundary condition for M6502. --- M6502/inc/mos6502.h | 1 + M6502/src/mos6502.cpp | 8 +++++++- 2 files changed, 8 insertions(+), 1 deletion(-) diff --git a/M6502/inc/mos6502.h b/M6502/inc/mos6502.h index 970e01e..cec6105 100644 --- a/M6502/inc/mos6502.h +++ b/M6502/inc/mos6502.h @@ -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 diff --git a/M6502/src/mos6502.cpp b/M6502/src/mos6502.cpp index dfb9c24..b520650 100644 --- a/M6502/src/mos6502.cpp +++ b/M6502/src/mos6502.cpp @@ -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()); +}