summaryrefslogtreecommitdiff
path: root/kernel/vesa.c
diff options
context:
space:
mode:
authorMichal Idziorek <m.i@gmx.at>2014-08-27 16:32:34 +0200
committerMichal Idziorek <m.i@gmx.at>2014-08-27 16:32:34 +0200
commitd680d4c641c085e7a31d19fe2d01f528e96d2ced (patch)
treefb1f35486c584feaeb087c740c42508f7abe32fc /kernel/vesa.c
parentd85b6209f37b4d886f9e85fd9592c9d7cf25deb9 (diff)
put vesa init to top and integrated binary font.
binary fool-font is now part of the kernel image and is loaded by the bootloader on startup into ram
Diffstat (limited to 'kernel/vesa.c')
-rw-r--r--kernel/vesa.c65
1 files changed, 24 insertions, 41 deletions
diff --git a/kernel/vesa.c b/kernel/vesa.c
index b1a298f..43e0dfb 100644
--- a/kernel/vesa.c
+++ b/kernel/vesa.c
@@ -36,9 +36,6 @@ typedef struct ModeInfoBlock {
uint16_t reserved2;
}vbemodeinfo;
-static vbemodeinfo *VbeModeInfoBlock;
-
-
typedef struct foolfont_struct
{
uint8_t line[10]; //every single fool font consists of 10 lines a 8 bit
@@ -46,23 +43,27 @@ typedef struct foolfont_struct
}foolfont;
-void vesa_init(vbeinfo *info,vbemodeinfo *mode)
+static foolfont *deffont;
+static vbemodeinfo *VbeModeInfoBlock;
+
+void vesa_init(vbeinfo *info,vbemodeinfo *mode,foolfont *rawfont)
{
- int i=0;
+ //the only functionallu important 2 init lines! (rest is log)
+ VbeModeInfoBlock=mode;
+ deffont=rawfont;
+ //
+
+ PutString("Welcome to Fool OS 001",30,30,0xfff00);
-// while(info[i].VbeSignature[0]=='V')
- // {
- scr_put_string("vesa: init vbe version: ");
- scr_put_hex(info[i].VbeVersion);
- scr_put_string(" / videomode ptr: ");
- scr_put_hex(info[i].VideoModePtr[0]);
- scr_put_hex(info[i].VideoModePtr[1]);
- scr_put_string_nl("");
+ int i=0;
+ scr_put_string("vesa: init vbe version: ");
+ scr_put_hex(info[i].VbeVersion);
+ scr_put_string(" / videomode ptr: ");
+ scr_put_hex(info[i].VideoModePtr[0]);
+ scr_put_hex(info[i].VideoModePtr[1]);
+ scr_put_string_nl("");
-// i++;
- // }
- //
- int *modeptr=info[i].VideoModePtr[0]; // 0x8322; // do not hardcode !!! take from vbeinfo!
+ int *modeptr=info[i].VideoModePtr[0]; // todo: take segment from vbeinfo!
while(*modeptr!=0xffff&&*modeptr!=0)
{
@@ -70,7 +71,6 @@ void vesa_init(vbeinfo *info,vbemodeinfo *mode)
scr_put_string("vesa: mode supported: ");
scr_put_hex(*modeptr);
scr_put_string_nl("");
-
modeptr++;
}
@@ -91,15 +91,7 @@ void vesa_init(vbeinfo *info,vbemodeinfo *mode)
scr_put_string("vesa: bpp: ");
scr_put_hex(mode->bpp);
scr_put_string_nl("");
-/*
-uint8_t *videomem=mode->physbase;
-for(i=0;i<0xffffff;i++)
-{
- videomem[i]=i;
-}
-*/
-
- VbeModeInfoBlock=mode;
+
}
@@ -108,7 +100,6 @@ void PutPixel(int x,int y, int color){
//do not write memory outside the screen buffer, check parameters against the VBE mode info
if (x<0 || x>VbeModeInfoBlock->Xres|| y<0 || y>VbeModeInfoBlock->Yres) return;
-//
if (x) x = (x*(VbeModeInfoBlock->bpp>>3)); // get bytes (divide by 8)
if (y) y = (y*VbeModeInfoBlock->pitch);
uint8_t *cTemp=VbeModeInfoBlock->physbase;
@@ -117,23 +108,22 @@ void PutPixel(int x,int y, int color){
cTemp[x+y+2] = (uint8_t)((color>>16) & 0xff);
}
-void PutFont(foolfont *font , char c, int x,int y, int color)
+void PutFont(char c, int x,int y, int color)
{
- int fnt=0;
+ int fnt=0;
if(c>='A'&&c<='Z')fnt=c-'A'+1;
else if(c>='a'&&c<='z')fnt=c-'a'+1;
else if(c>='0'&&c<='9')fnt=c-'0'+28;
else if(c=' ')fnt=27;
-
int posx, posy, sizex=8, sizey=10;
for(posx=x;posx<x+sizex;posx++)
for(posy=y;posy<y+sizey;posy++)
{
- if(font[fnt].line[posy-y]&1<<(7-(posx-x)))
+ if(deffont[fnt].line[posy-y]&1<<(7-(posx-x)))
{
PutPixel(posx,posy,color);
}
@@ -143,25 +133,18 @@ void PutFont(foolfont *font , char c, int x,int y, int color)
}
}
-
-
}
-void PutString(foolfont *font , char *str, int x,int y, int color)
+void PutString(char *str, int x,int y, int color)
{
int i=x;
while((*str)!=0)
{
- PutFont(font ,*str, i,y, color);
+ PutFont(*str, i,y, color);
i+=9; // spacing
str++;
}
-
-
-
-
-
}