From 5e48d8259fb2857ad4441de77cbacddd50a21ec0 Mon Sep 17 00:00:00 2001 From: Michal Idziorek Date: Wed, 27 Aug 2014 14:24:42 +0200 Subject: added bitmap fonts and put string for vesa modes --- kernel/floppy.c | 14 ++++++++------ kernel/kernel.c | 29 +++++++++-------------------- kernel/vesa.c | 56 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++ 3 files changed, 73 insertions(+), 26 deletions(-) (limited to 'kernel') diff --git a/kernel/floppy.c b/kernel/floppy.c index 8be440f..a373ec7 100644 --- a/kernel/floppy.c +++ b/kernel/floppy.c @@ -343,7 +343,7 @@ void flpydsk_write_sector_imp (uint8_t head, uint8_t track, uint8_t sector) { flpydsk_send_command ( head); // first head should match with above! flpydsk_send_command ( sector); flpydsk_send_command ( FLPYDSK_SECTOR_DTL_512 ); - flpydsk_send_command ( 3 ); // number of tracks we want + flpydsk_send_command ( 1 ); // number of tracks we want /* flpydsk_send_command ( @@ -367,7 +367,7 @@ void flpydsk_write_sector_imp (uint8_t head, uint8_t track, uint8_t sector) { } void flpydsk_read_sector_imp (uint8_t head, uint8_t track, uint8_t sector) { - sector=1; + //sector=1; //! set the DMA for read transfer flpydsk_dma_read (); @@ -376,7 +376,6 @@ void flpydsk_read_sector_imp (uint8_t head, uint8_t track, uint8_t sector) { uint32_t st0, cyl; - //! read in a sector flpydsk_send_command ( FDC_CMD_READ_SECT | FDC_CMD_EXT_MULTITRACK | @@ -386,12 +385,14 @@ void flpydsk_read_sector_imp (uint8_t head, uint8_t track, uint8_t sector) { flpydsk_send_command ( head); flpydsk_send_command ( sector); flpydsk_send_command ( FLPYDSK_SECTOR_DTL_512 ); - flpydsk_send_command ( 3 ); // number of tracks we want + flpydsk_send_command ( 1 ); // number of tracks we want + /* flpydsk_send_command ( ( ( sector + 1 ) >= FLPY_SECTORS_PER_TRACK ) ? FLPY_SECTORS_PER_TRACK : sector + 1 ); */ + flpydsk_send_command ( FLPYDSK_GAP3_LENGTH_3_5 ); flpydsk_send_command ( 0xff ); @@ -543,7 +544,7 @@ void floppy_init() // scr_put_string_nl("floppy: test read (sector 0)."); - flpydsk_read_sector(0); + flpydsk_read_sector(64); //0x8000 here the data starts! scr_put_string_nl("floppy: data: "); uint16_t *dma=0xb000; int i; @@ -552,9 +553,10 @@ void floppy_init() scr_put_string_nl(""); - // + /* scr_put_string_nl("floppy: test write (sector 100)."); flpydsk_write_sector(100); + */ } diff --git a/kernel/kernel.c b/kernel/kernel.c index 5af172e..05a4f9f 100644 --- a/kernel/kernel.c +++ b/kernel/kernel.c @@ -24,13 +24,11 @@ void int_test_handler() X86_IRQ_END - } void kernel_main() { - // clear console scr_clear(); @@ -83,7 +81,7 @@ void kernel_main() vesa_init(0x8300,0x8400); // floppy - //floppy_init(); + floppy_init(); scr_put_string_nl(""); @@ -98,26 +96,17 @@ void kernel_main() // { //} + //uint8_t rawfont[]={0xff,0xff,0xc3,0xc3,0xff,0xff,0xc3,0xc3}; + //uint8_t rawfont[]={0xf0,0xf0,0xf0,0xf0,0xf0,0xf0,0xff,0xff,}; + uint8_t *rawfont=0xb000; // here the floppy_init puts first sector + // after 0x8000 (font data :)) - while(1) - { - - int i; - int j; - for(i=0;i<1024;i++) + PutString(rawfont,"Welcome to Fool OS 001",10,10,0xff00); + PutString(rawfont,"Welcome to Fool OS 001",20,20,0xf00); + PutString(rawfont,"Welcome to Fool OS 001",30,30,0xfff00); - for(j=0;j<768;j++) - { - if(o<2)PutPixel(i,j,0xff); - else if(o<4)PutPixel(i,j,0x5f0); - else PutPixel(i,j,0xf0000); - - } - t+=125; - o++; - if(o>8)o=0; - } + while(1); // never ending loop } diff --git a/kernel/vesa.c b/kernel/vesa.c index 93a42f3..b1a298f 100644 --- a/kernel/vesa.c +++ b/kernel/vesa.c @@ -38,6 +38,14 @@ typedef struct ModeInfoBlock { static vbemodeinfo *VbeModeInfoBlock; + +typedef struct foolfont_struct +{ + uint8_t line[10]; //every single fool font consists of 10 lines a 8 bit + +}foolfont; + + void vesa_init(vbeinfo *info,vbemodeinfo *mode) { int i=0; @@ -109,3 +117,51 @@ 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) +{ + 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