2019-02-09 14:35:29 -06:00
|
|
|
#include <grub/text_fb_info.h>
|
|
|
|
#include "../vga.h"
|
2019-02-09 17:22:51 -06:00
|
|
|
#define xy_to_indx(x,y) ((x+(y*height))*2)
|
2019-02-09 14:35:29 -06:00
|
|
|
char* screen;
|
|
|
|
int width;
|
|
|
|
int height;
|
2019-02-09 17:15:38 -06:00
|
|
|
vga_colors fg_color;
|
|
|
|
vga_colors bg_color;
|
2019-02-09 14:35:29 -06:00
|
|
|
|
2019-02-09 14:35:45 -06:00
|
|
|
void vga_set_char(int x,int y,char c) {
|
2019-02-09 17:22:51 -06:00
|
|
|
screen[xy_to_indx(x,y)]=c;
|
|
|
|
screen[xy_to_indx(x,y)+1]=(bg_color<<4)|fg_color;
|
2019-02-09 14:35:45 -06:00
|
|
|
}
|
|
|
|
|
2019-02-09 14:35:29 -06:00
|
|
|
void vga_init(text_fb_info framebuffer_info) {
|
2019-02-09 17:15:38 -06:00
|
|
|
fg_color=VGA_WHITE;
|
|
|
|
bg_color=VGA_BLACK;
|
2019-02-09 14:35:29 -06:00
|
|
|
screen=framebuffer_info.address;
|
|
|
|
width=framebuffer_info.width;
|
|
|
|
height=framebuffer_info.height;
|
2019-02-09 14:35:45 -06:00
|
|
|
vga_clear();
|
|
|
|
}
|
|
|
|
|
|
|
|
void vga_clear() {
|
|
|
|
for (int y=0;y<height;y++) {
|
|
|
|
for (int x=0;x<width;x++) {
|
|
|
|
vga_set_char(x,y,' ');
|
|
|
|
}
|
|
|
|
}
|
2019-02-09 14:35:29 -06:00
|
|
|
}
|