[FREELDR:PC] Cache the type of video card installed on the system (#8505)

Cache the type when initializing the video, instead of invoking every time
`PcVideoDetectVideoCard()`. Indeed, the video card is not going to change
magically at runtime by the user :D
This commit is contained in:
Hermès Bélusca-Maïto
2025-12-16 20:13:07 +01:00
parent 0ffed7fd1e
commit 617f3bddfa
3 changed files with 15 additions and 5 deletions

View File

@@ -1807,6 +1807,7 @@ MachInit(const char *CmdLine)
MachVtbl.HwIdle = PcHwIdle;
HalpCalibrateStallExecution();
PcVideoInit();
}
VOID

View File

@@ -110,6 +110,7 @@ typedef struct
UCHAR MachDefaultTextColor = COLOR_GRAY;
static ULONG VideoCard = VIDEOCARD_CGA_OR_OTHER; /* Type of video card installed on the system */
static USHORT BiosVideoMode; /* Current video mode as known by BIOS */
static ULONG ScreenWidth = 80; /* Screen Width in characters */
static ULONG ScreenHeight = 25; /* Screen Height in characters */
@@ -587,7 +588,7 @@ PcVideoSetMode80x25(VOID)
static BOOLEAN
PcVideoSetMode80x50_80x43(VOID)
{
if (VIDEOCARD_VGA == PcVideoDetectVideoCard())
if (VideoCard == VIDEOCARD_VGA)
{
PcVideoSetBiosMode(0x03);
PcVideoSetFont8x8();
@@ -597,7 +598,7 @@ PcVideoSetMode80x50_80x43(VOID)
ScreenWidth = 80;
ScreenHeight = 50;
}
else if (VIDEOCARD_EGA == PcVideoDetectVideoCard())
else if (VideoCard == VIDEOCARD_EGA)
{
PcVideoSetBiosMode(0x03);
PcVideoSetFont8x8();
@@ -843,6 +844,13 @@ PcVideoSetMemoryBank(USHORT BankNumber)
CurrentMemoryBank = BankNumber;
}
VOID
PcVideoInit(VOID)
{
/* Detect the installed video card */
VideoCard = PcVideoDetectVideoCard();
}
VIDEODISPLAYMODE
PcVideoSetDisplayMode(PCSTR DisplayModeName, BOOLEAN Init)
{
@@ -854,21 +862,21 @@ PcVideoSetDisplayMode(PCSTR DisplayModeName, BOOLEAN Init)
return DisplayMode;
}
if (VIDEOCARD_CGA_OR_OTHER == PcVideoDetectVideoCard())
if (VideoCard == VIDEOCARD_CGA_OR_OTHER)
{
TRACE("CGA or other display adapter detected.\n");
printf("CGA or other display adapter detected.\n");
printf("Using 80x25 text mode.\n");
VideoMode = VIDEOMODE_NORMAL_TEXT;
}
else if (VIDEOCARD_EGA == PcVideoDetectVideoCard())
else if (VideoCard == VIDEOCARD_EGA)
{
TRACE("EGA display adapter detected.\n");
printf("EGA display adapter detected.\n");
printf("Using 80x25 text mode.\n");
VideoMode = VIDEOMODE_NORMAL_TEXT;
}
else /* if (VIDEOCARD_VGA == PcVideoDetectVideoCard()) */
else /* VIDEOCARD_VGA */
{
TRACE("VGA display adapter detected.\n");

View File

@@ -30,6 +30,7 @@ VOID PcConsPutChar(int Ch);
BOOLEAN PcConsKbHit(VOID);
int PcConsGetCh(VOID);
VOID PcVideoInit(VOID);
VOID PcVideoClearScreen(UCHAR Attr);
VIDEODISPLAYMODE PcVideoSetDisplayMode(PCSTR DisplayMode, BOOLEAN Init);
VOID PcVideoGetDisplaySize(PULONG Width, PULONG Height, PULONG Depth);