From 63b04ffc264aab5313811f1aa7ffc30715814e67 Mon Sep 17 00:00:00 2001 From: Michal Idziorek Date: Thu, 13 Nov 2014 02:27:05 +0100 Subject: cleanup and refactoring. abstracting away console --- kernel/console.c | 158 ++----------------------------------------------------- 1 file changed, 4 insertions(+), 154 deletions(-) (limited to 'kernel/console.c') diff --git a/kernel/console.c b/kernel/console.c index e06da45..b6866a7 100644 --- a/kernel/console.c +++ b/kernel/console.c @@ -1,155 +1,5 @@ -#include "console.h" +#include "video/console.h" -//#define FOOLOS_CONSOLE - -static int posx=0; -static int posy=0; - -// helper_funcs - -void print_char_col(int x, int y, char c, char col) -{ -#ifdef FOOLOS_CONSOLE - char* video_mem=(char *)SCR_VIDEOMEM+(x+y*SCR_REAL_WIDTH)*2; - video_mem[0]=c; - video_mem[1]=col; -#endif -} - -void print_char(int x, int y, char c) -{ - print_char_col(x,y,c,SCR_WHITE); -} - -void print_single_num(int i) -{ - if(i<10)print_char_col(posx,posy,'0'+i,SCR_GREEN); - else if(i<16)print_char_col(posx,posy,'A'+i-10,SCR_GREEN); - posx++; - if(posx>=SCR_WIDTH)scr_nextline(); - -} - -void print_str_col(int x,int y,char *str, char col) -{ - - while(*str!=0) - { - print_char_col(x++,y,*(str++),col); - } - -} - -void print_str(int x,int y,char *str) -{ - print_str_col(x,y,str,SCR_WHITE); -} - - -// -// -void scr_clear() -{ - int x,y; - - for(x=0;xSCR_HEIGHT-2) - { - for(i=1;i=SCR_WIDTH)scr_nextline(); -} - - -void scr_put_hex(uint16_t val) -{ - - int i; - - scr_put_string("0x"); - - for(i=0;i<4;i++) - { - print_single_num((val&0xf000)>>12); - val=val << 4; - - } - -} - - -void scr_put_hex32(uint32_t val) -{ - scr_put_string("["); - scr_put_hex(val>>16); - scr_put_string(","); - scr_put_hex(val&0xffff); - scr_put_string("]"); -} - -void scr_put_string(char *str) -{ - while(*str!=0) - { - scr_put_char(*(str++),SCR_WHITE); - } -} - -void scr_backspace() -{ - if(posx==0)return; - print_char_col(posx-1,posy,'@',SCR_LGREEN); - posx--; - -} +void console_init(){scr_clear();} +void console_put_char(char c){scr_put_char(c,SCR_RED);} +void console_put_str(char *s){scr_put_string(s);} -- cgit v1.2.3