mbr_asm/vga.c

31 lines
745 B
C

#include "vga.h"
void clearScreen(int bgColor)
{
volatile short *vga = (short *)VGA_ADDR;
long int colorAttr = bgColor << 12;
for (int i = 0; i < VGA_WIDTH * VGA_HEIGHT; i++) {
vga[i] = colorAttr;
}
}
void printChar(const char str, int color, int bgColor, int startX, int startY)
{
volatile short *vga = (short *)VGA_ADDR;
long int colorAttr = (bgColor << 4 | (color & 0x0f)) << 8;
vga[80 * startY + startX] = colorAttr | str;
}
void printString(const char *str, int color, int bgColor, int startX,
int startY)
{
volatile short *vga = (short *)VGA_ADDR;
int i = 0;
long int colorAttr = (bgColor << 4 | (color & 0x0f)) << 8;
while (*str) {
vga[80 * startY + startX + i] = colorAttr | *str;
str++;
i++;
}
}