Blitting characters in graphics modes
Hi,
I've been using this code (which is from "Teach Yourself Game Programming In 21 Days") to blit characters from the BIOS ROM font to the screen:-
Code:
unsigned char *screen = (unsigned char *)MK_FP(0xA000, 0);
unsigned char far *rom_char_set = (char far *)MK_FP(0xF000, 0xFA6E);
void Blit_Char(int x, int y, char c, int colour)
{
int offset, xc, yc;
char far *work_char;
unsigned char bit_mask = 0x80;
work_char = rom_char_set + c * 8;
offset = (y << 8) + (y << 6) + x;
for (yc=0;yc<8;yc++)
{
bit_mask = 0x80;
for (xc=0;xc<8;xc++)
{
if ((*work_char & bit_mask))
screen[offset+xc] = colour;
bit_mask = (bit_mask>>1);
}
offset += 320;
work_char++;
}
}
void Blit_String(int x, int y, int colour, char *string)
{
int index;
for (index=0;string[index]!=0;index++)
Blit_Char(x+(index<<3), y, string[index], colour);
}
The thing is, comparing it with a standard printf call, the characters look different, and the spacing between the characters seems a bit wayward. Does anyone know a way of emulating the printf function with transparent coloured text (i.e. for gaphics modes)?