mirror of
https://github.com/MoleskiCoder/EightBitNet.git
synced 2026-04-20 21:16:29 +00:00
Tighten up the sequence associated with changing pin levels + fix persistent HALT/PC bug
Signed-off-by: Adrian Conlon <Adrian.conlon@gmail.com>
This commit is contained in:
+12
-6
@@ -28,16 +28,22 @@ namespace EightBit
|
||||
|
||||
public virtual void RaisePOWER()
|
||||
{
|
||||
this.OnRaisingPOWER();
|
||||
this.POWER.Raise();
|
||||
this.OnRaisedPOWER();
|
||||
if (this.POWER.Lowered())
|
||||
{
|
||||
this.OnRaisingPOWER();
|
||||
this.POWER.Raise();
|
||||
this.OnRaisedPOWER();
|
||||
}
|
||||
}
|
||||
|
||||
public virtual void LowerPOWER()
|
||||
{
|
||||
this.OnLoweringPOWER();
|
||||
this.POWER.Lower();
|
||||
this.OnLoweredPOWER();
|
||||
if (this.POWER.Raised())
|
||||
{
|
||||
this.OnLoweringPOWER();
|
||||
this.POWER.Lower();
|
||||
this.OnLoweredPOWER();
|
||||
}
|
||||
}
|
||||
|
||||
protected virtual void OnRaisingPOWER() => this.RaisingPOWER?.Invoke(this, EventArgs.Empty);
|
||||
|
||||
+29
-15
@@ -64,25 +64,24 @@ namespace EightBit
|
||||
|
||||
public IntelOpCodeDecoded GetDecodedOpCode(byte opCode) => this.decodedOpCodes[opCode];
|
||||
|
||||
public override void RaisePOWER()
|
||||
{
|
||||
base.RaisePOWER();
|
||||
this.RaiseHALT();
|
||||
this.SP.Word = this.AF.Word = this.BC.Word = this.DE.Word = this.HL.Word = (ushort)Mask.Mask16;
|
||||
}
|
||||
|
||||
public virtual void RaiseHALT()
|
||||
{
|
||||
this.OnRaisingHALT();
|
||||
this.HALT.Raise();
|
||||
this.OnRaisedHALT();
|
||||
if (this.HALT.Lowered())
|
||||
{
|
||||
this.OnRaisingHALT();
|
||||
this.HALT.Raise();
|
||||
this.OnRaisedHALT();
|
||||
}
|
||||
}
|
||||
|
||||
public virtual void LowerHALT()
|
||||
{
|
||||
this.OnLoweringHALT();
|
||||
this.HALT.Lower();
|
||||
this.OnLoweredHALT();
|
||||
if (this.HALT.Raised())
|
||||
{
|
||||
this.OnLoweringHALT();
|
||||
this.HALT.Lower();
|
||||
this.OnLoweredHALT();
|
||||
}
|
||||
}
|
||||
|
||||
protected static int BuildHalfCarryIndex(byte before, byte value, int calculation) => ((before & 0x88) >> 1) | ((value & 0x88) >> 2) | ((calculation & 0x88) >> 3);
|
||||
@@ -99,13 +98,28 @@ namespace EightBit
|
||||
return HalfCarryTableSub[index & (int)Mask.Mask3];
|
||||
}
|
||||
|
||||
protected override void OnRaisedPOWER()
|
||||
{
|
||||
this.RaiseHALT();
|
||||
this.SP.Word = this.AF.Word = this.BC.Word = this.DE.Word = this.HL.Word = (ushort)Mask.Mask16;
|
||||
base.OnRaisedPOWER();
|
||||
}
|
||||
|
||||
protected virtual void OnRaisingHALT() => this.RaisingHALT?.Invoke(this, EventArgs.Empty);
|
||||
|
||||
protected virtual void OnRaisedHALT() => this.RaisedHALT?.Invoke(this, EventArgs.Empty);
|
||||
protected virtual void OnRaisedHALT()
|
||||
{
|
||||
++this.PC.Word; // Release the PC from HALT instruction
|
||||
this.RaisedHALT?.Invoke(this, EventArgs.Empty);
|
||||
}
|
||||
|
||||
protected virtual void OnLoweringHALT() => this.LoweringHALT?.Invoke(this, EventArgs.Empty);
|
||||
|
||||
protected virtual void OnLoweredHALT() => this.LoweredHALT?.Invoke(this, EventArgs.Empty);
|
||||
protected virtual void OnLoweredHALT()
|
||||
{
|
||||
--this.PC.Word; // Keep the PC on the HALT instruction (i.e. executing NOP)
|
||||
this.LoweredHALT?.Invoke(this, EventArgs.Empty);
|
||||
}
|
||||
|
||||
protected override void HandleRESET()
|
||||
{
|
||||
|
||||
+24
-12
@@ -78,30 +78,42 @@ namespace EightBit
|
||||
|
||||
public virtual void RaiseRESET()
|
||||
{
|
||||
this.OnRaisingRESET();
|
||||
this.RESET.Raise();
|
||||
this.OnRaisedRESET();
|
||||
if (this.RESET.Lowered())
|
||||
{
|
||||
this.OnRaisingRESET();
|
||||
this.RESET.Raise();
|
||||
this.OnRaisedRESET();
|
||||
}
|
||||
}
|
||||
|
||||
public virtual void LowerRESET()
|
||||
{
|
||||
this.OnLoweringRESET();
|
||||
this.RESET.Lower();
|
||||
this.OnLoweredRESET();
|
||||
if (this.RESET.Raised())
|
||||
{
|
||||
this.OnLoweringRESET();
|
||||
this.RESET.Lower();
|
||||
this.OnLoweredRESET();
|
||||
}
|
||||
}
|
||||
|
||||
public virtual void RaiseINT()
|
||||
{
|
||||
this.OnRaisingINT();
|
||||
this.INT.Raise();
|
||||
this.OnRaisedINT();
|
||||
if (this.INT.Lowered())
|
||||
{
|
||||
this.OnRaisingINT();
|
||||
this.INT.Raise();
|
||||
this.OnRaisedINT();
|
||||
}
|
||||
}
|
||||
|
||||
public virtual void LowerINT()
|
||||
{
|
||||
this.OnLoweringINT();
|
||||
this.INT.Lower();
|
||||
this.OnLoweredINT();
|
||||
if (this.INT.Raised())
|
||||
{
|
||||
this.OnLoweringINT();
|
||||
this.INT.Lower();
|
||||
this.OnLoweredINT();
|
||||
}
|
||||
}
|
||||
|
||||
protected virtual void OnRaisingRESET() => this.RaisingRESET?.Invoke(this, EventArgs.Empty);
|
||||
|
||||
Reference in New Issue
Block a user