]> code.delx.au - refind/blobdiff - refind/screen.c
Version 0.6.1 official release
[refind] / refind / screen.c
index 32711d60e43df1ef466db8d4e01e0f13770f5a3a..7f279dbc8d6ceb62fcb797ee8d34fef754375913 100644 (file)
@@ -100,6 +100,7 @@ VOID InitScreen(VOID)
         AllowGraphicsMode = TRUE;
     } else {
         AllowGraphicsMode = FALSE;
+        egSetTextMode(GlobalConfig.RequestedTextMode);
         egSetGraphicsModeEnabled(FALSE);   // just to be sure we are in text mode
     }
     GraphicsScreenDirty = TRUE;
@@ -116,18 +117,45 @@ VOID InitScreen(VOID)
 
     PrepareBlankLine();
 
-    // show the banner (even when in graphics mode)
-    DrawScreenHeader(L"Initializing...");
+    // show the banner if in text mode
+    if (GlobalConfig.TextOnly)
+       DrawScreenHeader(L"Initializing...");
 }
 
+// Set the screen resolution and mode (text vs. graphics).
 VOID SetupScreen(VOID)
 {
-    GlobalConfig.RequestedTextMode = egSetTextMode(GlobalConfig.RequestedTextMode);
+    UINTN NewWidth, NewHeight;
+
+    // Convert mode number to horizontal & vertical resolution values
+    if ((GlobalConfig.RequestedScreenWidth > 0) && (GlobalConfig.RequestedScreenHeight == 0))
+       egGetResFromMode(&(GlobalConfig.RequestedScreenWidth), &(GlobalConfig.RequestedScreenHeight));
+
+    // Set the believed-to-be current resolution to the LOWER of the current
+    // believed-to-be resolution and the requested resolution. This is done to
+    // enable setting a lower-than-default resolution.
+    if ((GlobalConfig.RequestedScreenWidth > 0) && (GlobalConfig.RequestedScreenHeight > 0)) {
+       UGAWidth = (UGAWidth < GlobalConfig.RequestedScreenWidth) ? UGAWidth : GlobalConfig.RequestedScreenWidth;
+       UGAHeight = (UGAHeight < GlobalConfig.RequestedScreenHeight) ? UGAHeight : GlobalConfig.RequestedScreenHeight;
+    }
+
+    // Set text mode. If this requires increasing the size of the graphics mode, do so.
+    if (egSetTextMode(GlobalConfig.RequestedTextMode)) {
+       egGetScreenSize(&NewWidth, &NewHeight);
+       if ((NewWidth > UGAWidth) || (NewHeight > UGAHeight)) {
+          UGAWidth = NewWidth;
+          UGAHeight = NewHeight;
+       }
+       if ((UGAWidth > GlobalConfig.RequestedScreenWidth) || (UGAHeight > GlobalConfig.RequestedScreenHeight)) {
+           // Requested text mode forces us to use a bigger graphics mode
+           GlobalConfig.RequestedScreenWidth = UGAWidth;
+           GlobalConfig.RequestedScreenHeight = UGAHeight;
+       } // if
+    }
 
-    if ((GlobalConfig.RequestedScreenWidth > 0) &&
-        (egSetScreenSize(&GlobalConfig.RequestedScreenWidth, &GlobalConfig.RequestedScreenHeight))) {
-          UGAWidth = GlobalConfig.RequestedScreenWidth;
-          UGAHeight = GlobalConfig.RequestedScreenHeight;
+    if (GlobalConfig.RequestedScreenWidth > 0) {
+       egSetScreenSize(&GlobalConfig.RequestedScreenWidth, &GlobalConfig.RequestedScreenHeight);
+       egGetScreenSize(&UGAWidth, &UGAHeight);
     } // if user requested a particular screen resolution
 
     if (GlobalConfig.TextOnly) {
@@ -141,7 +169,7 @@ VOID SetupScreen(VOID)
         SwitchToGraphics();
         BltClearScreen(TRUE);
     }
-}
+} // VOID SetupScreen()
 
 VOID SwitchToText(IN BOOLEAN CursorEnabled)
 {
@@ -197,12 +225,10 @@ VOID BeginExternalScreen(IN BOOLEAN UseGraphicsMode, IN CHAR16 *Title)
         SwitchToGraphics();
         BltClearScreen(FALSE);
     } else {
-       egClearScreen(&DarkBackgroundPixel);
-       DrawScreenHeader(Title);
-    } // if/else
-
-    if (!UseGraphicsMode)
+        egClearScreen(&DarkBackgroundPixel);
+        DrawScreenHeader(Title);
         SwitchToText(TRUE);
+    }
 
     // reset error flag
     haveError = FALSE;