From 1aef6760667736d83b9a32c4bed57d4ae08c91b9 Mon Sep 17 00:00:00 2001 From: "E. Almqvist" Date: Mon, 16 Aug 2021 19:18:12 +0200 Subject: [PATCH] Color codes --- src/kernel/kernel.c | 2 +- src/kernel/lib/vga.c | 17 ++++++++++------- 2 files changed, 11 insertions(+), 8 deletions(-) diff --git a/src/kernel/kernel.c b/src/kernel/kernel.c index 93da93f..398e90c 100644 --- a/src/kernel/kernel.c +++ b/src/kernel/kernel.c @@ -6,5 +6,5 @@ void main() { *vidmem = 'X'; clear_screen(); - println("Kernel loaded.", 14); + println("eOS Version 0.0 2021", 0x0f); } diff --git a/src/kernel/lib/vga.c b/src/kernel/lib/vga.c index 7e89353..4ba02d1 100644 --- a/src/kernel/lib/vga.c +++ b/src/kernel/lib/vga.c @@ -17,12 +17,15 @@ static int cursor_row = 0; /* VGA & Memory Functions */ -char* get_vga_memory_pointer(unsigned int col, unsigned int row) { +char* get_vga_charpos_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; +void putc(char c, unsigned int col, unsigned int row, int colorcode) { + char* mem = get_vga_charpos_pointer(col, row); + *mem = c; + *(mem+1) = colorcode; + } /* @@ -38,12 +41,12 @@ void clear_screen() { /* General Printing Functions */ -void print(char* str, unsigned int str_len) { +void print(char* str, int colorcode) { for( char* c = str; *c != '\0'; c++ ) - putc(*c, (int)(c - str), cursor_row); + putc(*c, (int)(c - str), cursor_row, colorcode); } -void println(char* str, unsigned int str_len) { - print(str, str_len); +void println(char* str, int colorcode) { + print(str, colorcode); cursor_row++; // Increment to next y-pos (newline) }