* Sync up to trunk head (r65074).
[reactos.git] / subsystems / ntvdm / bios / vidbios.c
index 3948121..bb5e537 100644 (file)
@@ -2296,9 +2296,16 @@ static BOOLEAN VidBiosSetVideoMode(BYTE ModeNumber)
 {
     BYTE Page;
     COORD Resolution;
-    BOOLEAN DoNotClear = !!(ModeNumber & 0x80);
     PVGA_REGISTERS VgaMode;
 
+    /*
+     * IBM standard modes do not clear the screen if the
+     * high bit of AL is set (EGA or higher only).
+     * See Ralf Brown: http://www.ctyme.com/intr/rb-0069.htm
+     * for more information.
+     */
+    BOOLEAN DoNotClear = !!(ModeNumber & 0x80);
+
     /* Retrieve the real mode number and check its validity */
     ModeNumber &= 0x7F;
     // if (ModeNumber >= sizeof(VideoModes)/sizeof(VideoModes[0]))
@@ -2308,6 +2315,14 @@ static BOOLEAN VidBiosSetVideoMode(BYTE ModeNumber)
         return FALSE;
     }
 
+    /* Check if this is the current mode */
+    if (ModeNumber == Bda->VideoMode)
+    {
+        /* Just clear the VGA memory if needed */
+        if (!DoNotClear) VgaClearMemory();
+        return TRUE;
+    }
+
     VgaMode = VideoModes[ModeNumber];
 
     DPRINT1("Switching to mode %02Xh %s clearing the screen; VgaMode = 0x%p\n",
@@ -2317,12 +2332,7 @@ static BOOLEAN VidBiosSetVideoMode(BYTE ModeNumber)
 
     VgaChangePalette(ModeNumber);
 
-    /*
-     * IBM standard modes do not clear the screen if the
-     * high bit of AL is set (EGA or higher only).
-     * See Ralf Brown: http://www.ctyme.com/intr/rb-0069.htm
-     * for more information.
-     */
+    /* Clear the VGA memory if needed */
     if (!DoNotClear) VgaClearMemory();
 
     // Bda->CrtModeControl;