Author: rharabien
Date: Tue Jun 14 22:04:42 2011
New Revision: 52239
URL:
http://svn.reactos.org/svn/reactos?rev=52239&view=rev
Log:
[BOOTVID]
- Fix scrolling if ScrollRegion contain whole screen.
- Add backspace support
- Remove unneeded code
- Now screen debugging in BSOD works much better :)
Modified:
trunk/reactos/drivers/base/bootvid/i386/vga.c
Modified: trunk/reactos/drivers/base/bootvid/i386/vga.c
URL:
http://svn.reactos.org/svn/reactos/trunk/reactos/drivers/base/bootvid/i386/…
==============================================================================
--- trunk/reactos/drivers/base/bootvid/i386/vga.c [iso-8859-1] (original)
+++ trunk/reactos/drivers/base/bootvid/i386/vga.c [iso-8859-1] Tue Jun 14 22:04:42 2011
@@ -66,7 +66,6 @@
ULONG TextColor = 0xF;
ULONG curr_x = 0;
ULONG curr_y = 0;
-BOOLEAN NextLine = FALSE;
ULONG_PTR VgaRegisterBase = 0;
ULONG_PTR VgaBase = 0;
@@ -346,8 +345,7 @@
VOID
NTAPI
PreserveRow(IN ULONG CurrentTop,
- IN ULONG TopDelta,
- IN BOOLEAN Direction)
+ IN ULONG TopDelta)
{
PUCHAR Position1, Position2;
ULONG Count;
@@ -361,19 +359,9 @@
/* Set Mode 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 */
- Position1 = (PUCHAR)VgaBase + 0x9600;
- Position2 = (PUCHAR)VgaBase + CurrentTop * 80;
- }
+ /* Calculate the position in memory for the row */
+ Position1 = (PUCHAR)VgaBase + 0x9600;
+ Position2 = (PUCHAR)VgaBase + CurrentTop * 80;
/* Set the count and make sure it's above 0 */
Count = TopDelta * 80;
@@ -390,6 +378,33 @@
Position1++;
} while (--Count);
}
+}
+
+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
@@ -749,57 +764,62 @@
{
/* Modify Y position */
curr_y += TopDelta;
- if (curr_y >= ScrollRegion[3])
+ if (curr_y + TopDelta >= ScrollRegion[3])
{
/* Scroll the view */
VgaScroll(TopDelta);
curr_y -= TopDelta;
-
- /* Preserve row */
- PreserveRow(curr_y, TopDelta, TRUE);
+ }
+ else
+ {
+ /* Preserve the current row */
+ PreserveRow(curr_y, TopDelta);
}
/* Update current X */
curr_x = ScrollRegion[0];
-
- /* Preseve the current row */
- PreserveRow(curr_y, TopDelta, FALSE);
}
else if (*String == '\r')
{
/* Update current X */
curr_x = ScrollRegion[0];
-
- /* Check if we're being followed by a new line */
- if (String[1] != '\n') NextLine = TRUE;
+ }
+ 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;
+ }
+
+ /* Clean current character */
+ CleanCharacter(curr_x, curr_y, TopDelta);
}
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 */
DisplayCharacter(*String, curr_x, curr_y, TextColor, 16);
curr_x += 8;
/* 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 */
curr_y += TopDelta;
- if (curr_y > ScrollRegion[3])
+ if (curr_y + TopDelta > ScrollRegion[3])
{
/* Do the scroll */
VgaScroll(TopDelta);
curr_y -= TopDelta;
-
- /* Save the row */
- PreserveRow(curr_y, TopDelta, TRUE);
+ }
+ else
+ {
+ /* Preserve the current row */
+ PreserveRow(curr_y, TopDelta);
}
/* Update X */