Correct some page crossing conditions affecting 6502 cycle counts.

Signed-off-by: Adrian Conlon <Adrian.conlon@gmail.com>
This commit is contained in:
Adrian Conlon 2017-12-29 14:49:53 +00:00
parent 0604d5cf22
commit 412a44fafd
3 changed files with 18 additions and 13 deletions

View File

@ -113,14 +113,18 @@ namespace EightBit {
MEMPTR().low += Y();
}
void Address_AbsoluteX() {
bool Address_AbsoluteX() {
Address_Absolute();
const auto page = MEMPTR().high;
MEMPTR().word += X();
return MEMPTR().high != page;
}
void Address_AbsoluteY() {
bool Address_AbsoluteY() {
Address_Absolute();
const auto page = MEMPTR().high;
MEMPTR().word += Y();
return MEMPTR().high != page;
}
void Address_IndexedIndirectX() {
@ -128,9 +132,11 @@ namespace EightBit {
getWord(0, MEMPTR().low, MEMPTR());
}
void Address_IndirectIndexedY() {
bool Address_IndirectIndexedY() {
Address_ZeroPageIndirect();
const auto page = MEMPTR().high;
MEMPTR().word += Y();
return MEMPTR().high != page;
}
#pragma endregion Addresses
@ -156,18 +162,16 @@ namespace EightBit {
}
uint8_t AM_AbsoluteX() {
Address_AbsoluteX();
BUS().ADDRESS() = MEMPTR();
if (BUS().ADDRESS().low == Mask8)
if (Address_AbsoluteX())
addCycle();
BUS().ADDRESS() = MEMPTR();
return getByte();
}
uint8_t AM_AbsoluteY() {
Address_AbsoluteY();
BUS().ADDRESS() = MEMPTR();
if (BUS().ADDRESS().low == Mask8)
if (Address_AbsoluteY())
addCycle();
BUS().ADDRESS() = MEMPTR();
return getByte();
}
@ -187,10 +191,9 @@ namespace EightBit {
}
uint8_t AM_IndirectIndexedY() {
Address_IndirectIndexedY();
BUS().ADDRESS() = MEMPTR();
if (BUS().ADDRESS().low == Mask8)
if (Address_IndirectIndexedY())
addCycle();
BUS().ADDRESS() = MEMPTR();
return getByte();
}

View File

@ -5,7 +5,7 @@ EightBit::MOS6502::MOS6502(Bus& bus)
: Processor(bus) {
m_timings = {
//// 0 1 2 3 4 5 6 7 8 9 A B C D E F
/* 0 */ 7, 6, 0, 0, 0, 4, 5, 0, 3, 2, 2, 0, 0, 4, 6, 0,
/* 0 */ 7, 6, 0, 0, 0, 3, 5, 0, 3, 2, 2, 0, 0, 4, 6, 0,
/* 1 */ 2, 5, 0, 0, 0, 4, 6, 0, 2, 4, 0, 0, 0, 4, 7, 0,
/* 2 */ 6, 6, 0, 0, 3, 3, 5, 0, 4, 2, 2, 0, 4, 4, 6, 0,
/* 3 */ 2, 5, 0, 0, 0, 4, 6, 0, 2, 4, 0, 0, 0, 4, 7, 0,

View File

@ -10,6 +10,8 @@ namespace EightBit {
Ricoh2A03(Bus& bus);
virtual ~Ricoh2A03() = default;
int clockCycles() const { return cycles(); }
protected:
virtual void SBC(uint8_t data) final;
virtual void ADC(uint8_t data) final;