ReactOS
0.4.16-dev-2104-gb84fa49
console.c
Go to the documentation of this file.
1
/*
2
* PROJECT: ReactOS Boot Video Driver
3
* LICENSE: GPL-2.0-or-later (https://spdx.org/licenses/GPL-2.0-or-later)
4
* PURPOSE: Platform-independent console functionality
5
* COPYRIGHT: Copyright 2010 Gregor Schneider <gregor.schneider@reactos.org>
6
* Copyright 2011 Rafal Harabien <rafalh@reactos.org>
7
* Copyright 2020 Stanislav Motylkov <x86corez@gmail.com>
8
*/
9
10
#include "
precomp.h
"
11
12
/* GLOBALS ********************************************************************/
13
14
UCHAR
VidpTextColor
=
BV_COLOR_WHITE
;
15
ULONG
VidpCurrentX
= 0;
16
ULONG
VidpCurrentY
= 0;
17
URECT
VidpScrollRegion
= {0, 0,
SCREEN_WIDTH
- 1,
SCREEN_HEIGHT
- 1};
18
19
static
BOOLEAN
ClearRow
=
FALSE
;
20
21
/* PUBLIC FUNCTIONS ***********************************************************/
22
23
VOID
24
NTAPI
25
VidResetDisplay
(
26
_In_
BOOLEAN
SetMode)
27
{
28
/* Clear the current position */
29
VidpCurrentX
= 0;
30
VidpCurrentY
= 0;
31
32
/* Invoke the hardware-specific routine */
33
ResetDisplay
(SetMode);
34
}
35
36
ULONG
37
NTAPI
38
VidSetTextColor
(
39
_In_
ULONG
Color
)
40
{
41
ULONG
OldColor;
42
43
/* Save the old color and set the new one */
44
OldColor =
VidpTextColor
;
45
VidpTextColor
=
Color
;
46
return
OldColor;
47
}
48
49
VOID
50
NTAPI
51
VidSetScrollRegion
(
52
_In_
ULONG
Left,
53
_In_
ULONG
Top
,
54
_In_
ULONG
Right,
55
_In_
ULONG
Bottom
)
56
{
57
/* Assert alignment */
58
ASSERT
((Left %
BOOTCHAR_WIDTH
) == 0);
59
ASSERT
((Right %
BOOTCHAR_WIDTH
) ==
BOOTCHAR_WIDTH
- 1);
60
61
/* Set the scroll region */
62
VidpScrollRegion
.
Left
= Left;
63
VidpScrollRegion
.
Top
=
Top
;
64
VidpScrollRegion
.
Right
= Right;
65
VidpScrollRegion
.
Bottom
=
Bottom
;
66
67
/* Set the current X and Y */
68
VidpCurrentX
= Left;
69
VidpCurrentY
=
Top
;
70
}
71
72
VOID
73
NTAPI
74
VidDisplayStringXY
(
75
_In_
PCSTR
String
,
76
_In_
ULONG
Left,
77
_In_
ULONG
Top
,
78
_In_
BOOLEAN
Transparent)
79
{
80
ULONG
BackColor;
81
82
/*
83
* If the caller wanted transparent, then send the special value (16),
84
* else use our default and call the helper routine.
85
*/
86
BackColor = Transparent ?
BV_COLOR_NONE
:
BV_COLOR_LIGHT_CYAN
;
87
88
/* Loop every character and adjust the position */
89
for
(; *
String
; ++
String
, Left +=
BOOTCHAR_WIDTH
)
90
{
91
/* Display a character */
92
DisplayCharacter
(*
String
, Left,
Top
,
BV_COLOR_LIGHT_BLUE
, BackColor);
93
}
94
}
95
96
VOID
97
NTAPI
98
VidDisplayString
(
99
_In_
PCSTR
String
)
100
{
101
/* Start looping the string */
102
for
(; *
String
; ++
String
)
103
{
104
/* Treat new-line separately */
105
if
(*
String
==
'\n'
)
106
{
107
/* Modify Y position */
108
VidpCurrentY
+=
BOOTCHAR_HEIGHT
+ 1;
109
if
(
VidpCurrentY
+
BOOTCHAR_HEIGHT
>
VidpScrollRegion
.
Bottom
)
110
{
111
/* Scroll the view and clear the current row */
112
DoScroll
(
BOOTCHAR_HEIGHT
+ 1);
113
VidpCurrentY
-=
BOOTCHAR_HEIGHT
+ 1;
114
PreserveRow
(
VidpCurrentY
,
BOOTCHAR_HEIGHT
+ 1,
TRUE
);
115
}
116
else
117
{
118
/* Preserve the current row */
119
PreserveRow
(
VidpCurrentY
,
BOOTCHAR_HEIGHT
+ 1,
FALSE
);
120
}
121
122
/* Update current X */
123
VidpCurrentX
=
VidpScrollRegion
.
Left
;
124
125
/* No need to clear this row */
126
ClearRow
=
FALSE
;
127
}
128
else
if
(*
String
==
'\r'
)
129
{
130
/* Update current X */
131
VidpCurrentX
=
VidpScrollRegion
.
Left
;
132
133
/* If a new-line does not follow we will clear the current row */
134
if
(
String
[1] !=
'\n'
)
135
ClearRow
=
TRUE
;
136
}
137
else
138
{
139
/* Clear the current row if we had a return-carriage without a new-line */
140
if
(
ClearRow
)
141
{
142
PreserveRow
(
VidpCurrentY
,
BOOTCHAR_HEIGHT
+ 1,
TRUE
);
143
ClearRow
=
FALSE
;
144
}
145
146
/* Display this character */
147
DisplayCharacter
(*
String
,
VidpCurrentX
,
VidpCurrentY
,
VidpTextColor
,
BV_COLOR_NONE
);
148
VidpCurrentX
+=
BOOTCHAR_WIDTH
;
149
150
/* Check if we should scroll */
151
if
(
VidpCurrentX
+
BOOTCHAR_WIDTH
- 1 >
VidpScrollRegion
.
Right
)
152
{
153
/* Update Y position and check if we should scroll it */
154
VidpCurrentY
+=
BOOTCHAR_HEIGHT
+ 1;
155
if
(
VidpCurrentY
+
BOOTCHAR_HEIGHT
>
VidpScrollRegion
.
Bottom
)
156
{
157
/* Scroll the view and clear the current row */
158
DoScroll
(
BOOTCHAR_HEIGHT
+ 1);
159
VidpCurrentY
-=
BOOTCHAR_HEIGHT
+ 1;
160
PreserveRow
(
VidpCurrentY
,
BOOTCHAR_HEIGHT
+ 1,
TRUE
);
161
}
162
else
163
{
164
/* Preserve the current row */
165
PreserveRow
(
VidpCurrentY
,
BOOTCHAR_HEIGHT
+ 1,
FALSE
);
166
}
167
168
/* Update current X */
169
VidpCurrentX
=
VidpScrollRegion
.
Left
;
170
}
171
}
172
}
173
}
BOOLEAN
unsigned char BOOLEAN
Definition:
ProcessorBind.h:185
PreserveRow
VOID PreserveRow(_In_ ULONG CurrentTop, _In_ ULONG TopDelta, _In_ BOOLEAN Restore)
Definition:
bootvid.c:159
ResetDisplay
VOID ResetDisplay(_In_ BOOLEAN SetMode)
Definition:
bootvid.c:263
DisplayCharacter
VOID DisplayCharacter(_In_ CHAR Character, _In_ ULONG Left, _In_ ULONG Top, _In_ ULONG TextColor, _In_ ULONG BackColor)
Definition:
bootvid.c:67
DoScroll
VOID DoScroll(_In_ ULONG Scroll)
Definition:
bootvid.c:112
Bottom
static LPHIST_ENTRY Bottom
Definition:
history.c:54
Top
static LPHIST_ENTRY Top
Definition:
history.c:53
TRUE
#define TRUE
Definition:
types.h:120
FALSE
#define FALSE
Definition:
types.h:117
VidDisplayStringXY
VOID NTAPI VidDisplayStringXY(_In_ PCSTR String, _In_ ULONG Left, _In_ ULONG Top, _In_ BOOLEAN Transparent)
Definition:
console.c:74
VidDisplayString
VOID NTAPI VidDisplayString(_In_ PCSTR String)
Definition:
console.c:98
VidSetTextColor
ULONG NTAPI VidSetTextColor(_In_ ULONG Color)
Definition:
console.c:38
VidpTextColor
UCHAR VidpTextColor
Definition:
console.c:14
VidResetDisplay
VOID NTAPI VidResetDisplay(_In_ BOOLEAN SetMode)
Definition:
console.c:25
VidpCurrentY
ULONG VidpCurrentY
Definition:
console.c:16
VidpCurrentX
ULONG VidpCurrentX
Definition:
console.c:15
VidpScrollRegion
URECT VidpScrollRegion
Definition:
console.c:17
VidSetScrollRegion
VOID NTAPI VidSetScrollRegion(_In_ ULONG Left, _In_ ULONG Top, _In_ ULONG Right, _In_ ULONG Bottom)
Definition:
console.c:51
ClearRow
static BOOLEAN ClearRow
Definition:
console.c:19
BOOTCHAR_HEIGHT
#define BOOTCHAR_HEIGHT
Definition:
precomp.h:35
BOOTCHAR_WIDTH
#define BOOTCHAR_WIDTH
Definition:
precomp.h:36
void
Definition:
nsiface.idl:2307
ASSERT
#define ASSERT(a)
Definition:
mode.c:44
_In_
#define _In_
Definition:
no_sal2.h:158
SCREEN_WIDTH
#define SCREEN_WIDTH
Definition:
pc98video.c:24
SCREEN_HEIGHT
#define SCREEN_HEIGHT
Definition:
pc98video.c:25
BV_COLOR_WHITE
#define BV_COLOR_WHITE
Definition:
display.h:30
BV_COLOR_LIGHT_CYAN
#define BV_COLOR_LIGHT_CYAN
Definition:
display.h:29
BV_COLOR_LIGHT_BLUE
#define BV_COLOR_LIGHT_BLUE
Definition:
display.h:27
BV_COLOR_NONE
#define BV_COLOR_NONE
Definition:
display.h:31
Color
Definition:
gdipluscolor.h:301
_URECT
Definition:
precomp.h:61
_URECT::Right
ULONG Right
Definition:
precomp.h:64
_URECT::Top
ULONG Top
Definition:
precomp.h:63
_URECT::Bottom
ULONG Bottom
Definition:
precomp.h:65
_URECT::Left
ULONG Left
Definition:
precomp.h:62
NTAPI
#define NTAPI
Definition:
typedefs.h:36
PCSTR
const char * PCSTR
Definition:
typedefs.h:52
ULONG
uint32_t ULONG
Definition:
typedefs.h:59
String
_Must_inspect_result_ _In_ WDFDEVICE _In_ WDFSTRING String
Definition:
wdfdevice.h:2439
precomp.h
UCHAR
unsigned char UCHAR
Definition:
xmlstorage.h:181
drivers
base
bootvid
console.c
Generated on Tue Jan 6 2026 06:21:36 for ReactOS by
1.9.6