Modernise some more c# code

This commit is contained in:
Adrian Conlon
2024-07-18 11:38:02 +01:00
parent 68c7d4bfbd
commit ee584867c2
17 changed files with 342 additions and 336 deletions
+8 -8
View File
@@ -19,11 +19,11 @@ namespace Z80.Test
public Board(Configuration configuration)
{
this.configuration = configuration;
this.ram = new Ram(0x10000);
this.ports = new InputOutput();
this.CPU = new Z80(this, this.ports);
this.disassembler = new Disassembler(this);
this.mapping = new MemoryMapping(this.ram, 0x0000, (ushort)Mask.Sixteen, AccessLevel.ReadWrite);
this.ram = new(0x10000);
this.ports = new();
this.CPU = new(this, this.ports);
this.disassembler = new(this);
this.mapping = new(this.ram, 0x0000, (ushort)Mask.Sixteen, AccessLevel.ReadWrite);
}
public Z80 CPU { get; }
@@ -81,7 +81,7 @@ namespace Z80.Test
}
}
private void CPU_ExecutingInstruction_CPM(object sender, System.EventArgs e)
private void CPU_ExecutingInstruction_CPM(object? sender, System.EventArgs e)
{
if (this.CPU.PC.High != 0)
{
@@ -105,8 +105,8 @@ namespace Z80.Test
}
}
private void CPU_LoweredHALT(object sender, System.EventArgs e) => this.LowerPOWER();
private void CPU_LoweredHALT(object? sender, System.EventArgs e) => this.LowerPOWER();
private void CPU_ExecutingInstruction_Debug(object sender, System.EventArgs e) => System.Console.Error.WriteLine($"{EightBit.Disassembler.State(this.CPU)}\t{this.disassembler.Disassemble(this.CPU)}");
private void CPU_ExecutingInstruction_Debug(object? sender, System.EventArgs e) => System.Console.Error.WriteLine($"{EightBit.Disassembler.State(this.CPU)}\t{this.disassembler.Disassemble(this.CPU)}");
}
}
+2 -2
View File
@@ -14,9 +14,9 @@ namespace Z80.Test
public bool DebugMode { get; set; } = false;
public Register16 LoadAddress { get; } = new Register16(0x100);
public Register16 LoadAddress { get; } = new(0x100);
public Register16 StartAddress { get; } = new Register16(0x100);
public Register16 StartAddress { get; } = new(0x100);
public string RomDirectory { get; } = "roms";
+3 -5
View File
@@ -7,16 +7,14 @@ namespace Z80.Test
using System;
using System.Diagnostics;
internal class TestHarness : IDisposable
internal class TestHarness(Configuration configuration) : IDisposable
{
private readonly Stopwatch timer = new Stopwatch();
private readonly Board board;
private readonly Stopwatch timer = new();
private readonly Board board = new(configuration);
private long totalCycles = 0;
private bool disposed = false;
public TestHarness(Configuration configuration) => this.board = new Board(configuration);
public void Dispose()
{
this.Dispose(true);
+3 -3
View File
@@ -118,13 +118,13 @@ namespace EightBit
public override Register16 HL => this.registers[this.registerSet, (int)RegisterIndex.IndexHL];
public Register16 IX { get; } = new Register16(0xffff);
public Register16 IX { get; } = new(0xffff);
public byte IXH { get => this.IX.High; set => this.IX.High = value; }
public byte IXL { get => this.IX.Low; set => this.IX.Low = value; }
public Register16 IY { get; } = new Register16(0xffff);
public Register16 IY { get; } = new(0xffff);
public byte IYH { get => this.IY.High; set => this.IY.High = value; }
@@ -410,7 +410,7 @@ namespace EightBit
this.DisableInterrupts();
this.IM = 0;
this.REFRESH = new RefreshRegister(0);
this.REFRESH = new(0);
this.IV = (byte)Mask.Eight;
this.ExxAF();