Complete all the undocumente M6502 features. Hurrah!

This commit is contained in:
Adrian Conlon 2024-01-07 16:20:58 +00:00
parent 72be3238f2
commit 0a9a1e5d4c
2 changed files with 25 additions and 2 deletions

View File

@ -174,6 +174,12 @@ namespace EightBit {
BUS().ADDRESS() = address;
}
void maybe_fixup(const register16_t address, const uint8_t unfixed_page) noexcept {
if (address.high != unfixed_page)
fixup(address, unfixed_page);
}
// Status flag operations
constexpr void set_flag(int which, int condition) noexcept { P() = setBit(P(), which, condition); }
@ -306,6 +312,12 @@ namespace EightBit {
void sha_AbsoluteY() noexcept;
void sha_IndirectIndexedY() noexcept;
// TAS
void tas_AbsoluteY() noexcept;
// LAS
void las_AbsoluteY() noexcept;
// SYA
void sya_AbsoluteX() noexcept;

View File

@ -292,7 +292,7 @@ int EightBit::MOS6502::execute() noexcept {
case 0x98: swallow(); A() = through(Y()); break; // TYA (implied)
case 0x99: sta_AbsoluteY(); break; // STA (absolute, Y)
case 0x9a: swallow(); S() = X(); break; // TXS (implied)
case 0x9b: break;
case 0x9b: tas_AbsoluteY(); break; // *TAS (absolute, Y)
case 0x9c: sya_AbsoluteX(); break; // *SYA (absolute, X)
case 0x9d: sta_AbsoluteX(); break; // STA (absolute, X)
case 0x9e: sxa_AbsoluteY(); break; // *SXA (absolute, Y)
@ -325,7 +325,7 @@ int EightBit::MOS6502::execute() noexcept {
case 0xb8: swallow(); reset_flag(VF); break; // CLV (implied)
case 0xb9: A() = through(AM_AbsoluteY()); break; // LDA (absolute, Y)
case 0xba: swallow(); X() = through(S()); break; // TSX (implied)
case 0xbb: break;
case 0xbb: las_AbsoluteY(); break; // *LAS (absolute, Y)
case 0xbc: Y() = through(AM_AbsoluteX()); break; // LDY (absolute, X)
case 0xbd: A() = through(AM_AbsoluteX()); break; // LDA (absolute, X)
case 0xbe: X() = through(AM_AbsoluteY()); break; // LDX (absolute, Y)
@ -891,6 +891,17 @@ void EightBit::MOS6502::sya_AbsoluteX() noexcept {
memoryWrite(Y() & (address.high + 1));
}
void EightBit::MOS6502::tas_AbsoluteY() noexcept {
S() = A() & X();
sha_AbsoluteY();
}
void EightBit::MOS6502::las_AbsoluteY() noexcept {
const auto [address, page] = Address_AbsoluteY();
maybe_fixup(address, page);
A() = X() = S() = through(memoryRead(address) & S());
}
void EightBit::MOS6502::sxa_AbsoluteY() noexcept {
const auto [address, page] = Address_AbsoluteY();
fixup(address, page);