[NTVDM]
authorAleksandar Andrejevic <aandrejevic@reactos.org>
Sat, 10 Aug 2013 19:24:00 +0000 (19:24 +0000)
committerAleksandar Andrejevic <aandrejevic@reactos.org>
Sat, 10 Aug 2013 19:24:00 +0000 (19:24 +0000)
Clear the screen when switching video modes.

svn path=/branches/ntvdm/; revision=59688

subsystems/ntvdm/bios.c

index 37e84df..1af7b8b 100644 (file)
@@ -255,6 +255,31 @@ static VOID BiosWriteWindow(LPWORD Buffer, SMALL_RECT Rectangle, BYTE Page)
     }
 }
 
+static VOID BiosClearScreen(VOID)
+{
+    INT i;
+    BYTE PlaneMask;
+
+    /* Save the plane write register */
+    VgaWritePort(VGA_SEQ_INDEX, VGA_SEQ_MASK_REG);
+    PlaneMask = VgaReadPort(VGA_SEQ_DATA);
+
+    /* Write to all planes */
+    VgaWritePort(VGA_SEQ_DATA, 0x0F);
+
+    /* Clear the screen */
+    for (i = VgaGetVideoBaseAddress();
+         i < VgaGetVideoLimitAddress();
+         i += sizeof(DWORD))
+    {
+        DWORD Zero = 0;
+        VgaWriteMemory(i, (LPVOID)&Zero, sizeof(DWORD));
+    }
+
+    /* Restore the plane write register */
+    VgaWritePort(VGA_SEQ_DATA, PlaneMask);
+}
+
 /* PUBLIC FUNCTIONS ***********************************************************/
 
 BYTE BiosGetVideoMode(VOID)
@@ -304,7 +329,7 @@ BOOLEAN BiosSetVideoMode(BYTE ModeNumber)
     /* Update the values in the BDA */
     Bda->VideoMode = ModeNumber;
     Bda->VideoPage = 0;
-    Bda->VideoPageSize   = BIOS_PAGE_SIZE;
+    Bda->VideoPageSize = BIOS_PAGE_SIZE;
     Bda->VideoPageOffset = 0;
 
     /* Get the character height */
@@ -629,6 +654,8 @@ VOID BiosVideoService(LPWORD Stack)
         case 0x00:
         {
             BiosSetVideoMode(LOBYTE(Eax));
+            BiosClearScreen();
+
             break;
         }