mirror of
https://github.com/MoleskiCoder/EightBitNet.git
synced 2026-10-23 23:02:16 +00:00
Some small consistency changes. Interesting!
This commit is contained in:
1 parent
c191639a24
commit
110c68a54e
8 files changed
+47
-51
No files matched your search
+1
-1
@@ -48,7 +48,7 @@ namespace EightBit
|
||||
Debug.Assert(!this._writing, "Writing flag is in an invalid state");
|
||||
this.ReadingByte?.Invoke(this, EventArgs.Empty);
|
||||
this.Data = this.Reference();
|
||||
ReadByte?.Invoke(this, EventArgs.Empty);
|
||||
this.ReadByte?.Invoke(this, EventArgs.Empty);
|
||||
Debug.Assert(!this._writing, "Writing flag is in an invalid state");
|
||||
}
|
||||
|
||||
|
||||
@@ -16,21 +16,16 @@ namespace EightBit
|
||||
|
||||
public int Cycles { get; protected set; }
|
||||
|
||||
public void Tick(int extra)
|
||||
[MethodImpl(MethodImplOptions.AggressiveInlining)]
|
||||
public void Tick(int extra = 1)
|
||||
{
|
||||
for (var i = 0; i < extra; ++i)
|
||||
{
|
||||
this.Tick();
|
||||
++this.Cycles;
|
||||
this.Ticked?.Invoke(this, EventArgs.Empty);
|
||||
}
|
||||
}
|
||||
|
||||
[MethodImpl(MethodImplOptions.AggressiveInlining)]
|
||||
public void Tick()
|
||||
{
|
||||
++this.Cycles;
|
||||
Ticked?.Invoke(this, EventArgs.Empty);
|
||||
}
|
||||
|
||||
protected void ResetCycles() => this.Cycles = 0;
|
||||
}
|
||||
}
|
||||
+4
-4
@@ -25,9 +25,9 @@ namespace EightBit
|
||||
{
|
||||
if (this.POWER.Lowered())
|
||||
{
|
||||
RaisingPOWER?.Invoke(this, EventArgs.Empty);
|
||||
this.RaisingPOWER?.Invoke(this, EventArgs.Empty);
|
||||
this.POWER.Raise();
|
||||
RaisedPOWER?.Invoke(this, EventArgs.Empty);
|
||||
this.RaisedPOWER?.Invoke(this, EventArgs.Empty);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -35,9 +35,9 @@ namespace EightBit
|
||||
{
|
||||
if (this.POWER.Raised())
|
||||
{
|
||||
LoweringPOWER?.Invoke(this, EventArgs.Empty);
|
||||
this.LoweringPOWER?.Invoke(this, EventArgs.Empty);
|
||||
this.POWER.Lower();
|
||||
LoweredPOWER?.Invoke(this, EventArgs.Empty);
|
||||
this.LoweredPOWER?.Invoke(this, EventArgs.Empty);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -25,9 +25,9 @@ namespace EightBit
|
||||
public byte ReadInputPort(Register16 port)
|
||||
{
|
||||
Debug.Assert(port is not null, "port cannot be null");
|
||||
ReadingPort?.Invoke(this, new PortEventArgs(port));
|
||||
this.ReadingPort?.Invoke(this, new PortEventArgs(port));
|
||||
var value = this._input[port.Joined];
|
||||
ReadPort?.Invoke(this, new PortEventArgs(port));
|
||||
this.ReadPort?.Invoke(this, new PortEventArgs(port));
|
||||
return value;
|
||||
}
|
||||
|
||||
@@ -44,9 +44,9 @@ namespace EightBit
|
||||
public void WriteOutputPort(Register16 port, byte value)
|
||||
{
|
||||
Debug.Assert(port is not null, "port cannot be null");
|
||||
WritingPort?.Invoke(this, new PortEventArgs(port));
|
||||
this.WritingPort?.Invoke(this, new PortEventArgs(port));
|
||||
this._output[port.Joined] = value;
|
||||
WrittenPort?.Invoke(this, new PortEventArgs(port));
|
||||
this.WrittenPort?.Invoke(this, new PortEventArgs(port));
|
||||
}
|
||||
|
||||
public byte ReadOutputPort(ushort port) => this._output[port];
|
||||
|
||||
@@ -68,9 +68,9 @@ namespace EightBit
|
||||
{
|
||||
if (this.HALT.Lowered())
|
||||
{
|
||||
RaisingHALT?.Invoke(this, EventArgs.Empty);
|
||||
this.RaisingHALT?.Invoke(this, EventArgs.Empty);
|
||||
this.HALT.Raise();
|
||||
RaisedHALT?.Invoke(this, EventArgs.Empty);
|
||||
this.RaisedHALT?.Invoke(this, EventArgs.Empty);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -78,9 +78,9 @@ namespace EightBit
|
||||
{
|
||||
if (this.HALT.Raised())
|
||||
{
|
||||
LoweringHALT?.Invoke(this, EventArgs.Empty);
|
||||
this.LoweringHALT?.Invoke(this, EventArgs.Empty);
|
||||
this.HALT.Lower();
|
||||
LoweredHALT?.Invoke(this, EventArgs.Empty);
|
||||
this.LoweredHALT?.Invoke(this, EventArgs.Empty);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
+10
-10
@@ -70,12 +70,12 @@ namespace EightBit
|
||||
public virtual int Step()
|
||||
{
|
||||
this.ResetCycles();
|
||||
ExecutingInstruction?.Invoke(this, EventArgs.Empty);
|
||||
this.ExecutingInstruction?.Invoke(this, EventArgs.Empty);
|
||||
if (this.Powered)
|
||||
{
|
||||
this.PoweredStep();
|
||||
}
|
||||
ExecutedInstruction?.Invoke(this, EventArgs.Empty);
|
||||
this.ExecutedInstruction?.Invoke(this, EventArgs.Empty);
|
||||
return this.Cycles;
|
||||
}
|
||||
|
||||
@@ -117,9 +117,9 @@ namespace EightBit
|
||||
{
|
||||
if (this.RESET.Lowered())
|
||||
{
|
||||
RaisingRESET?.Invoke(this, EventArgs.Empty);
|
||||
this.RaisingRESET?.Invoke(this, EventArgs.Empty);
|
||||
this.RESET.Raise();
|
||||
RaisedRESET?.Invoke(this, EventArgs.Empty);
|
||||
this.RaisedRESET?.Invoke(this, EventArgs.Empty);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -127,9 +127,9 @@ namespace EightBit
|
||||
{
|
||||
if (this.RESET.Raised())
|
||||
{
|
||||
LoweringRESET?.Invoke(this, EventArgs.Empty);
|
||||
this.LoweringRESET?.Invoke(this, EventArgs.Empty);
|
||||
this.RESET.Lower();
|
||||
LoweredRESET?.Invoke(this, EventArgs.Empty);
|
||||
this.LoweredRESET?.Invoke(this, EventArgs.Empty);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -138,9 +138,9 @@ namespace EightBit
|
||||
{
|
||||
if (this.INT.Lowered())
|
||||
{
|
||||
RaisingINT?.Invoke(this, EventArgs.Empty);
|
||||
this.RaisingINT?.Invoke(this, EventArgs.Empty);
|
||||
this.INT.Raise();
|
||||
RaisedINT?.Invoke(this, EventArgs.Empty);
|
||||
this.RaisedINT?.Invoke(this, EventArgs.Empty);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -148,9 +148,9 @@ namespace EightBit
|
||||
{
|
||||
if (this.INT.Raised())
|
||||
{
|
||||
LoweringINT?.Invoke(this, EventArgs.Empty);
|
||||
this.LoweringINT?.Invoke(this, EventArgs.Empty);
|
||||
this.INT.Lower();
|
||||
LoweredINT?.Invoke(this, EventArgs.Empty);
|
||||
this.LoweredINT?.Invoke(this, EventArgs.Empty);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -47,11 +47,11 @@ namespace EightBit
|
||||
|
||||
public ushort Joined
|
||||
{
|
||||
get => Chip.MakeShort(this._low, this._high);
|
||||
get => Chip.MakeShort(this.Low, this.High);
|
||||
set
|
||||
{
|
||||
this._low = Chip.LowByte(value);
|
||||
this._high = Chip.HighByte(value);
|
||||
this.Low = Chip.LowByte(value);
|
||||
this.High = Chip.HighByte(value);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
+17
-16
@@ -548,6 +548,18 @@ namespace Z80
|
||||
return this.Bus.Data;
|
||||
}
|
||||
|
||||
private void HandleNMI()
|
||||
{
|
||||
this.RaiseNMI();
|
||||
this.RaiseHALT();
|
||||
this.IFF2 = this.IFF1;
|
||||
this.IFF1 = false;
|
||||
this.LowerM1();
|
||||
_ = this.Bus.Data;
|
||||
this.RaiseM1();
|
||||
this.Restart(0x66);
|
||||
}
|
||||
|
||||
protected override void HandleINT()
|
||||
{
|
||||
base.HandleINT();
|
||||
@@ -575,6 +587,11 @@ namespace Z80
|
||||
}
|
||||
}
|
||||
|
||||
protected override void DisableInterrupts() => this.IFF1 = this.IFF2 = false;
|
||||
|
||||
protected override void EnableInterrupts() => this.IFF1 = this.IFF2 = true;
|
||||
|
||||
|
||||
protected override void Call(Register16 destination)
|
||||
{
|
||||
this.Tick();
|
||||
@@ -725,10 +742,6 @@ namespace Z80
|
||||
|
||||
private static byte SET(int n, byte operand) => SetBit(operand, Bit(n));
|
||||
|
||||
protected override void DisableInterrupts() => this.IFF1 = this.IFF2 = false;
|
||||
|
||||
protected override void EnableInterrupts() => this.IFF1 = this.IFF2 = true;
|
||||
|
||||
private Register16 HL2() => this._prefixDD ? this.IX : this._prefixFD ? this.IY : this.HL;
|
||||
|
||||
private Register16 RP(int rp) => rp switch
|
||||
@@ -1612,18 +1625,6 @@ namespace Z80
|
||||
this.Execute(this.FetchInstruction());
|
||||
}
|
||||
|
||||
private void HandleNMI()
|
||||
{
|
||||
this.RaiseNMI();
|
||||
this.RaiseHALT();
|
||||
this.IFF2 = this.IFF1;
|
||||
this.IFF1 = false;
|
||||
this.LowerM1();
|
||||
_ = this.Bus.Data;
|
||||
this.RaiseM1();
|
||||
this.Restart(0x66);
|
||||
}
|
||||
|
||||
private void FetchDisplacement()
|
||||
{
|
||||
Debug.Assert(this.M1.Raised(), "Displacement cannot be fetched during an M1 cycle");
|
||||
|
||||
Reference in new issue
Block a user