Skip to content

Commit c67e376

Browse files
committed
Add support for checking deferred EI correctness
1 parent 4da07a8 commit c67e376

2 files changed

Lines changed: 12 additions & 6 deletions

File tree

LR35902/LR35902.cs

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -56,7 +56,7 @@ public byte IF
5656

5757
private bool Stopped { get; set; }
5858

59-
private bool _deferredInterruptEnable;
59+
public bool EI { get; set; }
6060

6161
#region MWR pin
6262

@@ -196,10 +196,10 @@ public override void PoweredStep()
196196
{
197197
this.prefixCB = false;
198198

199-
if ( this._deferredInterruptEnable)
199+
if (this.EI)
200200
{
201201
this.EnableInterrupts();
202-
this._deferredInterruptEnable = false;
202+
this.EI = false;
203203
}
204204

205205
if (this.MaskedInterrupts != 0)
@@ -235,7 +235,7 @@ private void LR35902_RaisedPOWER(object? sender, EventArgs e)
235235
this.RaiseWR();
236236
this.RaiseRD();
237237
this.RaiseMWR();
238-
this._deferredInterruptEnable = false;
238+
this.EI = false;
239239
}
240240

241241
protected override void HandleRESET()
@@ -839,7 +839,7 @@ private void ExecuteOther(int x, int y, int z, int p, int q)
839839
this.DisableInterrupts();
840840
break;
841841
case 7: // EI
842-
this._deferredInterruptEnable = true;
842+
this.EI = true;
843843
break;
844844
default:
845845
break;

LR35902/SM83.HarteTest/Checker.cs

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -219,6 +219,12 @@ private bool CheckState(Test test)
219219
ie_good = this.Check("IE", final.IE.Value, cpu.IE);
220220
}
221221

222+
var ei_good = true;
223+
if (final.EI is not null)
224+
{
225+
ei_good = this.Check("EI", final.EI.Value, (byte)(cpu.EI ? 1 : 0));
226+
}
227+
222228
if (!f_good)
223229
{
224230
this.Messages.Add($"Expected flags: {LR35902.Disassembler.AsFlags(final.F)}");
@@ -255,7 +261,7 @@ private bool CheckState(Test test)
255261
&& d_good && e_good
256262
&& h_good && l_good
257263
&& ime_good
258-
&& ie_good;
264+
&& ie_good && ei_good;
259265
}
260266

261267
private void Raise(string what, ushort expected, ushort actual) => this.Messages.Add($"{what}: expected: {expected:X4}, actual: {actual:X4}");

0 commit comments

Comments
 (0)