[NTVDM]
authorAleksandar Andrejevic <aandrejevic@reactos.org>
Fri, 9 May 2014 21:56:40 +0000 (21:56 +0000)
committerAleksandar Andrejevic <aandrejevic@reactos.org>
Fri, 9 May 2014 21:56:40 +0000 (21:56 +0000)
Replace the temporary CGA hack with a working solution.
CORE-8177 #comment CGA should work as of r63208.

svn path=/trunk/; revision=63208

reactos/subsystems/ntvdm/hardware/vga.c
reactos/subsystems/ntvdm/hardware/vga.h

index 050b5f3..47fe3a6 100644 (file)
@@ -1146,7 +1146,19 @@ static VOID VgaUpdateFramebuffer(VOID)
         /* Loop through the scanlines */
         for (i = 0; i < Resolution.Y; i++)
         {
-            BOOL RepeatScanline = FALSE;
+            DWORD InterlaceHighBit = VGA_INTERLACE_HIGH_BIT;
+
+            if (VgaGcRegisters[VGA_GC_MODE_REG] & VGA_GC_MODE_OE)
+            {
+                /* Shift the high bit right by 1 in odd/even mode */
+                InterlaceHighBit >>= 1;
+            }
+
+            if ((VgaGcRegisters[VGA_GC_MISC_REG] & VGA_GC_MISC_OE) && (i & 1))
+            {
+                /* Odd-numbered line in interlaced mode - set the high bit */
+                Address |= InterlaceHighBit;
+            }
 
             /* Loop through the pixels */
             for (j = 0; j < Resolution.X; j++)
@@ -1203,21 +1215,8 @@ static VOID VgaUpdateFramebuffer(VOID)
                          */
                         DWORD BankNumber = (j / 4) % 2;
                         DWORD Offset = Address + (j / 8);
-                        BYTE LowPlaneData, HighPlaneData;
-
-                        if (i % 2 != 0)
-                        {
-                            /* Odd-numbered line - add the CGA emulation offset */
-                            Offset += VGA_CGA_ODD_LINE_OFFSET;
-                        }
-                        else
-                        {
-                            /* Even-numbered line - use the same scanline */
-                            RepeatScanline = TRUE;
-                        }
-
-                        LowPlaneData = VgaMemory[BankNumber * VGA_BANK_SIZE + Offset * AddressSize];
-                        HighPlaneData = VgaMemory[(BankNumber + 2) * VGA_BANK_SIZE + Offset * AddressSize];
+                        BYTE LowPlaneData = VgaMemory[BankNumber * VGA_BANK_SIZE + Offset * AddressSize];
+                        BYTE HighPlaneData = VgaMemory[(BankNumber + 2) * VGA_BANK_SIZE + Offset * AddressSize];
 
                         /* Extract the two bits from each plane */
                         LowPlaneData = (LowPlaneData >> (6 - ((j % 4) * 2))) & 3;
@@ -1310,8 +1309,17 @@ static VOID VgaUpdateFramebuffer(VOID)
                 }
             }
 
-            /* Move to the next scanline */
-            if (!RepeatScanline) Address += ScanlineSize;
+            if (VgaGcRegisters[VGA_GC_MISC_REG] & VGA_GC_MISC_OE && (i & 1))
+            {
+                /* Clear the high bit */
+                Address &= ~InterlaceHighBit;
+            }
+
+            if (!(VgaGcRegisters[VGA_GC_MISC_REG] & VGA_GC_MISC_OE) || (i & 1))
+            {
+                /* Move to the next scanline */
+                Address += ScanlineSize;
+            }
         }
 
         /*
index ba7884e..ca6de8d 100644 (file)
@@ -24,7 +24,7 @@
 #define VGA_MINIMUM_HEIGHT 300
 #define VGA_DAC_TO_COLOR(x) (((x) << 2) | ((x) >> 4))
 #define VGA_COLOR_TO_DAC(x) ((x) >> 2)
-#define VGA_CGA_ODD_LINE_OFFSET 0x1000
+#define VGA_INTERLACE_HIGH_BIT (1 << 13)
 
 
 /* Register I/O ports */