diff options
Diffstat (limited to 'src/kernel/vga.c')
-rw-r--r-- | src/kernel/vga.c | 45 |
1 files changed, 43 insertions, 2 deletions
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 <stdbool.h> -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; } |