[solved] VGA Text Mode Scrolling
Posted: Tue May 08, 2018 3:03 pm
How does the VGA text buffer relate to the display? Is the buffer an array? If so does buffer[0..NCOLS] correspond to the top row of text displayed on the screen?
If so, why does this scrolling code work? If buffer[0..NCOLS] holds the oldest data (top row) and buffer[lastRow*NCOLS..NROWS*NCOLS] holds the most recent data (bottom row), shouldn't we be shifting the buffer elements by -row instead of +row?
Re: OSDev Wiki, JamesM Kernel Tutorial
If so, why does this scrolling code work? If buffer[0..NCOLS] holds the oldest data (top row) and buffer[lastRow*NCOLS..NROWS*NCOLS] holds the most recent data (bottom row), shouldn't we be shifting the buffer elements by -row instead of +row?
Code: Select all
void monitor_scrollUp ()
{
int i;
int lastRow = NROWS - 1;
u16int spaceChar = m_attribute | 0x20; // space character
// Move the current text chunk that makes up the screen back in the buffer by a line
for ( i = 0; i < NROWS * NCOLS; i += 1 )
{
videoMemory[ i ] = videoMemory[ i + NCOLS ];
}
// The last line should now be blank. Do this by writing 80 spaces to it
for ( i = lastRow * NCOLS; i < NROWS * NCOLS; i += 1 )
{
videoMemory[ i ] = spaceChar;
}
// The cursor should now be on the last line
cursorY = lastRow;
}