From 336cfa313d0ebd435690610e8006b90dc8bd0e56 Mon Sep 17 00:00:00 2001 From: Benji Dial Date: Thu, 26 Dec 2019 13:06:21 -0500 Subject: got multiboot info parsed! --- src/kernel/vga.c | 23 +++++++++++++++-------- 1 file changed, 15 insertions(+), 8 deletions(-) (limited to 'src/kernel/vga.c') diff --git a/src/kernel/vga.c b/src/kernel/vga.c index 96a691f..3d8de43 100644 --- a/src/kernel/vga.c +++ b/src/kernel/vga.c @@ -18,6 +18,7 @@ OF THIS SOFTWARE. */ #include "vga.h" +#include "serial.h" #include uint16_t cursor_pos = 0; @@ -25,18 +26,24 @@ uint8_t color = 0x70; #define cols 80 #define rows 25 +void clear(void) { + uint32_t fill = 0x00200020 | (color << 24) | (color << 8); + for (uint32_t *i = (uint32_t *)VGA_BUFFER; i < (uint32_t *)(VGA_BUFFER + rows * cols * 2); ++i) + *i = fill; + cursor_pos = 0; +} + void scroll(void) { cursor_pos -= cols * 2; - uint32_t *limit = (uint32_t *)(VGA_BUFFER + cols * (rows - 1)); - for (uint32_t *i = (uint32_t *)VGA_BUFFER; i < limit; ++i) + for (uint32_t *i = (uint32_t *)VGA_BUFFER; i < (uint32_t *)(VGA_BUFFER + (rows - 1) * cols * 2); ++i) *i = *(i + cols / 2); - limit += cols / 2; - uint32_t fill = (color * 0x0100 + (uint8_t)' ') * 0x00010001; - for (uint32_t *i = limit - cols / 2; i < limit; ++i) + uint32_t fill = (color << 8) | (color << 24) | 0x00200020; + for (uint32_t *i = (uint32_t *)(VGA_BUFFER + (rows - 1) * cols * 2); i < (uint32_t *)(VGA_BUFFER + rows * cols * 2); ++i) *i = fill; } void put_char(uint8_t ch) { + //send_byte(ch, COM2); switch (ch) { case '\b': if (cursor_pos) @@ -89,12 +96,12 @@ void put_16(uint16_t n) { void put_32_hex(uint32_t n) { for (uint8_t i = 0; i < 4; ++i) { - put_char(n / 0xf0000000 + (n < 0xa0000000 ? (uint8_t)'0' : (uint8_t)'a' - 1)); + put_char("0123456789abcdef"[n >> 28]); n <<= 4; } - put_char('_'); + put_char('.'); for (uint8_t i = 0; i < 4; ++i) { - put_char(n / 0xf0000000 + (n < 0xa0000000 ? (uint8_t)'0' : (uint8_t)'a' - 1)); + put_char("0123456789abcdef"[n >> 28]); n <<= 4; } } -- cgit v1.2.3