Correct a couple of cycle counting issues.

Signed-off-by: Adrian.Conlon <adrian.conlon@gmail.com>
This commit is contained in:
Adrian.Conlon 2017-08-31 01:19:51 +01:00
parent e70686c5de
commit 20c126adfc
2 changed files with 15 additions and 13 deletions

View File

@ -335,10 +335,10 @@ void EightBit::LR35902::ccf(uint8_t& a, uint8_t& f) {
int EightBit::LR35902::runRasterLines() {
m_bus.resetLY();
int cycles = 0;
int count = 0;
for (int line = 0; line < Display::RasterHeight; ++line)
cycles += runRasterLine();
return cycles;
count += runRasterLine();
return count;
}
int EightBit::LR35902::runRasterLine() {
@ -351,10 +351,10 @@ int EightBit::LR35902::runRasterLine() {
int EightBit::LR35902::runVerticalBlankLines() {
m_bus.triggerInterrupt(Bus::Interrupts::VerticalBlank);
int cycles = 0;
int count = 0;
for (int line = 0; line < (Bus::TotalLineCount - Display::RasterHeight); ++line)
cycles += runRasterLine();
return cycles;
count += runRasterLine();
return count;
}
int EightBit::LR35902::singleStep() {

View File

@ -33,13 +33,11 @@ void EightBit::MOS6502::initialise() {
}
PC().word = 0;
X() = Bit7;
Y() = 0;
A() = 0;
P() = 0;
setFlag(P(), RF);
P() = RF;
S() = Mask8;
MEMPTR().word = 0;
@ -47,7 +45,8 @@ void EightBit::MOS6502::initialise() {
int EightBit::MOS6502::step() {
ExecutingInstruction.fire(*this);
auto returned = execute(fetchByte());
cycles = 0;
auto returned = fetchExecute();
ExecutedInstruction.fire(*this);
return returned;
}
@ -344,6 +343,9 @@ int EightBit::MOS6502::execute(uint8_t cell) {
__assume(0);
}
if (cycles == 0)
throw std::logic_error("Unhandled opcode");
return cycles;
}
@ -483,7 +485,7 @@ void EightBit::MOS6502::ADC_d(uint8_t data) {
////
void EightBit::MOS6502::Branch(int8_t displacement) {
auto page = PC().high;
const auto page = PC().high;
PC().word += displacement;
if (PC().high != page)
cycles++;
@ -491,7 +493,7 @@ void EightBit::MOS6502::Branch(int8_t displacement) {
}
void EightBit::MOS6502::Branch(bool flag) {
int8_t displacement = AM_Immediate();
const int8_t displacement = AM_Immediate();
if (flag)
Branch(displacement);
}