diff --git a/M6502/inc/mos6502.h b/M6502/inc/mos6502.h index 4249f23..77a3b84 100644 --- a/M6502/inc/mos6502.h +++ b/M6502/inc/mos6502.h @@ -65,7 +65,7 @@ namespace EightBit { adjustNegative(datum); } - void getWordPaged(uint8_t page, uint8_t offset, register16_t& output); + register16_t getWordPaged(uint8_t page, uint8_t offset); uint8_t getBytePaged(uint8_t page, uint8_t offset); void setBytePaged(uint8_t page, uint8_t offset, uint8_t value); @@ -85,12 +85,12 @@ namespace EightBit { void Address_ZeroPageIndirect() { Address_ZeroPage(); - getWordPaged(0, MEMPTR().low, MEMPTR()); + MEMPTR() = getWordPaged(0, MEMPTR().low); } void Address_Indirect() { Address_Absolute(); - getWordPaged(MEMPTR().high, MEMPTR().low, MEMPTR()); + MEMPTR() = getWordPaged(MEMPTR().high, MEMPTR().low); } void Address_ZeroPageX() { @@ -119,7 +119,7 @@ namespace EightBit { void Address_IndexedIndirectX() { Address_ZeroPageX(); - getWordPaged(0, MEMPTR().low, MEMPTR()); + MEMPTR() = getWordPaged(0, MEMPTR().low); } bool Address_IndirectIndexedY() { diff --git a/M6502/src/mos6502.cpp b/M6502/src/mos6502.cpp index 8f57a56..80cefe5 100644 --- a/M6502/src/mos6502.cpp +++ b/M6502/src/mos6502.cpp @@ -47,13 +47,15 @@ int EightBit::MOS6502::step() { void EightBit::MOS6502::reset() { Processor::reset(); - getWordPaged(0xff, RSTvector, PC()); + PC() = getWordPaged(0xff, RSTvector); } -void EightBit::MOS6502::getWordPaged(uint8_t page, uint8_t offset, register16_t& output) { - output.low = getBytePaged(page, offset); +EightBit::register16_t EightBit::MOS6502::getWordPaged(uint8_t page, uint8_t offset) { + EightBit::register16_t returned; + returned.low = getBytePaged(page, offset); BUS().ADDRESS().low++; - output.high = getByte(); + returned.high = getByte(); + return returned; } uint8_t EightBit::MOS6502::getBytePaged(uint8_t page, uint8_t offset) { @@ -73,7 +75,7 @@ void EightBit::MOS6502::interrupt(uint8_t vector) { pushWord(PC()); push(P()); setFlag(P(), IF); - getWordPaged(0xff, vector, PC()); + PC() = getWordPaged(0xff, vector); } int EightBit::MOS6502::execute(uint8_t cell) { @@ -545,5 +547,5 @@ void EightBit::MOS6502::BRK() { pushWord(PC()); PHP(); setFlag(P(), IF); - getWordPaged(0xff, IRQvector, PC()); + PC() = getWordPaged(0xff, IRQvector); } diff --git a/Z80/inc/Z80.h b/Z80/inc/Z80.h index a07dd23..9c8ddf2 100644 --- a/Z80/inc/Z80.h +++ b/Z80/inc/Z80.h @@ -315,10 +315,10 @@ namespace EightBit { void retn(); void reti(); - bool jrConditionalFlag(uint8_t& f, int flag); - bool returnConditionalFlag(uint8_t& f, int flag); - bool jumpConditionalFlag(uint8_t& f, int flag); - bool callConditionalFlag(uint8_t& f, int flag); + bool jrConditionalFlag(uint8_t f, int flag); + bool returnConditionalFlag(uint8_t f, int flag); + bool jumpConditionalFlag(uint8_t f, int flag); + bool callConditionalFlag(uint8_t f, int flag); void sbc(uint8_t& f, register16_t& operand, register16_t value); void adc(uint8_t& f, register16_t& operand, register16_t value); diff --git a/Z80/src/Z80.cpp b/Z80/src/Z80.cpp index ad6c8c9..2406e32 100644 --- a/Z80/src/Z80.cpp +++ b/Z80/src/Z80.cpp @@ -73,7 +73,7 @@ void EightBit::Z80::decrement(uint8_t& f, uint8_t& operand) { setFlag(f, VF, operand == Mask7); } -bool EightBit::Z80::jrConditionalFlag(uint8_t& f, const int flag) { +bool EightBit::Z80::jrConditionalFlag(uint8_t f, const int flag) { switch (flag) { case 0: // NZ return jrConditional(!(f & ZF)); @@ -89,7 +89,7 @@ bool EightBit::Z80::jrConditionalFlag(uint8_t& f, const int flag) { throw std::logic_error("Unhandled JR conditional"); } -bool EightBit::Z80::jumpConditionalFlag(uint8_t& f, const int flag) { +bool EightBit::Z80::jumpConditionalFlag(uint8_t f, const int flag) { switch (flag) { case 0: // NZ return jumpConditional(!(f & ZF)); @@ -122,7 +122,7 @@ void EightBit::Z80::reti() { retn(); } -bool EightBit::Z80::returnConditionalFlag(uint8_t& f, const int flag) { +bool EightBit::Z80::returnConditionalFlag(uint8_t f, const int flag) { switch (flag) { case 0: // NZ return returnConditional(!(f & ZF)); @@ -146,7 +146,7 @@ bool EightBit::Z80::returnConditionalFlag(uint8_t& f, const int flag) { throw std::logic_error("Unhandled RET conditional"); } -bool EightBit::Z80::callConditionalFlag(uint8_t& f, const int flag) { +bool EightBit::Z80::callConditionalFlag(uint8_t f, const int flag) { switch (flag) { case 0: // NZ return callConditional(!(f & ZF));