Implemented a load more Z80 OpCodes. Added IX, IY and Interrupts to Debugger
This commit is contained in:
@@ -134,6 +134,9 @@ namespace Desktop
|
||||
lblSP.Text = $"SP: {_cpu.SP:X4}";
|
||||
lblIX.Text = $"IX: {_cpu.IX.Word:X4}";
|
||||
lblIY.Text = $"IY: {_cpu.IY.Word:X4}";
|
||||
lblIff1.Text = $"IFF1: {_cpu.IFF1}";
|
||||
lblIff2.Text = $"IFF2: {_cpu.IFF2}";
|
||||
lblIE.Text = $"Interrupt Mode: {_cpu.InterruptMode}";
|
||||
|
||||
// 2. Update Flags & T-States
|
||||
lblFlags.Text = $"Flags: {_cpu.GetFlagsString()}";
|
||||
@@ -232,6 +235,12 @@ namespace Desktop
|
||||
case 0x04:
|
||||
mnemonic = "INC B";
|
||||
break;
|
||||
case 0x10:
|
||||
sbyte djnzOffset = (sbyte)_memoryBus.Read((ushort)(currentPc + 1));
|
||||
ushort djnzDest = (ushort)(currentPc + 2 + djnzOffset);
|
||||
mnemonic = $"DJNZ 0x{djnzDest:X4}";
|
||||
instructionLength = 2;
|
||||
break;
|
||||
case 0x11:
|
||||
// LD DE, nn
|
||||
byte deLow = _memoryBus.Read((ushort)(currentPc + 1));
|
||||
@@ -285,6 +294,13 @@ namespace Desktop
|
||||
mnemonic = $"JR NC, 0x{dest:X4}";
|
||||
instructionLength = 2;
|
||||
break;
|
||||
case 0x32:
|
||||
{
|
||||
ushort addr32 = (ushort)(_memoryBus.Read((ushort)(currentPc + 1)) | (_memoryBus.Read((ushort)(currentPc + 2)) << 8));
|
||||
mnemonic = $"LD (0x{addr32:X4}), A";
|
||||
instructionLength = 3;
|
||||
break;
|
||||
}
|
||||
case 0x35:
|
||||
mnemonic = "DEC (HL)";
|
||||
break;
|
||||
@@ -306,6 +322,9 @@ namespace Desktop
|
||||
case 0x6B:
|
||||
mnemonic = "LD L, E";
|
||||
break;
|
||||
case 0x77:
|
||||
mnemonic = "LD (HL), A";
|
||||
break;
|
||||
case 0xA7:
|
||||
mnemonic = "AND A";
|
||||
break;
|
||||
@@ -322,6 +341,11 @@ namespace Desktop
|
||||
mnemonic = $"JP 0x{jpHigh:X2}{jpLow:X2}";
|
||||
instructionLength = 3;
|
||||
break;
|
||||
case 0xCD:
|
||||
ushort callDest = (ushort)(_memoryBus.Read((ushort)(currentPc + 1)) | (_memoryBus.Read((ushort)(currentPc + 2)) << 8));
|
||||
mnemonic = $"CALL 0x{callDest:X4}";
|
||||
instructionLength = 3;
|
||||
break;
|
||||
case 0xD3:
|
||||
byte outPort = _memoryBus.Read((ushort)(currentPc + 1));
|
||||
mnemonic = $"OUT (0x{outPort:X2}), A";
|
||||
@@ -386,6 +410,9 @@ namespace Desktop
|
||||
case 0xF9:
|
||||
mnemonic = "LD SP, HL";
|
||||
break;
|
||||
case 0xFB:
|
||||
mnemonic = "EI";
|
||||
break;
|
||||
case 0xFD:
|
||||
{
|
||||
byte fdOpcode = _memoryBus.Read((ushort)(currentPc + 1));
|
||||
@@ -396,6 +423,36 @@ namespace Desktop
|
||||
mnemonic = $"LD IY, 0x{iyVal:X4}";
|
||||
instructionLength = 4;
|
||||
}
|
||||
else if (fdOpcode == 0x35) // DEC (IY+d)
|
||||
{
|
||||
sbyte d = (sbyte)_memoryBus.Read((ushort)(currentPc + 2));
|
||||
string sign = d >= 0 ? "+" : ""; // Gives us a clean + or -
|
||||
mnemonic = $"DEC (IY{sign}{d})";
|
||||
instructionLength = 3;
|
||||
}
|
||||
else if (fdOpcode == 0xCB) // FD CB prefix
|
||||
{
|
||||
sbyte d = (sbyte)_memoryBus.Read((ushort)(currentPc + 2));
|
||||
byte cbOpcode = _memoryBus.Read((ushort)(currentPc + 3));
|
||||
string sign = d >= 0 ? "+" : "";
|
||||
|
||||
if (cbOpcode == 0xCE)
|
||||
{
|
||||
mnemonic = $"SET 1, (IY{sign}{d})";
|
||||
}
|
||||
else
|
||||
{
|
||||
mnemonic = $"FD CB {d:X2} {cbOpcode:X2}"; // Fallback
|
||||
}
|
||||
instructionLength = 4;
|
||||
}
|
||||
else if (fdOpcode == 0x75) // LD (IY+d), L
|
||||
{
|
||||
sbyte d = (sbyte)_memoryBus.Read((ushort)(currentPc + 2));
|
||||
string sign = d >= 0 ? "+" : "";
|
||||
mnemonic = $"LD (IY{sign}{d}), L";
|
||||
instructionLength = 3;
|
||||
}
|
||||
else
|
||||
{
|
||||
mnemonic = $"FD PREFIX UNKNOWN (0x{fdOpcode:X2})";
|
||||
|
||||
Reference in New Issue
Block a user