From de698f05a70186c5854417a95bb77b8459aedd7f Mon Sep 17 00:00:00 2001 From: Asnivor Date: Fri, 6 Sep 2024 19:12:18 +0100 Subject: [PATCH] [ChannelFHawk] Revert VRAM back to the correct size and mitigate any index out of range errors in the ClockVideo() method --- .../Fairchild/ChannelF/ChannelF.IVideoProvider.cs | 15 +++++++++------ 1 file changed, 9 insertions(+), 6 deletions(-) diff --git a/src/BizHawk.Emulation.Cores/Consoles/Fairchild/ChannelF/ChannelF.IVideoProvider.cs b/src/BizHawk.Emulation.Cores/Consoles/Fairchild/ChannelF/ChannelF.IVideoProvider.cs index 4e4fc0ac6a..a5629806b5 100644 --- a/src/BizHawk.Emulation.Cores/Consoles/Fairchild/ChannelF/ChannelF.IVideoProvider.cs +++ b/src/BizHawk.Emulation.Cores/Consoles/Fairchild/ChannelF/ChannelF.IVideoProvider.cs @@ -10,7 +10,7 @@ namespace BizHawk.Emulation.Cores.Consoles.ChannelF /// For the purposes of this core we will use 8192 bytes and just mask 0x03 /// (Also adding an additional 10 rows to the RAM buffer so that it's more aligned with the actual display) /// - public byte[] VRAM = new byte[128 * (64 + 10)]; + public byte[] VRAM = new byte[128 * 64]; public static readonly int[] FPalette = @@ -82,12 +82,15 @@ namespace BizHawk.Emulation.Cores.Consoles.ChannelF else { // active display - var p1 = (VRAM[(currRowInVram * 0x80) + 125]) & 0x03; - var p2 = (VRAM[(currRowInVram * 0x80) + 126]) & 0x03; - var pOffset = ((p2 & 0x02) | (p1 >> 1)) << 2; + if (currRowInVram < 64) + { + var p1 = (VRAM[(currRowInVram * 0x80) + 125]) & 0x03; + var p2 = (VRAM[(currRowInVram * 0x80) + 126]) & 0x03; + var pOffset = ((p2 & 0x02) | (p1 >> 1)) << 2; - var colourIndex = pOffset + (VRAM[currColInVram | (currRowInVram << 7)] & 0x03); - videoBuffer[(currScanline * HTotal) + currPixelInLine] = FPalette[CMap[colourIndex]]; + var colourIndex = pOffset + (VRAM[currColInVram | (currRowInVram << 7)] & 0x03); + videoBuffer[(currScanline * HTotal) + currPixelInLine] = FPalette[CMap[colourIndex]]; + } } _pixelClockCounter++;