summaryrefslogtreecommitdiff
path: root/src/kernel/vga.c
diff options
context:
space:
mode:
authorBenji Dial <Benji3.141@gmail.com>2020-08-13 23:59:14 -0400
committerBenji Dial <Benji3.141@gmail.com>2020-08-13 23:59:14 -0400
commit7ff724fe8f709440da9c730fdb8dcbaa4f989ed5 (patch)
treee7f768ff56798bef3edc166a30e9cb8d7f25bd1e /src/kernel/vga.c
parent2ddbeb9f7214f6d3feef651eba83e6a9d120a743 (diff)
downloadportland-os-7ff724fe8f709440da9c730fdb8dcbaa4f989ed5.tar.gz
FAT16 directory enumeration, making many functions static, new 'log' functions to wrap vga and serial
Diffstat (limited to 'src/kernel/vga.c')
-rw-r--r--src/kernel/vga.c44
1 files changed, 12 insertions, 32 deletions
diff --git a/src/kernel/vga.c b/src/kernel/vga.c
index e103732..7506416 100644
--- a/src/kernel/vga.c
+++ b/src/kernel/vga.c
@@ -1,61 +1,41 @@
#include <stdbool.h>
#include <stdint.h>
-#define VGA_COM_MIRROR
-
-#ifdef VGA_COM_MIRROR
-#include "serial.h"
-#endif
-
#define VGA_COLUMNS 80
#define VGA_LINES 25
#define VGA_START (uint16_t *)0x000b8000
#define VGA_END (VGA_START + VGA_COLUMNS * VGA_LINES)
-uint16_t *cursor = VGA_START;
-uint16_t color = 0x1f00;
+static uint16_t *cursor = VGA_START;
+static uint16_t mask;
void vga_set_color(uint8_t new_color) {
- color = new_color << 8;
+ mask = new_color << 8;
}
void vga_scroll() {
- cursor = VGA_START;
+ 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() {
-#ifdef VGA_COM_MIRROR
- soutsz("\r\n\r\n<CLEAR>\r\n\r\n");
-#endif
- uint32_t f = (color << 16) | color | 0x00200020;
+ uint32_t f = (mask | (uint8_t)' ') * 0x00010001;
uint32_t *p = (uint32_t *)VGA_START;
while (p < (uint32_t *)VGA_END)
- *(p++) = f;
+ *p++ = f;
cursor = VGA_START;
}
void vga_printch(char ch) {
if (ch == '\n') {
-#ifdef VGA_COM_MIRROR
- soutsz("\r\n");
-#endif
if ((cursor = cursor - (cursor - VGA_START) % VGA_COLUMNS + VGA_COLUMNS) == VGA_END)
vga_scroll();
return;
}
-#ifdef VGA_COM_MIRROR
- sout(ch);
-#endif
- *(cursor++) = color | (uint8_t)ch;
+ *cursor++ = mask | (uint8_t)ch;
if (cursor == VGA_END)
vga_scroll();
-}
-
-void vga_printsz(const char *sz) {
- while (*sz)
- vga_printch(*(sz++));
-}
-
-void vga_printsn(const char *sn, uint8_t n) {
- while (n--)
- vga_printch(*(sn++));
} \ No newline at end of file