1
0
mirror of https://github.com/TomHarte/CLK.git synced 2025-02-16 18:30:32 +00:00

Attempt to capture MVP and MVN in their entirety.

This commit is contained in:
Thomas Harte 2022-06-24 07:39:58 -04:00
parent 069a057a94
commit 6c638712f3

View File

@ -35,12 +35,12 @@ struct BusHandler: public CPU::MOS6502Esque::BusHandler<uint32_t> {
auto ram_value = ram.find(address); auto ram_value = ram.find(address);
switch(operation) { switch(operation) {
case BusOperation::ReadOpcode: case BusOperation::ReadOpcode:
--opcodes_remaining; if(initial_pc && *initial_pc != address) {
if(!opcodes_remaining) {
cycles.pop_back(); cycles.pop_back();
pc_overshoot = -1; pc_overshoot = -1;
throw StopException(); throw StopException();
} }
initial_pc = address;
case BusOperation::Read: case BusOperation::Read:
case BusOperation::ReadProgram: case BusOperation::ReadProgram:
case BusOperation::ReadVector: case BusOperation::ReadVector:
@ -61,6 +61,10 @@ struct BusHandler: public CPU::MOS6502Esque::BusHandler<uint32_t> {
throw StopException(); throw StopException();
break; break;
case BusOperation::InternalOperationRead:
case BusOperation::InternalOperationWrite:
break;
default: assert(false); default: assert(false);
} }
@ -73,6 +77,7 @@ struct BusHandler: public CPU::MOS6502Esque::BusHandler<uint32_t> {
inventions.clear(); inventions.clear();
cycles.clear(); cycles.clear();
pc_overshoot = 0; pc_overshoot = 0;
initial_pc = std::nullopt;
using Register = CPU::MOS6502Esque::Register; using Register = CPU::MOS6502Esque::Register;
const uint32_t pc = const uint32_t pc =
@ -81,8 +86,8 @@ struct BusHandler: public CPU::MOS6502Esque::BusHandler<uint32_t> {
inventions[pc] = ram[pc] = opcode; inventions[pc] = ram[pc] = opcode;
} }
int opcodes_remaining = 0;
int pc_overshoot = 0; int pc_overshoot = 0;
std::optional<uint32_t> initial_pc;
struct Cycle { struct Cycle {
CPU::MOS6502Esque::BusOperation operation; CPU::MOS6502Esque::BusOperation operation;
@ -185,7 +190,6 @@ void print_ram(FILE *file, const std::unordered_map<uint32_t, uint8_t> &data) {
print_registers(target, handler.processor, 0); print_registers(target, handler.processor, 0);
// Run to the second opcode fetch. // Run to the second opcode fetch.
handler.opcodes_remaining = 2;
try { try {
handler.processor.run_for(Cycles(100)); handler.processor.run_for(Cycles(100));
} catch (const StopException &) {} } catch (const StopException &) {}