diff options
author | Benji Dial <Benji3.141@gmail.com> | 2019-12-26 13:06:21 -0500 |
---|---|---|
committer | Benji Dial <Benji3.141@gmail.com> | 2019-12-26 13:06:21 -0500 |
commit | 336cfa313d0ebd435690610e8006b90dc8bd0e56 (patch) | |
tree | a2c3038462b6edcd13339fd741b34525f50c880e /src/kernel/vga.c | |
parent | 2c542b87ff3dc2eacc036dc296a81f8fc215e6d9 (diff) | |
download | portland-os-336cfa313d0ebd435690610e8006b90dc8bd0e56.tar.gz |
got multiboot info parsed!
Diffstat (limited to 'src/kernel/vga.c')
-rw-r--r-- | src/kernel/vga.c | 23 |
1 files changed, 15 insertions, 8 deletions
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 <stdbool.h> 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; } } |