From 516653f4477bfa6d125faf0b9034ef1dcc6c4018 Mon Sep 17 00:00:00 2001 From: Aleksandar Andrejevic Date: Wed, 14 Aug 2013 17:17:43 +0000 Subject: [PATCH] [NTVDM] Fix 16 color modes. Implement 4-bit interleaved shift mode. svn path=/branches/ntvdm/; revision=59738 --- subsystems/ntvdm/vga.c | 35 +++++++++++++++++++++++++++++------ 1 file changed, 29 insertions(+), 6 deletions(-) diff --git a/subsystems/ntvdm/vga.c b/subsystems/ntvdm/vga.c index eae4f113c3c..17f6f18ae57 100644 --- a/subsystems/ntvdm/vga.c +++ b/subsystems/ntvdm/vga.c @@ -572,13 +572,30 @@ static VOID VgaUpdateFramebuffer(VOID) } else if (VgaGcRegisters[VGA_GC_MODE_REG] & VGA_GC_MODE_SHIFTREG) { - /* - * 2 bits shifted from plane 0 and 2 for the first 4 pixels, - * then 2 bits shifted from plane 1 and 3 for the next 4 - */ + /* Check if this is 16 or 256 color mode */ + if (VgaAcRegisters[VGA_AC_CONTROL_REG] & VGA_AC_CONTROL_8BIT) + { + /* + * 2 bits shifted from plane 0 and 2 for the first 4 pixels, + * then 2 bits shifted from plane 1 and 3 for the next 4 + */ + BYTE LowPlaneData = VgaMemory[((j / 4) % 2) * VGA_BANK_SIZE + + (Address + (j / 4)) * AddressSize]; + BYTE HighPlaneData = VgaMemory[(((j / 4) % 2) + 1) * VGA_BANK_SIZE + + (Address + (j / 4)) * AddressSize]; - // TODO: NOT IMPLEMENTED! - DPRINT1("Interleaved shift mode is not implemented!\n"); + /* Extract the two bits from each plane */ + LowPlaneData = (LowPlaneData >> (6 - ((j % 4) * 2))) & 3; + HighPlaneData = (HighPlaneData >> (6 - ((j % 4) * 2))) & 3; + + /* Combine them into the pixel */ + PixelData = LowPlaneData | (HighPlaneData << 2); + } + else + { + // TODO: NOT IMPLEMENTED + DPRINT1("8-bit interleaved mode is not implemented!\n"); + } } else { @@ -620,6 +637,12 @@ static VOID VgaUpdateFramebuffer(VOID) } } + if (!(VgaAcRegisters[VGA_AC_CONTROL_REG] & VGA_AC_CONTROL_8BIT)) + { + /* In 16 color mode, the value is an index to the AC registers */ + PixelData = VgaAcRegisters[PixelData]; + } + /* Now check if the resulting pixel data has changed */ if (GraphicsBuffer[i * Resolution.X + j] != PixelData) {