diff --git a/EightBit/Processor.cs b/EightBit/Processor.cs index c8a5c01..879b76e 100644 --- a/EightBit/Processor.cs +++ b/EightBit/Processor.cs @@ -155,7 +155,9 @@ namespace EightBit } } - protected virtual void HandleRESET() => this.RaiseRESET(); + protected virtual void HandleRESET() + { + } protected virtual void HandleINT() => this.RaiseINT(); diff --git a/Z80/Disassembler.cs b/Z80/Disassembler.cs index dbddbea..e233f2b 100644 --- a/Z80/Disassembler.cs +++ b/Z80/Disassembler.cs @@ -63,10 +63,10 @@ namespace Z80 + $"I={i:x2} R={(byte)r:x2} " + $"IM={im} " + $"IFF1={(cpu.IFF1 ? 1 : 0)} " - + $"{(cpu.RESET.Lowered() ? "R" : "-")}" - + $"{(cpu.INT.Lowered() ? "I" : "-")}" + $"{(cpu.HALT.Lowered() ? "H" : "-")}" - + $"{(cpu.NMI.Lowered() ? "N" : "-")}"; + + $"{(cpu.RESET.Lowered() ? "R" : "-")}" + + $"{(cpu.NMI.Lowered() ? "N" : "-")}" + + $"{(cpu.INT.Lowered() ? "I" : "-")}"; } public string Disassemble(Z80 cpu) diff --git a/Z80/Z80.UnitTests/ResetTests.cs b/Z80/Z80.UnitTests/ResetTests.cs index 2d9a17a..7583292 100644 --- a/Z80/Z80.UnitTests/ResetTests.cs +++ b/Z80/Z80.UnitTests/ResetTests.cs @@ -64,12 +64,12 @@ namespace Z80.UnitTests } [TestMethod] - public void Reset_Deasserts_Reset_Pin() + public void Reset_Ignores_Reset_Pin() { this.cpu.LowerRESET(); // asserts RESET — fires LoweredRESET event Assert.IsTrue(this.cpu.RESET.Lowered(), "RESET pin must be asserted before step"); this.cpu.Step(); - Assert.IsTrue(this.cpu.RESET.Raised(), "HandleRESET must deassert the RESET pin"); + Assert.IsTrue(this.cpu.RESET.Lowered()); } [TestMethod] diff --git a/Z80/Z80.cs b/Z80/Z80.cs index 5ea5613..8e37210 100644 --- a/Z80/Z80.cs +++ b/Z80/Z80.cs @@ -17,14 +17,12 @@ namespace Z80 this.UpdateRegisterBank(); this.UpdateAFBank(); this.RaisedPOWER += this.Z80_RaisedPOWER; - this.LoweredRESET += this.Z80_LoweredRESET; this.LoweredNMI += this.Z80_LoweredNMI; this.LoweredINT += this.Z80_LoweredINT; } private bool _interruptPending; private bool _nonMaskableInterruptPending; - private bool _resetPending; private readonly InputOutput _ports; @@ -182,9 +180,8 @@ namespace Z80 this._modifiedF = 0; this._displaced = this._prefixCB = this._prefixDD = this._prefixED = this._prefixFD = false; - if (this._resetPending) + if (this.RESET.Lowered()) { - this._resetPending = false; this.HandleRESET(); return; } @@ -204,6 +201,8 @@ namespace Z80 } } + Debug.Assert(this.RESET.Raised()); + // ** From the Z80 CPU User Manual // When a software HALT instruction is executed, the CPU executes NOPs until an interrupt // is received(either a non-maskable or a maskable interrupt while the interrupt flip-flop is @@ -252,8 +251,6 @@ namespace Z80 private void Z80_LoweredNMI(object? sender, EventArgs e) => this._nonMaskableInterruptPending = true; - private void Z80_LoweredRESET(object? sender, EventArgs e) => this._resetPending = true; - #region Z80 specific pins #region NMI pin @@ -594,10 +591,10 @@ namespace Z80 protected override void HandleRESET() { base.HandleRESET(); - this.DisableInterrupts(); this.IM = 0; this.IV = this.REFRESH = 0; this.SP.Joined = this.AF.Joined = (ushort)Mask.Sixteen; + this.Tick(); } private byte ReadDataUnderInterrupt()