diff --git a/Makefile b/Makefile index 4a99e2c..d381f62 100644 --- a/Makefile +++ b/Makefile @@ -32,4 +32,3 @@ clean: kernel.dis : kernel.bin ndisasm -b 32 $< > $@ - diff --git a/src/kernel/lib/vga.c b/src/kernel/lib/vga.c index e3948e9..f0d9f02 100644 --- a/src/kernel/lib/vga.c +++ b/src/kernel/lib/vga.c @@ -3,20 +3,44 @@ // VGA base address: 0xb8000 // Charpos = 0xb8000 + 2(row*80 + col) +// Screen Dimensions +#define WIDTH 640 +#define HEIGHT 480 + +// Memory #define VIDEO_MEM (char*)0xb8000 -#define GET_INDEX(s, c) (int)(c-s) -static int cursor_y = 0; -char* get_cursor_pos(unsigned int col, unsigned int row) { +// Global +static int cursor_row = 0; + +/* + VGA & Memory Functions +*/ +char* get_vga_memory_pointer(unsigned int col, unsigned int row) { return (char*)(VIDEO_MEM + 2*((row*80) + col)); } +void putc(char c, unsigned int col, unsigned int row) { + *get_vga_memory_pointer(col, row) = c; +} + +/* + Graphics Functions +*/ +void clear_screen(unsigned int width = 640, unsigned int height = 480) { + +} + + +/* + General Printing Functions +*/ void print(char* str, unsigned int str_len) { for( char* c = str; *c != '\0'; c++ ) - *get_cursor_pos( GET_INDEX(str, c), cursor_y ) = *c; + putc(*c, (int)(c - str), cursor_row); } void println(char* str, unsigned int str_len) { print(str, str_len); - cursor_y++; // Increment to next y-pos (newline) + cursor_row++; // Increment to next y-pos (newline) }