From ad1ab61f744a852f194020061b9a9a6980293d73 Mon Sep 17 00:00:00 2001 From: Adrian Conlon <98398945+AdrianConlon@users.noreply.github.com> Date: Mon, 18 Mar 2024 21:38:51 +0000 Subject: [PATCH] Small 6502 consolidation --- M6502/inc/mos6502.h | 18 +++--------------- M6502/src/mos6502.cpp | 3 +-- 2 files changed, 4 insertions(+), 17 deletions(-) diff --git a/M6502/inc/mos6502.h b/M6502/inc/mos6502.h index 04c1df9..b93bbe0 100644 --- a/M6502/inc/mos6502.h +++ b/M6502/inc/mos6502.h @@ -105,7 +105,7 @@ namespace EightBit { // Addressing modes - constexpr void noteFixedPage(uint8_t page) noexcept { m_fixed_page = page; } + constexpr void noteFixedAddress(register16_t fixed) noexcept { m_fixed_page = fixed.high; BUS().ADDRESS().low = fixed.low; } constexpr void Address_Immediate() noexcept { BUS().ADDRESS() = PC()++; } void Address_Absolute() noexcept { BUS().ADDRESS() = fetchWord(); } @@ -115,23 +115,11 @@ namespace EightBit { void Address_ZeroPageWithIndex(uint8_t index) noexcept { AM_ZeroPage(); BUS().ADDRESS().low += index; } void Address_ZeroPageX() noexcept { Address_ZeroPageWithIndex(X()); } void Address_ZeroPageY() noexcept { Address_ZeroPageWithIndex(Y()); } + void Address_AbsoluteWithIndex(uint8_t index) noexcept { Address_Absolute(); noteFixedAddress(BUS().ADDRESS() + index); } void Address_AbsoluteX() noexcept { Address_AbsoluteWithIndex(X()); } void Address_AbsoluteY() noexcept { Address_AbsoluteWithIndex(Y()); } void Address_IndexedIndirectX() noexcept { Address_ZeroPageX(); BUS().ADDRESS() = getWordPaged(); } - - void Address_AbsoluteWithIndex(uint8_t index) noexcept { - Address_Absolute(); - const auto address = BUS().ADDRESS() + index; - noteFixedPage(address.high); - BUS().ADDRESS().low = address.low; - } - - void Address_IndirectIndexedY() noexcept { - Address_ZeroPageIndirect(); - const auto address = BUS().ADDRESS() + Y(); - noteFixedPage(address.high); - BUS().ADDRESS().low = address.low; - } + void Address_IndirectIndexedY() noexcept { Address_ZeroPageIndirect(); noteFixedAddress(BUS().ADDRESS() + Y()); } // Addressing modes, with read diff --git a/M6502/src/mos6502.cpp b/M6502/src/mos6502.cpp index a6041c9..75cab5a 100644 --- a/M6502/src/mos6502.cpp +++ b/M6502/src/mos6502.cpp @@ -428,9 +428,8 @@ void EightBit::MOS6502::branch(const int condition) noexcept { if (condition) { swallow(); const auto address = PC() + relative; - noteFixedPage(address.high); + noteFixedAddress(address); jump(address); - BUS().ADDRESS().low = address.low; maybe_fixup(); } }