Skip to content

Commit 53f0b74

Browse files
committed
More reset tweaks
1 parent db02f57 commit 53f0b74

2 files changed

Lines changed: 8 additions & 8 deletions

File tree

EightBit/Processor.cs

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -155,7 +155,9 @@ public virtual void LowerINT()
155155
}
156156
}
157157

158-
protected virtual void HandleRESET() => this.RaiseRESET();
158+
protected virtual void HandleRESET()
159+
{
160+
}
159161

160162
protected virtual void HandleINT() => this.RaiseINT();
161163

Z80/Z80.cs

Lines changed: 5 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -17,14 +17,12 @@ public Z80(Bus bus, InputOutput ports)
1717
this.UpdateRegisterBank();
1818
this.UpdateAFBank();
1919
this.RaisedPOWER += this.Z80_RaisedPOWER;
20-
this.LoweredRESET += this.Z80_LoweredRESET;
2120
this.LoweredNMI += this.Z80_LoweredNMI;
2221
this.LoweredINT += this.Z80_LoweredINT;
2322
}
2423

2524
private bool _interruptPending;
2625
private bool _nonMaskableInterruptPending;
27-
private bool _resetPending;
2826

2927
private readonly InputOutput _ports;
3028

@@ -182,9 +180,8 @@ public override void PoweredStep()
182180
this._modifiedF = 0;
183181
this._displaced = this._prefixCB = this._prefixDD = this._prefixED = this._prefixFD = false;
184182

185-
if (this._resetPending)
183+
if (this.RESET.Lowered())
186184
{
187-
this._resetPending = false;
188185
this.HandleRESET();
189186
return;
190187
}
@@ -204,6 +201,9 @@ public override void PoweredStep()
204201
}
205202
}
206203

204+
Debug.Assert(this.RESET.Raised());
205+
Debug.Assert(this.NMI.Raised());
206+
207207
// ** From the Z80 CPU User Manual
208208
// When a software HALT instruction is executed, the CPU executes NOPs until an interrupt
209209
// is received(either a non-maskable or a maskable interrupt while the interrupt flip-flop is
@@ -252,8 +252,6 @@ private void Z80_RaisedPOWER(object? sender, EventArgs e)
252252

253253
private void Z80_LoweredNMI(object? sender, EventArgs e) => this._nonMaskableInterruptPending = true;
254254

255-
private void Z80_LoweredRESET(object? sender, EventArgs e) => this._resetPending = true;
256-
257255
#region Z80 specific pins
258256

259257
#region NMI pin
@@ -594,10 +592,10 @@ protected override void MemoryRead()
594592
protected override void HandleRESET()
595593
{
596594
base.HandleRESET();
597-
this.DisableInterrupts();
598595
this.IM = 0;
599596
this.IV = this.REFRESH = 0;
600597
this.SP.Joined = this.AF.Joined = (ushort)Mask.Sixteen;
598+
this.Tick();
601599
}
602600

603601
private byte ReadDataUnderInterrupt()

0 commit comments

Comments
 (0)