#define READ_REGISTER_USHORT(r) (*(volatile USHORT * const)(r))
#define WRITE_REGISTER_USHORT(r, v) (*(volatile USHORT *)(r) = (v))
-PALETTE_ENTRY VidpVga8To16BitTransform[16] =
-{
- {0x00, 0x00, 0x00}, // Black
- {0x00, 0x00, 0x08}, // Blue
- {0x00, 0x08, 0x00}, // Green
- {0x00, 0x08, 0x08}, // Cyan
- {0x08, 0x00, 0x00}, // Red
- {0x08, 0x00, 0x08}, // Magenta
- {0x0B, 0x0D, 0x0F}, // Brown
- {0x10, 0x10, 0x10}, // Light Gray
- {0x08, 0x08, 0x08}, // Dark Gray
- {0x00, 0x00, 0x1F}, // Light Blue
- {0x00, 0x1F, 0x00}, // Light Green
- {0x00, 0x1F, 0x1F}, // Light Cyan
- {0x1F, 0x00, 0x00}, // Light Red
- {0x1F, 0x00, 0x1F}, // Light Magenta
- {0x1F, 0x1F, 0x00}, // Yellow
- {0x1F, 0x1F, 0x1F}, // White
-};
-
FORCEINLINE
USHORT
-VidpBuildColor(_In_ UCHAR Color)
+VidpBuildColor(
+ _In_ UCHAR Color)
{
UCHAR Red, Green, Blue;
/* Extract color components */
- Red = VidpVga8To16BitTransform[Color].Red;
- Green = VidpVga8To16BitTransform[Color].Green;
- Blue = VidpVga8To16BitTransform[Color].Blue;
+ Red = GetRValue(DefaultPalette[Color]) >> 3;
+ Green = GetGValue(DefaultPalette[Color]) >> 3;
+ Blue = GetBValue(DefaultPalette[Color]) >> 3;
/* Build the 16-bit color mask */
return ((Red & 0x1F) << 11) | ((Green & 0x1F) << 6) | ((Blue & 0x1F));
}
+VOID
+NTAPI
+InitPaletteWithTable(
+ _In_ PULONG Table,
+ _In_ ULONG Count);
+
FORCEINLINE
VOID
SetPixel(
/* Set our color */
WRITE_REGISTER_USHORT(PixelPosition, VidpBuildColor(Color));
}
+
+VOID
+NTAPI
+PreserveRow(
+ _In_ ULONG CurrentTop,
+ _In_ ULONG TopDelta,
+ _In_ BOOLEAN Restore);
+
+VOID
+NTAPI
+DoScroll(
+ _In_ ULONG Scroll);
+
+VOID
+NTAPI
+DisplayCharacter(
+ _In_ CHAR Character,
+ _In_ ULONG Left,
+ _In_ ULONG Top,
+ _In_ ULONG TextColor,
+ _In_ ULONG BackColor);
PUSHORT VgaArmBase;
PHYSICAL_ADDRESS VgaPhysical;
-BOOLEAN ClearRow = FALSE;
/* PRIVATE FUNCTIONS *********************************************************/
VOID
NTAPI
-DisplayCharacter(IN CHAR Character,
- IN ULONG Left,
- IN ULONG Top,
- IN ULONG TextColor,
- IN ULONG BackColor)
+DisplayCharacter(
+ _In_ CHAR Character,
+ _In_ ULONG Left,
+ _In_ ULONG Top,
+ _In_ ULONG TextColor,
+ _In_ ULONG BackColor)
{
PUCHAR FontChar;
ULONG i, j, XOffset;
/* Get the font line for this character */
- FontChar = &FontData[Character * BOOTCHAR_HEIGHT - Top];
+ FontChar = &VidpFontData[Character * BOOTCHAR_HEIGHT - Top];
/* Loop each pixel height */
for (i = BOOTCHAR_HEIGHT; i > 0; --i)
/* We do, use the given Text Color */
SetPixel(XOffset, Top, (UCHAR)TextColor);
}
- else if (BackColor < 16)
+ else if (BackColor < BV_COLOR_NONE)
{
/*
* This is a background pixel. We're drawing it
VOID
NTAPI
-VgaScroll(IN ULONG Scroll)
+DoScroll(
+ _In_ ULONG Scroll)
{
ULONG Top, Offset;
PUSHORT SourceOffset, DestOffset;
VOID
NTAPI
-PreserveRow(IN ULONG CurrentTop,
- IN ULONG TopDelta,
- IN BOOLEAN Restore)
+PreserveRow(
+ _In_ ULONG CurrentTop,
+ _In_ ULONG TopDelta,
+ _In_ BOOLEAN Restore)
{
PUSHORT Position1, Position2;
ULONG Count;
*/
BOOLEAN
NTAPI
-VidInitialize(IN BOOLEAN SetMode)
+VidInitialize(
+ _In_ BOOLEAN SetMode)
{
DPRINT1("bv-arm v0.1\n");
*/
VOID
NTAPI
-VidResetDisplay(IN BOOLEAN HalReset)
+VidResetDisplay(
+ _In_ BOOLEAN HalReset)
{
//
// Clear the current position
//
// Re-initialize the palette and fill the screen black
//
- //InitializePalette();
- VidSolidColorFill(0, 0, SCREEN_WIDTH - 1, SCREEN_HEIGHT - 1, 0);
-}
-
-/*
- * @implemented
- */
-ULONG
-NTAPI
-VidSetTextColor(IN ULONG Color)
-{
- UCHAR OldColor;
-
- //
- // Save the old, set the new
- //
- OldColor = VidpTextColor;
- VidpTextColor = Color;
-
- //
- // Return the old text color
- //
- return OldColor;
+ InitializePalette();
+ VidSolidColorFill(0, 0, SCREEN_WIDTH - 1, SCREEN_HEIGHT - 1, BV_COLOR_BLACK);
}
/*
*/
VOID
NTAPI
-VidDisplayString(IN PUCHAR String)
-{
- ULONG TopDelta = BOOTCHAR_HEIGHT + 1;
-
- /* Start looping the string */
- for (; *String; ++String)
- {
- /* Treat new-line separately */
- if (*String == '\n')
- {
- /* Modify Y position */
- VidpCurrentY += TopDelta;
- if (VidpCurrentY + TopDelta - 1 > VidpScrollRegion[3])
- {
- /* Scroll the view and clear the current row */
- VgaScroll(TopDelta);
- VidpCurrentY -= TopDelta;
- PreserveRow(VidpCurrentY, TopDelta, TRUE);
- }
- else
- {
- /* Preserve the current row */
- PreserveRow(VidpCurrentY, TopDelta, FALSE);
- }
-
- /* Update current X */
- VidpCurrentX = VidpScrollRegion[0];
-
- /* No need to clear this row */
- ClearRow = FALSE;
- }
- else if (*String == '\r')
- {
- /* Update current X */
- VidpCurrentX = VidpScrollRegion[0];
-
- /* If a new-line does not follow we will clear the current row */
- if (String[1] != '\n') ClearRow = TRUE;
- }
- else
- {
- /* Clear the current row if we had a return-carriage without a new-line */
- if (ClearRow)
- {
- PreserveRow(VidpCurrentY, TopDelta, TRUE);
- ClearRow = FALSE;
- }
-
- /* Display this character */
- DisplayCharacter(*String,
- VidpCurrentX,
- VidpCurrentY,
- VidpTextColor,
- 16);
- VidpCurrentX += 8;
-
- /* Check if we should scroll */
- if (VidpCurrentX + 7 > VidpScrollRegion[2])
- {
- /* Update Y position and check if we should scroll it */
- VidpCurrentY += TopDelta;
- if (VidpCurrentY + TopDelta - 1 > VidpScrollRegion[3])
- {
- /* Scroll the view and clear the current row */
- VgaScroll(TopDelta);
- VidpCurrentY -= TopDelta;
- PreserveRow(VidpCurrentY, TopDelta, TRUE);
- }
- else
- {
- /* Preserve the current row */
- PreserveRow(VidpCurrentY, TopDelta, FALSE);
- }
-
- /* Update current X */
- VidpCurrentX = VidpScrollRegion[0];
- }
- }
- }
-}
-
-/*
- * @implemented
- */
-VOID
-NTAPI
-VidScreenToBufferBlt(OUT PUCHAR Buffer,
- IN ULONG Left,
- IN ULONG Top,
- IN ULONG Width,
- IN ULONG Height,
- IN ULONG Delta)
+VidScreenToBufferBlt(
+ _Out_ PUCHAR Buffer,
+ _In_ ULONG Left,
+ _In_ ULONG Top,
+ _In_ ULONG Width,
+ _In_ ULONG Height,
+ _In_ ULONG Delta)
{
UNIMPLEMENTED;
while (TRUE);
*/
VOID
NTAPI
-VidSolidColorFill(IN ULONG Left,
- IN ULONG Top,
- IN ULONG Right,
- IN ULONG Bottom,
- IN UCHAR Color)
+VidSolidColorFill(
+ _In_ ULONG Left,
+ _In_ ULONG Top,
+ _In_ ULONG Right,
+ _In_ ULONG Bottom,
+ _In_ UCHAR Color)
{
int y, x;
/* GLOBALS ********************************************************************/
-UCHAR VidpTextColor = 0x0F;
+UCHAR VidpTextColor = BV_COLOR_WHITE;
ULONG VidpCurrentX = 0;
ULONG VidpCurrentY = 0;
SCREEN_HEIGHT - 1
};
+/*
+ * Boot video driver default palette is similar to the standard 16-color
+ * CGA palette, but it has Red and Blue channels swapped, and also dark
+ * and light gray colors swapped.
+ */
+const RGBQUAD VidpDefaultPalette[BV_MAX_COLORS] =
+{
+ RGB( 0, 0, 0), /* Black */
+ RGB(128, 0, 0), /* Red */
+ RGB( 0, 128, 0), /* Green */
+ RGB(128, 128, 0), /* Brown */
+ RGB( 0, 0, 128), /* Blue */
+ RGB(128, 0, 128), /* Magenta */
+ RGB( 0, 128, 128), /* Cyan */
+ RGB(128, 128, 128), /* Dark Gray */
+ RGB(192, 192, 192), /* Light Gray */
+ RGB(255, 0, 0), /* Light Red */
+ RGB( 0, 255, 0), /* Light Green */
+ RGB(255, 255, 0), /* Yellow */
+ RGB( 0, 0, 255), /* Light Blue */
+ RGB(255, 0, 255), /* Light Magenta */
+ RGB( 0, 255, 255), /* Light Cyan */
+ RGB(255, 255, 255), /* White */
+};
+
+static BOOLEAN ClearRow = FALSE;
+
/* PRIVATE FUNCTIONS **********************************************************/
static VOID
/* PUBLIC FUNCTIONS ***********************************************************/
+/*
+ * @implemented
+ */
+ULONG
+NTAPI
+VidSetTextColor(
+ _In_ ULONG Color)
+{
+ ULONG OldColor;
+
+ /* Save the old color and set the new one */
+ OldColor = VidpTextColor;
+ VidpTextColor = Color;
+ return OldColor;
+}
+
VOID
NTAPI
VidDisplayStringXY(
* If the caller wanted transparent, then send the special value (16),
* else use our default and call the helper routine.
*/
- BackColor = Transparent ? 16 : 14;
+ BackColor = Transparent ? BV_COLOR_NONE : BV_COLOR_LIGHT_CYAN;
/* Loop every character and adjust the position */
- for (; *String; ++String, Left += 8)
+ for (; *String; ++String, Left += BOOTCHAR_WIDTH)
{
/* Display a character */
- DisplayCharacter(*String, Left, Top, 12, BackColor);
+ DisplayCharacter(*String, Left, Top, BV_COLOR_LIGHT_BLUE, BackColor);
}
}
_In_ ULONG Bottom)
{
/* Assert alignment */
- ASSERT((Left & 0x7) == 0);
- ASSERT((Right & 0x7) == 7);
+ ASSERT((Left % BOOTCHAR_WIDTH) == 0);
+ ASSERT((Right % BOOTCHAR_WIDTH) == BOOTCHAR_WIDTH - 1);
/* Set Scroll Region */
VidpScrollRegion[0] = Left;
VidpCurrentY = Top;
}
+/*
+ * @implemented
+ */
+VOID
+NTAPI
+VidDisplayString(
+ _In_ PUCHAR String)
+{
+ /* Start looping the string */
+ for (; *String; ++String)
+ {
+ /* Treat new-line separately */
+ if (*String == '\n')
+ {
+ /* Modify Y position */
+ VidpCurrentY += BOOTCHAR_HEIGHT + 1;
+ if (VidpCurrentY + BOOTCHAR_HEIGHT > VidpScrollRegion[3])
+ {
+ /* Scroll the view and clear the current row */
+ DoScroll(BOOTCHAR_HEIGHT + 1);
+ VidpCurrentY -= BOOTCHAR_HEIGHT + 1;
+ PreserveRow(VidpCurrentY, BOOTCHAR_HEIGHT + 1, TRUE);
+ }
+ else
+ {
+ /* Preserve the current row */
+ PreserveRow(VidpCurrentY, BOOTCHAR_HEIGHT + 1, FALSE);
+ }
+
+ /* Update current X */
+ VidpCurrentX = VidpScrollRegion[0];
+
+ /* No need to clear this row */
+ ClearRow = FALSE;
+ }
+ else if (*String == '\r')
+ {
+ /* Update current X */
+ VidpCurrentX = VidpScrollRegion[0];
+
+ /* If a new-line does not follow we will clear the current row */
+ if (String[1] != '\n') ClearRow = TRUE;
+ }
+ else
+ {
+ /* Clear the current row if we had a return-carriage without a new-line */
+ if (ClearRow)
+ {
+ PreserveRow(VidpCurrentY, BOOTCHAR_HEIGHT + 1, TRUE);
+ ClearRow = FALSE;
+ }
+
+ /* Display this character */
+ DisplayCharacter(*String, VidpCurrentX, VidpCurrentY, VidpTextColor, BV_COLOR_NONE);
+ VidpCurrentX += BOOTCHAR_WIDTH;
+
+ /* Check if we should scroll */
+ if (VidpCurrentX + BOOTCHAR_WIDTH - 1 > VidpScrollRegion[2])
+ {
+ /* Update Y position and check if we should scroll it */
+ VidpCurrentY += BOOTCHAR_HEIGHT + 1;
+ if (VidpCurrentY + BOOTCHAR_HEIGHT > VidpScrollRegion[3])
+ {
+ /* Scroll the view and clear the current row */
+ DoScroll(BOOTCHAR_HEIGHT + 1);
+ VidpCurrentY -= BOOTCHAR_HEIGHT + 1;
+ PreserveRow(VidpCurrentY, BOOTCHAR_HEIGHT + 1, TRUE);
+ }
+ else
+ {
+ /* Preserve the current row */
+ PreserveRow(VidpCurrentY, BOOTCHAR_HEIGHT + 1, FALSE);
+ }
+
+ /* Update current X */
+ VidpCurrentX = VidpScrollRegion[0];
+ }
+ }
+ }
+}
+
VOID
NTAPI
VidBufferToScreenBlt(
PBITMAPINFOHEADER BitmapInfoHeader;
LONG Delta;
PUCHAR BitmapOffset;
+ ULONG PaletteCount;
/* Get the Bitmap Header */
BitmapInfoHeader = (PBITMAPINFOHEADER)Buffer;
/* Initialize the palette */
+ PaletteCount = BitmapInfoHeader->biClrUsed ?
+ BitmapInfoHeader->biClrUsed : BV_MAX_COLORS;
InitPaletteWithTable((PULONG)(Buffer + BitmapInfoHeader->biSize),
- (BitmapInfoHeader->biClrUsed) ?
- BitmapInfoHeader->biClrUsed : 16);
+ PaletteCount);
/* Make sure we can support this bitmap */
ASSERT((BitmapInfoHeader->biBitCount * BitmapInfoHeader->biPlanes) <= 4);
Delta = (BitmapInfoHeader->biBitCount * BitmapInfoHeader->biWidth) + 31;
Delta >>= 3;
Delta &= ~3;
- BitmapOffset = Buffer + sizeof(BITMAPINFOHEADER) + 16 * sizeof(ULONG);
+ BitmapOffset = Buffer + sizeof(BITMAPINFOHEADER) + PaletteCount * sizeof(ULONG);
/* Check the compression of the bitmap */
if (BitmapInfoHeader->biCompression == BI_RLE4)
// Available from http://mirtchovski.com/p9/fonts/
// FontData Array generated by bootvid_font_generator.
//
-UCHAR FontData[256 * BOOTCHAR_HEIGHT] =
+UCHAR VidpFontData[256 * BOOTCHAR_HEIGHT] =
{
0x00, 0x00, 0x00, 0x00, 0xFE, 0x82, 0x82, 0x82, 0x82, 0x82, 0xFE, 0x00, 0x00, // 0
0x00, 0x00, 0x00, 0x00, 0xFE, 0x82, 0x82, 0x82, 0x82, 0x82, 0xFE, 0x00, 0x00, // 13
static BOOLEAN
NTAPI
-VgaInterpretCmdStream(IN PUSHORT CmdStream)
+VgaInterpretCmdStream(
+ _In_ PUSHORT CmdStream)
{
USHORT Cmd;
UCHAR Major, Minor;
*/
BOOLEAN
NTAPI
-VidInitialize(IN BOOLEAN SetMode)
+VidInitialize(
+ _In_ BOOLEAN SetMode)
{
ULONG_PTR Context = 0;
PHYSICAL_ADDRESS TranslatedAddress;
*/
VOID
NTAPI
-VidResetDisplay(IN BOOLEAN HalReset)
+VidResetDisplay(
+ _In_ BOOLEAN HalReset)
{
/* Clear the current position */
VidpCurrentX = 0;
/* Re-initialize the palette and fill the screen black */
InitializePalette();
- VidSolidColorFill(0, 0, SCREEN_WIDTH - 1, SCREEN_HEIGHT - 1, 0);
+ VidSolidColorFill(0, 0, SCREEN_WIDTH - 1, SCREEN_HEIGHT - 1, BV_COLOR_BLACK);
}
#define __outpw(Port, Value) \
WRITE_PORT_USHORT((PUSHORT)(VgaRegisterBase + (Port)), (USHORT)(Value))
+VOID
+NTAPI
+InitPaletteWithTable(
+ _In_ PULONG Table,
+ _In_ ULONG Count);
+
+VOID
+PrepareForSetPixel(VOID);
+
FORCEINLINE
VOID
SetPixel(
/* Read the current pixel value and add our color */
WRITE_REGISTER_UCHAR(PixelPosition, READ_REGISTER_UCHAR(PixelPosition) & Color);
}
+
+VOID
+NTAPI
+PreserveRow(
+ _In_ ULONG CurrentTop,
+ _In_ ULONG TopDelta,
+ _In_ BOOLEAN Restore);
+
+VOID
+NTAPI
+DoScroll(
+ _In_ ULONG Scroll);
+
+VOID
+NTAPI
+DisplayCharacter(
+ _In_ CHAR Character,
+ _In_ ULONG Left,
+ _In_ ULONG Top,
+ _In_ ULONG TextColor,
+ _In_ ULONG BackColor);
ULONG_PTR VgaRegisterBase = 0;
ULONG_PTR VgaBase = 0;
-static BOOLEAN ClearRow = FALSE;
/* PRIVATE FUNCTIONS *********************************************************/
static VOID
NTAPI
-ReadWriteMode(IN UCHAR Mode)
+ReadWriteMode(
+ _In_ UCHAR Mode)
{
UCHAR Value;
WRITE_REGISTER_UCHAR((_PixelPtr), (UCHAR)(_TextColor)); \
} while (0);
-#ifdef CHAR_GEN_UPSIDE_DOWN
-# define GetFontPtr(_Char) &FontData[_Char * BOOTCHAR_HEIGHT] + BOOTCHAR_HEIGHT - 1;
-# define FONT_PTR_DELTA (-1)
-#else
-# define GetFontPtr(_Char) &FontData[_Char * BOOTCHAR_HEIGHT];
-# define FONT_PTR_DELTA (1)
-#endif
-
VOID
NTAPI
DisplayCharacter(
}
/* Check if the background color is transparent */
- if (BackColor >= 16)
+ if (BackColor >= BV_COLOR_NONE)
{
/* We are done */
return;
static VOID
NTAPI
-SetPaletteEntryRGB(IN ULONG Id,
- IN ULONG Rgb)
+SetPaletteEntryRGB(
+ _In_ ULONG Id,
+ _In_ RGBQUAD Rgb)
{
- PCHAR Colors = (PCHAR)&Rgb;
-
/* Set the palette index */
__outpb(VGA_BASE_IO_PORT + DAC_ADDRESS_WRITE_PORT, (UCHAR)Id);
/* Set RGB colors */
- __outpb(VGA_BASE_IO_PORT + DAC_DATA_REG_PORT, Colors[2] >> 2);
- __outpb(VGA_BASE_IO_PORT + DAC_DATA_REG_PORT, Colors[1] >> 2);
- __outpb(VGA_BASE_IO_PORT + DAC_DATA_REG_PORT, Colors[0] >> 2);
+ __outpb(VGA_BASE_IO_PORT + DAC_DATA_REG_PORT, GetRValue(Rgb) >> 2);
+ __outpb(VGA_BASE_IO_PORT + DAC_DATA_REG_PORT, GetGValue(Rgb) >> 2);
+ __outpb(VGA_BASE_IO_PORT + DAC_DATA_REG_PORT, GetBValue(Rgb) >> 2);
}
VOID
ULONG i;
PULONG Entry = Table;
- /* Loop every entry */
for (i = 0; i < Count; i++, Entry++)
{
- /* Set the entry */
SetPaletteEntryRGB(i, *Entry);
}
}
-static VOID
-NTAPI
-SetPaletteEntry(IN ULONG Id,
- IN ULONG PaletteEntry)
-{
- /* Set the palette index */
- __outpb(VGA_BASE_IO_PORT + DAC_ADDRESS_WRITE_PORT, (UCHAR)Id);
-
- /* Set RGB colors */
- __outpb(VGA_BASE_IO_PORT + DAC_DATA_REG_PORT, PaletteEntry & 0xFF);
- __outpb(VGA_BASE_IO_PORT + DAC_DATA_REG_PORT, (PaletteEntry >>= 8) & 0xFF);
- __outpb(VGA_BASE_IO_PORT + DAC_DATA_REG_PORT, (PaletteEntry >> 8) & 0xFF);
-}
-
VOID
NTAPI
-InitializePalette(VOID)
-{
- ULONG PaletteEntry[16] = {0x000000,
- 0x000020,
- 0x002000,
- 0x002020,
- 0x200000,
- 0x200020,
- 0x202000,
- 0x202020,
- 0x303030,
- 0x00003F,
- 0x003F00,
- 0x003F3F,
- 0x3F0000,
- 0x3F003F,
- 0x3F3F00,
- 0x3F3F3F};
- ULONG i;
-
- /* Loop all the entries and set their palettes */
- for (i = 0; i < 16; i++) SetPaletteEntry(i, PaletteEntry[i]);
-}
-
-static VOID
-NTAPI
-VgaScroll(IN ULONG Scroll)
+DoScroll(
+ _In_ ULONG Scroll)
{
ULONG Top, RowSize;
PUCHAR OldPosition, NewPosition;
}
}
-static VOID
+VOID
NTAPI
-PreserveRow(IN ULONG CurrentTop,
- IN ULONG TopDelta,
- IN BOOLEAN Restore)
+PreserveRow(
+ _In_ ULONG CurrentTop,
+ _In_ ULONG TopDelta,
+ _In_ BOOLEAN Restore)
{
PUCHAR Position1, Position2;
ULONG Count;
/* PUBLIC FUNCTIONS **********************************************************/
-/*
- * @implemented
- */
-ULONG
-NTAPI
-VidSetTextColor(IN ULONG Color)
-{
- ULONG OldColor;
-
- /* Save the old color and set the new one */
- OldColor = VidpTextColor;
- VidpTextColor = Color;
- return OldColor;
-}
-
/*
* @implemented
*/
*/
VOID
NTAPI
-VidDisplayString(IN PUCHAR String)
-{
- ULONG TopDelta = BOOTCHAR_HEIGHT + 1;
-
- /* Start looping the string */
- for (; *String; ++String)
- {
- /* Treat new-line separately */
- if (*String == '\n')
- {
- /* Modify Y position */
- VidpCurrentY += TopDelta;
- if (VidpCurrentY + TopDelta - 1 > VidpScrollRegion[3])
- {
- /* Scroll the view and clear the current row */
- VgaScroll(TopDelta);
- VidpCurrentY -= TopDelta;
- PreserveRow(VidpCurrentY, TopDelta, TRUE);
- }
- else
- {
- /* Preserve the current row */
- PreserveRow(VidpCurrentY, TopDelta, FALSE);
- }
-
- /* Update current X */
- VidpCurrentX = VidpScrollRegion[0];
-
- /* No need to clear this row */
- ClearRow = FALSE;
- }
- else if (*String == '\r')
- {
- /* Update current X */
- VidpCurrentX = VidpScrollRegion[0];
-
- /* If a new-line does not follow we will clear the current row */
- if (String[1] != '\n') ClearRow = TRUE;
- }
- else
- {
- /* Clear the current row if we had a return-carriage without a new-line */
- if (ClearRow)
- {
- PreserveRow(VidpCurrentY, TopDelta, TRUE);
- ClearRow = FALSE;
- }
-
- /* Display this character */
- DisplayCharacter(*String, VidpCurrentX, VidpCurrentY, VidpTextColor, 16);
- VidpCurrentX += 8;
-
- /* Check if we should scroll */
- if (VidpCurrentX + 7 > VidpScrollRegion[2])
- {
- /* Update Y position and check if we should scroll it */
- VidpCurrentY += TopDelta;
- if (VidpCurrentY + TopDelta - 1 > VidpScrollRegion[3])
- {
- /* Scroll the view and clear the current row */
- VgaScroll(TopDelta);
- VidpCurrentY -= TopDelta;
- PreserveRow(VidpCurrentY, TopDelta, TRUE);
- }
- else
- {
- /* Preserve the current row */
- PreserveRow(VidpCurrentY, TopDelta, FALSE);
- }
-
- /* Update current X */
- VidpCurrentX = VidpScrollRegion[0];
- }
- }
- }
-}
-
-/*
- * @implemented
- */
-VOID
-NTAPI
-VidScreenToBufferBlt(OUT PUCHAR Buffer,
- IN ULONG Left,
- IN ULONG Top,
- IN ULONG Width,
- IN ULONG Height,
- IN ULONG Delta)
+VidScreenToBufferBlt(
+ _Out_ PUCHAR Buffer,
+ _In_ ULONG Left,
+ _In_ ULONG Top,
+ _In_ ULONG Width,
+ _In_ ULONG Height,
+ _In_ ULONG Delta)
{
ULONG Plane;
ULONG XDistance;
*/
VOID
NTAPI
-VidSolidColorFill(IN ULONG Left,
- IN ULONG Top,
- IN ULONG Right,
- IN ULONG Bottom,
- IN UCHAR Color)
+VidSolidColorFill(
+ _In_ ULONG Left,
+ _In_ ULONG Top,
+ _In_ ULONG Right,
+ _In_ ULONG Bottom,
+ _In_ UCHAR Color)
{
ULONG rMask, lMask;
ULONG LeftOffset, RightOffset, Distance;
#define BI_RGB 0
#define BI_RLE4 2
-typedef struct _PALETTE_ENTRY
-{
- UCHAR Red;
- UCHAR Green;
- UCHAR Blue;
-} PALETTE_ENTRY, *PPALETTE_ENTRY;
-
-VOID
-NTAPI
-InitializePalette(VOID);
-
-VOID
-NTAPI
-DisplayCharacter(
- _In_ CHAR Character,
- _In_ ULONG Left,
- _In_ ULONG Top,
- _In_ ULONG TextColor,
- _In_ ULONG BackColor
-);
-
-VOID
-PrepareForSetPixel(VOID);
-
-VOID
-NTAPI
-InitPaletteWithTable(
- _In_ PULONG Table,
- _In_ ULONG Count);
+typedef ULONG RGBQUAD;
/*
* Globals
extern ULONG VidpCurrentX;
extern ULONG VidpCurrentY;
extern ULONG VidpScrollRegion[4];
-extern UCHAR FontData[256 * BOOTCHAR_HEIGHT];
+extern UCHAR VidpFontData[256 * BOOTCHAR_HEIGHT];
+extern const RGBQUAD VidpDefaultPalette[BV_MAX_COLORS];
+
+#define RGB(r, g, b) ((RGBQUAD)(((UCHAR)(b) | ((USHORT)((UCHAR)(g))<<8)) | (((ULONG)(UCHAR)(r))<<16)))
+
+#define GetRValue(quad) ((UCHAR)(((quad)>>16) & 0xFF))
+#define GetGValue(quad) ((UCHAR)(((quad)>>8) & 0xFF))
+#define GetBValue(quad) ((UCHAR)((quad) & 0xFF))
+
+#define InitializePalette() InitPaletteWithTable((PULONG)VidpDefaultPalette, BV_MAX_COLORS)
+
+#ifdef CHAR_GEN_UPSIDE_DOWN
+# define GetFontPtr(_Char) &VidpFontData[_Char * BOOTCHAR_HEIGHT] + BOOTCHAR_HEIGHT - 1;
+# define FONT_PTR_DELTA (-1)
+#else
+# define GetFontPtr(_Char) &VidpFontData[_Char * BOOTCHAR_HEIGHT];
+# define FONT_PTR_DELTA (1)
+#endif
#endif /* _BOOTVID_PCH_ */
SystemControl.Bits = __inbyte(SYSTEM_CONTROL_PORT_B);
//
- // Switch to boot vieo
+ // Switch to boot video
//
if (InbvIsBootDriverInstalled())
{
//
// Fill the screen
//
- InbvSolidColorFill(0, 0, SCREEN_WIDTH - 1, SCREEN_HEIGHT - 1, 1);
+ InbvSolidColorFill(0, 0, SCREEN_WIDTH - 1, SCREEN_HEIGHT - 1, BV_COLOR_RED);
InbvSetScrollRegion(0, 0, SCREEN_WIDTH - 1, SCREEN_HEIGHT - 1);
//
// Enable text
//
- InbvSetTextColor(15);
+ InbvSetTextColor(BV_COLOR_WHITE);
InbvInstallDisplayStringFilter(NULL);
InbvEnableDisplayString(TRUE);
}
ProgressBarTop,
ProgressBarLeft + FillCount,
ProgressBarTop + 12,
- 15);
+ BV_COLOR_WHITE);
/* Release the lock */
InbvReleaseLock();
VOID
NTAPI
-InbvScreenToBufferBlt(IN PUCHAR Buffer,
+InbvScreenToBufferBlt(OUT PUCHAR Buffer,
IN ULONG X,
IN ULONG Y,
IN ULONG Width,
if (Index >= 3)
{
/* Fill previous bar position */
- VidSolidColorFill(X + ((Index - 3) * 8), Y, (X + ((Index - 3) * 8)) + 8 - 1, Y + 9 - 1, 0);
+ VidSolidColorFill(X + ((Index - 3) * 8), Y, (X + ((Index - 3) * 8)) + 8 - 1, Y + 9 - 1, BV_COLOR_BLACK);
}
if (Index < Total - 1)
{
if (SharedUserData->NtProductType == NtProductWinNt)
{
/* Workstation; set colors */
- InbvSetTextColor(15);
- InbvSolidColorFill(0, 0, SCREEN_WIDTH-1, SCREEN_HEIGHT-1, 7);
- InbvSolidColorFill(0, VID_FOOTER_BG_TOP, SCREEN_WIDTH-1, SCREEN_HEIGHT-1, 1);
+ InbvSetTextColor(BV_COLOR_WHITE);
+ InbvSolidColorFill(0, 0, SCREEN_WIDTH-1, SCREEN_HEIGHT-1, BV_COLOR_DARK_GRAY);
+ InbvSolidColorFill(0, VID_FOOTER_BG_TOP, SCREEN_WIDTH-1, SCREEN_HEIGHT-1, BV_COLOR_RED);
/* Get resources */
Header = InbvGetResourceAddress(IDB_WKSTA_HEADER);
else
{
/* Server; set colors */
- InbvSetTextColor(14);
- InbvSolidColorFill(0, 0, SCREEN_WIDTH-1, SCREEN_HEIGHT-1, 6);
- InbvSolidColorFill(0, VID_FOOTER_BG_TOP, SCREEN_WIDTH-1, SCREEN_HEIGHT-1, 1);
+ InbvSetTextColor(BV_COLOR_LIGHT_CYAN);
+ InbvSolidColorFill(0, 0, SCREEN_WIDTH-1, SCREEN_HEIGHT-1, BV_COLOR_CYAN);
+ InbvSolidColorFill(0, VID_FOOTER_BG_TOP, SCREEN_WIDTH-1, SCREEN_HEIGHT-1, BV_COLOR_RED);
/* Get resources */
Header = InbvGetResourceAddress(IDB_SERVER_HEADER);
InbvScreenToBufferBlt(Buffer, VID_SKU_SAVE_AREA_LEFT,
VID_SKU_SAVE_AREA_TOP, 7, 7, 8);
InbvSolidColorFill(VID_SKU_AREA_LEFT, VID_SKU_AREA_TOP,
- VID_SKU_AREA_RIGHT, VID_SKU_AREA_BOTTOM, 0);
+ VID_SKU_AREA_RIGHT, VID_SKU_AREA_BOTTOM, BV_COLOR_BLACK);
InbvBufferToScreenBlt(Buffer, VID_SKU_SAVE_AREA_LEFT,
VID_SKU_SAVE_AREA_TOP, 7, 7, 8);
if (InbvGetDisplayState() == INBV_DISPLAY_STATE_OWNED)
{
/* Clear the screen */
- VidSolidColorFill(0, 0, SCREEN_WIDTH-1, SCREEN_HEIGHT-1, 0);
+ VidSolidColorFill(0, 0, SCREEN_WIDTH-1, SCREEN_HEIGHT-1, BV_COLOR_BLACK);
}
/* Reset progress bar and lock */
/* Acquire ownership and reset the display */
InbvAcquireDisplayOwnership();
InbvResetDisplay();
- InbvSolidColorFill(0, 0, SCREEN_WIDTH - 1, SCREEN_HEIGHT - 1, 0);
- InbvSetTextColor(15);
+ InbvSolidColorFill(0, 0, SCREEN_WIDTH - 1, SCREEN_HEIGHT - 1, BV_COLOR_BLACK);
+ InbvSetTextColor(BV_COLOR_WHITE);
InbvInstallDisplayStringFilter(NULL);
InbvEnableDisplayString(TRUE);
InbvSetScrollRegion(0, 0, SCREEN_WIDTH - 1, SCREEN_HEIGHT - 1);
InbvResetDisplay();
/* Display blue screen */
- InbvSolidColorFill(0, 0, SCREEN_WIDTH - 1, SCREEN_HEIGHT - 1, 4);
- InbvSetTextColor(15);
+ InbvSolidColorFill(0, 0, SCREEN_WIDTH - 1, SCREEN_HEIGHT - 1, BV_COLOR_BLUE);
+ InbvSetTextColor(BV_COLOR_WHITE);
InbvInstallDisplayStringFilter(NULL);
InbvEnableDisplayString(TRUE);
InbvSetScrollRegion(0, 0, SCREEN_WIDTH - 1, SCREEN_HEIGHT - 1);
/* Yes we do, cleanup for shutdown screen */
if (!InbvCheckDisplayOwnership()) InbvAcquireDisplayOwnership();
InbvResetDisplay();
- InbvSolidColorFill(0, 0, SCREEN_WIDTH - 1, SCREEN_HEIGHT - 1, 0);
+ InbvSolidColorFill(0, 0, SCREEN_WIDTH - 1, SCREEN_HEIGHT - 1, BV_COLOR_BLACK);
InbvEnableDisplayString(TRUE);
InbvSetScrollRegion(0, 0, SCREEN_WIDTH - 1, SCREEN_HEIGHT - 1);
BOOLEAN
NTAPI
-VidInitialize(IN BOOLEAN SetMode);
+VidInitialize(
+ _In_ BOOLEAN SetMode);
VOID
NTAPI
-VidResetDisplay(IN BOOLEAN HalReset);
+VidResetDisplay(
+ _In_ BOOLEAN HalReset);
ULONG
NTAPI
-VidSetTextColor(IN ULONG Color);
+VidSetTextColor(
+ _In_ ULONG Color);
VOID
NTAPI
-VidDisplayStringXY(IN PUCHAR String,
- IN ULONG Left,
- IN ULONG Top,
- IN BOOLEAN Transparent);
+VidDisplayStringXY(
+ _In_ PUCHAR String,
+ _In_ ULONG Left,
+ _In_ ULONG Top,
+ _In_ BOOLEAN Transparent);
VOID
NTAPI
-VidSetScrollRegion(IN ULONG Left,
- IN ULONG Top,
- IN ULONG Right,
- IN ULONG Bottom);
+VidSetScrollRegion(
+ _In_ ULONG Left,
+ _In_ ULONG Top,
+ _In_ ULONG Right,
+ _In_ ULONG Bottom);
VOID
NTAPI
VOID
NTAPI
-VidBufferToScreenBlt(IN PUCHAR Buffer,
- IN ULONG Left,
- IN ULONG Top,
- IN ULONG Width,
- IN ULONG Height,
- IN ULONG Delta);
+VidBufferToScreenBlt(
+ _In_ PUCHAR Buffer,
+ _In_ ULONG Left,
+ _In_ ULONG Top,
+ _In_ ULONG Width,
+ _In_ ULONG Height,
+ _In_ ULONG Delta);
VOID
NTAPI
-VidDisplayString(IN PUCHAR String);
+VidDisplayString(
+ _In_ PUCHAR String);
VOID
NTAPI
-VidBitBlt(IN PUCHAR Buffer,
- IN ULONG Left,
- IN ULONG Top);
+VidBitBlt(
+ _In_ PUCHAR Buffer,
+ _In_ ULONG Left,
+ _In_ ULONG Top);
VOID
NTAPI
-VidScreenToBufferBlt(OUT PUCHAR Buffer,
- IN ULONG Left,
- IN ULONG Top,
- IN ULONG Width,
- IN ULONG Height,
- IN ULONG Delta);
+VidScreenToBufferBlt(
+ _Out_ PUCHAR Buffer,
+ _In_ ULONG Left,
+ _In_ ULONG Top,
+ _In_ ULONG Width,
+ _In_ ULONG Height,
+ _In_ ULONG Delta);
VOID
NTAPI
-VidSolidColorFill(IN ULONG Left,
- IN ULONG Top,
- IN ULONG Right,
- IN ULONG Bottom,
- IN UCHAR Color);
+VidSolidColorFill(
+ _In_ ULONG Left,
+ _In_ ULONG Top,
+ _In_ ULONG Right,
+ _In_ ULONG Bottom,
+ _In_ UCHAR Color);
#endif // _BOOTVID_
/* For default VGA */
#define SCREEN_WIDTH 640
#define SCREEN_HEIGHT 480
+
+/* Boot video default color palette constants */
+#define BV_COLOR_BLACK 0
+#define BV_COLOR_RED 1
+#define BV_COLOR_GREEN 2
+#define BV_COLOR_BROWN 3
+#define BV_COLOR_BLUE 4
+#define BV_COLOR_MAGENTA 5
+#define BV_COLOR_CYAN 6
+#define BV_COLOR_DARK_GRAY 7
+#define BV_COLOR_LIGHT_GRAY 8
+#define BV_COLOR_LIGHT_RED 9
+#define BV_COLOR_LIGHT_GREEN 10
+#define BV_COLOR_YELLOW 11
+#define BV_COLOR_LIGHT_BLUE 12
+#define BV_COLOR_LIGHT_MAGENTA 13
+#define BV_COLOR_LIGHT_CYAN 14
+#define BV_COLOR_WHITE 15
+#define BV_COLOR_NONE 16
+#define BV_MAX_COLORS 16