diff --git a/reactos/drivers/base/bootvid/i386/vga.c b/reactos/drivers/base/bootvid/i386/vga.c index 9e64d1789d9..a39d20e2f39 100644 --- a/reactos/drivers/base/bootvid/i386/vga.c +++ b/reactos/drivers/base/bootvid/i386/vga.c @@ -66,7 +66,6 @@ ULONG lookup[16] = 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 @@ VgaScroll(ULONG Scroll) VOID NTAPI PreserveRow(IN ULONG CurrentTop, - IN ULONG TopDelta, - IN BOOLEAN Direction) + IN ULONG TopDelta) { PUCHAR Position1, Position2; ULONG Count; @@ -361,19 +359,9 @@ PreserveRow(IN ULONG CurrentTop, /* 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; @@ -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 NTAPI BitBlt(IN ULONG Left, @@ -749,57 +764,62 @@ VidDisplayString(PUCHAR String) { /* 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 */