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 15:02:57 +01:00
|
|
|
for (s16 i = 0; i <= VGA_TEXT_SIZE; i++) {
|
|
|
|
vga_vidmem[i * 2] = sequence[using_size + i];
|
|
|
|
vga_vidmem[i * 2 + 1] = flags;
|
|
|
|
}
|
2024-02-18 01:49:19 +01:00
|
|
|
|
2024-02-18 15:02:57 +01:00
|
|
|
unused = VGA_SIZE;
|
2024-02-18 01:49:19 +01:00
|
|
|
return;
|
2024-02-18 14:40:09 +01:00
|
|
|
}
|
2024-02-18 01:39:28 +01:00
|
|
|
|
2024-02-18 14:39:13 +01:00
|
|
|
if (size * 2 + unused > VGA_SIZE) {
|
2024-02-18 06:33:00 +01:00
|
|
|
s16 needed_space = size * 2;
|
2024-02-18 03:53:36 +01:00
|
|
|
|
2024-02-18 06:33:00 +01:00
|
|
|
for (s16 i = 0; i <= (unused = VGA_SIZE - needed_space); i++) {
|
|
|
|
vga_vidmem[i] = vga_vidmem[needed_space + i];
|
2024-02-18 14:40:09 +01:00
|
|
|
}
|
|
|
|
}
|
2024-02-18 03:53:36 +01:00
|
|
|
|
2024-02-18 05:42:18 +01:00
|
|
|
for (s16 i = 0; i < size; i++) {
|
2024-02-18 06:21:22 +01:00
|
|
|
vga_vidmem[unused++] = sequence[i];
|
|
|
|
vga_vidmem[unused++] = flags;
|
2024-02-17 23:19:28 +01:00
|
|
|
}
|
2024-02-18 14:40:09 +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 06:21:22 +01:00
|
|
|
unused = 0;
|
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
|
|
|
}
|