diff options
author | Freya Murphy <freya@freyacat.org> | 2025-04-17 00:51:46 -0400 |
---|---|---|
committer | Freya Murphy <freya@freyacat.org> | 2025-04-17 00:51:46 -0400 |
commit | f3e6838b44a5b37ce7664db5b8662e3d02e5f539 (patch) | |
tree | e97eeeabab78ba2c84d3b0069c8db9911cd021b2 /kernel/drivers/vga.c | |
parent | fmt (diff) | |
download | comus-f3e6838b44a5b37ce7664db5b8662e3d02e5f539.tar.gz comus-f3e6838b44a5b37ce7664db5b8662e3d02e5f539.tar.bz2 comus-f3e6838b44a5b37ce7664db5b8662e3d02e5f539.zip |
font rending in framebuffer yay!!
Diffstat (limited to '')
-rw-r--r-- | kernel/drivers/vga.c | 25 |
1 files changed, 25 insertions, 0 deletions
diff --git a/kernel/drivers/vga.c b/kernel/drivers/vga.c new file mode 100644 index 0000000..d73fa9f --- /dev/null +++ b/kernel/drivers/vga.c @@ -0,0 +1,25 @@ +#include <lib.h> +#include <comus/term.h> +#include <comus/asm.h> +#include <comus/memory.h> +#include <comus/drivers/vga.h> + +#define VGA_ADDR 0xB8000 +static volatile uint16_t *buffer = (uint16_t *)VGA_ADDR; + +// color +static uint8_t fg = 15, bg = 0; + +void vga_draw_char(char c, uint16_t x, uint16_t y) +{ + // output character + const size_t index = y * VGA_WIDTH + x; + buffer[index] = c | bg << 12 | fg << 8; + + // set cursor position on screen + const uint16_t pos = y * VGA_HEIGHT + x; + outb(0x3D4, 0x0F); + outb(0x3D5, (uint8_t)(pos & 0xFF)); + outb(0x3D4, 0x0E); + outb(0x3D5, (uint8_t)((pos >> 8) & 0xFF)); +} |