mbr_asm/vga.c
Mathieu Maret f1341d3d72 Add some "kernel" code written in C
Draw few message on VGA
Setup Interruption Description Table
Setup IRQ
2017-11-27 14:51:51 +01:00

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++;
}
}