A few small simplifications

This commit is contained in:
Adrian Conlon 2024-03-05 08:56:15 +00:00
parent 8369e0d976
commit ff01ed5f6f

View File

@ -435,27 +435,25 @@ EightBit::register16_t EightBit::MOS6502::Address_Indirect() noexcept {
} }
EightBit::register16_t EightBit::MOS6502::Address_ZeroPageX() noexcept { EightBit::register16_t EightBit::MOS6502::Address_ZeroPageX() noexcept {
const auto address = Address_ZeroPage(); BUS().ADDRESS() = Address_ZeroPage();
memoryRead(address); memoryRead();
return register16_t(address.low + X(), 0); return register16_t(BUS().ADDRESS().low + X(), 0);
} }
EightBit::register16_t EightBit::MOS6502::Address_ZeroPageY() noexcept { EightBit::register16_t EightBit::MOS6502::Address_ZeroPageY() noexcept {
const auto address = Address_ZeroPage(); BUS().ADDRESS() = Address_ZeroPage();
memoryRead(address); memoryRead();
return register16_t(address.low + Y(), 0); return register16_t(BUS().ADDRESS().low + Y(), 0);
} }
std::pair<EightBit::register16_t, uint8_t> EightBit::MOS6502::Address_AbsoluteX() noexcept { std::pair<EightBit::register16_t, uint8_t> EightBit::MOS6502::Address_AbsoluteX() noexcept {
const auto address = Address_Absolute(); const auto address = Address_Absolute();
const auto page = address.high; return { address + X(), address.high };
return { address + X(), page };
} }
std::pair<EightBit::register16_t, uint8_t> EightBit::MOS6502::Address_AbsoluteY() noexcept { std::pair<EightBit::register16_t, uint8_t> EightBit::MOS6502::Address_AbsoluteY() noexcept {
const auto address = Address_Absolute(); const auto address = Address_Absolute();
const auto page = address.high; return { address + Y(), address.high };
return { address + Y(), page };
} }
EightBit::register16_t EightBit::MOS6502::Address_IndexedIndirectX() noexcept { EightBit::register16_t EightBit::MOS6502::Address_IndexedIndirectX() noexcept {
@ -465,12 +463,11 @@ EightBit::register16_t EightBit::MOS6502::Address_IndexedIndirectX() noexcept {
std::pair<EightBit::register16_t, uint8_t> EightBit::MOS6502::Address_IndirectIndexedY() noexcept { std::pair<EightBit::register16_t, uint8_t> EightBit::MOS6502::Address_IndirectIndexedY() noexcept {
const auto address = Address_ZeroPageIndirect(); const auto address = Address_ZeroPageIndirect();
const auto page = address.high; return { address + Y(), address.high };
return { address + Y(), page };
} }
EightBit::register16_t EightBit::MOS6502::Address_relative_byte() noexcept { EightBit::register16_t EightBit::MOS6502::Address_relative_byte() noexcept {
return PC() + (int8_t)fetchByte(); return PC() + int8_t(fetchByte());
} }
//// ////
@ -714,13 +711,13 @@ void EightBit::MOS6502::jam() noexcept {
void EightBit::MOS6502::sha_AbsoluteY() noexcept { void EightBit::MOS6502::sha_AbsoluteY() noexcept {
const auto [address, page] = Address_AbsoluteY(); const auto [address, page] = Address_AbsoluteY();
fixup(address, page); fixup(address, page);
memoryWrite(address, A() & X() & (address.high + 1)); memoryWrite(A() & X() & (address.high + 1));
} }
void EightBit::MOS6502::sha_IndirectIndexedY() noexcept { void EightBit::MOS6502::sha_IndirectIndexedY() noexcept {
const auto [address, page] = Address_IndirectIndexedY(); const auto [address, page] = Address_IndirectIndexedY();
fixup(address, page); fixup(address, page);
memoryWrite(address, A() & X() & (address.high + 1)); memoryWrite(A() & X() & (address.high + 1));
} }
void EightBit::MOS6502::sya_AbsoluteX() noexcept { void EightBit::MOS6502::sya_AbsoluteX() noexcept {
@ -737,7 +734,7 @@ void EightBit::MOS6502::tas_AbsoluteY() noexcept {
void EightBit::MOS6502::las_AbsoluteY() noexcept { void EightBit::MOS6502::las_AbsoluteY() noexcept {
const auto [address, page] = Address_AbsoluteY(); const auto [address, page] = Address_AbsoluteY();
maybe_fixup(address, page); maybe_fixup(address, page);
A() = X() = S() = through(memoryRead(address) & S()); A() = X() = S() = through(memoryRead() & S());
} }
void EightBit::MOS6502::sxa_AbsoluteY() noexcept { void EightBit::MOS6502::sxa_AbsoluteY() noexcept {