VOID NTAPI LlbVideoDrawChar(IN UCHAR c, IN PUSHORT Buffer, IN USHORT Color, IN USHORT BackColor) { PCHAR Pixels; CHAR Line; ULONG y, ScreenWidth; LONG x; /* Get screen width */ ScreenWidth = LlbHwGetScreenWidth(); Pixels = LlbHwBootFont + c * FONT_HEIGHT; /* Loop y pixels */ for (y = 0; y < FONT_HEIGHT; y++) { /* Loop x pixels */ Line = *Pixels++; for (x = 7; x >= 0; x--) { /* Draw either a character or background pixel */ Buffer[x] = (Line & 1) ? Color : BackColor; Line >>= 1; } /* Next line */ Buffer += ScreenWidth; } }
VOID LlbFwVideoGetDisplaySize(OUT PULONG Width, OUT PULONG Height, OUT PULONG Depth) { /* Query static settings */ *Width = LlbHwGetScreenWidth() / 8; *Height = LlbHwGetScreenHeight() / 16; /* Depth is always 16 bpp */ *Depth = 16; }
VOID NTAPI LlbVideoPutChar(IN UCHAR c) { ULONG cx, cy, CharsPerLine, BackColor, ScreenWidth; /* Backcolor on this machine */ #ifdef BLUE_SCREEN BackColor = LlbHwVideoCreateColor(14, 0, 82); #else BackColor = LlbHwVideoCreateColor(0, 0, 0); #endif /* Amount of characters in a line */ ScreenWidth = LlbHwGetScreenWidth(); CharsPerLine = ScreenWidth / 8; /* Handle new line and scrolling */ if (c == '\n') { /* Move a line down */ ScreenCursor += CharsPerLine - (ScreenCursor % CharsPerLine); /* FIXME: Scrolling */ } else { /* Calculate character position from pixel position */ cy = (ScreenCursor / CharsPerLine) * FONT_HEIGHT; cx = (ScreenCursor % CharsPerLine) * 8; /* Draw the character and increment the cursor */ LlbVideoDrawChar(c, (PUSHORT)LlbHwGetFrameBuffer() + ScreenWidth * cy + cx, 0xFFFF, BackColor); ScreenCursor++; } }
VOID NTAPI LlbVideoClearScreen(IN BOOLEAN OsLoader) { ULONG ScreenSize, p; ULONG BackColor; PUSHORT VideoBuffer; /* Get frame buffer and reset cursor position */ VideoBuffer = LlbHwGetFrameBuffer(); ScreenCursor = 0; /* Backcolor on this machine */ if (OsLoader) { /* Black */ BackColor = 0; } else { /* Deep blue */ #ifdef BLUE_SCREEN BackColor = LlbHwVideoCreateColor(14, 0, 82); #else BackColor = LlbHwVideoCreateColor(0, 0, 0); #endif BackColor = (BackColor << 16) | BackColor; } /* Screen size on this machine */ ScreenSize = LlbHwGetScreenWidth() * LlbHwGetScreenHeight(); /* Clear the screen with the given color */ for (p = 0; p < ScreenSize * 2; p += 4) { *(PULONG)((PCHAR)VideoBuffer + p) = BackColor; } }
VOID LlbFwVideoPutChar(IN INT c, IN UCHAR Attr, IN ULONG X, IN ULONG Y) { ULONG Color, BackColor; PUSHORT Buffer; /* Convert EGA index to color used by hardware */ Color = LlbHwVideoCreateColor(ColorPalette[Attr & 0xF][0], ColorPalette[Attr & 0xF][1], ColorPalette[Attr & 0xF][2]); BackColor = LlbHwVideoCreateColor(ColorPalette[Attr >> 4][0], ColorPalette[Attr >> 4][1], ColorPalette[Attr >> 4][2]); /* Compute buffer address */ Buffer = (PUSHORT)LlbHwGetFrameBuffer() + (LlbHwGetScreenWidth() * (Y * 16)) + (X * 8); /* Draw it */ LlbVideoDrawChar(c, Buffer, Color, BackColor); }