I'm already starting with osdev, but I'm stuck on one of the easiest part. Going throught Bare Bones tutorial I succeed with booting simple kernel, and handling new lines. But I can't figure out how to sole problem of scrolling terminal. After dozens of tries my own soutions I've found this one here on the forum:
Code: Select all
void terminal_scroll(void) {
int attrib = 0x0F;
uint16_t blank;
uint16_t temp;
/**
* A blank is defined as a space... we need to give it
* backcolor too
*/
blank = 0x20 | (attrib << 8);
/**
* Move the current text chunk that makes up the screen
* back in the buffer by a line
*/
temp = terminal_row - 25 + 1;
memcpy(terminal_buffer, terminal_buffer + temp * 80, (25 - temp) * 80 * 2);
/**
* Finally, we set the chunk of memory that occupies
* the last line of text to our 'blank' character
*/
memset(terminal_buffer + (25 - temp) * 80, blank, 80);
terminal_row = 25 - 1;
}