Implemented a simple draw_rect function into the video driver.

This commit is contained in:
2020-05-22 16:30:00 -05:00
parent a1b1b90793
commit 7613ba9de2
3 changed files with 24 additions and 1 deletions
+1 -1
View File
@@ -1,3 +1,3 @@
#ifndef KERNEL_VERSION_NUMBER
#define KERNEL_VERSION_NUMBER "0.0.1-239"
#define KERNEL_VERSION_NUMBER "0.0.1-276"
#endif
+9
View File
@@ -5,6 +5,15 @@ void kmain()
{
clear_screen();
print_banner();
//draw_rect(20, 5, 50, 7, 0x4, 0xF);
draw_rect(0, 5, 5, 13, 0xF, 0x4);
draw_rect(5, 8, 10, 10, 0x4, 0xF);
draw_rect(10, 5, 15, 13, 0x8, 0x6);
draw_rect(20, 5, 25, 7, 0xF, 0x1);
draw_rect(20, 8, 25, 13, 0x5, 0x3);
//draw_rect(20, 5, 50, 7, 0x4, 0xF);
//draw_rect(20, 5, 50, 7, 0x4, 0xF);
//draw_rect(20, 5, 50, 7, 0x4, 0xF);
//draw_s("Hello, World!", 2, 9);
//row = 2;
///column = 80;
+14
View File
@@ -45,6 +45,20 @@ void print_banner(){
}
}
}
//index = (y_value * width_of_screen) + x_value;
void draw_rect(int start_x, int start_y, int end_x, int end_y, unsigned char fg, unsigned char bg){
unsigned char y = end_y - start_y;
unsigned char x = end_x - start_x;
int attr = ((bg << 4) | (fg & 0x0F));
unsigned short *buffer = (unsigned short*) 0x000B8000 + (start_y * 80) + start_x;
for(unsigned char i = 0; i < y; i++){
for(unsigned char j = 0; j < x; j++){
unsigned short *where = (unsigned short*) buffer + (i * 80) + j;
*where = 0x23 | (attr << 8);
}
}
}
void draw_s(char* string, unsigned char fg, unsigned char bg)
{