mirror of
https://github.com/MoleskiCoder/EightBitNet.git
synced 2025-07-25 13:24:08 +00:00
Correct timing issues both conditional and unconditional relative jumpson Z80
This commit is contained in:
@@ -64,7 +64,7 @@
|
||||
this.Raise("SP", final.SP, cpu.SP);
|
||||
|
||||
this.Raise("A", final.A, cpu.A);
|
||||
this.Raise("F", final.F, cpu.F);
|
||||
this.RaiseFlags("F", final.F, cpu.F);
|
||||
this.Raise("B", final.B, cpu.B);
|
||||
this.Raise("C", final.C, cpu.C);
|
||||
this.Raise("D", final.D, cpu.D);
|
||||
@@ -308,6 +308,8 @@
|
||||
|
||||
private void Raise(string what, byte expected, byte actual) => this.Messages.Add($"{what}: expected: {expected:X2}, actual: {actual:X2}");
|
||||
|
||||
private void RaiseFlags(string what, byte expected, byte actual) => this.Messages.Add($"{what}: expected: {Disassembler.AsFlags(expected)}, actual: {Disassembler.AsFlags(actual)}");
|
||||
|
||||
private void Raise(string what, ushort expected, Register16 actual) => this.Raise(what, expected, actual.Word);
|
||||
|
||||
private void Raise(string what, ushort expected, ushort actual) => this.Messages.Add($"{what}: expected: {expected:X4}, actual: {actual:X4}");
|
||||
|
@@ -6,7 +6,7 @@
|
||||
|
||||
public IEnumerable<OpcodeTestSuite> OpcodeTests()
|
||||
{
|
||||
foreach (var filename in Directory.EnumerateFiles(this.Location, "*.json"))
|
||||
foreach (var filename in Directory.EnumerateFiles(this.Location, "0?.json"))
|
||||
{
|
||||
var fileInformation = new FileInfo(filename);
|
||||
if (fileInformation.Length > 0)
|
||||
|
25
Z80/Z80.cs
25
Z80/Z80.cs
@@ -550,6 +550,23 @@ namespace Z80
|
||||
base.Call(destination);
|
||||
}
|
||||
|
||||
protected override void JumpRelative(sbyte offset)
|
||||
{
|
||||
base.JumpRelative(offset);
|
||||
this.Tick(5);
|
||||
}
|
||||
|
||||
protected override bool JumpRelativeConditional(bool condition)
|
||||
{
|
||||
this.Tick();
|
||||
var offset = this.FetchByte();
|
||||
if (condition)
|
||||
{
|
||||
this.JumpRelative(offset);
|
||||
}
|
||||
return condition;
|
||||
}
|
||||
|
||||
private int Zero()
|
||||
{
|
||||
return ZeroTest(this.F);
|
||||
@@ -1139,13 +1156,7 @@ namespace Z80
|
||||
this.ExxAF();
|
||||
break;
|
||||
case 2: // DJNZ d
|
||||
this.Tick();
|
||||
if (this.JumpRelativeConditional(--this.B != 0))
|
||||
{
|
||||
this.Tick(2);
|
||||
}
|
||||
|
||||
this.Tick(3);
|
||||
_ = this.JumpRelativeConditional(--this.B != 0);
|
||||
break;
|
||||
case 3: // JR d
|
||||
this.JumpRelative(this.FetchByte());
|
||||
|
Reference in New Issue
Block a user