From dcf99bf65d08fc6c8a3c34dcb282bf34f7bc655b Mon Sep 17 00:00:00 2001 From: Adrian Conlon Date: Thu, 28 Dec 2017 15:16:21 +0000 Subject: [PATCH] Zero page indirection should completely ignore the high byte of the address line. Signed-off-by: Adrian Conlon --- M6502/inc/mos6502.h | 6 ++++-- M6502/src/mos6502.cpp | 14 +++++++++++--- 2 files changed, 15 insertions(+), 5 deletions(-) diff --git a/M6502/inc/mos6502.h b/M6502/inc/mos6502.h index 180efec..c924c9f 100644 --- a/M6502/inc/mos6502.h +++ b/M6502/inc/mos6502.h @@ -75,6 +75,8 @@ namespace EightBit { adjustNegative(datum); } + void getWord(uint8_t offset, register16_t& output); + void getWord(register16_t& output); void getWord(uint16_t offset, register16_t& output); void getWord(const register16_t& offset, register16_t& output); @@ -97,7 +99,7 @@ namespace EightBit { void Address_ZeroPageIndirect() { Address_ZeroPage(); - getWord(MEMPTR(), MEMPTR()); + getWord(MEMPTR().low, MEMPTR()); } void Address_Indirect() { @@ -127,7 +129,7 @@ namespace EightBit { void Address_IndexedIndirectX() { Address_ZeroPageX(); - getWord(MEMPTR(), MEMPTR()); + getWord(MEMPTR().low, MEMPTR()); } void Address_IndirectIndexedY() { diff --git a/M6502/src/mos6502.cpp b/M6502/src/mos6502.cpp index 38ef66c..5eb6563 100644 --- a/M6502/src/mos6502.cpp +++ b/M6502/src/mos6502.cpp @@ -63,6 +63,14 @@ void EightBit::MOS6502::reset() { getWord(RSTvector, PC()); } +void EightBit::MOS6502::getWord(uint8_t offset, register16_t& output) { + BUS().ADDRESS().low = offset; + BUS().ADDRESS().high = 0; + output.low = getByte(); + BUS().ADDRESS().low++; + output.high = getByte(); +} + void EightBit::MOS6502::getWord(register16_t& output) { output.low = getByte(); BUS().ADDRESS().word++; @@ -502,12 +510,12 @@ void EightBit::MOS6502::Branch(bool flag) { // void EightBit::MOS6502::PHP() { - setFlag(P(), BF); - push(P()); + //setFlag(P(), BF); + push(P() | BF); } void EightBit::MOS6502::PLP() { - P() = pop() | RF; + P() = pop() | RF & (~BF); } //