diff options
author | Benji Dial <Benji3.141@gmail.com> | 2019-12-26 19:42:52 -0500 |
---|---|---|
committer | Benji Dial <Benji3.141@gmail.com> | 2019-12-26 19:42:52 -0500 |
commit | 3353bdaf2bc2f0eb7c37b57728c5b3ce2017e7f5 (patch) | |
tree | c0c8e15c5b71f0c6b1a686be7e591b2c643396a2 /src/kernel/vga.c | |
parent | c055a2f6a9778f93a8f09b6d820d2504d3fa2601 (diff) | |
download | portland-os-3353bdaf2bc2f0eb7c37b57728c5b3ce2017e7f5.tar.gz |
more info tags
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; } |