From 0f3456c643e13c0bafffb58c80b5eff6195024a1 Mon Sep 17 00:00:00 2001 From: spikey Date: Sat, 17 Feb 2024 19:39:28 -0500 Subject: [PATCH] less broken vga --- sys/drv/vga/include/video.h | 7 ++++--- sys/drv/vga/video.c | 16 ++++++++++++---- 2 files changed, 16 insertions(+), 7 deletions(-) diff --git a/sys/drv/vga/include/video.h b/sys/drv/vga/include/video.h index b9ec86a..4d5c948 100644 --- a/sys/drv/vga/include/video.h +++ b/sys/drv/vga/include/video.h @@ -3,11 +3,12 @@ #include -#define SIZE 4000 +#define VGA_SIZE 4000 -s8 *vga_vidmem = (s8 *)0xb8000; +s8 *vga_vidmem = (s8 *)0xb8000; +s8 vga_unused = 0; -void vga_write(s8 *, s8); +void vga_write(s8 *, s32, s8); void vga_clearscreen(void); #endif diff --git a/sys/drv/vga/video.c b/sys/drv/vga/video.c index d8b607a..d0728bb 100644 --- a/sys/drv/vga/video.c +++ b/sys/drv/vga/video.c @@ -2,23 +2,31 @@ #include void -vga_write(s8 *sequence, s8 flags) +vga_write(s8 *sequence, s32 size, s8 flags) { + if (size > VGA_SIZE) { + s32 using_size = size - VGA_SIZE; + + for (s32 i = 0; i <= VGA_SIZE; i++) { + vga_vidmem[i] = sequence[using_size + i]; + } + } + u32 i = *vga_vidmem; while (*sequence != '\0') { + vga_vidmem[unused++] = flags; + i++; vga_vidmem[i] = *sequence; *sequence++; i++; - vga_vidmem[i] = flags; - i++; } } void vga_clearscreen(void) { - for (int i = 0; i <= SIZE; i++) { + for (int i = 0; i <= VGA_SIZE; i++) { vga_vidmem[i] = 0; } }