less broken vga

This commit is contained in:
spikey 2024-02-17 19:39:28 -05:00
parent 719e37dd5a
commit 0f3456c643
2 changed files with 16 additions and 7 deletions

View File

@ -3,11 +3,12 @@
#include <types.h> #include <types.h>
#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); void vga_clearscreen(void);
#endif #endif

View File

@ -2,23 +2,31 @@
#include <video.h> #include <video.h>
void 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; u32 i = *vga_vidmem;
while (*sequence != '\0') { while (*sequence != '\0') {
vga_vidmem[unused++] = flags;
i++;
vga_vidmem[i] = *sequence; vga_vidmem[i] = *sequence;
*sequence++; *sequence++;
i++; i++;
vga_vidmem[i] = flags;
i++;
} }
} }
void void
vga_clearscreen(void) vga_clearscreen(void)
{ {
for (int i = 0; i <= SIZE; i++) { for (int i = 0; i <= VGA_SIZE; i++) {
vga_vidmem[i] = 0; vga_vidmem[i] = 0;
} }
} }