VGA driver now clears on initialization

This commit is contained in:
pjht 2019-02-09 14:35:45 -06:00
parent 60c56c064d
commit b1506d95ed

View File

@ -1,13 +1,28 @@
#include <grub/text_fb_info.h> #include <grub/text_fb_info.h>
#include "../vga.h" #include "../vga.h"
#define xy_to_mem(x,y) ((x+(y*height))*2)
char* screen; char* screen;
int width; int width;
int height; int height;
vga_colors fg_color=VGA_WHITE; vga_colors fg_color=VGA_WHITE;
vga_colors bg_color=VGA_BLACK; vga_colors bg_color=VGA_BLACK;
void vga_set_char(int x,int y,char c) {
screen[xy_to_mem(x,y)]=c;
screen[xy_to_mem(x,y)+1]=(bg_color<<4)|fg_color;
}
void vga_init(text_fb_info framebuffer_info) { void vga_init(text_fb_info framebuffer_info) {
screen=framebuffer_info.address; screen=framebuffer_info.address;
width=framebuffer_info.width; width=framebuffer_info.width;
height=framebuffer_info.height; height=framebuffer_info.height;
vga_clear();
}
void vga_clear() {
for (int y=0;y<height;y++) {
for (int x=0;x<width;x++) {
vga_set_char(x,y,' ');
}
}
} }