From 3353bdaf2bc2f0eb7c37b57728c5b3ce2017e7f5 Mon Sep 17 00:00:00 2001 From: Benji Dial Date: Thu, 26 Dec 2019 19:42:52 -0500 Subject: more info tags --- src/kernel/vga.c | 45 +++++++++++++++++++++++++++++++++++++++++++-- 1 file changed, 43 insertions(+), 2 deletions(-) (limited to 'src/kernel/vga.c') diff --git a/src/kernel/vga.c b/src/kernel/vga.c index 5fd8a46..cf95bc2 100644 --- a/src/kernel/vga.c +++ b/src/kernel/vga.c @@ -21,10 +21,11 @@ OF THIS SOFTWARE. #include "serial.h" #include -uint16_t cursor_pos = 0; -uint8_t color = 0x70; +#define VGA_BUFFER ((uint8_t *)0x000b8000) #define cols 80 #define rows 25 +uint16_t cursor_pos = 0; +uint8_t color = 0x70; void clear(void) { uint32_t fill = 0x00200020 | (color << 24) | (color << 8); @@ -82,6 +83,46 @@ void put_32_hex(uint32_t n) { } } +void put_16_hex(uint16_t n) { + for (uint8_t i = 0; i < 4; ++i) { + put_char("0123456789abcdef"[n >> 12]); + n <<= 4; + } +} + +void put_8_hex(uint8_t n) { + put_char("0123456789abcdef"[n >> 4]); + put_char("0123456789abcdef"[n & 0x0f]); +} + +void put_32_dec(uint32_t n) { + if (n) { + bool sig = false; + for (uint32_t m = 1000000000; m; m /= 10) { + if (((n / m) % 10) || sig) { + sig = true; + put_char((uint8_t)'0' + (n / m) % 10); + } + } + } + else + put_char('0'); +} + +void put_8_dec(uint8_t n) { + if (n) { + bool sig = false; + for (uint8_t m = 100; m; m /= 10) { + if (((n / m) % 10) || sig) { + sig = true; + put_char((uint8_t)'0' + (n / m) % 10); + } + } + } + else + put_char('0'); +} + void move_cursor(uint8_t col, uint8_t row) { cursor_pos = (col + row * cols) * 2; } -- cgit v1.2.3