Plus 3 mode fully working. Added Plus 3 keyboard

This commit is contained in:
2026-04-30 15:42:54 +01:00
parent d90537de59
commit bc2748250d
5 changed files with 67 additions and 21 deletions

View File

@@ -2472,8 +2472,8 @@ namespace Core.Cpu
SP = IY.Word; SP = IY.Word;
return 10; return 10;
default: default:
// The Z80 Ignored Prefix Quirk! // Z80 nonsense loopback bug
return ExecuteOpcode(ddOpcode) + 4; // Note: You named the fetched variable 'opcode' here instead of 'ddOpcode' return ExecuteOpcode(ddOpcode) + 4;
} }
} }
} }

View File

@@ -73,28 +73,40 @@ namespace Core.Io
// Bit 3 handles the cassette MIC output // Bit 3 handles the cassette MIC output
} }
// 128K Standard Paging Port (0x7FFD) // 128K Standard Paging Port (0x7FFD)
if ((portAddress & 0x8002) == 0) // Mask 0xC002 checks A15=0, A14=1, A1=0 to prevent 0x1FFD from triggering this!
if ((portAddress & 0xC002) == 0x4000)
{ {
_memory.HandlePaging(0x7FFD, portValue); _memory.HandlePaging(0x7FFD, portValue);
} }
// +2A/+3 Extended Paging Port (0x1FFD) // +2A/+3 Extended Paging Port (0x1FFD)
if ((portAddress & 0xF002) == 0x1000) // Mask 0xF002 checks A15=0, A14=0, A13=0, A12=1, A1=0
else if ((portAddress & 0xF002) == 0x1000)
{ {
_memory.HandlePaging(0x1FFD, portValue); _memory.HandlePaging(0x1FFD, portValue);
} }
// AY-3-8912 Register Select (Port 0xFFFD)
if ((portAddress & 0xC002) == 0xC000) //// 128K Standard Paging Port (0x7FFD)
{ //if ((portAddress & 0x8002) == 0)
AyChip.SelectRegister(portValue); //{
} // _memory.HandlePaging(0x7FFD, portValue);
// AY-3-8912 Data Write (Port 0xBFFD) //}
else if ((portAddress & 0xC002) == 0x8000)
{ //// +2A/+3 Extended Paging Port (0x1FFD)
AyChip.WriteRegister(portValue); //if ((portAddress & 0xF002) == 0x1000)
} //{
// _memory.HandlePaging(0x1FFD, portValue);
//}
//// AY-3-8912 Register Select (Port 0xFFFD)
//if ((portAddress & 0xC002) == 0xC000)
//{
// AyChip.SelectRegister(portValue);
//}
//// AY-3-8912 Data Write (Port 0xBFFD)
//else if ((portAddress & 0xC002) == 0x8000)
//{
// AyChip.WriteRegister(portValue);
//}
} }
} }
} }

View File

@@ -54,6 +54,7 @@ namespace Core.Io
// The perfectly cropped, 320x256 Scanline Renderer // The perfectly cropped, 320x256 Scanline Renderer
public void RenderScanline(int scanline) public void RenderScanline(int scanline)
{ {
byte[] videoRam = _memoryBus.GetVideoRam();
// 1. Drop the invisible lines instantly (VBlank/Overscan) // 1. Drop the invisible lines instantly (VBlank/Overscan)
if (scanline < 32 || scanline > 287) return; if (scanline < 32 || scanline > 287) return;
@@ -91,11 +92,18 @@ namespace Core.Io
// Draw the 32 horizontal character blocks of the visible screen // Draw the 32 horizontal character blocks of the visible screen
for (int col = 0; col < 32; col++) for (int col = 0; col < 32; col++)
{ {
ushort pixelAddress = (ushort)(0x4000 | (third << 11) | (pixelRow << 8) | (characterRow << 5) | col); // Calculate the exact internal array offsets (Base 0, no 0x4000 needed!)
ushort attrAddress = (ushort)(0x5800 + (y / 8) * 32 + col); int pixelOffset = (third << 11) | (pixelRow << 8) | (characterRow << 5) | col;
int attrOffset = 0x1800 + (y / 8) * 32 + col;
byte pixels = _memoryBus.Read(pixelAddress); // Read directly from the raw array
byte attr = _memoryBus.Read(attrAddress); byte pixels = videoRam[pixelOffset];
byte attr = videoRam[attrOffset];
//ushort pixelAddress = (ushort)(0x4000 | (third << 11) | (pixelRow << 8) | (characterRow << 5) | col);
//ushort attrAddress = (ushort)(0x5800 + (y / 8) * 32 + col);
//byte pixels = _memoryBus.Read(pixelAddress);
//byte attr = _memoryBus.Read(attrAddress);
int ink = attr & 0x07; int ink = attr & 0x07;
int paper = (attr >> 3) & 0x07; int paper = (attr >> 3) & 0x07;

View File

@@ -47,7 +47,7 @@ namespace Core.Memory
// Called by the IO Bus when the CPU writes to a paging port // Called by the IO Bus when the CPU writes to a paging port
public void HandlePaging(ushort port, byte value) public void HandlePaging(ushort port, byte value)
{ {
Debug.WriteLine($"[PAGING] 0x7FFD Triggered! Hex: 0x{value:X2} | Bank: {value & 0x07}"); //Debug.WriteLine($"[PAGING] 0x7FFD Triggered! Hex: 0x{value:X2} | Bank: {value & 0x07}");
if (_pagingDisabled || _currentRomBank == 4) return; // Ignore if locked or in 48K mode if (_pagingDisabled || _currentRomBank == 4) return; // Ignore if locked or in 48K mode
if (port == 0x7FFD) if (port == 0x7FFD)
@@ -126,6 +126,11 @@ namespace Core.Memory
} }
} }
public byte[] GetVideoRam()
{
// Bit 3 of 7FFD dictates the active screen. 0 = Bank 5 (Standard), 1 = Bank 7 (Shadow).
return (_port7FFD & 0x08) != 0 ? _ramBanks[7] : _ramBanks[5];
}
public void LoadRom(byte[] romData, int bankIndex) public void LoadRom(byte[] romData, int bankIndex)
{ {
Array.Copy(romData, 0, _romBanks[bankIndex], 0, Math.Min(romData.Length, 0x4000)); Array.Copy(romData, 0, _romBanks[bankIndex], 0, Math.Min(romData.Length, 0x4000));

View File

@@ -227,6 +227,27 @@ namespace Desktop
case Keys.M: UpdateMatrix(7, 2, isPressed); break; case Keys.M: UpdateMatrix(7, 2, isPressed); break;
case Keys.N: UpdateMatrix(7, 3, isPressed); break; case Keys.N: UpdateMatrix(7, 3, isPressed); break;
case Keys.B: UpdateMatrix(7, 4, isPressed); break; case Keys.B: UpdateMatrix(7, 4, isPressed); break;
// --- EXTENDED +2A KEYS (Macros) ---
case Keys.Left:
UpdateMatrix(0, 0, isPressed); // CAPS SHIFT
UpdateMatrix(3, 4, isPressed); // 5
break;
case Keys.Down:
UpdateMatrix(0, 0, isPressed); // CAPS SHIFT
UpdateMatrix(4, 4, isPressed); // 6
break;
case Keys.Up:
UpdateMatrix(0, 0, isPressed); // CAPS SHIFT
UpdateMatrix(4, 3, isPressed); // 7
break;
case Keys.Right:
UpdateMatrix(0, 0, isPressed); // CAPS SHIFT
UpdateMatrix(4, 2, isPressed); // 8
break;
case Keys.Back:
UpdateMatrix(0, 0, isPressed); // CAPS SHIFT
UpdateMatrix(4, 0, isPressed); // 0
break;
} }
} }