The lookup table:
Code: Select all
unsigned int FontDataTable[] = {0x00000000, 0x000000FF, 0x0000FF00, 0x0000FFFF,
0x00FF0000, 0x00FF00FF, 0x00FFFF00, 0x00FFFFFF,
0xFF000000, 0xFF0000FF, 0xFF00FF00, 0xFF00FFFF,
0xFFFF0000, 0xFFFF00FF, 0xFFFFFF00, 0xFFFFFFFF};
Code: Select all
void kernelDrawChar(unsigned int Character, unsigned char Foreground, unsigned char Background) {
char *Where = &Framebuffer[FramebufferPosition];
unsigned char RowData;
unsigned int Mask;
unsigned char *CharacterBMP = &Font[(Character)*16];
unsigned int PackedForeground =
(Foreground << 24) | (Foreground << 16) | (Foreground << 8) | Foreground;
unsigned int PackedBackground =
(Background << 24) | (Background << 16) | (Background << 8) | Background;
for (int Row = 0; Row < FontHeight; Row++) {
RowData = CharacterBMP[Row];
Mask = FontDataTable[RowData >> 16] | FontDataTable[RowData & 0x0F];
*(unsigned int *)Where =
(PackedForeground & Mask) | (PackedBackground & ~Mask);
RowData = CharacterBMP[Row] >> 4;
Mask = FontDataTable[RowData >> 16] | FontDataTable[RowData & 0x0F];
*(unsigned int *)&Where[4] =
(PackedForeground & Mask) | (PackedBackground & ~Mask);
Where += FramebufferPitch;
}
FramebufferPosition += FontWidth;
}
It's also probably worth noting I'm using the font from Apple's Darwin Kernel. https://github.com/apple/darwin-xnu/blo ... iso_font.c
I haven't ever done anything like this, so it's all a very new fun learning experience.
I've been trying to fix this for a while because to me it seems like it would be easy to fix, but I just can't solve it. I apologize if it's something simple or if my code is just all wrong .
Thanks in advance!