omos-tcnj2024/sys/video.c

41 lines
751 B
C

#include <types.h>
#include <video.h>
void
vga_write(s8 *sequence, s16 size, s8 flags)
{
if (size > VGA_TEXT_SIZE) {
s16 using_size = size - VGA_TEXT_SIZE;
for (s16 i = 0; i <= VGA_TEXT_SIZE; i++) {
vga_vidmem[i * 2] = sequence[using_size + i];
vga_vidmem[i * 2 + 1] = flags;
}
unused = VGA_SIZE;
return;
}
if (size * 2 + unused > VGA_SIZE) {
s16 needed_space = size * 2;
for (s16 i = 0; i <= (unused = VGA_SIZE - needed_space); i++) {
vga_vidmem[i] = vga_vidmem[needed_space + i];
}
}
for (s16 i = 0; i < size; i++) {
vga_vidmem[unused++] = sequence[i];
vga_vidmem[unused++] = flags;
}
}
void
vga_clearscreen(void)
{
unused = 0;
for (s16 i = 0; i <= VGA_SIZE; i++) {
vga_vidmem[i] = 0;
}
}