omos-tcnj2024/sys/drv/vga/video.c

41 lines
773 B
C
Raw Normal View History

2024-02-17 23:19:28 +01:00
#include <types.h>
#include <video.h>
2024-02-17 20:34:30 +01:00
2024-02-17 23:19:28 +01:00
void
2024-02-18 03:53:36 +01:00
vga_write(s8 *sequence, s16 size, s8 flags)
2024-02-17 23:19:28 +01:00
{
2024-02-18 02:16:03 +01:00
if (size > VGA_TEXT_SIZE) {
2024-02-18 03:53:36 +01:00
s16 using_size = size - VGA_TEXT_SIZE;
2024-02-18 01:39:28 +01:00
2024-02-18 03:53:36 +01:00
for (s16 i = 0; i <= VGA_SIZE; i++) {
2024-02-18 01:39:28 +01:00
vga_vidmem[i] = sequence[using_size + i];
2024-02-18 02:16:03 +01:00
vga_vidmem[++i] = flags;
2024-02-18 01:39:28 +01:00
}
2024-02-18 01:49:19 +01:00
2024-02-18 05:42:18 +01:00
unused = 2001;
2024-02-18 01:49:19 +01:00
return;
2024-02-18 01:39:28 +01:00
}
2024-02-18 05:47:57 +01:00
s16 needed_space = (size + unused) * 2 - VGA_SIZE;
2024-02-18 03:53:36 +01:00
if (needed_space >= 0) {
for (s16 i = 0; i <= VGA_SIZE - needed_space; i++) {
2024-02-18 05:47:57 +01:00
vga_vidmem[i] = vga_vidmem[i++ + needed_space];
2024-02-18 03:53:36 +01:00
}
unused = VGA_SIZE - needed_space;
}
2024-02-18 05:42:18 +01:00
for (s16 i = 0; i < size; i++) {
vga_vidmem[unused * 2] = sequence[i];
vga_vidmem[(unused++ * 2) + 1] = flags;
2024-02-17 23:19:28 +01:00
}
}
2024-02-17 23:22:21 +01:00
2024-02-18 01:16:13 +01:00
void
vga_clearscreen(void)
{
2024-02-18 03:53:36 +01:00
for (s16 i = 0; i <= VGA_SIZE; i++) {
2024-02-17 23:53:35 +01:00
vga_vidmem[i] = 0;
2024-02-17 23:22:21 +01:00
}
2024-02-17 23:53:35 +01:00
}