[NTVDM]
authorAleksandar Andrejevic <aandrejevic@reactos.org>
Sat, 10 Aug 2013 19:30:14 +0000 (19:30 +0000)
committerAleksandar Andrejevic <aandrejevic@reactos.org>
Sat, 10 Aug 2013 19:30:14 +0000 (19:30 +0000)
Optimize screen clearing by implementing it as a helper function in vga.c.

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

subsystems/ntvdm/bios.c
subsystems/ntvdm/vga.c
subsystems/ntvdm/vga.h

index 1af7b8b..058ff64 100644 (file)
@@ -255,31 +255,6 @@ 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)
@@ -654,7 +629,7 @@ VOID BiosVideoService(LPWORD Stack)
         case 0x00:
         {
             BiosSetVideoMode(LOBYTE(Eax));
-            BiosClearScreen();
+            VgaClearMemory();
 
             break;
         }
index 4eef0ef..cebd09d 100644 (file)
@@ -1021,6 +1021,11 @@ VOID VgaWritePort(WORD Port, BYTE Data)
     }
 }
 
+VOID VgaClearMemory(VOID)
+{
+    ZeroMemory(VgaMemory, sizeof(VgaMemory));
+}
+
 VOID VgaInitialize(HANDLE TextHandle)
 {
     INT i, j;
index 533fb24..b06cc75 100644 (file)
@@ -193,6 +193,7 @@ VOID VgaReadMemory(DWORD Address, LPBYTE Buffer, DWORD Size);
 VOID VgaWriteMemory(DWORD Address, LPBYTE Buffer, DWORD Size);
 BYTE VgaReadPort(WORD Port);
 VOID VgaWritePort(WORD Port, BYTE Data);
+VOID VgaClearMemory(VOID);
 VOID VgaInitialize(HANDLE TextHandle);
 
 #endif // _VGA_H_