Fix HALT instruction

This commit is contained in:
Adrian Conlon
2025-05-03 02:08:52 +01:00
parent 561483d65d
commit 946121defb

View File

@@ -13,8 +13,6 @@ namespace Z80
{
this._ports = ports;
this.RaisedPOWER += this.Z80_RaisedPOWER;
this.LoweredHALT += this.Z80_LoweredHALT;
this.RaisedHALT += this.Z80_RaisedHALT;
}
private readonly InputOutput _ports;
@@ -194,16 +192,6 @@ namespace Z80
this.ResetPrefixes();
}
private void Z80_RaisedHALT(object? sender, EventArgs e)
{
++this.PC.Word; // Release the PC from HALT instruction
}
private void Z80_LoweredHALT(object? sender, EventArgs e)
{
--this.PC.Word; // Keep the PC on the HALT instruction (i.e. executing NOP)
}
private void ResetPrefixes()
{
this._prefixCB = this._prefixDD = this._prefixED = this._prefixFD = false;
@@ -494,11 +482,14 @@ namespace Z80
protected override void MemoryWrite()
{
this.OnWritingMemory();
this.MemoryUpdate(3);
this.OnWroteMemory();
}
protected override byte MemoryRead()
{
this.OnReadingMemory();
this.Tick();
this.LowerMREQ();
this.LowerRD();
@@ -516,6 +507,7 @@ namespace Z80
this.RaiseRFSH();
}
this.Tick();
this.OnReadMemory();
return returned;
}