VGA Fonts In Graphics Mode
Posted: Sat May 25, 2019 4:52 pm
I'm currently trying to set up printing characters to the screen and I'm following the article on the wiki: https://wiki.osdev.org/VGA_Fonts
I can get the inefficient versions to work quit easily, that is, just calling the putpixel command several times. but I can't seem to get he optimised versions to work. I'm Specifically talking about the last piece of code in the article:
I cant seem to get this code to work even after modifying it a fair bunch. There is also an example on the wiki in a slightly different article https://wiki.osdev.org/Drawing_In_Protected_Mode
(the last code section in the article) but i also cant get that one to work either. Can someone confirm is these pieces of code are actually correct? or if you have any alternate implementations?
cheers
danny
I can get the inefficient versions to work quit easily, that is, just calling the putpixel command several times. but I can't seem to get he optimised versions to work. I'm Specifically talking about the last piece of code in the article:
Code: Select all
void drawchar_transparent_8BPP(unsigned char c, int x, int y, int fgcolor)
{
void *dest;
uint32_t *dest32;
unsigned char *src;
int row;
uint32_t fgcolor32;
fgcolor32 = fgcolor | (fgcolor << 8) | (fgcolor << 16) | (fgcolor << 24);
src = font + c * 16;
dest = videoBuffer + y * bytes_per_line + x;
for(row = 0; row < 16; row++) {
if(*src != 0) {
mask_low = mask_table[*src][0];
mask_high = mask_table[*src][1];
dest32 = dest;
dest32[0] = (dest[0] & ~mask_low) | (fgcolor32 & mask_low);
dest32[1] = (dest[1] & ~mask_high) | (fgcolor32 & mask_high);
}
src++;
dest += bytes_per_line;
}
}
(the last code section in the article) but i also cant get that one to work either. Can someone confirm is these pieces of code are actually correct? or if you have any alternate implementations?
cheers
danny