Minor code clean up, and added some convenience to the draw_string function.

This commit is contained in:
2020-08-06 17:00:05 -05:00
parent 9fe73abe53
commit db1a68188f
5 changed files with 35 additions and 39 deletions
+15 -34
View File
@@ -11,47 +11,28 @@ void kmain()
{
set_serial_baud_rate(COM1_PORT, 0x03);
configure_serial_line(COM1_PORT);
write_to_com(COM1_PORT, "Set up COM1 for messaging.\n");
clear_screen();
write_to_com(COM1_PORT, "Clearing screen.\n");
print_banner();
write_to_com(COM1_PORT, "Displaying OS banner.\n");
//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);
set_cursor(0, 14);
move_cursor(0, 14);
move_cursor(0, 15);
draw_string("Test print", 0x8, 0xF);
move_cursor(0, 16);
draw_string("And now the cursor has been moved to y = 16.", 0x1, 0xF);
move_cursor(5, 20);
draw_string("Cursor moved over 5 cells and down 4 cells.", 0xF, 0x0);
draw_string("And the cursor moves to the end of the string", 0x1, 0xF);
draw_string("Now this string should have a newline now:\nAnd now a new line is here.\n", 0xF, 0x0);
//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;
//draw_s("And 2nd Row. Now the 3rd row.", 2, 9);
move_cursor(0, 3);
draw_string("Installing GDT...\n", 0xF, 0x0);
write_to_com(COM1_PORT, "Installing the GDT.\n");
print_message("Displaying OS banner.\n", 0xF, 0x0);
print_message("Installing GDT...\n", 0xF, 0x0);
gdt_install();
//move_cursor(0, 4);
//asm("xchg %bx, %bx");
//write_to_com(COM1_PORT, "GDT installed.\n");
print_message("GDT installed!\n", 0xF, 0x0);
//asm("xchg %bx, %bx"); // Boch's break point
//draw_string("Installed GDT\n", 0xf, 0x0);
//asm("xchg %bx, %bx");
print_message("Installing IDT...\n", 0xF, 0x0);
idt_install();
write_to_com(COM1_PORT, "IDT installed.\n");
print_message("IDT installed.\n", 0xF, 0x0);
int i = 5 / 0;
asm("hlt");
}
void print_message(unsigned char* msg, unsigned char fg, unsigned char bg)
{
write_to_com(COM1_PORT, msg);
draw_string(msg, fg, bg);
}