Fix screen scrolling.

This commit is contained in:
Alexander Myltsev 2025-01-28 22:56:59 +04:00
parent 033efd7a02
commit 280bde3be8
No known key found for this signature in database
GPG Key ID: 3A5AEABA3DDAE62E

View File

@ -73,7 +73,7 @@ void vga_clear_screen() {
} }
static unsigned scroll() { static unsigned scroll() {
kmemmove(video_memory, video_memory + COLS, 2 * COLS * (ROWS-1)); kmemmove(video_memory, video_memory + 2 * COLS, 2 * COLS * (ROWS-1));
for (int col = 0; col < COLS; col++) { for (int col = 0; col < COLS; col++) {
vga_set_char(get_offset(col, ROWS - 1), ' '); vga_set_char(get_offset(col, ROWS - 1), ' ');
} }
@ -90,7 +90,7 @@ void vga_print_string(const char* s) {
offset++; offset++;
} }
s++; s++;
if (offset > COLS * ROWS) { if (offset >= COLS * ROWS) {
offset = scroll(); offset = scroll();
} }
} }