More cleanup

pull/28/head
E. Almqvist 3 years ago
parent 4a56eb0156
commit f5771c0dc9
  1. 25
      drivers/vga.c
  2. 3
      drivers/vga.h

@ -1,4 +1,5 @@
// VGA Graphics Library // VGA Graphics Library
#include "vga.h"
#include "../kernel/io.h" #include "../kernel/io.h"
// Memory // Memory
@ -11,10 +12,19 @@
static unsigned int cursor_row = 0; static unsigned int cursor_row = 0;
static unsigned int cursor_col = 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 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)); 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 ) if( !attribute_byte )
attribute_byte = 0x0f; attribute_byte = 0x0f;
char* mem = get_vga_charpos_pointer(col, row); char* mem = get_memory_charpos(col, row);
*mem = c; // Write the character *mem = c; // Write the character
*(mem+1) = attribute_byte; // Write the attribute_byte *(mem+1) = attribute_byte; // Write the attribute_byte
@ -42,12 +52,6 @@ void clear_screen() {
writechar(0x20, c, r, 0xf0); writechar(0x20, c, r, 0xf0);
} }
void disable_vga_cursor() {
port_outb(0x0a, 0x3d4);
port_outb(0x20, 0x3d5);
}
/* /*
General Printing Functions 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();
}

@ -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 writechar(char c, unsigned int col, unsigned int row, int colorcode);
void clear_screen(); void clear_screen();
void disable_vga_cursor();
void set_cursor_pos(); void set_cursor_pos();
void print(); void print();
void println(); void println();

Loading…
Cancel
Save