diff --git a/Z80/Disassembler.cs b/Z80/Disassembler.cs
index 0abdbe6..0cb31a6 100644
--- a/Z80/Disassembler.cs
+++ b/Z80/Disassembler.cs
@@ -8,10 +8,10 @@ namespace EightBit
public class Disassembler(Bus bus)
{
- private bool _prefixCB = false;
- private bool _prefixDD = false;
- private bool _prefixED = false;
- private bool _prefixFD = false;
+ private bool _prefixCB;
+ private bool _prefixDD;
+ private bool _prefixED;
+ private bool _prefixFD;
public Bus Bus { get; } = bus;
@@ -155,7 +155,7 @@ namespace EightBit
if (outputFormatSpecification)
{
output += '\t';
- output += string.Format(specification, (int)immediate, (int)absolute, relative, (int)displacement, indexedImmediate);
+ output += string.Format(CultureInfo.InvariantCulture, specification, (int)immediate, (int)absolute, relative, (int)displacement, indexedImmediate);
}
return output;
diff --git a/Z80/Z80.Test/Board.cs b/Z80/Z80.Test/Board.cs
index e763aaf..d4b7266 100644
--- a/Z80/Z80.Test/Board.cs
+++ b/Z80/Z80.Test/Board.cs
@@ -5,6 +5,7 @@
namespace Z80.Test
{
using EightBit;
+ using System.Globalization;
internal class Board : Bus
{
@@ -14,7 +15,7 @@ namespace Z80.Test
private readonly Disassembler disassembler;
private readonly MemoryMapping mapping;
- private int warmstartCount = 0;
+ private int warmstartCount;
public Board(Configuration configuration)
{
@@ -69,7 +70,7 @@ namespace Z80.Test
switch (this.CPU.C)
{
case 0x2:
- System.Console.Out.Write(this.CPU.E.ToString());
+ System.Console.Out.Write(this.CPU.E.ToString(CultureInfo.InvariantCulture));
break;
case 0x9:
for (var i = this.CPU.DE.Word; this.Peek(i) != '$'; ++i)
diff --git a/Z80/Z80.Test/Configuration.cs b/Z80/Z80.Test/Configuration.cs
index a9a1a69..28afe64 100644
--- a/Z80/Z80.Test/Configuration.cs
+++ b/Z80/Z80.Test/Configuration.cs
@@ -6,13 +6,13 @@ namespace Z80.Test
{
using EightBit;
- internal class Configuration
+ internal sealed class Configuration
{
public Configuration()
{
}
- public bool DebugMode { get; set; } = false;
+ public bool DebugMode { get; set; }
public Register16 LoadAddress { get; } = new(0x100);
diff --git a/Z80/Z80.Test/TestHarness.cs b/Z80/Z80.Test/TestHarness.cs
index eb25567..7ef86ed 100644
--- a/Z80/Z80.Test/TestHarness.cs
+++ b/Z80/Z80.Test/TestHarness.cs
@@ -9,60 +9,62 @@ namespace Z80.Test
internal class TestHarness(Configuration configuration) : IDisposable
{
- private readonly Process process = Process.GetCurrentProcess();
private readonly Stopwatch timer = new();
private readonly Board board = new(configuration);
- private long totalCycles = 0;
+ private long totalCycles;
private TimeSpan totalUserProcessorTime;
- private bool disposed = false;
+ private bool disposed;
public void Dispose()
{
- this.Dispose(true);
+ Dispose(true);
GC.SuppressFinalize(this);
}
- public long ElapsedMilliseconds => this.timer.ElapsedMilliseconds;
+ public long ElapsedMilliseconds => timer.ElapsedMilliseconds;
- public float ElapsedSeconds => this.ElapsedMilliseconds / 1000.0f;
+ public float ElapsedSeconds => ElapsedMilliseconds / 1000.0f;
- public float CyclesPerSecond => this.totalCycles / this.ElapsedSeconds;
+ public float CyclesPerSecond => totalCycles / ElapsedSeconds;
public void Run()
{
- this.timer.Start();
- var startingUsage = this.process.UserProcessorTime;
-
- this.board.Initialize();
- this.board.RaisePOWER();
-
- var cpu = this.board.CPU;
- while (cpu.Powered)
+ using var process = Process.GetCurrentProcess();
{
- this.totalCycles += cpu.Step();
- }
+ timer.Start();
+ var startingUsage = process.UserProcessorTime;
- var finishingUsage = this.process.UserProcessorTime;
- this.timer.Stop();
- this.totalUserProcessorTime = finishingUsage - startingUsage;
+ board.Initialize();
+ board.RaisePOWER();
+
+ var cpu = board.CPU;
+ while (cpu.Powered)
+ {
+ totalCycles += cpu.Step();
+ }
+
+ var finishingUsage = process.UserProcessorTime;
+ timer.Stop();
+ totalUserProcessorTime = finishingUsage - startingUsage;
+ }
}
protected virtual void Dispose(bool disposing)
{
- if (!this.disposed)
+ if (!disposed)
{
if (disposing)
{
System.Console.Out.WriteLine();
- System.Console.Out.WriteLine($"Guest cycles = {this.totalCycles:N0}");
- System.Console.Out.WriteLine($"Seconds = {this.ElapsedSeconds}");
+ System.Console.Out.WriteLine($"Guest cycles = {totalCycles:N0}");
+ System.Console.Out.WriteLine($"Seconds = {ElapsedSeconds}");
- System.Console.Out.WriteLine($"{this.CyclesPerSecond / 1000000} MHz");
- System.Console.Out.WriteLine($"Processor time = {this.totalUserProcessorTime.TotalSeconds:g}");
+ System.Console.Out.WriteLine($"{CyclesPerSecond / 1000000} MHz");
+ System.Console.Out.WriteLine($"Processor time = {totalUserProcessorTime.TotalSeconds:g}");
}
- this.disposed = true;
+ disposed = true;
}
}
}
diff --git a/Z80/Z80.Test/Z80.Test.csproj b/Z80/Z80.Test/Z80.Test.csproj
index 8512cd8..8565ced 100644
--- a/Z80/Z80.Test/Z80.Test.csproj
+++ b/Z80/Z80.Test/Z80.Test.csproj
@@ -7,7 +7,7 @@
False
False
True
- latest
+ latest-all
Exe
diff --git a/Z80/Z80.cs b/Z80/Z80.cs
index 50fb00f..75a5438 100644
--- a/Z80/Z80.cs
+++ b/Z80/Z80.cs
@@ -23,10 +23,10 @@ namespace EightBit
private RefreshRegister _refresh = new(0x7f);
- private bool _prefixCB = false;
- private bool _prefixDD = false;
- private bool _prefixED = false;
- private bool _prefixFD = false;
+ private bool _prefixCB;
+ private bool _prefixDD;
+ private bool _prefixED;
+ private bool _prefixFD;
private PinLevel _nmiLine = PinLevel.Low;
private PinLevel _m1Line = PinLevel.Low;
@@ -36,11 +36,11 @@ namespace EightBit
private PinLevel _rdLine = PinLevel.Low;
private PinLevel _wrLine = PinLevel.Low;
- private int _accumulatorFlagsSet = 0;
+ private int _accumulatorFlagsSet;
- private int _registerSet = 0;
- private sbyte _displacement = 0;
- private bool _displaced = false;
+ private int _registerSet;
+ private sbyte _displacement;
+ private bool _displaced;
public event EventHandler? RaisingNMI;
@@ -100,11 +100,11 @@ namespace EightBit
public byte IV { get; set; } = 0xff;
- public int IM { get; set; } = 0;
+ public int IM { get; set; }
- public bool IFF1 { get; set; } = false;
+ public bool IFF1 { get; set; }
- public bool IFF2 { get; set; } = false;
+ public bool IFF2 { get; set; }
public override Register16 AF => _accumulatorFlags[_accumulatorFlagsSet];
diff --git a/Z80/Z80.csproj b/Z80/Z80.csproj
index b887ba8..49e1ce8 100644
--- a/Z80/Z80.csproj
+++ b/Z80/Z80.csproj
@@ -7,7 +7,7 @@
False
False
True
- latest
+ latest-all