forked from skeeto/dosdefender-ld31
-
Notifications
You must be signed in to change notification settings - Fork 0
/
vga_font.h
32 lines (28 loc) · 1.02 KB
/
vga_font.h
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
#include "int.h"
#include "vga.h"
/* Letters are 7 pixels tall and 5 pixels wide. */
/* http://redd.it/2ba3g3 */
static const char LINES[] = "BCDEIKOPQRSTUVYZ\\_`";
static const char LETTERS[] =
"DFJSJJJRJJRJJRGJIIIJGRJJJJJRSIIRIISSIIRIIIHIILJJHJJJSJJJGDDDD"
"DGAAAAAJHJKMOMKJIIIIIISJQNJJJJJJPNLJJGJJJJJGRJJRIIIGJJJNGCRJJ"
"RMKJGJIGAJGSDDDDDDJJJJJJGJJJJJFDJJJNQJJJJFDFJJJJFDDDDSABDEIS";
static int vga_font_line(int c, int row) {
return c == ' ' ? 0 : LINES[LETTERS[(c - 'A') * 7 + row] - 'A'] - 'A';
}
static void vga_print(struct point p, uint8_t color, const char *message)
{
for (int y = 0; y < 7; y++) {
for (int x = 0; message[x]; x++) {
int c = message[x];
int line = vga_font_line(c, y);
for (int i = 0; i < 5; i++) {
if ((line >> i) & 0x01) {
int dx = p.x + x * 6 + (4 - i);
int dy = p.y + y;
vga_pixel((struct point){dx, dy}, color);
}
}
}
}
}