Skip to content

Commit 44e4781

Browse files
committed
[BOOTVID] Split common.c into graphics-specific and console (in console.c) parts (reactos#8547)
In addition: - move back common function prototypes to precomp.h; - const-ify `VidpFontData` and adjust its usages; - improve SAL annotations for `InitPaletteWithTable()`; - rename the (Vid)ResetDisplay() parameter to "SetMode".
1 parent 379eb14 commit 44e4781

15 files changed

Lines changed: 248 additions & 306 deletions

File tree

‎drivers/base/bootvid/CMakeLists.txt‎

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,7 @@ endif()
2727

2828
list(APPEND SOURCE
2929
common.c
30+
console.c
3031
fontdata.c
3132
precomp.h)
3233

‎drivers/base/bootvid/arm/arm.h‎

Lines changed: 1 addition & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,7 @@ extern PUSHORT VgaArmBase;
3131

3232
VOID
3333
InitPaletteWithTable(
34-
_In_ PULONG Table,
34+
_In_reads_(Count) const ULONG* Table,
3535
_In_ ULONG Count);
3636

3737
VOID
@@ -42,21 +42,3 @@ SetPixel(
4242
_In_ ULONG Left,
4343
_In_ ULONG Top,
4444
_In_ UCHAR Color);
45-
46-
VOID
47-
PreserveRow(
48-
_In_ ULONG CurrentTop,
49-
_In_ ULONG TopDelta,
50-
_In_ BOOLEAN Restore);
51-
52-
VOID
53-
DoScroll(
54-
_In_ ULONG Scroll);
55-
56-
VOID
57-
DisplayCharacter(
58-
_In_ CHAR Character,
59-
_In_ ULONG Left,
60-
_In_ ULONG Top,
61-
_In_ ULONG TextColor,
62-
_In_ ULONG BackColor);

‎drivers/base/bootvid/arm/bootvid.c‎

Lines changed: 6 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -62,7 +62,7 @@ DisplayCharacter(
6262
_In_ ULONG TextColor,
6363
_In_ ULONG BackColor)
6464
{
65-
PUCHAR FontChar;
65+
const UCHAR* FontChar;
6666
ULONG i, j, XOffset;
6767

6868
/* Get the font line for this character */
@@ -209,7 +209,7 @@ VidpInitializeDisplay(VOID)
209209

210210
VOID
211211
InitPaletteWithTable(
212-
_In_ PULONG Table,
212+
_In_reads_(Count) const ULONG* Table,
213213
_In_ ULONG Count)
214214
{
215215
UNIMPLEMENTED;
@@ -251,24 +251,13 @@ VidInitialize(
251251
}
252252

253253
VOID
254-
NTAPI
255-
VidResetDisplay(
256-
_In_ BOOLEAN HalReset)
254+
ResetDisplay(
255+
_In_ BOOLEAN SetMode)
257256
{
258-
//
259-
// Clear the current position
260-
//
261-
VidpCurrentX = 0;
262-
VidpCurrentY = 0;
263-
264-
//
265-
// Re-initialize the VGA Display
266-
//
257+
/* Re-initialize the display */
267258
VidpInitializeDisplay();
268259

269-
//
270-
// Re-initialize the palette and fill the screen black
271-
//
260+
/* Re-initialize the palette and fill the screen black */
272261
InitializePalette();
273262
VidSolidColorFill(0, 0, SCREEN_WIDTH - 1, SCREEN_HEIGHT - 1, BV_COLOR_BLACK);
274263
}

‎drivers/base/bootvid/common.c‎

Lines changed: 0 additions & 153 deletions
Original file line numberDiff line numberDiff line change
@@ -11,19 +11,6 @@
1111

1212
/* GLOBALS ********************************************************************/
1313

14-
UCHAR VidpTextColor = BV_COLOR_WHITE;
15-
16-
ULONG VidpCurrentX = 0;
17-
ULONG VidpCurrentY = 0;
18-
19-
ULONG VidpScrollRegion[4] =
20-
{
21-
0,
22-
0,
23-
SCREEN_WIDTH - 1,
24-
SCREEN_HEIGHT - 1
25-
};
26-
2714
/*
2815
* Boot video driver default palette is similar to the standard 16-color
2916
* CGA palette, but it has Red and Blue channels swapped, and also dark
@@ -49,8 +36,6 @@ const RGBQUAD VidpDefaultPalette[BV_MAX_COLORS] =
4936
RGB(255, 255, 255), /* White */
5037
};
5138

52-
static BOOLEAN ClearRow = FALSE;
53-
5439
/* PRIVATE FUNCTIONS **********************************************************/
5540

5641
static VOID
@@ -310,144 +295,6 @@ RleBitBlt(
310295

311296
/* PUBLIC FUNCTIONS ***********************************************************/
312297

313-
ULONG
314-
NTAPI
315-
VidSetTextColor(
316-
_In_ ULONG Color)
317-
{
318-
ULONG OldColor;
319-
320-
/* Save the old color and set the new one */
321-
OldColor = VidpTextColor;
322-
VidpTextColor = Color;
323-
return OldColor;
324-
}
325-
326-
VOID
327-
NTAPI
328-
VidDisplayStringXY(
329-
_In_z_ PUCHAR String,
330-
_In_ ULONG Left,
331-
_In_ ULONG Top,
332-
_In_ BOOLEAN Transparent)
333-
{
334-
ULONG BackColor;
335-
336-
/*
337-
* If the caller wanted transparent, then send the special value (16),
338-
* else use our default and call the helper routine.
339-
*/
340-
BackColor = Transparent ? BV_COLOR_NONE : BV_COLOR_LIGHT_CYAN;
341-
342-
/* Loop every character and adjust the position */
343-
for (; *String; ++String, Left += BOOTCHAR_WIDTH)
344-
{
345-
/* Display a character */
346-
DisplayCharacter(*String, Left, Top, BV_COLOR_LIGHT_BLUE, BackColor);
347-
}
348-
}
349-
350-
VOID
351-
NTAPI
352-
VidSetScrollRegion(
353-
_In_ ULONG Left,
354-
_In_ ULONG Top,
355-
_In_ ULONG Right,
356-
_In_ ULONG Bottom)
357-
{
358-
/* Assert alignment */
359-
ASSERT((Left % BOOTCHAR_WIDTH) == 0);
360-
ASSERT((Right % BOOTCHAR_WIDTH) == BOOTCHAR_WIDTH - 1);
361-
362-
/* Set Scroll Region */
363-
VidpScrollRegion[0] = Left;
364-
VidpScrollRegion[1] = Top;
365-
VidpScrollRegion[2] = Right;
366-
VidpScrollRegion[3] = Bottom;
367-
368-
/* Set current X and Y */
369-
VidpCurrentX = Left;
370-
VidpCurrentY = Top;
371-
}
372-
373-
VOID
374-
NTAPI
375-
VidDisplayString(
376-
_In_z_ PUCHAR String)
377-
{
378-
/* Start looping the string */
379-
for (; *String; ++String)
380-
{
381-
/* Treat new-line separately */
382-
if (*String == '\n')
383-
{
384-
/* Modify Y position */
385-
VidpCurrentY += BOOTCHAR_HEIGHT + 1;
386-
if (VidpCurrentY + BOOTCHAR_HEIGHT > VidpScrollRegion[3])
387-
{
388-
/* Scroll the view and clear the current row */
389-
DoScroll(BOOTCHAR_HEIGHT + 1);
390-
VidpCurrentY -= BOOTCHAR_HEIGHT + 1;
391-
PreserveRow(VidpCurrentY, BOOTCHAR_HEIGHT + 1, TRUE);
392-
}
393-
else
394-
{
395-
/* Preserve the current row */
396-
PreserveRow(VidpCurrentY, BOOTCHAR_HEIGHT + 1, FALSE);
397-
}
398-
399-
/* Update current X */
400-
VidpCurrentX = VidpScrollRegion[0];
401-
402-
/* No need to clear this row */
403-
ClearRow = FALSE;
404-
}
405-
else if (*String == '\r')
406-
{
407-
/* Update current X */
408-
VidpCurrentX = VidpScrollRegion[0];
409-
410-
/* If a new-line does not follow we will clear the current row */
411-
if (String[1] != '\n') ClearRow = TRUE;
412-
}
413-
else
414-
{
415-
/* Clear the current row if we had a return-carriage without a new-line */
416-
if (ClearRow)
417-
{
418-
PreserveRow(VidpCurrentY, BOOTCHAR_HEIGHT + 1, TRUE);
419-
ClearRow = FALSE;
420-
}
421-
422-
/* Display this character */
423-
DisplayCharacter(*String, VidpCurrentX, VidpCurrentY, VidpTextColor, BV_COLOR_NONE);
424-
VidpCurrentX += BOOTCHAR_WIDTH;
425-
426-
/* Check if we should scroll */
427-
if (VidpCurrentX + BOOTCHAR_WIDTH - 1 > VidpScrollRegion[2])
428-
{
429-
/* Update Y position and check if we should scroll it */
430-
VidpCurrentY += BOOTCHAR_HEIGHT + 1;
431-
if (VidpCurrentY + BOOTCHAR_HEIGHT > VidpScrollRegion[3])
432-
{
433-
/* Scroll the view and clear the current row */
434-
DoScroll(BOOTCHAR_HEIGHT + 1);
435-
VidpCurrentY -= BOOTCHAR_HEIGHT + 1;
436-
PreserveRow(VidpCurrentY, BOOTCHAR_HEIGHT + 1, TRUE);
437-
}
438-
else
439-
{
440-
/* Preserve the current row */
441-
PreserveRow(VidpCurrentY, BOOTCHAR_HEIGHT + 1, FALSE);
442-
}
443-
444-
/* Update current X */
445-
VidpCurrentX = VidpScrollRegion[0];
446-
}
447-
}
448-
}
449-
}
450-
451298
VOID
452299
NTAPI
453300
VidBufferToScreenBlt(

0 commit comments

Comments
 (0)