From 898a2bc7ea79dc098e2784b448f889def2de9343 Mon Sep 17 00:00:00 2001 From: Adrian Conlon <98398945+AdrianConlon@users.noreply.github.com> Date: Sat, 3 May 2025 02:09:31 +0100 Subject: [PATCH] Try to bring the Z80 fusetest back to life --- EightBit/Processor.cs | 16 ++++++++++++++++ Z80/Z80.FuseTest/TestRunner.cs | 8 ++++---- 2 files changed, 20 insertions(+), 4 deletions(-) diff --git a/EightBit/Processor.cs b/EightBit/Processor.cs index 7269661..538fd15 100644 --- a/EightBit/Processor.cs +++ b/EightBit/Processor.cs @@ -13,6 +13,14 @@ namespace EightBit #endregion + #region Instruction execution events + + public event EventHandler? ReadingMemory; + public event EventHandler? ReadMemory; + public event EventHandler? WritingMemory; + public event EventHandler? WroteMemory; + + #endregion private PinLevel _resetLine; private PinLevel _intLine; @@ -142,6 +150,14 @@ namespace EightBit protected virtual void HandleINT() => this.RaiseINT(); + protected void OnReadingMemory() => this.ReadingMemory?.Invoke(this, EventArgs.Empty); + + protected void OnReadMemory() => this.ReadMemory?.Invoke(this, EventArgs.Empty); + + protected void OnWritingMemory() => this.WritingMemory?.Invoke(this, EventArgs.Empty); + + protected void OnWroteMemory() => this.WroteMemory?.Invoke(this, EventArgs.Empty); + protected void MemoryWrite(byte low, byte high) { this.Bus.Address.Assign(low, high); diff --git a/Z80/Z80.FuseTest/TestRunner.cs b/Z80/Z80.FuseTest/TestRunner.cs index 8477d43..63585fc 100644 --- a/Z80/Z80.FuseTest/TestRunner.cs +++ b/Z80/Z80.FuseTest/TestRunner.cs @@ -98,8 +98,8 @@ namespace Z80.FuseTest public override void Initialize() { - this.ReadByte += this.Event_ReadByte; - this.WrittenByte += this.Event_WrittenByte; + this.cpu.ReadMemory += this.Cpu_ReadMemory; + this.cpu.WroteMemory += this.Cpu_WroteMemory; this.ports.ReadPort += this.Ports_ReadPort; this.ports.WrittenPort += this.Ports_WrittenPort; this.cpu.ExecutedInstruction += this.Cpu_ExecutedInstruction; @@ -107,8 +107,8 @@ namespace Z80.FuseTest private void Ports_ReadPort(object? sender, EventArgs e) => this.AddActualEvent("PR"); private void Ports_WrittenPort(object? sender, EventArgs e) => this.AddActualEvent("PW"); - private void Event_ReadByte(object? sender, EventArgs e) => this.AddActualEvent("MR"); - private void Event_WrittenByte(object? sender, EventArgs e) => this.AddActualEvent("MW"); + private void Cpu_ReadMemory(object? sender, EventArgs e) => this.AddActualEvent("MR"); + private void Cpu_WroteMemory(object? sender, EventArgs e) => this.AddActualEvent("MW"); private void AddActualEvent(string specifier) {