summaryrefslogtreecommitdiff
path: root/src/kernel/vga.c
diff options
context:
space:
mode:
authorBenji Dial <benji6283@gmail.com>2021-01-24 12:00:11 -0500
committerBenji Dial <benji6283@gmail.com>2021-01-24 12:00:11 -0500
commitbce944d1498eaa3b6940ee234c863b3548a66b37 (patch)
treeea40c087ab4f0f236aee8d158cf68550f5209f72 /src/kernel/vga.c
parentca731aa747214919df7b3dfe3478dbe787ce5b68 (diff)
downloadportland-os-bce944d1498eaa3b6940ee234c863b3548a66b37.tar.gz
graphics!
Diffstat (limited to 'src/kernel/vga.c')
-rw-r--r--src/kernel/vga.c52
1 files changed, 0 insertions, 52 deletions
diff --git a/src/kernel/vga.c b/src/kernel/vga.c
deleted file mode 100644
index 6ae1588..0000000
--- a/src/kernel/vga.c
+++ /dev/null
@@ -1,52 +0,0 @@
-#include <stdbool.h>
-#include <stdint.h>
-
-#define VGA_COLUMNS 80
-#define VGA_ROWS 25
-#define VGA_START (uint16_t *)0x000b8000
-#define VGA_END (VGA_START + VGA_COLUMNS * VGA_ROWS)
-static uint16_t *cursor = VGA_START;
-static uint16_t mask;
-
-void vga_set_color(uint8_t new_color) {
- mask = new_color << 8;
-}
-
-void vga_swap_color(uint16_t pos) {
- uint8_t *color_byte = (uint8_t *)(VGA_START + (pos >> 8) * VGA_COLUMNS + (pos & 0xff)) + 1;
- *color_byte = (*color_byte << 4) + (*color_byte >> 4);
-}
-
-static void vga_scroll() {
- for (uint32_t *i = (uint32_t *)VGA_START; i < (uint32_t *)(VGA_END - VGA_COLUMNS); ++i)
- *i = *(i + VGA_COLUMNS / 2);
- uint32_t f = (mask | (uint8_t)' ') * 0x00010001;
- for (uint32_t *i = (uint32_t *)(VGA_END - VGA_COLUMNS); i < (uint32_t *)VGA_END; ++i)
- *i = f;
- cursor -= VGA_COLUMNS;
-}
-
-void vga_blank() {
- uint32_t f = (mask | (uint8_t)' ') * 0x00010001;
- uint32_t *p = (uint32_t *)VGA_START;
- while (p < (uint32_t *)VGA_END)
- *p++ = f;
- cursor = VGA_END - VGA_COLUMNS;
-}
-
-void vga_printch(char ch) {
- if (ch == '\n')
- cursor = ((cursor - VGA_START) / VGA_COLUMNS + 1) * VGA_COLUMNS + VGA_START;
- else if (ch == '\b')
- *--cursor = mask | ' ';
- else
- *cursor++ = mask | (uint8_t)ch;
- if (cursor == VGA_END)
- vga_scroll();
-}
-
-void vga_print_at(uint16_t pos, const char *sz) {
- cursor = VGA_START + (pos >> 8) * VGA_COLUMNS + (pos & 0xff);
- while (*sz)
- vga_printch(*sz++);
-} \ No newline at end of file