From ff01ed5f6faa725596653d469627d8b7816cc991 Mon Sep 17 00:00:00 2001 From: Adrian Conlon <98398945+AdrianConlon@users.noreply.github.com> Date: Tue, 5 Mar 2024 08:56:15 +0000 Subject: [PATCH] A few small simplifications --- M6502/src/mos6502.cpp | 29 +++++++++++++---------------- 1 file changed, 13 insertions(+), 16 deletions(-) diff --git a/M6502/src/mos6502.cpp b/M6502/src/mos6502.cpp index 5b87bc3..1d1cd9d 100644 --- a/M6502/src/mos6502.cpp +++ b/M6502/src/mos6502.cpp @@ -435,27 +435,25 @@ EightBit::register16_t EightBit::MOS6502::Address_Indirect() noexcept { } EightBit::register16_t EightBit::MOS6502::Address_ZeroPageX() noexcept { - const auto address = Address_ZeroPage(); - memoryRead(address); - return register16_t(address.low + X(), 0); + BUS().ADDRESS() = Address_ZeroPage(); + memoryRead(); + return register16_t(BUS().ADDRESS().low + X(), 0); } EightBit::register16_t EightBit::MOS6502::Address_ZeroPageY() noexcept { - const auto address = Address_ZeroPage(); - memoryRead(address); - return register16_t(address.low + Y(), 0); + BUS().ADDRESS() = Address_ZeroPage(); + memoryRead(); + return register16_t(BUS().ADDRESS().low + Y(), 0); } std::pair EightBit::MOS6502::Address_AbsoluteX() noexcept { const auto address = Address_Absolute(); - const auto page = address.high; - return { address + X(), page }; + return { address + X(), address.high }; } std::pair EightBit::MOS6502::Address_AbsoluteY() noexcept { const auto address = Address_Absolute(); - const auto page = address.high; - return { address + Y(), page }; + return { address + Y(), address.high }; } EightBit::register16_t EightBit::MOS6502::Address_IndexedIndirectX() noexcept { @@ -465,12 +463,11 @@ EightBit::register16_t EightBit::MOS6502::Address_IndexedIndirectX() noexcept { std::pair EightBit::MOS6502::Address_IndirectIndexedY() noexcept { const auto address = Address_ZeroPageIndirect(); - const auto page = address.high; - return { address + Y(), page }; + return { address + Y(), address.high }; } 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 { const auto [address, page] = Address_AbsoluteY(); fixup(address, page); - memoryWrite(address, A() & X() & (address.high + 1)); + memoryWrite(A() & X() & (address.high + 1)); } void EightBit::MOS6502::sha_IndirectIndexedY() noexcept { const auto [address, page] = Address_IndirectIndexedY(); fixup(address, page); - memoryWrite(address, A() & X() & (address.high + 1)); + memoryWrite(A() & X() & (address.high + 1)); } void EightBit::MOS6502::sya_AbsoluteX() noexcept { @@ -737,7 +734,7 @@ void EightBit::MOS6502::tas_AbsoluteY() noexcept { void EightBit::MOS6502::las_AbsoluteY() noexcept { const auto [address, page] = Address_AbsoluteY(); maybe_fixup(address, page); - A() = X() = S() = through(memoryRead(address) & S()); + A() = X() = S() = through(memoryRead() & S()); } void EightBit::MOS6502::sxa_AbsoluteY() noexcept {