forked from dhepper/font8x8
-
Notifications
You must be signed in to change notification settings - Fork 0
/
render.c
39 lines (34 loc) · 769 Bytes
/
render.c
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
#include <stdio.h>
#include <stdlib.h>
#include "font8x8_basic.h"
void usage(char *exec) {
printf("Usage: %s <char_code>\n", exec);
printf(" <char_code> Decimal character code between 0 and 127\n");
}
void render(char *bitmap) {
int x,y;
int set;
int mask;
for (x=0; x < 8; x++) {
for (y=0; y < 8; y++) {
set = bitmap[x] & 1 << y;
printf("%c", set ? 'X' : ' ');
}
printf("\n");
}
}
int main(int argc, char **argv) {
int ord;
if (argc != 2) {
usage(argv[0]);
return 1;
}
ord = atoi(argv[1]);
if (ord > 127 || ord < 0) {
usage(argv[0]);
return 2;
}
char *bitmap = font8x8_basic[ord];
render(bitmap);
return 0;
}