Formatting fix only.
[reactos.git] / subsystems / ntvdm / bios.c
index a1b5682..e7657c8 100644 (file)
@@ -37,7 +37,7 @@ static BYTE VideoMode_40x25_text[] =
     0x00, 0x00, 0x00, 0x00, 0x00, 0x10, 0x0E, 0x0F, 0xFF,
 
     /* CRTC Registers */
-    0x2D, 0x27, 0x28, 0x90, 0x2B, 0xA0, 0xBF, 0x1F, 0x00, 0x4F, 0x0E, 0x0F,
+    0x2D, 0x27, 0x28, 0x90, 0x2B, 0xA0, 0xBF, 0x1F, 0x00, 0x4F, 0x0D, 0x0F,
     0x00, 0x00, 0x00, 0x00, 0x9C, 0x8E, 0x8F, 0x14, 0x1F, 0x96, 0xB9, 0xA3,
     0xFF,
 
@@ -58,7 +58,7 @@ static BYTE VideoMode_80x25_text[] =
     0x00, 0x00, 0x00, 0x00, 0x00, 0x10, 0x0E, 0x0F, 0xFF,
 
     /* CRTC Registers */
-    0x5F, 0x4F, 0x50, 0x82, 0x55, 0x81, 0xBF, 0x1F, 0x00, 0x4F, 0x0E, 0x0F,
+    0x5F, 0x4F, 0x50, 0x82, 0x55, 0x81, 0xBF, 0x1F, 0x00, 0x4F, 0x0D, 0x0F,
     0x00, 0x00, 0x00, 0x00, 0x9C, 0x8E, 0x8F, 0x28, 0x1F, 0x96, 0xB9, 0xA3,
     0xFF,
 
@@ -304,9 +304,12 @@ 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;
-    Bda->CharacterHeight = 16;
+
+    /* Get the character height */
+    VgaWritePort(VGA_CRTC_INDEX, VGA_CRTC_MAX_SCAN_LINE_REG);
+    Bda->CharacterHeight = 1 + (VgaReadPort(VGA_CRTC_DATA) & 0x1F);
 
     Resolution = VgaGetDisplayResolution();
     Bda->ScreenColumns = Resolution.X;
@@ -404,11 +407,18 @@ BOOLEAN BiosInitialize(VOID)
         return FALSE;
     }
 
-    /* Store the cursor position */
-    Bda->CursorPosition[0] = MAKEWORD(BiosSavedBufferInfo.dwCursorPosition.X,
-                                      BiosSavedBufferInfo.dwCursorPosition.Y);
-    
-    VgaInitialize(BiosConsoleOutput);
+    /* Initialize VGA */
+    if (!VgaInitialize(BiosConsoleOutput))
+    {
+        CloseHandle(BiosConsoleOutput);
+        CloseHandle(BiosConsoleInput);
+        return FALSE;
+    }
+
+    /* Update the cursor position */
+    BiosSetCursorPosition(BiosSavedBufferInfo.dwCursorPosition.Y,
+                          BiosSavedBufferInfo.dwCursorPosition.X,
+                          0);
 
     /* Set the console input mode */
     SetConsoleMode(BiosConsoleInput, ENABLE_MOUSE_INPUT | ENABLE_PROCESSED_INPUT);
@@ -529,7 +539,7 @@ BOOLEAN BiosScrollWindow(INT Direction,
                          BYTE Page,
                          BYTE FillAttribute)
 {
-    INT i;
+    DWORD i;
     LPWORD WindowData;
     DWORD WindowSize = (Rectangle.Bottom - Rectangle.Top + 1)
                        * (Rectangle.Right - Rectangle.Left + 1);
@@ -624,6 +634,8 @@ VOID BiosVideoService(LPWORD Stack)
         case 0x00:
         {
             BiosSetVideoMode(LOBYTE(Eax));
+            VgaClearMemory();
+
             break;
         }
 
@@ -665,6 +677,17 @@ VOID BiosVideoService(LPWORD Stack)
             break;
         }
 
+        /* Query Light Pen */
+        case 0x04:
+        {
+            /*
+             * On modern BIOSes, this function returns 0
+             * so that we can ignore the other registers.
+             */
+            EmulatorSetRegister(EMULATOR_REG_AX, 0);
+            break;
+        }
+
         /* Select Active Display Page */
         case 0x05:
         {
@@ -693,7 +716,7 @@ VOID BiosVideoService(LPWORD Stack)
             };
 
             /* Call the internal function */
-            BiosScrollWindow((HIBYTE(Eax)== 0x06)
+            BiosScrollWindow((HIBYTE(Eax) == 0x06)
                              ? SCROLL_DIRECTION_UP : SCROLL_DIRECTION_DOWN,
                              LOBYTE(Eax),
                              Rectangle,