From 99c2e2a71974e3c224798bba04cddca353c9a433 Mon Sep 17 00:00:00 2001 From: "Adrian.Conlon" Date: Mon, 7 Aug 2017 21:25:21 +0100 Subject: [PATCH] Tidy up the 10 addressing mode write set to make it clearer when memory writes occur. Signed-off-by: Adrian.Conlon --- M6502/inc/mos6502.h | 34 +++++++++++++--------------------- 1 file changed, 13 insertions(+), 21 deletions(-) diff --git a/M6502/inc/mos6502.h b/M6502/inc/mos6502.h index 7d87ba3..597cf9c 100644 --- a/M6502/inc/mos6502.h +++ b/M6502/inc/mos6502.h @@ -175,7 +175,7 @@ namespace EightBit { m_memory.ADDRESS() = MEMPTR(); if (m_memory.ADDRESS().low == Mask8) ++cycles; - return m_memory.read(); + return getByte(); } uint8_t AM_AbsoluteY() { @@ -183,7 +183,7 @@ namespace EightBit { m_memory.ADDRESS() = MEMPTR(); if (m_memory.ADDRESS().low == Mask8) ++cycles; - return m_memory.read(); + return getByte(); } uint8_t AM_ZeroPageX() { @@ -206,7 +206,7 @@ namespace EightBit { m_memory.ADDRESS() = MEMPTR(); if (m_memory.ADDRESS().low == Mask8) ++cycles; - return m_memory.read(); + return getByte(); } #pragma endregion Addressing modes, read @@ -385,26 +385,18 @@ namespace EightBit { return 0xff; } - void AM_10(int bbb, uint8_t value, bool fetched = false) { + void AM_10(int bbb, uint8_t value) { switch (bbb) { - case 0b000: - assert(false); - break; - case 0b001: - fetched ? m_memory.write(MEMPTR(), value) : AM_ZeroPage(value); - break; case 0b010: AM_A(value); break; + case 0b001: case 0b011: - fetched ? m_memory.write(MEMPTR(), value) : AM_Absolute(value); - break; case 0b101: - fetched ? m_memory.write(MEMPTR(), value) : AM_ZeroPageX(value); - break; case 0b111: - fetched ? m_memory.write(MEMPTR(), value) : AM_AbsoluteX(value); + m_memory.write(MEMPTR(), value); break; + case 0b000: case 0b100: case 0b110: throw std::domain_error("Illegal addressing mode"); @@ -470,37 +462,37 @@ namespace EightBit { void ASL(int bbb) { auto operand = AM_10(bbb); ASL(operand); - AM_10(bbb, operand, true); + AM_10(bbb, operand); } void ROL(int bbb) { auto operand = AM_10(bbb); ROL(operand); - AM_10(bbb, operand, true); + AM_10(bbb, operand); } void LSR(int bbb) { auto operand = AM_10(bbb); LSR(operand); - AM_10(bbb, operand, true); + AM_10(bbb, operand); } void ROR(int bbb) { auto operand = AM_10(bbb); ROR(operand); - AM_10(bbb, operand, true); + AM_10(bbb, operand); } void DEC(int bbb) { auto operand = AM_10(bbb); adjustNZ(--operand); - AM_10(bbb, operand, true); + AM_10(bbb, operand); } void INC(int bbb) { auto operand = AM_10(bbb); adjustNZ(++operand); - AM_10(bbb, operand, true); + AM_10(bbb, operand); } void ROR(uint8_t& output);