summaryrefslogtreecommitdiff
path: root/lib/vga.c
diff options
context:
space:
mode:
Diffstat (limited to 'lib/vga.c')
-rw-r--r--lib/vga.c23
1 files changed, 23 insertions, 0 deletions
diff --git a/lib/vga.c b/lib/vga.c
new file mode 100644
index 0000000..9727025
--- /dev/null
+++ b/lib/vga.c
@@ -0,0 +1,23 @@
+#include <vga.h>
+#include <stddef.h>
+
+static uint16_t* vga_buffer BLSEC_DATA = VGA_MEMORY_ADDR;
+
+void vga_setup(int xmax, int ymax)
+{
+ for (size_t i = 0; i < MAX_WIDTH; i++) {
+ for (size_t j = 0; j < MAX_HEIGHT; j++) {
+ vga_put(i, j, ' ', 0);
+ }
+ }
+}
+
+uint8_t vga_color(uint8_t fg, uint8_t bg)
+{
+ return (uint8_t) fg | (uint8_t) bg << 4;
+}
+
+void vga_put(uint32_t x, uint32_t y, unsigned char uc, uint8_t color)
+{
+ vga_buffer[y*80+x] = (uint16_t) uc | (uint16_t) color << 8;
+}