Pass all Klaus Dormann tests again: correct AM_10 write algorithm.

Signed-off-by: Adrian.Conlon <adrian.conlon@gmail.com>
This commit is contained in:
Adrian.Conlon 2017-08-07 21:02:31 +01:00
parent ab20fc6107
commit aa720c4c12
2 changed files with 12 additions and 18 deletions

View File

@ -4,6 +4,7 @@
#include <string> #include <string>
#include <array> #include <array>
#include <functional> #include <functional>
#include <cassert>
#include "Memory.h" #include "Memory.h"
#include "Processor.h" #include "Processor.h"
@ -91,8 +92,6 @@ namespace EightBit {
void pushWord(register16_t value); void pushWord(register16_t value);
void popWord(register16_t& output); void popWord(register16_t& output);
virtual uint8_t fetchByte() override;
#pragma region 6502 addressing modes #pragma region 6502 addressing modes
#pragma region Addresses #pragma region Addresses
@ -386,25 +385,25 @@ namespace EightBit {
return 0xff; return 0xff;
} }
void AM_10(int bbb, uint8_t value) { void AM_10(int bbb, uint8_t value, bool fetched = false) {
switch (bbb) { switch (bbb) {
case 0b000: case 0b000:
assert(false); assert(false);
break; break;
case 0b001: case 0b001:
AM_ZeroPage(value); fetched ? m_memory.write(MEMPTR(), value) : AM_ZeroPage(value);
break; break;
case 0b010: case 0b010:
AM_A(value); AM_A(value);
break; break;
case 0b011: case 0b011:
AM_Absolute(value); fetched ? m_memory.write(MEMPTR(), value) : AM_Absolute(value);
break; break;
case 0b101: case 0b101:
AM_ZeroPageX(value); fetched ? m_memory.write(MEMPTR(), value) : AM_ZeroPageX(value);
break; break;
case 0b111: case 0b111:
AM_AbsoluteX(value); fetched ? m_memory.write(MEMPTR(), value) : AM_AbsoluteX(value);
break; break;
case 0b100: case 0b100:
case 0b110: case 0b110:
@ -471,37 +470,37 @@ namespace EightBit {
void ASL(int bbb) { void ASL(int bbb) {
auto operand = AM_10(bbb); auto operand = AM_10(bbb);
ASL(operand); ASL(operand);
AM_10(bbb, operand); AM_10(bbb, operand, true);
} }
void ROL(int bbb) { void ROL(int bbb) {
auto operand = AM_10(bbb); auto operand = AM_10(bbb);
ROL(operand); ROL(operand);
AM_10(bbb, operand); AM_10(bbb, operand, true);
} }
void LSR(int bbb) { void LSR(int bbb) {
auto operand = AM_10(bbb); auto operand = AM_10(bbb);
LSR(operand); LSR(operand);
AM_10(bbb, operand); AM_10(bbb, operand, true);
} }
void ROR(int bbb) { void ROR(int bbb) {
auto operand = AM_10(bbb); auto operand = AM_10(bbb);
ROR(operand); ROR(operand);
AM_10(bbb, operand); AM_10(bbb, operand, true);
} }
void DEC(int bbb) { void DEC(int bbb) {
auto operand = AM_10(bbb); auto operand = AM_10(bbb);
adjustNZ(--operand); adjustNZ(--operand);
AM_10(bbb, operand); AM_10(bbb, operand, true);
} }
void INC(int bbb) { void INC(int bbb) {
auto operand = AM_10(bbb); auto operand = AM_10(bbb);
adjustNZ(++operand); adjustNZ(++operand);
AM_10(bbb, operand); AM_10(bbb, operand, true);
} }
void ROR(uint8_t& output); void ROR(uint8_t& output);

View File

@ -365,11 +365,6 @@ void EightBit::MOS6502::popWord(register16_t& output) {
output.high = popByte(); output.high = popByte();
} }
uint8_t EightBit::MOS6502::fetchByte() {
m_memory.ADDRESS().word = PC().word++;
return getByte();
}
//// ////
void EightBit::MOS6502::ROR(uint8_t& output) { void EightBit::MOS6502::ROR(uint8_t& output) {