From 97267bed7ac04d021ed26d781c467626fe710db4 Mon Sep 17 00:00:00 2001 From: Marc Parsons Date: Fri, 24 Apr 2026 21:52:30 +0100 Subject: [PATCH] Added double buffering 2 --- Core/Cpu/Z80.cs | 2 +- Core/Io/ULA.cs | 2 +- Desktop/Form1.cs | 1 + 3 files changed, 3 insertions(+), 2 deletions(-) diff --git a/Core/Cpu/Z80.cs b/Core/Cpu/Z80.cs index ed9c80d..773eaed 100644 --- a/Core/Cpu/Z80.cs +++ b/Core/Cpu/Z80.cs @@ -1596,7 +1596,7 @@ namespace Core.Cpu if ((n & 0x02) != 0) AF.Low |= 0x20; return 16; } - case 0xA9: // CPD (The opcode that just crashed!) + case 0xA9: // CPD { byte memVal = ReadMemory(HL.Word); byte result = (byte)(AF.High - memVal); diff --git a/Core/Io/ULA.cs b/Core/Io/ULA.cs index 451bbb3..aeb41e9 100644 --- a/Core/Io/ULA.cs +++ b/Core/Io/ULA.cs @@ -11,7 +11,7 @@ namespace Core.Io // The ULA owns the frame buffer now! public const int ScreenWidth = 320; public const int ScreenHeight = 256; // Perfectly cropped size - public int[] FrameBuffer { get; private set; } + public int[] FrameBuffer { get; private set; } = new int[ScreenWidth * ScreenHeight]; public int[] FrontBuffer { get; private set; } = new int[ScreenWidth * ScreenHeight]; private int _ulaFrameCount = 0; diff --git a/Desktop/Form1.cs b/Desktop/Form1.cs index ab93bda..b97adab 100644 --- a/Desktop/Form1.cs +++ b/Desktop/Form1.cs @@ -170,6 +170,7 @@ namespace Desktop if (scanlineCount % 312 == 0) { _cpu.RequestInterrupt(); // 50Hz interrupt + _ula.CommitFrame(); TotalFrameCount++; if (highSpeed)