From 2e7afb13c79eae2f66468ba3e37ed5b2b5db9f28 Mon Sep 17 00:00:00 2001 From: Thomas Harte Date: Thu, 23 Jun 2022 21:03:40 -0400 Subject: [PATCH] Exit gracefully upon a STP or WAI. --- .../Mac/Clock SignalTests/65816ComparativeTests.mm | 13 ++++++++++--- 1 file changed, 10 insertions(+), 3 deletions(-) diff --git a/OSBindings/Mac/Clock SignalTests/65816ComparativeTests.mm b/OSBindings/Mac/Clock SignalTests/65816ComparativeTests.mm index 342bf51d9..b6cab8023 100644 --- a/OSBindings/Mac/Clock SignalTests/65816ComparativeTests.mm +++ b/OSBindings/Mac/Clock SignalTests/65816ComparativeTests.mm @@ -38,6 +38,7 @@ struct BusHandler: public CPU::MOS6502Esque::BusHandler { --opcodes_remaining; if(!opcodes_remaining) { cycles.pop_back(); + pc_overshoot = -1; throw StopException(); } case BusOperation::Read: @@ -55,7 +56,12 @@ struct BusHandler: public CPU::MOS6502Esque::BusHandler { cycle.value = ram[address] = *value; break; - default: break; + case BusOperation::Ready: + case BusOperation::None: + throw StopException(); + break; + + default: assert(false); } // Don't occupy any bonus time. @@ -66,6 +72,7 @@ struct BusHandler: public CPU::MOS6502Esque::BusHandler { ram.clear(); inventions.clear(); cycles.clear(); + pc_overshoot = 0; using Register = CPU::MOS6502Esque::Register; const uint32_t pc = @@ -75,6 +82,7 @@ struct BusHandler: public CPU::MOS6502Esque::BusHandler { } int opcodes_remaining = 0; + int pc_overshoot = 0; struct Cycle { CPU::MOS6502Esque::BusOperation operation; @@ -89,7 +97,6 @@ struct BusHandler: public CPU::MOS6502Esque::BusHandler { BusHandler() : processor(*this) { // Never run the official reset procedure. processor.set_power_on(false); - } }; @@ -188,7 +195,7 @@ void print_ram(FILE *file, const std::unordered_map &data) { // Dump final state. fprintf(target, "}, \"final\": {"); - print_registers(target, handler.processor, -1); + print_registers(target, handler.processor, handler.pc_overshoot); print_ram(target, handler.ram); fprintf(target, "}, ");