From f5771c0dc9823c5505a9032f4b26e92e8abb17ce Mon Sep 17 00:00:00 2001 From: "E. Almqvist" Date: Mon, 23 Aug 2021 21:58:22 +0200 Subject: [PATCH] More cleanup --- drivers/vga.c | 25 ++++++++++++------------- drivers/vga.h | 3 +-- 2 files changed, 13 insertions(+), 15 deletions(-) diff --git a/drivers/vga.c b/drivers/vga.c index 8173d5a..e215b7f 100644 --- a/drivers/vga.c +++ b/drivers/vga.c @@ -1,4 +1,5 @@ // VGA Graphics Library +#include "vga.h" #include "../kernel/io.h" // Memory @@ -11,10 +12,19 @@ static unsigned int cursor_row = 0; static unsigned int cursor_col = 0; +void vga_init() { + // Disable cursor + port_outb(0x0a, 0x3d4); + port_outb(0x20, 0x3d5); + + // Clear screen + clear_screen(); +} + /* VGA & Memory Functions */ -char* get_vga_charpos_pointer(unsigned int col, unsigned int row) { +char* get_memory_charpos(unsigned int col, unsigned int row) { return (char*)(VGA_ADDRESS + 2*((row*80) + col)); } @@ -22,7 +32,7 @@ void writechar(char c, unsigned int col, unsigned int row, int attribute_byte) { if( !attribute_byte ) attribute_byte = 0x0f; - char* mem = get_vga_charpos_pointer(col, row); + char* mem = get_memory_charpos(col, row); *mem = c; // Write the character *(mem+1) = attribute_byte; // Write the attribute_byte @@ -42,12 +52,6 @@ void clear_screen() { writechar(0x20, c, r, 0xf0); } -void disable_vga_cursor() { - port_outb(0x0a, 0x3d4); - port_outb(0x20, 0x3d5); -} - - /* General Printing Functions */ @@ -62,8 +66,3 @@ void println(char* str, int attribute_byte) { } -// VGA Initialization Function -void vga_init() { - disable_vga_cursor(); - clear_screen(); -} diff --git a/drivers/vga.h b/drivers/vga.h index cf7a721..983fb09 100644 --- a/drivers/vga.h +++ b/drivers/vga.h @@ -1,7 +1,6 @@ -char* get_vga_charpos_pointer(unsigned int col, unsigned int row); +char* get_memory_charpos(unsigned int col, unsigned int row); void writechar(char c, unsigned int col, unsigned int row, int colorcode); void clear_screen(); -void disable_vga_cursor(); void set_cursor_pos(); void print(); void println();