diff --git a/MC6809/MC6809.Test/Board.cs b/MC6809/MC6809.Test/Board.cs index 249f839..ac1dd86 100644 --- a/MC6809/MC6809.Test/Board.cs +++ b/MC6809/MC6809.Test/Board.cs @@ -23,9 +23,10 @@ namespace MC6809.Test private readonly Disassembler _disassembler; private readonly Profiler _profiler; - private ulong _totalCycleCount; private long _frameCycleCount; + private readonly Register16 _oldPC = new((ushort)Mask.Sixteen); + // The _disassembleAt and _ignoreDisassembly are used to skip pin events private ushort _disassembleAt; private bool _ignoreDisassembly; @@ -101,9 +102,13 @@ namespace MC6809.Test { Console.TreatControlCAsInput = true; - // Load our BASIC interpreter var directory = this._configuration.RomDirectory + "\\"; - LoadHexFile(directory + "ExBasROM.hex"); + + // Load our BASIC interpreter + LoadHexFile(directory + "searle\\ExBasROM.hex"); + + // Load our Sudoku solver + //LoadHexFile(directory + "6809_sudoku\\sudoku.hex"); // Catch a byte being transmitted this.ACIA.Transmitting += ACIA_Transmitting; @@ -163,8 +168,11 @@ namespace MC6809.Test private void CPU_ExecutedInstruction_Termination(object? sender, EventArgs e) { - this._totalCycleCount += (ulong)this.CPU.Cycles; - if (this._totalCycleCount > Configuration.TerminationCycles) + if (this._oldPC != this.CPU.PC) + { + this._oldPC.Assign(this.CPU.PC); + } + else { this.LowerPOWER(); } diff --git a/MC6809/MC6809.Test/Configuration.cs b/MC6809/MC6809.Test/Configuration.cs index f820db5..319a675 100644 --- a/MC6809/MC6809.Test/Configuration.cs +++ b/MC6809/MC6809.Test/Configuration.cs @@ -8,12 +8,11 @@ namespace EightBit { public static readonly ulong CyclesPerSecond = 2 * 1024 * 1024; public static readonly ulong FrameCycleInterval = CyclesPerSecond / 60; - public static readonly ulong TerminationCycles = CyclesPerSecond * 10 * 10; - + public bool DebugMode { get; set; } = false; - public bool TerminatesEarly { get; } = false; + public bool TerminatesEarly { get; } = true; - public string RomDirectory { get; } = "roms\\searle"; + public string RomDirectory { get; } = "roms"; } } \ No newline at end of file diff --git a/MC6809/MC6809.Test/Program.cs b/MC6809/MC6809.Test/Program.cs index 077aea0..fcad903 100644 --- a/MC6809/MC6809.Test/Program.cs +++ b/MC6809/MC6809.Test/Program.cs @@ -4,6 +4,8 @@ namespace EightBit { + using MC6809.Test; + internal static class Program { public static void Main(string[] args) @@ -14,7 +16,8 @@ namespace EightBit configuration.DebugMode = true; #endif - var harness = new TestHarness(configuration); + var board = new Board(configuration); + var harness = new EightBit.TestHarness(board, board.CPU); harness.Run(); } } diff --git a/MC6809/MC6809.Test/TestHarness.cs b/MC6809/MC6809.Test/TestHarness.cs deleted file mode 100644 index e120216..0000000 --- a/MC6809/MC6809.Test/TestHarness.cs +++ /dev/null @@ -1,35 +0,0 @@ -// -// Copyright (c) Adrian Conlon. All rights reserved. -// - -namespace EightBit -{ - using MC6809.Test; - using System.Diagnostics; - - internal sealed class TestHarness(Configuration configuration) - { - private readonly Stopwatch timer = new(); - private readonly Board board = new(configuration); - private long totalCycles; - - public void Run() - { - this.board.Initialize(); - this.board.RaisePOWER(); - - var cpu = this.board.CPU; - - this.timer.Start(); - while (cpu.Powered) - { - this.totalCycles += cpu.Step(); - } - - this.timer.Stop(); - - System.Console.Out.WriteLine($"\n\nGuest cycles = {this.totalCycles}"); - System.Console.Out.WriteLine($"Seconds = {this.timer.ElapsedMilliseconds / 1000.0}"); - } - } -}