Zero page indirection should completely ignore the high byte of the address line.

Signed-off-by: Adrian Conlon <Adrian.conlon@gmail.com>
This commit is contained in:
Adrian Conlon 2017-12-28 15:16:21 +00:00
parent bfa1c07ea4
commit dcf99bf65d
2 changed files with 15 additions and 5 deletions

View File

@ -75,6 +75,8 @@ namespace EightBit {
adjustNegative(datum); adjustNegative(datum);
} }
void getWord(uint8_t offset, register16_t& output);
void getWord(register16_t& output); void getWord(register16_t& output);
void getWord(uint16_t offset, register16_t& output); void getWord(uint16_t offset, register16_t& output);
void getWord(const register16_t& offset, register16_t& output); void getWord(const register16_t& offset, register16_t& output);
@ -97,7 +99,7 @@ namespace EightBit {
void Address_ZeroPageIndirect() { void Address_ZeroPageIndirect() {
Address_ZeroPage(); Address_ZeroPage();
getWord(MEMPTR(), MEMPTR()); getWord(MEMPTR().low, MEMPTR());
} }
void Address_Indirect() { void Address_Indirect() {
@ -127,7 +129,7 @@ namespace EightBit {
void Address_IndexedIndirectX() { void Address_IndexedIndirectX() {
Address_ZeroPageX(); Address_ZeroPageX();
getWord(MEMPTR(), MEMPTR()); getWord(MEMPTR().low, MEMPTR());
} }
void Address_IndirectIndexedY() { void Address_IndirectIndexedY() {

View File

@ -63,6 +63,14 @@ void EightBit::MOS6502::reset() {
getWord(RSTvector, PC()); 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) { void EightBit::MOS6502::getWord(register16_t& output) {
output.low = getByte(); output.low = getByte();
BUS().ADDRESS().word++; BUS().ADDRESS().word++;
@ -502,12 +510,12 @@ void EightBit::MOS6502::Branch(bool flag) {
// //
void EightBit::MOS6502::PHP() { void EightBit::MOS6502::PHP() {
setFlag(P(), BF); //setFlag(P(), BF);
push(P()); push(P() | BF);
} }
void EightBit::MOS6502::PLP() { void EightBit::MOS6502::PLP() {
P() = pop() | RF; P() = pop() | RF & (~BF);
} }
// //