diff --git a/EightBit/InputOutput.cs b/EightBit/InputOutput.cs index 2d774be..aafbc7f 100644 --- a/EightBit/InputOutput.cs +++ b/EightBit/InputOutput.cs @@ -17,31 +17,32 @@ namespace EightBit public event EventHandler? WrittenPort; - public byte Read(ushort port) => this.ReadInputPort(port); - public byte Read(Register16 port) => this.Read(port.Word); + public byte Read(Register16 port) => this.ReadInputPort(port); - public void Write(ushort port, byte value) => this.WriteOutputPort(port, value); - - public void Write(Register16 port, byte value) => this.Write(port.Word, value); - - public byte ReadInputPort(ushort port) + public byte ReadInputPort(Register16 port) { ReadingPort?.Invoke(this, new PortEventArgs(port)); - var value = this._input[port]; + var value = this._input[port.Word]; ReadPort?.Invoke(this, new PortEventArgs(port)); return value; } public void WriteInputPort(ushort port, byte value) => this._input[port] = value; - public byte ReadOutputPort(ushort port) => this._output[port]; + public void WriteInputPort(Register16 port, byte value) => this.WriteInputPort(port.Word, value); - public void WriteOutputPort(ushort port, byte value) + public void Write(Register16 port, byte value) => this.WriteOutputPort(port, value); + + public void WriteOutputPort(Register16 port, byte value) { WritingPort?.Invoke(this, new PortEventArgs(port)); - this._output[port] = value; + this._output[port.Word] = value; WrittenPort?.Invoke(this, new PortEventArgs(port)); } + + public byte ReadOutputPort(ushort port) => this._output[port]; + + public byte ReadOutputPort(Register16 port) => this.ReadOutputPort(port.Word); } } diff --git a/EightBit/PortEventArgs.cs b/EightBit/PortEventArgs.cs index a98907b..bbd7650 100644 --- a/EightBit/PortEventArgs.cs +++ b/EightBit/PortEventArgs.cs @@ -4,8 +4,8 @@ namespace EightBit { - public sealed class PortEventArgs(ushort value) : EventArgs + public sealed class PortEventArgs(Register16 value) : EventArgs { - public ushort Port { get; } = value; + public Register16 Port { get; } = value; } } diff --git a/Z80/Z80.HarteTest/Checker.cs b/Z80/Z80.HarteTest/Checker.cs index 92da725..54e9339 100644 --- a/Z80/Z80.HarteTest/Checker.cs +++ b/Z80/Z80.HarteTest/Checker.cs @@ -407,14 +407,13 @@ foreach (var port in ports) { - var value = port.Value; if (port.Type == "r") { - cpu.Ports.WriteInputPort(port.Address, value); + cpu.Ports.WriteInputPort(port.Address, port.Value); } else if (port.Type == "w") { - cpu.Ports.WriteOutputPort(port.Address, value); + cpu.Ports.WriteOutputPort(new Register16(port.Address), port.Value); } else {