simplification and unification of build stuff

This commit is contained in:
Adrian Conlon
2026-02-16 11:15:58 +00:00
parent e1bf58afbc
commit a8ef9aa7db
28 changed files with 88 additions and 44 deletions

View File

@@ -14,18 +14,21 @@ namespace EightBit
public override void PokeWord(ushort address, Register16 value)
{
ArgumentNullException.ThrowIfNull(value);
this.Bus.Poke(address, value.High);
this.Bus.Poke(++address, value.Low);
}
protected override void FetchInto(Register16 into)
{
ArgumentNullException.ThrowIfNull(into);
into.High = this.FetchByte();
into.Low = this.FetchByte();
}
protected override void GetInto(Register16 into)
{
ArgumentNullException.ThrowIfNull(into);
into.High = this.MemoryRead();
_ = this.Bus.Address.Increment();
into.Low = this.MemoryRead();
@@ -41,18 +44,21 @@ namespace EightBit
protected override void PopInto(Register16 into)
{
ArgumentNullException.ThrowIfNull(into);
into.High = this.Pop();
into.Low = this.Pop();
}
protected override void PushWord(Register16 value)
{
ArgumentNullException.ThrowIfNull(value);
this.Push(value.Low);
this.Push(value.High);
}
protected override void SetWord(Register16 value)
{
ArgumentNullException.ThrowIfNull(value);
this.MemoryWrite(value.High);
_ = this.Bus.Address.Increment();
this.MemoryWrite(value.Low);
@@ -60,6 +66,7 @@ namespace EightBit
protected override void SetWordPaged(Register16 value)
{
ArgumentNullException.ThrowIfNull(value);
this.MemoryWrite(value.High);
++this.Bus.Address.Low;
this.MemoryWrite(value.Low);

View File

@@ -24,13 +24,21 @@ namespace EightBit
public byte Peek(ushort absolute) => this.Reference(absolute);
public byte Peek(Register16 absolute) => this.Peek(absolute.Word);
public byte Peek(Register16 absolute)
{
ArgumentNullException.ThrowIfNull(absolute);
return this.Peek(absolute.Word);
}
public void Poke(byte value) => this.Reference() = value;
public void Poke(ushort absolute, byte value) => this.Reference(absolute) = value;
public void Poke(Register16 absolute, byte value) => this.Poke(absolute.Word, value);
public void Poke(Register16 absolute, byte value)
{
ArgumentNullException.ThrowIfNull(absolute);
this.Poke(absolute.Word, value);
}
public byte Read()
{

View File

@@ -1,7 +1,7 @@
<Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup>
<TargetFramework>net9.0</TargetFramework>
<TargetFramework>net10.0</TargetFramework>
<LangVersion>latest</LangVersion>
<ImplicitUsings>enable</ImplicitUsings>
<Nullable>enable</Nullable>
@@ -9,7 +9,7 @@
<OutputType>Exe</OutputType>
<TestingPlatformDotnetTestSupport>true</TestingPlatformDotnetTestSupport>
<EnforceCodeStyleInBuild>True</EnforceCodeStyleInBuild>
<AnalysisLevel>latest</AnalysisLevel>
<AnalysisLevel>latest-all</AnalysisLevel>
<!--
Displays error on console in addition to the log file. Note that this feature comes with a performance impact.
For more information, visit https://learn.microsoft.com/dotnet/core/testing/unit-testing-platform-integration-dotnet-test#show-failure-per-test

View File

@@ -1,13 +1,13 @@
<Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup>
<TargetFramework>net9.0</TargetFramework>
<TargetFramework>net10.0</TargetFramework>
<ImplicitUsings>enable</ImplicitUsings>
<Nullable>enable</Nullable>
<GenerateDocumentationFile>False</GenerateDocumentationFile>
<SignAssembly>False</SignAssembly>
<EnforceCodeStyleInBuild>True</EnforceCodeStyleInBuild>
<AnalysisLevel>latest-recommended</AnalysisLevel>
<AnalysisLevel>latest-all</AnalysisLevel>
<AllowUnsafeBlocks>true</AllowUnsafeBlocks>
</PropertyGroup>

View File

@@ -22,6 +22,7 @@ namespace EightBit
public byte ReadInputPort(Register16 port)
{
ArgumentNullException.ThrowIfNull(port);
ReadingPort?.Invoke(this, new PortEventArgs(port));
var value = this._input[port.Word];
ReadPort?.Invoke(this, new PortEventArgs(port));
@@ -30,12 +31,17 @@ namespace EightBit
public void WriteInputPort(ushort port, byte value) => this._input[port] = value;
public void WriteInputPort(Register16 port, byte value) => this.WriteInputPort(port.Word, value);
public void WriteInputPort(Register16 port, byte value)
{
ArgumentNullException.ThrowIfNull(port);
this.WriteInputPort(port.Word, value);
}
public void Write(Register16 port, byte value) => this.WriteOutputPort(port, value);
public void WriteOutputPort(Register16 port, byte value)
{
ArgumentNullException.ThrowIfNull(port);
WritingPort?.Invoke(this, new PortEventArgs(port));
this._output[port.Word] = value;
WrittenPort?.Invoke(this, new PortEventArgs(port));
@@ -43,6 +49,10 @@ namespace EightBit
public byte ReadOutputPort(ushort port) => this._output[port];
public byte ReadOutputPort(Register16 port) => this.ReadOutputPort(port.Word);
public byte ReadOutputPort(Register16 port)
{
ArgumentNullException.ThrowIfNull(port);
return this.ReadOutputPort(port.Word);
}
}
}

View File

@@ -285,5 +285,8 @@ namespace EightBit
protected virtual void ReturnConditionalFlag(int flag) => this.ReturnConditional(this.ConvertCondition(flag));
protected virtual void CallConditionalFlag(int flag) => this.CallConditional(this.ConvertCondition(flag));
protected virtual void CPL() => this.A = (byte)~this.A;
}
}

View File

@@ -15,18 +15,21 @@ namespace EightBit
public override void PokeWord(ushort address, Register16 value)
{
ArgumentNullException.ThrowIfNull(value);
this.Bus.Poke(address, value.Low);
this.Bus.Poke(++address, value.High);
}
protected override void FetchInto(Register16 into)
{
ArgumentNullException.ThrowIfNull(into);
into.Low = this.FetchByte();
into.High = this.FetchByte();
}
protected override void GetInto(Register16 into)
{
ArgumentNullException.ThrowIfNull(into);
into.Low = this.MemoryRead();
_ = this.Bus.Address.Increment();
into.High = this.MemoryRead();
@@ -42,18 +45,21 @@ namespace EightBit
protected override void PopInto(Register16 into)
{
ArgumentNullException.ThrowIfNull(into);
into.Low = this.Pop();
into.High = this.Pop();
}
protected override void PushWord(Register16 value)
{
ArgumentNullException.ThrowIfNull(value);
this.Push(value.High);
this.Push(value.Low);
}
protected override void SetWord(Register16 value)
{
ArgumentNullException.ThrowIfNull(value);
this.MemoryWrite(value.Low);
_ = this.Bus.Address.Increment();
this.MemoryWrite(value.High);
@@ -61,6 +67,7 @@ namespace EightBit
protected override void SetWordPaged(Register16 value)
{
ArgumentNullException.ThrowIfNull(value);
this.MemoryWrite(value.Low);
++this.Bus.Address.Low;
this.MemoryWrite(value.High);

View File

@@ -45,6 +45,7 @@ namespace EightBit
public Register16(Register16 rhs)
{
ArgumentNullException.ThrowIfNull(rhs);
this.Low = rhs.Low;
this.High = rhs.High;
}
@@ -71,7 +72,11 @@ namespace EightBit
public ref byte High => ref this._high;
public static bool operator ==(Register16 left, Register16 right) => left.Equals(right);
public static bool operator ==(Register16 left, Register16 right)
{
ArgumentNullException.ThrowIfNull(left);
return left.Equals(right);
}
public static bool operator !=(Register16 left, Register16 right) => !(left == right);
@@ -89,6 +94,7 @@ namespace EightBit
public void Assign(Register16 from)
{
ArgumentNullException.ThrowIfNull(from);
this.Low = from.Low;
this.High = from.High;
}

View File

@@ -1,7 +1,7 @@
<Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup>
<TargetFramework>net9.0</TargetFramework>
<TargetFramework>net10.0</TargetFramework>
<ImplicitUsings>enable</ImplicitUsings>
<Nullable>enable</Nullable>
<GenerateDocumentationFile>False</GenerateDocumentationFile>

View File

@@ -1,13 +1,13 @@
<Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup>
<TargetFramework>net9.0</TargetFramework>
<TargetFramework>net10.0</TargetFramework>
<ImplicitUsings>enable</ImplicitUsings>
<Nullable>enable</Nullable>
<GenerateDocumentationFile>False</GenerateDocumentationFile>
<SignAssembly>False</SignAssembly>
<EnforceCodeStyleInBuild>True</EnforceCodeStyleInBuild>
<AnalysisLevel>latest</AnalysisLevel>
<AnalysisLevel>latest-all</AnalysisLevel>
<OutputType>Exe</OutputType>
</PropertyGroup>

View File

@@ -1,7 +1,7 @@
<Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup>
<TargetFramework>net9.0</TargetFramework>
<TargetFramework>net10.0</TargetFramework>
<ImplicitUsings>enable</ImplicitUsings>
<Nullable>enable</Nullable>
<GenerateDocumentationFile>False</GenerateDocumentationFile>

View File

@@ -1,7 +1,7 @@
<Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup>
<TargetFramework>net9.0</TargetFramework>
<TargetFramework>net10.0</TargetFramework>
<ImplicitUsings>enable</ImplicitUsings>
<Nullable>enable</Nullable>
<GenerateDocumentationFile>False</GenerateDocumentationFile>

View File

@@ -1,13 +1,13 @@
<Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup>
<TargetFramework>net9.0</TargetFramework>
<TargetFramework>net10.0</TargetFramework>
<ImplicitUsings>enable</ImplicitUsings>
<Nullable>enable</Nullable>
<GenerateDocumentationFile>False</GenerateDocumentationFile>
<SignAssembly>False</SignAssembly>
<EnforceCodeStyleInBuild>True</EnforceCodeStyleInBuild>
<AnalysisLevel>latest</AnalysisLevel>
<AnalysisLevel>latest-all</AnalysisLevel>
<OutputType>Exe</OutputType>
</PropertyGroup>

View File

@@ -553,7 +553,7 @@ namespace LR35902
switch (q)
{
case 0: // LD rp,nn
this.RP(p).Assign(this.FetchWord());
this.FetchInto(this.RP(p));
break;
case 1: // ADD HL,rp
@@ -676,7 +676,7 @@ namespace LR35902
this.DAA();
break;
case 5:
this.Cpl();
this.CPL();
break;
case 6:
this.SCF();
@@ -1150,10 +1150,10 @@ namespace LR35902
this.F = AdjustZero(this.F, this.A);
}
private void Cpl()
protected override void CPL()
{
base.CPL();
this.F = SetBit(this.F, StatusBits.HC | StatusBits.NF);
this.A = (byte)~this.A;
}
private void SCF()

View File

@@ -1,7 +1,7 @@
<Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup>
<TargetFramework>net9.0</TargetFramework>
<TargetFramework>net10.0</TargetFramework>
<ImplicitUsings>enable</ImplicitUsings>
<Nullable>enable</Nullable>
<GenerateDocumentationFile>False</GenerateDocumentationFile>

View File

@@ -2,11 +2,11 @@
<PropertyGroup>
<OutputType>Exe</OutputType>
<TargetFramework>net9.0</TargetFramework>
<TargetFramework>net10.0</TargetFramework>
<ImplicitUsings>enable</ImplicitUsings>
<Nullable>enable</Nullable>
<EnforceCodeStyleInBuild>True</EnforceCodeStyleInBuild>
<AnalysisLevel>latest-recommended</AnalysisLevel>
<AnalysisLevel>latest-all</AnalysisLevel>
</PropertyGroup>
<ItemGroup>

View File

@@ -2,11 +2,11 @@
<PropertyGroup>
<OutputType>Exe</OutputType>
<TargetFramework>net9.0</TargetFramework>
<TargetFramework>net10.0</TargetFramework>
<ImplicitUsings>enable</ImplicitUsings>
<Nullable>enable</Nullable>
<EnforceCodeStyleInBuild>True</EnforceCodeStyleInBuild>
<AnalysisLevel>latest-recommended</AnalysisLevel>
<AnalysisLevel>latest-all</AnalysisLevel>
</PropertyGroup>
<ItemGroup>

View File

@@ -1,7 +1,7 @@
<Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup>
<TargetFramework>net9.0</TargetFramework>
<TargetFramework>net10.0</TargetFramework>
<ImplicitUsings>enable</ImplicitUsings>
<Nullable>enable</Nullable>
<EnforceCodeStyleInBuild>True</EnforceCodeStyleInBuild>

View File

@@ -1,7 +1,7 @@
<Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup>
<TargetFramework>net9.0</TargetFramework>
<TargetFramework>net10.0</TargetFramework>
<ImplicitUsings>enable</ImplicitUsings>
<Nullable>enable</Nullable>
<GenerateDocumentationFile>False</GenerateDocumentationFile>

View File

@@ -1,13 +1,13 @@
<Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup>
<TargetFramework>net9.0</TargetFramework>
<TargetFramework>net10.0</TargetFramework>
<ImplicitUsings>enable</ImplicitUsings>
<Nullable>enable</Nullable>
<GenerateDocumentationFile>False</GenerateDocumentationFile>
<SignAssembly>False</SignAssembly>
<EnforceCodeStyleInBuild>True</EnforceCodeStyleInBuild>
<AnalysisLevel>latest</AnalysisLevel>
<AnalysisLevel>latest-all</AnalysisLevel>
<OutputType>Exe</OutputType>
</PropertyGroup>

View File

@@ -1,7 +1,7 @@
<Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup>
<TargetFramework>net9.0</TargetFramework>
<TargetFramework>net10.0</TargetFramework>
<LangVersion>latest</LangVersion>
<ImplicitUsings>enable</ImplicitUsings>
<Nullable>enable</Nullable>
@@ -11,7 +11,7 @@
<OutputType>Exe</OutputType>
<TestingPlatformDotnetTestSupport>true</TestingPlatformDotnetTestSupport>
<EnforceCodeStyleInBuild>True</EnforceCodeStyleInBuild>
<AnalysisLevel>latest</AnalysisLevel>
<AnalysisLevel>latest-all</AnalysisLevel>
<!--
Displays error on console in addition to the log file. Note that this feature comes with a performance impact.
For more information, visit https://learn.microsoft.com/dotnet/core/testing/unit-testing-platform-integration-dotnet-test#show-failure-per-test

View File

@@ -1,7 +1,7 @@
<Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup>
<TargetFramework>net9.0</TargetFramework>
<TargetFramework>net10.0</TargetFramework>
<ImplicitUsings>enable</ImplicitUsings>
<Nullable>enable</Nullable>
<GenerateDocumentationFile>False</GenerateDocumentationFile>

View File

@@ -1,13 +1,13 @@
<Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup>
<TargetFramework>net9.0</TargetFramework>
<TargetFramework>net10.0</TargetFramework>
<ImplicitUsings>enable</ImplicitUsings>
<Nullable>enable</Nullable>
<GenerateDocumentationFile>False</GenerateDocumentationFile>
<SignAssembly>False</SignAssembly>
<EnforceCodeStyleInBuild>True</EnforceCodeStyleInBuild>
<AnalysisLevel>latest</AnalysisLevel>
<AnalysisLevel>latest-all</AnalysisLevel>
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|AnyCPU'">

View File

@@ -1,7 +1,7 @@
<Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup>
<TargetFramework>net9.0</TargetFramework>
<TargetFramework>net10.0</TargetFramework>
<ImplicitUsings>enable</ImplicitUsings>
<Nullable>enable</Nullable>
<GenerateDocumentationFile>False</GenerateDocumentationFile>

View File

@@ -2,9 +2,11 @@
<PropertyGroup>
<OutputType>Exe</OutputType>
<TargetFramework>net9.0</TargetFramework>
<TargetFramework>net10.0</TargetFramework>
<ImplicitUsings>enable</ImplicitUsings>
<Nullable>enable</Nullable>
<EnforceCodeStyleInBuild>True</EnforceCodeStyleInBuild>
<AnalysisLevel>latest-all</AnalysisLevel>
</PropertyGroup>
<ItemGroup>

View File

@@ -1,7 +1,7 @@
<Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup>
<TargetFramework>net9.0</TargetFramework>
<TargetFramework>net10.0</TargetFramework>
<ImplicitUsings>enable</ImplicitUsings>
<Nullable>enable</Nullable>
<GenerateDocumentationFile>False</GenerateDocumentationFile>

View File

@@ -522,8 +522,8 @@ namespace Z80
{
this.RefreshMemory();
}
this.OnReadMemory();
this.Tick();
this.OnReadMemory();
return this.Bus.Data;
}
@@ -1169,7 +1169,7 @@ namespace Z80
switch (q)
{
case 0: // LD rp,nn
this.RP(p).Assign(this.FetchWord());
this.FetchInto(this.RP(p));
break;
case 1: // ADD HL,rp
this.HL2().Assign(this.Add(this.HL2(), this.RP(p)));
@@ -1816,20 +1816,20 @@ namespace Z80
private byte RL(byte operand)
{
this.ClearBit(StatusBits.NF | StatusBits.HC);
var carry = this.Carry();
this.SetBit(StatusBits.CF, operand & (byte)Bits.Bit7);
var result = (byte)((operand << 1) | carry);
this.ClearBit(StatusBits.NF | StatusBits.HC);
this.AdjustXY(result);
return result;
}
private byte RR(byte operand)
{
this.ClearBit(StatusBits.NF | StatusBits.HC);
var carry = this.Carry();
this.SetBit(StatusBits.CF, operand & (byte)Bits.Bit0);
var result = (byte)((operand >> 1) | (carry << 7));
this.ClearBit(StatusBits.NF | StatusBits.HC);
this.AdjustXY(result);
return result;
}
@@ -1934,10 +1934,11 @@ namespace Z80
this.AdjustXY((byte)((this.Q ^ this.F) | this.A));
}
private void CPL()
protected override void CPL()
{
base.CPL();
this.SetBit(StatusBits.HC | StatusBits.NF);
this.AdjustXY(this.A = (byte)~this.A);
this.AdjustXY(this.A);
}
private void XHTL(Register16 exchange)

View File

@@ -1,7 +1,7 @@
<Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup>
<TargetFramework>net9.0</TargetFramework>
<TargetFramework>net10.0</TargetFramework>
<ImplicitUsings>enable</ImplicitUsings>
<Nullable>enable</Nullable>
<GenerateDocumentationFile>False</GenerateDocumentationFile>