Qbasicnews.com
February 21, 2020, 10:00:24 PM *
Welcome, Guest. Please login or register.

Login with username, password and session length
News: Back to Qbasicnews.com | QB Online Help | FAQ | Chat | All Basic Code | QB Knowledge Base
 
   Home   Help Search Login Register  
Pages: [1]
  Print  
Author Topic: bitmap fonts  (Read 1528 times)
eno_on
Senior Member
**
Posts: 210


« on: August 23, 2004, 11:07:34 AM »

I've been working on a tile scrolling engine in djgpp in mode 13h(finally works!), but I've encountered a roadblock with bitmap fonts.  Does anyone have a way to divide up a bitmap I loaded into 94 blocks of text.  Bitmaps and Fonts use these structures:
[syntax="c"]
typedef struct tagBITMAP              
{
    short width;
    short height;
    char palette[256*3];
    char *data;
} BITMAP;

typedef struct tagFONT
{
    short width;
    short height;
    char *data[94];
} FONT;  
[/syntax]  
I've been using this code to load fonts and ouput their text, but It looks all wierd and doesn't work at all.
[syntax="c"]
void createfont(BITMAP *fontbmp, FONT *font)
{
           
      int x,y,j;
      for(j=0;j<94;j++){
      if((font->data[j] = (char *) malloc(10*23))==NULL)
      {
          printf("Error allocating memory\n");
          exit(1);
      }
      for(y=0;y<23;y++)
      for(x=0;x<10;x++)
      {
            font->data[j][y*10+x] = fontbmp->data[j*10 + x + y*959];
           
      }
      }    

}    

void textout(char *text, FONT *font, unsigned char *buffer)
{
    int x=1;
    int y=1;
    int i,j,c;
    int let;
    int screen_offset = (y<<Cool+(y<<6);
    int bitmap_offset = 0;
   
    for(c=0;c<sizeof(*text);c++,x=x+10){
        let=((int)text[c])-32;
        for(j=0;j<23;j++)
        {
                for(i=0;i<10;i++,bitmap_offset++)
                {
                                buffer[screen_offset+x+i] = font->data[let][bitmap_offset];
                               
                }
        screen_offset+=320;
        }
        screen_offset = (y<<Cool+(y<<6);
    }    
     
}    
[/syntax]
Any help?
Logged
Pages: [1]
  Print  
 
Jump to:  

Powered by MySQL Powered by PHP Powered by SMF 1.1.21 | SMF © 2015, Simple Machines Valid XHTML 1.0! Valid CSS!