Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
bitmap fonts
#1
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<<8)+(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<<8)+(y<<6);
}

}
[/syntax]
Any help?
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)