diff options
Diffstat (limited to 'src/kernel/vga.c')
-rw-r--r-- | src/kernel/vga.c | 17 |
1 files changed, 7 insertions, 10 deletions
diff --git a/src/kernel/vga.c b/src/kernel/vga.c index 7506416..c03e5f0 100644 --- a/src/kernel/vga.c +++ b/src/kernel/vga.c @@ -2,9 +2,8 @@ #include <stdint.h> #define VGA_COLUMNS 80 -#define VGA_LINES 25 #define VGA_START (uint16_t *)0x000b8000 -#define VGA_END (VGA_START + VGA_COLUMNS * VGA_LINES) +#define VGA_END (VGA_START + VGA_COLUMNS * 25) static uint16_t *cursor = VGA_START; static uint16_t mask; @@ -12,12 +11,12 @@ void vga_set_color(uint8_t new_color) { mask = new_color << 8; } -void vga_scroll() { +static void vga_scroll() { for (uint32_t *i = (uint32_t *)VGA_START; i < (uint32_t *)(VGA_END - VGA_COLUMNS); ++i) *i = *(i + VGA_COLUMNS / 2); uint32_t f = (mask | (uint8_t)' ') * 0x00010001; for (uint32_t *i = (uint32_t *)(VGA_END - VGA_COLUMNS); i < (uint32_t *)VGA_END; ++i) - *i++ = f; + *i = f; cursor -= VGA_COLUMNS; } @@ -30,12 +29,10 @@ void vga_blank() { } void vga_printch(char ch) { - if (ch == '\n') { - if ((cursor = cursor - (cursor - VGA_START) % VGA_COLUMNS + VGA_COLUMNS) == VGA_END) - vga_scroll(); - return; - } - *cursor++ = mask | (uint8_t)ch; + if (ch == '\n') + cursor = ((cursor - VGA_START) / VGA_COLUMNS + 1) * VGA_COLUMNS + VGA_START; + else + *cursor++ = mask | (uint8_t)ch; if (cursor == VGA_END) vga_scroll(); }
\ No newline at end of file |