diff --git a/Core/Cpu/Z80.cs b/Core/Cpu/Z80.cs index 60dc8ac..27bd517 100644 --- a/Core/Cpu/Z80.cs +++ b/Core/Cpu/Z80.cs @@ -1677,6 +1677,17 @@ namespace Core.Cpu // 4. Write the immediate value directly into memory _memory.Write(address36, n36); + return 19; + case 0x56: // LD D, (IX+d) + // 1. Fetch the displacement byte and cast it to a signed sbyte + sbyte offset56 = (sbyte)FetchByte(); + + // 2. Calculate the exact memory address (IX + offset) + ushort address56 = (ushort)(IX.Word + offset56); + + // 3. Read the byte from memory and drop it into the D register (High byte of DE) + DE.High = _memory.Read(address56); + return 19; case 0x5E: // LD E, (IX+d) // 1. Fetch the displacement byte and cast it to a signed sbyte @@ -1688,7 +1699,18 @@ namespace Core.Cpu // 3. Read the byte from memory and drop it into the E register DE.Low = _memory.Read(address5E); - return 19; // 19 T-States + return 19; + case 0x6E: // LD L, (IX+d) + // 1. Fetch the displacement byte and cast it to a signed sbyte + sbyte offset6E = (sbyte)FetchByte(); + + // 2. Calculate the exact memory address (IX + offset) + ushort address6E = (ushort)(IX.Word + offset6E); + + // 3. Read the byte from memory and drop it into the L register (Low byte of HL) + HL.Low = _memory.Read(address6E); + + return 19; case 0x74: // LD (IX+d), H // 1. Fetch the displacement byte and cast it to a signed sbyte sbyte offset74 = (sbyte)FetchByte(); diff --git a/Desktop/DebuggerForm.cs b/Desktop/DebuggerForm.cs index 8d9b855..b9cddd8 100644 --- a/Desktop/DebuggerForm.cs +++ b/Desktop/DebuggerForm.cs @@ -850,6 +850,13 @@ namespace Desktop mnemonic = $"LD (IX{sign}{d}), 0x{n:X2}"; instructionLength = 4; } + else if (ddOpcode == 0x56) // LD D, (IX+d) + { + sbyte d = (sbyte)_memoryBus.Read((ushort)(currentPc + 2)); + string sign = d >= 0 ? "+" : ""; + mnemonic = $"LD D, (IX{sign}{d})"; + instructionLength = 3; + } else if (ddOpcode == 0x5E) // LD E, (IX+d) { sbyte d = (sbyte)_memoryBus.Read((ushort)(currentPc + 2)); @@ -857,6 +864,13 @@ namespace Desktop mnemonic = $"LD E, (IX{sign}{d})"; instructionLength = 3; } + else if (ddOpcode == 0x6E) // LD L, (IX+d) + { + sbyte d = (sbyte)_memoryBus.Read((ushort)(currentPc + 2)); + string sign = d >= 0 ? "+" : ""; + mnemonic = $"LD L, (IX{sign}{d})"; + instructionLength = 3; + } else if (ddOpcode == 0x74) // LD (IX+d), H { sbyte d = (sbyte)_memoryBus.Read((ushort)(currentPc + 2)); diff --git a/Desktop/Form1.cs b/Desktop/Form1.cs index 935e053..b3d34ad 100644 --- a/Desktop/Form1.cs +++ b/Desktop/Form1.cs @@ -198,6 +198,15 @@ namespace Desktop { switch (key) { + //1:6 - + + //Row 0: CAPS_SHIFT, Z, X, C, V + case Keys.ShiftKey: UpdateMatrix(0, 0, isPressed); break; + case Keys.Z: UpdateMatrix(0, 1, isPressed); break; + case Keys.X: UpdateMatrix(0, 2, isPressed); break; + case Keys.C: UpdateMatrix(0, 3, isPressed); break; + case Keys.V: UpdateMatrix(0, 4, isPressed); break; + // Row 1: A, S, D, F, G case Keys.A: UpdateMatrix(1, 0, isPressed); break; case Keys.S: UpdateMatrix(1, 1, isPressed); break; @@ -205,26 +214,47 @@ namespace Desktop case Keys.F: UpdateMatrix(1, 3, isPressed); break; case Keys.G: UpdateMatrix(1, 4, isPressed); break; + //Row 2: + case Keys.Q: UpdateMatrix(2, 0, isPressed); break; + case Keys.W: UpdateMatrix(2, 1, isPressed); break; + case Keys.E: UpdateMatrix(2, 2, isPressed); break; + case Keys.R: UpdateMatrix(2, 3, isPressed); break; + case Keys.T: UpdateMatrix(2, 4, isPressed); break; + + // Row 3: + case Keys.D1: UpdateMatrix(3, 0, isPressed); break; + case Keys.D2: UpdateMatrix(3, 1, isPressed); break; + case Keys.D3: UpdateMatrix(3, 2, isPressed); break; + case Keys.D4: UpdateMatrix(3, 3, isPressed); break; + case Keys.D5: UpdateMatrix(3, 4, isPressed); break; + + // Row 4: + case Keys.D0: UpdateMatrix(4, 0, isPressed); break; + case Keys.D9: UpdateMatrix(4, 1, isPressed); break; + case Keys.D8: UpdateMatrix(4, 2, isPressed); break; + case Keys.D7: UpdateMatrix(4, 3, isPressed); break; + case Keys.D6: UpdateMatrix(4, 4, isPressed); break; + // Row 5: case Keys.P: UpdateMatrix(5, 0, isPressed); break; + case Keys.O: UpdateMatrix(5, 1, isPressed); break; + case Keys.I: UpdateMatrix(5, 2, isPressed); break; + case Keys.U: UpdateMatrix(5, 3, isPressed); break; + case Keys.Y: UpdateMatrix(5, 4, isPressed); break; // Row 6: ENTER, L, K, J, H case Keys.Enter: UpdateMatrix(6, 0, isPressed); break; case Keys.L: UpdateMatrix(6, 1, isPressed); break; case Keys.K: UpdateMatrix(6, 2, isPressed); break; case Keys.J: UpdateMatrix(6, 3, isPressed); break; - case Keys.H: UpdateMatrix(6, 4, isPressed); break; + case Keys.H: UpdateMatrix(6, 4, isPressed); break; // Row 7: SPACE, SYM SHIFT, M, N, B case Keys.Space: UpdateMatrix(7, 0, isPressed); break; + case Keys.ControlKey: UpdateMatrix(7, 1, isPressed); break; // Symbol Shift case Keys.M: UpdateMatrix(7, 2, isPressed); break; case Keys.N: UpdateMatrix(7, 3, isPressed); break; - case Keys.B: UpdateMatrix(7, 4, isPressed); break; - case Keys.ControlKey: UpdateMatrix(7, 1, isPressed); break; // Symbol Shift - - - - + case Keys.B: UpdateMatrix(7, 4, isPressed); break; } } }