Skip to content
Snippets Groups Projects
Commit 1c81f9f5 authored by y2-shaffan's avatar y2-shaffan
Browse files

Update file kernel.c

parent bda66c09
Branches
No related tags found
No related merge requests found
...@@ -80,12 +80,11 @@ void terminal_setcolor(uint8_t color) { ...@@ -80,12 +80,11 @@ void terminal_setcolor(uint8_t color) {
} }
void terminal_putentryat(char c, uint8_t color, size_t x, size_t y) { void terminal_putentryat(char c, uint8_t color, size_t x, size_t y) {
// Check if the cursor is at the bottom of the screen
if (y == VGA_HEIGHT) { if (y == VGA_HEIGHT) {
// Scroll the screen up one row // Scroll the screen up one row
for (size_t i = 0; i < VGA_HEIGHT - 1; i++) { for (size_t i = 1; i < VGA_HEIGHT; i++) {
for (size_t x = 0; x < VGA_WIDTH; x++) { for (size_t j = 0; j < VGA_WIDTH; j++) {
terminal_buffer[i * VGA_WIDTH + x] = terminal_buffer[(i + 1) * VGA_WIDTH + x]; terminal_buffer[(i - 1) * VGA_WIDTH + j] = terminal_buffer[i * VGA_WIDTH + j];
} }
} }
// Clear the last row // Clear the last row
...@@ -100,14 +99,14 @@ void terminal_putentryat(char c, uint8_t color, size_t x, size_t y) { ...@@ -100,14 +99,14 @@ void terminal_putentryat(char c, uint8_t color, size_t x, size_t y) {
terminal_buffer[index] = make_vgaentry(c, color); terminal_buffer[index] = make_vgaentry(c, color);
} }
void terminal_putchar(char c) { void terminal_putchar(char c) {
if (c == '\n') { if (c == '\n') {
terminal_column = 0; terminal_column = 0;
if (++terminal_row == VGA_HEIGHT) { if (++terminal_row == VGA_HEIGHT) {
terminal_row = 0; terminal_row = 0;
} }
} else if (c == '\r') {
terminal_column = 0;
} else { } else {
terminal_putentryat(c, terminal_color, terminal_column, terminal_row); terminal_putentryat(c, terminal_color, terminal_column, terminal_row);
if (++terminal_column == VGA_WIDTH) { if (++terminal_column == VGA_WIDTH) {
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment