Get the memory access more correct for more of boundary crossing indexed addressing modes.

Signed-off-by: Adrian Conlon <Adrian.conlon@gmail.com>
This commit is contained in:
Adrian Conlon 2019-01-06 12:17:43 +00:00
parent a13ad5042a
commit baf32cef89
2 changed files with 24 additions and 21 deletions

View File

@ -84,10 +84,10 @@ namespace EightBit {
register16_t Address_Indirect(); register16_t Address_Indirect();
uint8_t Address_ZeroPageX(); uint8_t Address_ZeroPageX();
uint8_t Address_ZeroPageY(); uint8_t Address_ZeroPageY();
std::pair<register16_t, bool> Address_AbsoluteX(); std::pair<register16_t, uint8_t> Address_AbsoluteX();
std::pair<register16_t, bool> Address_AbsoluteY(); std::pair<register16_t, uint8_t> Address_AbsoluteY();
register16_t Address_IndexedIndirectX(); register16_t Address_IndexedIndirectX();
std::pair<register16_t, bool> Address_IndirectIndexedY(); std::pair<register16_t, uint8_t> Address_IndirectIndexedY();
register16_t Address_relative_byte(); register16_t Address_relative_byte();
// Addressing modes, read // Addressing modes, read

View File

@ -414,29 +414,29 @@ uint8_t EightBit::MOS6502::Address_ZeroPageY() {
return address + Y(); return address + Y();
} }
std::pair<EightBit::register16_t, bool> EightBit::MOS6502::Address_AbsoluteX() { std::pair<EightBit::register16_t, uint8_t> EightBit::MOS6502::Address_AbsoluteX() {
auto address = Address_Absolute(); auto address = Address_Absolute();
const auto page = address.high; const auto page = address.high;
address += X(); address += X();
return { address, address.high != page }; return { address, page };
} }
std::pair<EightBit::register16_t, bool> EightBit::MOS6502::Address_AbsoluteY() { std::pair<EightBit::register16_t, uint8_t> EightBit::MOS6502::Address_AbsoluteY() {
auto address = Address_Absolute(); auto address = Address_Absolute();
const auto page = address.high; const auto page = address.high;
address += Y(); address += Y();
return { address, address.high != page }; return { address, page };
} }
EightBit::register16_t EightBit::MOS6502::Address_IndexedIndirectX() { EightBit::register16_t EightBit::MOS6502::Address_IndexedIndirectX() {
return getWordPaged(0, Address_ZeroPageX()); return getWordPaged(0, Address_ZeroPageX());
} }
std::pair<EightBit::register16_t, bool> EightBit::MOS6502::Address_IndirectIndexedY() { std::pair<EightBit::register16_t, uint8_t> EightBit::MOS6502::Address_IndirectIndexedY() {
auto address = Address_ZeroPageIndirect(); auto address = Address_ZeroPageIndirect();
const auto page = address.high; const auto page = address.high;
address += Y(); address += Y();
return { address, address.high != page }; return { address, page };
} }
EightBit::register16_t EightBit::MOS6502::Address_relative_byte() { EightBit::register16_t EightBit::MOS6502::Address_relative_byte() {
@ -458,17 +458,19 @@ uint8_t EightBit::MOS6502::AM_ZeroPage() {
} }
uint8_t EightBit::MOS6502::AM_AbsoluteX() { uint8_t EightBit::MOS6502::AM_AbsoluteX() {
const auto [address, paged] = Address_AbsoluteX(); const auto [address, page] = Address_AbsoluteX();
if (UNLIKELY(paged)) auto possible = getBytePaged(page, address.low);
addCycle(); if (UNLIKELY(page != address.high))
return Processor::busRead(address); possible = Processor::busRead(address);
return possible;
} }
uint8_t EightBit::MOS6502::AM_AbsoluteY() { uint8_t EightBit::MOS6502::AM_AbsoluteY() {
const auto [address, paged] = Address_AbsoluteY(); const auto[address, page] = Address_AbsoluteY();
if (UNLIKELY(paged)) auto possible = getBytePaged(page, address.low);
addCycle(); if (UNLIKELY(page != address.high))
return Processor::busRead(address); possible = Processor::busRead(address);
return possible;
} }
uint8_t EightBit::MOS6502::AM_ZeroPageX() { uint8_t EightBit::MOS6502::AM_ZeroPageX() {
@ -484,10 +486,11 @@ uint8_t EightBit::MOS6502::AM_IndexedIndirectX() {
} }
uint8_t EightBit::MOS6502::AM_IndirectIndexedY() { uint8_t EightBit::MOS6502::AM_IndirectIndexedY() {
const auto [address, paged] = Address_IndirectIndexedY(); const auto [address, page] = Address_IndirectIndexedY();
if (UNLIKELY(paged)) auto possible = getBytePaged(page, address.low);
addCycle(); if (page != address.high)
return Processor::busRead(address); possible = Processor::busRead(address);
return possible;
} }
//// ////