From 827028386831d03c05509661a2b951d30a164a3e Mon Sep 17 00:00:00 2001 From: Sean Cross Date: Mon, 23 Nov 2020 19:31:11 +0800 Subject: [PATCH] renode: memlcd: accurately map all hardware dirty bits Previously we were only checking one dirty bit, which doesn't match what's going on with the real hardware. Check all the bits to ensure we're accurate. Signed-off-by: Sean Cross --- emulation/peripherals/memlcd.cs | 22 +++++++++++++++++++--- 1 file changed, 19 insertions(+), 3 deletions(-) diff --git a/emulation/peripherals/memlcd.cs b/emulation/peripherals/memlcd.cs index 792582731..13a72556d 100644 --- a/emulation/peripherals/memlcd.cs +++ b/emulation/peripherals/memlcd.cs @@ -6,6 +6,7 @@ // using System; +using System.Linq; using Antmicro.Renode.Backends.Display; using Antmicro.Renode.Core; using Antmicro.Renode.Core.Structure.Registers; @@ -51,9 +52,23 @@ namespace Antmicro.Renode.Peripherals.Video machine.SystemBus.ReadBytes(bufferAddress, newbuf.Length, newbuf, 0); for (int y = 0; y < Height; y++) { - if (!updateDirty || updateAll || ((newbuf[y * 44 + 0x2a] & 0x1) == 0x1)) for (int x = 0; x < Width; x++) + // We should redraw the line if: + // 1) The `updateDirty` bit is set and the current line is dirty, or + // 2) The `updateAll` bit is set. + bool shouldRedrawLine = updateAll; + foreach (int i in Enumerable.Range(42, 22)) { + if (shouldRedrawLine) { + break; + } + if (updateDirty && (newbuf[y * 44 + i] != 0)) { + shouldRedrawLine = true; + } + } + if (shouldRedrawLine) + { + for (int x = 0; x < Width; x++) { - if (((newbuf[((x + y * 44 * 8)) / 8] >> (x % 8)) & 1) > 0) + if (((newbuf[(x + y * 44 * 8) / 8] >> (x % 8)) & 1) > 0) { buffer[2 * (x + y * Width)] = 0xFF; buffer[2 * (x + y * Width) + 1] = 0xFF; @@ -64,6 +79,7 @@ namespace Antmicro.Renode.Peripherals.Video buffer[2 * (x + y * Width) + 1] = 0x0; } } + } } } @@ -85,7 +101,7 @@ namespace Antmicro.Renode.Peripherals.Video private bool updateDirty = false; private bool updateAll = false; - private uint bufferAddress = 0xB0000000; + private readonly uint bufferAddress = 0xB0000000; private readonly Machine machine;