Simplify ignored return value handling

This commit is contained in:
Adrian Conlon committed 2026-05-12 22:21:13 +01:00
1 parent a98b904207
commit ac200d7f76
22 files changed
+93 -93

No files matched your search

+2 -2
View File
@@ -30,7 +30,7 @@ namespace EightBit
{
ArgumentNullException.ThrowIfNull(into);
into.High = this.MemoryRead();
_ = this.Bus.Address.Increment();
this.Bus.Address.Increment();
into.Low = this.MemoryRead();
}
@@ -60,7 +60,7 @@ namespace EightBit
{
ArgumentNullException.ThrowIfNull(value);
this.MemoryWrite(value.High);
_ = this.Bus.Address.Increment();
this.Bus.Address.Increment();
this.MemoryWrite(value.Low);
}
+1 -1
View File
@@ -89,7 +89,7 @@ namespace EightBit
{
var mapped = this.Mapping(address);
var offset = address - mapped.Begin;
_ = mapped.Memory.Load(content, offset);
mapped.Memory.Load(content, offset);
}
}
}
+6 -6
View File
@@ -92,14 +92,14 @@ namespace EightBit
{
if (this.HALT.Raised())
{
_ = base.IncrementPC();
base.IncrementPC();
}
return this.PC;
}
protected override byte FetchInstruction()
{
_ = this.FetchByte();
this.FetchByte();
return this.HALT.Lowered() ? (byte)0 : this.Bus.Data;
}
@@ -150,8 +150,8 @@ namespace EightBit
protected sealed override byte Pop()
{
_ = this.MemoryRead(this.SP);
_ = this.SP.Increment();
this.MemoryRead(this.SP);
this.SP.Increment();
return this.Bus.Data;
}
@@ -178,7 +178,7 @@ namespace EightBit
protected byte ReadMemoryIndirect()
{
this.Bus.Address.Assign(this.MEMPTR);
_ = this.MEMPTR.Increment();
this.MEMPTR.Increment();
return this.MemoryRead();
}
@@ -191,7 +191,7 @@ namespace EightBit
protected void WriteMemoryIndirect(byte data)
{
this.Bus.Address.Assign(this.MEMPTR);
_ = this.MEMPTR.Increment();
this.MEMPTR.Increment();
this.MEMPTR.High = this.Bus.Data = data;
this.MemoryWrite();
}
+2 -2
View File
@@ -31,7 +31,7 @@ namespace EightBit
{
ArgumentNullException.ThrowIfNull(into);
into.Low = this.MemoryRead();
_ = this.Bus.Address.Increment();
this.Bus.Address.Increment();
into.High = this.MemoryRead();
}
@@ -61,7 +61,7 @@ namespace EightBit
{
ArgumentNullException.ThrowIfNull(value);
this.MemoryWrite(value.Low);
_ = this.Bus.Address.Increment();
this.Bus.Address.Increment();
this.MemoryWrite(value.High);
}
+1 -1
View File
@@ -208,7 +208,7 @@ namespace EightBit
protected virtual void ImmediateAddress()
{
this.Bus.Address.Assign(this.PC);
_ = this.IncrementPC();
this.IncrementPC();
}
protected virtual byte FetchByte()
+1 -1
View File
@@ -46,7 +46,7 @@ namespace Intel8080.Test
{
var programPath = this.configuration.RomDirectory + "/" + this.configuration.Program;
var loadAddress = this.configuration.LoadAddress;
_ = this.ram.Load(programPath, loadAddress.Word);
this.ram.Load(programPath, loadAddress.Word);
this.CPU.LoweredHALT += this.CPU_LoweredHALT;
this.CPU.ExecutingInstruction += this.CPU_ExecutingInstruction_CPM;
+1 -1
View File
@@ -792,7 +792,7 @@ namespace Intel8080
this.Bus.Data = exchange.High;
exchange.High = this.MEMPTR.High;
this.MemoryUpdate(2);
_ = this.Bus.Address.Decrement();
this.Bus.Address.Decrement();
this.Bus.Data = exchange.Low;
exchange.Low = this.MEMPTR.Low;
this.MemoryUpdate();
+1 -1
View File
@@ -97,7 +97,7 @@ namespace LR35902
for (var bank = 1; bank < banks; ++bank)
{
var bankedROM = new Rom();
_ = bankedROM.Load(path, 0, bankSize * bank, bankSize);
bankedROM.Load(path, 0, bankSize * bank, bankSize);
this.gameRomBanks.Add(bankedROM);
}
+1 -1
View File
@@ -153,7 +153,7 @@ namespace LR35902
public void IncrementDIV()
{
_ = this.divCounter.Increment();
this.divCounter.Increment();
this.Poke(DIV, this.divCounter.High);
}
+1 -1
View File
@@ -36,7 +36,7 @@ namespace LR35902.FuseTest
var allowedCycles = this.test.RegisterState.TStates;
try
{
_ = this.CPU.Run(allowedCycles);
this.CPU.Run(allowedCycles);
this.Check();
}
catch (InvalidOperationException error)
+8 -8
View File
@@ -243,7 +243,7 @@ namespace LR35902
private void LR35902_RaisingHALT(object? sender, EventArgs e)
{
_ = this.PC.Increment();
this.PC.Increment();
}
protected override void HandleRESET()
@@ -360,7 +360,7 @@ namespace LR35902
this.OnReadingMemory();
this.LowerMWR();
this.LowerRD();
_ = base.MemoryRead();
base.MemoryRead();
this.TickMachine();
this.RaiseRD();
this.RaiseMWR();
@@ -590,13 +590,13 @@ namespace LR35902
case 2: // GB: LDI (HL),A
this.Bus.Address.Assign(this.HL);
_ = this.HL.Increment();
this.HL.Increment();
this.MemoryWrite(this.A);
break;
case 3: // GB: LDD (HL),A
this.Bus.Address.Assign(this.HL);
_ = this.HL.Decrement();
this.HL.Decrement();
this.MemoryWrite(this.A);
break;
@@ -616,12 +616,12 @@ namespace LR35902
break;
case 2: // GB: LDI A,(HL)
this.Bus.Address.Assign(this.HL);
_ = this.HL.Increment();
this.HL.Increment();
this.A = this.MemoryRead();
break;
case 3: // GB: LDD A,(HL)
this.Bus.Address.Assign(this.HL);
_ = this.HL.Decrement();
this.HL.Decrement();
this.A = this.MemoryRead();
break;
default:
@@ -639,11 +639,11 @@ namespace LR35902
switch (q)
{
case 0: // INC rp
_ = this.RP(p).Increment();
this.RP(p).Increment();
break;
case 1: // DEC rp
_ = this.RP(p).Decrement();
this.RP(p).Decrement();
break;
default:
throw new InvalidOperationException("Invalid operation mode");
+3 -3
View File
@@ -178,7 +178,7 @@
var expectedAddress = expectedCycle.Address;
var actualAddress = actualCycle.Address;
_ = this.Check("Cycle address", expectedAddress, actualAddress);
this.Check("Cycle address", expectedAddress, actualAddress);
Debug.Assert(expectedCycle.Value is not null);
var expectedValue = (byte)expectedCycle.Value;
@@ -186,11 +186,11 @@
Debug.Assert(actualCycle.Value is not null);
var actualValue = (byte)actualCycle.Value;
_ = this.Check("Cycle value", expectedValue, actualValue);
this.Check("Cycle value", expectedValue, actualValue);
var expectedAction = expectedCycle.Type;
var actualAction = actualCycle.Type;
_ = this.Check("Cycle action", expectedAction, actualAction);
this.Check("Cycle action", expectedAction, actualAction);
}
if (actualIDX < actualCycles.Count)
+5 -5
View File
@@ -306,11 +306,11 @@ namespace M6502
#region Cycle wastage
protected void SwallowRead() => _ = this.MemoryRead(this.PC);
protected void SwallowRead() => this.MemoryRead(this.PC);
protected void SwallowPop() => _ = this.MemoryRead(this.S, 1);
protected void SwallowPop() => this.MemoryRead(this.S, 1);
protected void SwallowFetch() => _ = this.FetchByte();
protected void SwallowFetch() => this.FetchByte();
#endregion
@@ -776,7 +776,7 @@ namespace M6502
var relative = (sbyte)this.Bus.Data;
this.SwallowRead();
this.FixupBranch(relative);
this.Jump(this.Bus.Address);
this.JMP();
}
}
@@ -929,7 +929,7 @@ namespace M6502
private byte DecimalSUB(byte operand, int borrow)
{
_ = this.BinarySUB(operand, borrow);
this.BinarySUB(operand, borrow);
var data = this.Bus.Data;
var low = (byte)(LowNibble(operand) - LowNibble(data) - borrow);
+3 -3
View File
@@ -172,15 +172,15 @@
var expectedAddress = expectedCycle.Address;
var actualAddress = actualCycle.Address;
_ = this.Check("Cycle address", expectedAddress, actualAddress);
this.Check("Cycle address", expectedAddress, actualAddress);
var expectedValue = expectedCycle.Value;
var actualValue = actualCycle.Value;
_ = this.Check("Cycle value", expectedValue, actualValue);
this.Check("Cycle value", expectedValue, actualValue);
var expectedAction = expectedCycle.Type;
var actualAction = actualCycle.Type;
_ = this.Check("Cycle action", expectedAction, actualAction);
this.Check("Cycle action", expectedAction, actualAction);
}
if (actualIDX < actualCycles.Count)
+8 -8
View File
@@ -71,7 +71,7 @@ namespace M6502.Test
var programPath = this.configuration.RomDirectory + "/" + this.configuration.Program;
var loadAddress = this.configuration.LoadAddress;
_ = this.ram.Load(programPath, loadAddress.Word);
this.ram.Load(programPath, loadAddress.Word);
if (this.configuration.DebugMode)
{
@@ -196,13 +196,13 @@ namespace M6502.Test
var output = new StringBuilder();
_ = output.Append(CultureInfo.InvariantCulture, $"PC={Disassembler.DumpWordValue(address)}:");
_ = output.Append(CultureInfo.InvariantCulture, $"P={Disassembler.DumpFlags(this.CPU.P)}, ");
_ = output.Append(CultureInfo.InvariantCulture, $"A={Disassembler.DumpByteValue(this.CPU.A)}, ");
_ = output.Append(CultureInfo.InvariantCulture, $"X={Disassembler.DumpByteValue(this.CPU.X)}, ");
_ = output.Append(CultureInfo.InvariantCulture, $"Y={Disassembler.DumpByteValue(this.CPU.Y)}, ");
_ = output.Append(CultureInfo.InvariantCulture, $"S={Disassembler.DumpByteValue(this.CPU.S)}\t");
_ = output.Append(this.disassembler.Disassemble(address));
output.Append(CultureInfo.InvariantCulture, $"PC={Disassembler.DumpWordValue(address)}:");
output.Append(CultureInfo.InvariantCulture, $"P={Disassembler.DumpFlags(this.CPU.P)}, ");
output.Append(CultureInfo.InvariantCulture, $"A={Disassembler.DumpByteValue(this.CPU.A)}, ");
output.Append(CultureInfo.InvariantCulture, $"X={Disassembler.DumpByteValue(this.CPU.X)}, ");
output.Append(CultureInfo.InvariantCulture, $"Y={Disassembler.DumpByteValue(this.CPU.Y)}, ");
output.Append(CultureInfo.InvariantCulture, $"S={Disassembler.DumpByteValue(this.CPU.S)}\t");
output.Append(this.disassembler.Disassemble(address));
Console.Out.WriteLine(output.ToString());
}
+2 -2
View File
@@ -182,7 +182,7 @@
{
this.addressCycleDistributions[this.executingAddress] = addressDistribution = [];
}
_ = addressDistribution.TryGetValue(cycles, out var current);
addressDistribution.TryGetValue(cycles, out var current);
addressDistribution[cycles] = ++current;
}
@@ -194,7 +194,7 @@
{
var id = scope.ID;
// Current will be initialised to zero, if absent
_ = this.scopeCycles.TryGetValue(id, out var current);
this.scopeCycles.TryGetValue(id, out var current);
this.scopeCycles[id] = current + cycles;
}
}
+1 -1
View File
@@ -390,7 +390,7 @@ namespace M6502
private void BranchBit(bool condition)
{
_ = this.FetchByte();
this.FetchByte();
if (condition)
{
var relative = (sbyte)this.Bus.Data;
+9 -9
View File
@@ -605,8 +605,8 @@ namespace MC6809
private byte Pop(Register16 stack)
{
_ = this.MemoryRead(stack);
_ = stack.Increment();
this.MemoryRead(stack);
stack.Increment();
return this.Bus.Data;
}
@@ -626,7 +626,7 @@ namespace MC6809
protected override void ImmediateAddress()
{
this.EA.Assign(this.PC);
_ = this.IncrementPC();
this.IncrementPC();
}
private void RelativeByteAddress()
@@ -910,7 +910,7 @@ namespace MC6809
private void LBGT() => this.BranchLong(this.GT);
private void LBLE() => this.BranchLong(this.LE);
private void BranchShort(bool condition) => _ = this.Branch(this.EA, condition);
private void BranchShort(bool condition) => this.Branch(this.EA, condition);
private void BranchLong(bool condition)
{
@@ -1205,7 +1205,7 @@ namespace MC6809
{
for (int i = 0; i < ticks; i++)
{
_ = this.MemoryRead(0xff, 0xff);
this.MemoryRead(0xff, 0xff);
}
}
@@ -1213,13 +1213,13 @@ namespace MC6809
{
for (int i = 0; i < ticks; i++)
{
_ = this.MemoryRead(this.PC);
this.MemoryRead(this.PC);
}
}
private void SwallowPop(Register16 stack) => _ = this.MemoryRead(stack);
private void SwallowPop(Register16 stack) => this.MemoryRead(stack);
private void SwallowEffectiveAddress() => _ = this.MemoryRead(this.EA);
private void SwallowEffectiveAddress() => this.MemoryRead(this.EA);
private void SwallowSpin(int ticks = 1)
{
@@ -2159,7 +2159,7 @@ namespace MC6809
this.SwallowRead(2);
}
private void Test(byte data) => _ = this.Through(data);
private void Test(byte data) => this.Through(data);
private void LEAX()
{
+1 -1
View File
@@ -69,7 +69,7 @@ namespace Z80.FuseTest
var allowedCycles = this.test.RegisterState.TStates;
try
{
_ = this.cpu.Run(allowedCycles);
this.cpu.Run(allowedCycles);
this.Check();
}
catch (InvalidOperationException error)
+3 -3
View File
@@ -203,16 +203,16 @@
{
var expectedValue = expectedCycle.Value ?? throw new InvalidOperationException("Expected cycle value cannot be null.");
var actualValue = actualCycle.Value ?? throw new InvalidOperationException("Actual cycle value cannot be null.");
_ = this.Check("Cycle value", expectedValue, actualValue);
this.Check("Cycle value", expectedValue, actualValue);
}
var expectedAddress = expectedCycle.Address;
var actualAddress = actualCycle.Address;
_ = this.Check("Cycle address", expectedAddress, actualAddress);
this.Check("Cycle address", expectedAddress, actualAddress);
var expectedAction = expectedCycle.Type;
var actualAction = actualCycle.Type;
_ = this.Check("Cycle action", expectedAction, actualAction);
this.Check("Cycle action", expectedAction, actualAction);
}
if (actualIDX < actualCycles.Count)
+1 -1
View File
@@ -48,7 +48,7 @@ namespace Z80.Test
{
var programPath = this.configuration.RomDirectory + "/" + this.configuration.Program;
var loadAddress = this.configuration.LoadAddress;
_ = this.ram.Load(programPath, loadAddress.Word);
this.ram.Load(programPath, loadAddress.Word);
this.CPU.LoweredHALT += this.CPU_LoweredHALT;
this.CPU.ExecutingInstruction += this.CPU_ExecutingInstruction_CPM;
+32 -32
View File
@@ -515,7 +515,7 @@ namespace Z80
this.LowerMREQ();
this.LowerRD();
this.Tick();
_ = base.MemoryRead();
base.MemoryRead();
this.RaiseRD();
this.RaiseMREQ();
if (this.M1.Lowered())
@@ -842,7 +842,7 @@ namespace Z80
return ref this.L;
case 6:
// N.B. Write not possible, when r == 6
_ = this.MemoryRead(this.HL);
this.MemoryRead(this.HL);
return ref this.Bus.Data;
case 7:
return ref this.A;
@@ -933,7 +933,7 @@ namespace Z80
{
case 0: // Input from port with 16-bit address
this.ReadPort(this.BC);
_ = this.MEMPTR.Increment();
this.MEMPTR.Increment();
if (y != 6)
{
this.R(y, AccessLevel.WriteOnly) = this.Bus.Data; // IN r[y],(C)
@@ -944,7 +944,7 @@ namespace Z80
break;
case 1: // Output to port with 16-bit address
this.WritePort(this.BC, y == 6 ? (byte)0 : this.R(y));
_ = this.MEMPTR.Increment();
this.MEMPTR.Increment();
break;
case 2: // 16-bit add/subtract with carry
this.HL2().Assign(q switch
@@ -1237,10 +1237,10 @@ namespace Z80
switch (q)
{
case 0: // INC rp
_ = this.RP(p).Increment();
this.RP(p).Increment();
break;
case 1: // DEC rp
_ = this.RP(p).Decrement();
this.RP(p).Decrement();
break;
default:
throw new NotSupportedException("Invalid operation mode");
@@ -1562,7 +1562,7 @@ namespace Z80
this.FetchDisplacement();
}
_ = this.FetchByte(); // LD r,n
this.FetchByte(); // LD r,n
if (memoryY)
{
this.Tick(2);
@@ -1668,7 +1668,7 @@ namespace Z80
protected override byte FetchInstruction()
{
this.LowerM1();
_ = base.FetchInstruction();
base.FetchInstruction();
this.RaiseM1();
return this.Bus.Data;
}
@@ -1760,7 +1760,7 @@ namespace Z80
private Register16 ADC(Register16 operand, Register16 value)
{
_ = this.Add(operand, value, this.Carry());
this.Add(operand, value, this.Carry());
this.ClearBit(StatusBits.ZF, this.Intermediate.Word);
var beforeNegative = SignTest(operand.High);
@@ -1835,7 +1835,7 @@ namespace Z80
private void Compare(byte value)
{
_ = this.Subtract(this.A, value);
this.Subtract(this.A, value);
this.AdjustXY(value);
}
@@ -1993,7 +1993,7 @@ namespace Z80
this.Bus.Data = exchange.High;
exchange.High = this.MEMPTR.High;
this.MemoryUpdate(2);
_ = this.Bus.Address.Decrement();
this.Bus.Address.Decrement();
this.Bus.Data = exchange.Low;
exchange.Low = this.MEMPTR.Low;
this.MemoryUpdate();
@@ -2005,7 +2005,7 @@ namespace Z80
private void RepeatBlockInstruction()
{
this.MEMPTR.Assign(this.DecrementPC());
_ = this.DecrementPC();
this.DecrementPC();
this.AdjustXY(this.PC.High);
}
@@ -2013,7 +2013,7 @@ namespace Z80
private void BlockCompare()
{
_ = this.MemoryRead(this.HL);
this.MemoryRead(this.HL);
var result = (byte)(this.A - this.Bus.Data);
this.SetBit(StatusBits.PF, --this.BC.Word);
@@ -2035,15 +2035,15 @@ namespace Z80
private void CPI()
{
this.BlockCompare();
_ = this.HL.Increment();
_ = this.MEMPTR.Increment();
this.HL.Increment();
this.MEMPTR.Increment();
}
private void CPD()
{
this.BlockCompare();
_ = this.HL.Decrement();
_ = this.MEMPTR.Decrement();
this.HL.Decrement();
this.MEMPTR.Decrement();
}
#endregion
@@ -2083,7 +2083,7 @@ namespace Z80
private void BlockLoad()
{
_ = this.MemoryRead(this.HL);
this.MemoryRead(this.HL);
this.Bus.Address.Assign(this.DE);
this.MemoryUpdate();
this.Tick(2);
@@ -2099,15 +2099,15 @@ namespace Z80
private void LDI()
{
this.BlockLoad();
_ = this.HL.Increment();
_ = this.DE.Increment();
this.HL.Increment();
this.DE.Increment();
}
private void LDD()
{
this.BlockLoad();
_ = this.HL.Decrement();
_ = this.DE.Decrement();
this.HL.Decrement();
this.DE.Decrement();
}
#endregion
@@ -2195,16 +2195,16 @@ namespace Z80
{
this.BlockIn();
this.AdjustBlockInFlagsIncrement();
_ = this.HL.Increment();
_ = this.MEMPTR.Increment();
this.HL.Increment();
this.MEMPTR.Increment();
}
private void IND()
{
this.BlockIn();
this.AdjustBlockInFlagsDecrement();
_ = this.HL.Decrement();
_ = this.MEMPTR.Decrement();
this.HL.Decrement();
this.MEMPTR.Decrement();
}
#endregion
@@ -2242,7 +2242,7 @@ namespace Z80
private void BlockOut()
{
this.Tick();
_ = this.MemoryRead(this.HL);
this.MemoryRead(this.HL);
this.B = this.Decrement(this.B);
this.WritePort(this.BC);
}
@@ -2252,17 +2252,17 @@ namespace Z80
private void OUTI()
{
this.BlockOut();
_ = this.HL.Increment();
this.HL.Increment();
this.AdjustBlockOutFlags();
_ = this.MEMPTR.Increment();
this.MEMPTR.Increment();
}
private void OUTD()
{
this.BlockOut();
_ = this.HL.Decrement();
this.HL.Decrement();
this.AdjustBlockOutFlags();
_ = this.MEMPTR.Decrement();
this.MEMPTR.Decrement();
}
#endregion
@@ -2379,7 +2379,7 @@ namespace Z80
{
this.Bus.Address.Assign(port, this.A);
this.ReadPort();
_ = this.MEMPTR.Increment();
this.MEMPTR.Increment();
}
private void ReadPort()