From 264e6ebaa0816d0d2070090ebd7a75d7767929cb Mon Sep 17 00:00:00 2001 From: Michal Idziorek Date: Tue, 8 Jul 2014 11:34:16 +0200 Subject: Merge in parts of the experimental branch --- kernel/console.c | 68 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 68 insertions(+) create mode 100644 kernel/console.c (limited to 'kernel/console.c') diff --git a/kernel/console.c b/kernel/console.c new file mode 100644 index 0000000..9381eed --- /dev/null +++ b/kernel/console.c @@ -0,0 +1,68 @@ +#include + +#include "console.h" + +static int posx=0; +static int posy=0; + +void print_nextline() +{ + posx=0; + posy++; + if(posy>SCR_HEIGHT-2)posy=0; +} + +void print_hex(uint16_t val) +{ + int i; + + print_char_col(posx,posy,'0',SCR_WHITE); + posx++; + print_char_col(posx,posy,'x',SCR_WHITE); + posx++; + + for(i=0;i<4;i++) + { + print_single_hex((val&0xf000)>>12); + val=val << 4; + + + } + +} + +void print_single_hex(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++; + +} + + +void print_str(int x,int y,char *str) +{ + print_str_col(x,y,str,SCR_WHITE); +} + +void print_char(int x, int y, char c) +{ + print_char_col(x,y,c,SCR_WHITE); +} + +void print_str_col(int x,int y,char *str, char col) +{ + + while(*str!=0) + { + print_char_col(x++,y,*(str++),col); + } + +} + +void print_char_col(int x, int y, char c, char col) +{ + char* video_mem=(char *)SCR_VIDEOMEM+(x+y*SCR_WIDTH)*2; + video_mem[0]=c; + video_mem[1]=col; +} -- cgit v1.2.3