From cf369d4d2b676364a0f558bb25f9f4ea901f52d5 Mon Sep 17 00:00:00 2001 From: edmccard Date: Sat, 14 Apr 2012 02:43:03 -0400 Subject: [PATCH] WIP --- src/cpu/d6502.d | 9 ++++----- test/test_decimal.d | 16 +++++++++++++--- 2 files changed, 17 insertions(+), 8 deletions(-) diff --git a/src/cpu/d6502.d b/src/cpu/d6502.d index cace916..da77b94 100644 --- a/src/cpu/d6502.d +++ b/src/cpu/d6502.d @@ -93,9 +93,6 @@ else ubyte data; } - // TODO: other methods for stopping cpu - bool keepRunning; - this(MEM memory, CLK clock) { version(RunTest) {} @@ -128,10 +125,11 @@ else (N & 0x80); } + bool keepRunning; + final void run(bool continuous) { keepRunning = continuous; - // TODO debugging info? ubyte opcode; static if (!opArray) { @@ -139,7 +137,8 @@ else ushort address, base; ubyte data; } - do { + do + { version(Cumulative) { static if (!opArray) cycles = 1; diff --git a/test/test_decimal.d b/test/test_decimal.d index 8c690b7..0f5c5f6 100644 --- a/test/test_decimal.d +++ b/test/test_decimal.d @@ -218,8 +218,9 @@ version(Benchmark) { auto runner = new BreakRunner(mem); auto cpu = new T(runner, runner); + runner.keepRunning = &cpu.keepRunning; setPC(cpu, 0x8000); - try { cpu.run(true); } catch (StopException e) {} + cpu.run(true); } else { @@ -243,6 +244,7 @@ version(Benchmark) final class BreakRunner { TestMemory* mem; + bool* keepRunning; this(ref TestMemory mem) { @@ -251,8 +253,16 @@ version(Benchmark) final ubyte read(ushort addr) { - if (addr == 0xFFFE) throw new StopException("BRK"); - return mem.read(addr); + if (addr == 0xfffe) + { + *keepRunning = false; + return 0x00; + } + else if (addr == 0xffff) + { + return 0x80; + } + else return mem.read(addr); } final void write(ushort addr, ubyte val)