[BOOTVID]

- Fix scrolling if ScrollRegion contain whole screen.
- Add backspace support
- Remove unneeded code
- Now screen debugging in BSOD works much better :)

svn path=/trunk/; revision=52239
This commit is contained in:
Rafal Harabien 2011-06-14 22:04:42 +00:00
parent 86b5a7454a
commit ca370b4954

View file

@ -66,7 +66,6 @@ ULONG lookup[16] =
ULONG TextColor = 0xF; ULONG TextColor = 0xF;
ULONG curr_x = 0; ULONG curr_x = 0;
ULONG curr_y = 0; ULONG curr_y = 0;
BOOLEAN NextLine = FALSE;
ULONG_PTR VgaRegisterBase = 0; ULONG_PTR VgaRegisterBase = 0;
ULONG_PTR VgaBase = 0; ULONG_PTR VgaBase = 0;
@ -346,8 +345,7 @@ VgaScroll(ULONG Scroll)
VOID VOID
NTAPI NTAPI
PreserveRow(IN ULONG CurrentTop, PreserveRow(IN ULONG CurrentTop,
IN ULONG TopDelta, IN ULONG TopDelta)
IN BOOLEAN Direction)
{ {
PUCHAR Position1, Position2; PUCHAR Position1, Position2;
ULONG Count; ULONG Count;
@ -361,19 +359,9 @@ PreserveRow(IN ULONG CurrentTop,
/* Set Mode 1 */ /* Set Mode 1 */
ReadWriteMode(1); ReadWriteMode(1);
/* Check which way we're preserving */
if (Direction)
{
/* Calculate the position in memory for the row */
Position1 = (PUCHAR)VgaBase + CurrentTop * 80;
Position2 = (PUCHAR)VgaBase + 0x9600;
}
else
{
/* Calculate the position in memory for the row */ /* Calculate the position in memory for the row */
Position1 = (PUCHAR)VgaBase + 0x9600; Position1 = (PUCHAR)VgaBase + 0x9600;
Position2 = (PUCHAR)VgaBase + CurrentTop * 80; Position2 = (PUCHAR)VgaBase + CurrentTop * 80;
}
/* Set the count and make sure it's above 0 */ /* Set the count and make sure it's above 0 */
Count = TopDelta * 80; Count = TopDelta * 80;
@ -392,6 +380,33 @@ PreserveRow(IN ULONG CurrentTop,
} }
} }
VOID
NTAPI
CleanCharacter(IN ULONG Left,
IN ULONG Top,
IN ULONG TopDelta)
{
PUCHAR Position1, Position2;
ULONG i;
/* Clear the 4 planes */
__outpw(0x3C4, 0xF02);
/* Set the bitmask to 0xFF for all 4 planes */
__outpw(0x3CE, 0xFF08);
/* Set Mode 1 */
ReadWriteMode(1);
/* Calculate the position in memory for the character */
Position1 = (PUCHAR)VgaBase + 0x9600 + Left / 8;
Position2 = (PUCHAR)VgaBase + Top * 80 + Left / 8;
/* Copy data from preserved row */
for(i = 0; i < TopDelta; ++i)
WRITE_REGISTER_UCHAR(Position2 + i * 80, READ_REGISTER_UCHAR(Position1));
}
VOID VOID
NTAPI NTAPI
BitBlt(IN ULONG Left, BitBlt(IN ULONG Left,
@ -749,57 +764,62 @@ VidDisplayString(PUCHAR String)
{ {
/* Modify Y position */ /* Modify Y position */
curr_y += TopDelta; curr_y += TopDelta;
if (curr_y >= ScrollRegion[3]) if (curr_y + TopDelta >= ScrollRegion[3])
{ {
/* Scroll the view */ /* Scroll the view */
VgaScroll(TopDelta); VgaScroll(TopDelta);
curr_y -= TopDelta; curr_y -= TopDelta;
}
/* Preserve row */ else
PreserveRow(curr_y, TopDelta, TRUE); {
/* Preserve the current row */
PreserveRow(curr_y, TopDelta);
} }
/* Update current X */ /* Update current X */
curr_x = ScrollRegion[0]; curr_x = ScrollRegion[0];
/* Preseve the current row */
PreserveRow(curr_y, TopDelta, FALSE);
} }
else if (*String == '\r') else if (*String == '\r')
{ {
/* Update current X */ /* Update current X */
curr_x = ScrollRegion[0]; curr_x = ScrollRegion[0];
}
else if (*String == '\b')
{
/* Update current X */
if (curr_x > ScrollRegion[0])
curr_x -= 8;
else
{
/* We are at line begin - move to previous row */
curr_x = ScrollRegion[0];
curr_y -= TopDelta;
}
/* Check if we're being followed by a new line */ /* Clean current character */
if (String[1] != '\n') NextLine = TRUE; CleanCharacter(curr_x, curr_y, TopDelta);
} }
else else
{ {
/* Check if we had a \n\r last time */
if (NextLine)
{
/* We did, preserve the current row */
PreserveRow(curr_y, TopDelta, TRUE);
NextLine = FALSE;
}
/* Display this character */ /* Display this character */
DisplayCharacter(*String, curr_x, curr_y, TextColor, 16); DisplayCharacter(*String, curr_x, curr_y, TextColor, 16);
curr_x += 8; curr_x += 8;
/* Check if we should scroll */ /* Check if we should scroll */
if (curr_x > ScrollRegion[2]) if (curr_x + 8 > ScrollRegion[2])
{ {
/* Update Y position and check if we should scroll it */ /* Update Y position and check if we should scroll it */
curr_y += TopDelta; curr_y += TopDelta;
if (curr_y > ScrollRegion[3]) if (curr_y + TopDelta > ScrollRegion[3])
{ {
/* Do the scroll */ /* Do the scroll */
VgaScroll(TopDelta); VgaScroll(TopDelta);
curr_y -= TopDelta; curr_y -= TopDelta;
}
/* Save the row */ else
PreserveRow(curr_y, TopDelta, TRUE); {
/* Preserve the current row */
PreserveRow(curr_y, TopDelta);
} }
/* Update X */ /* Update X */