Last active
August 29, 2015 14:12
-
-
Save Trinitek/6ec475871bb0973f3888 to your computer and use it in GitHub Desktop.
putChar
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
void putChar(char c, short x, short y, char color) { | |
char* glyphOfs = getGlyph(c); | |
char byte = 0; | |
char i; | |
unsigned char pattern = 128u; // 0b10000000 | |
short xOfs = 0; | |
short yOfs = 0; | |
for (i = 0; i < 5*5; i++) { | |
// Plot pixel only if bit is set | |
if (*(glyphOfs + byte) & pattern) setPixel(x+xOfs, y+yOfs, color); | |
// Maximum of 5 pixels per row | |
if (!((i + 1) % 5) && i){ | |
xOfs = 0; | |
yOfs++; | |
} | |
else xOfs++; | |
// Next string of bits if the pattern is used up | |
pattern = pattern >> 1; | |
if (!pattern) { | |
byte++; | |
pattern = 128u; | |
} | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment