-
Notifications
You must be signed in to change notification settings - Fork 0
/
fontnew.c
114 lines (99 loc) · 4.79 KB
/
fontnew.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
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
/*****************************************
Mroczna Harmonia
font.c xxxxxxxxxxxx
(C) 2001, 2023 M. Feliks
*****************************************/
#include <string.h>
#include "gfx.h"
unsigned char chardata[];
void init_font(void)
{
}
void put_char(char ascii_code, int x, int y, unsigned char color, unsigned char* where)
{
int i, j, col;
unsigned char *ptr_char, *ptr_sprite, sprite[64];
if (ascii_code >= 'a' && ascii_code <= 'z') {
ascii_code += ('A' - 'a');
}
ptr_char = &chardata[((ascii_code - ' ') & 63) << 3];
ptr_sprite = sprite;
for (i = 0; i < 8; i++, ptr_char++) {
for (j = 0; j < 8; j++, ptr_sprite++) {
col = 7 - j;
if ((*ptr_char >> col) & 1) {
*ptr_sprite = (unsigned char)i + color;
}
else {
*ptr_sprite = 0;
}
}
}
draw_sprite(sprite, x, y, 8, 8, where);
}
void put_string(char* text, int x, int y, unsigned char color, unsigned char* where)
{
int i = 0;
if (x < 0) {
x = 160 - 4 * strlen(text);
}
if (y < 0) {
y = 100 - 4;
}
while (text[i]) {
put_char(text[i], x, y, color, where);
i++;
x += 8;
}
}
unsigned char chardata[] =
{
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x18, 0x18, 0x18,
0x18, 0x08, 0x00, 0x18, 0x00, 0x28, 0x28, 0x28, 0x00, 0x00, 0x00,
0x00, 0x00, 0x28, 0x7c, 0x28, 0x28, 0x28, 0x7c, 0x28, 0x00, 0x10,
0x7e, 0x40, 0x7e, 0x86, 0xfe, 0x10, 0x00, 0xe2, 0xa4, 0xe8, 0x10,
0x2e, 0x4a, 0x8e, 0x00, 0x38, 0x28, 0x7c, 0x44, 0xc4, 0xce, 0xfc,
0x00, 0x10, 0x10, 0x10, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0x04,
0x0c, 0x08, 0x0c, 0x04, 0x02, 0x00, 0x80, 0x40, 0x60, 0x20, 0x60,
0x40, 0x80, 0x00, 0x00, 0x54, 0x38, 0x6c, 0x38, 0x54, 0x00, 0x00,
0x00, 0x10, 0x10, 0x7c, 0x10, 0x10, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x18, 0x08, 0x00, 0x00, 0x00, 0x00, 0x38, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x18, 0x00, 0x04,
0x04, 0x08, 0x10, 0x20, 0x40, 0x40, 0x00, 0x7e, 0x42, 0x42, 0xc2,
0xc6, 0xc6, 0xfe, 0x00, 0x38, 0x00, 0x08, 0x18, 0x18, 0x18, 0x18,
0x00, 0x7c, 0x04, 0x7c, 0xc0, 0xc0, 0xc6, 0xfe, 0x00, 0x7e, 0x02,
0x1e, 0x06, 0x06, 0xc6, 0xfe, 0x00, 0x26, 0x22, 0x3e, 0x06, 0x06,
0x06, 0x06, 0x00, 0x7c, 0x40, 0x7c, 0x06, 0x06, 0xc6, 0xfe, 0x00,
0x78, 0x40, 0x7e, 0x46, 0xc6, 0xc6, 0xfe, 0x00, 0xfe, 0x86, 0x0c,
0x0c, 0x18, 0x18, 0x18, 0x00, 0x3c, 0x24, 0x7e, 0x42, 0xc2, 0xc6,
0xfe, 0x00, 0x7e, 0x42, 0x7e, 0x02, 0x06, 0xc6, 0xfe, 0x00, 0x00,
0x00, 0x18, 0x00, 0x18, 0x00, 0x00, 0x00, 0x00, 0x00, 0x18, 0x00,
0x18, 0x08, 0x00, 0x00, 0x0c, 0x18, 0x30, 0x60, 0x30, 0x18,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7e, 0x08,
0x08, 0x18, 0x18, 0x18, 0x18, 0x00, 0x46, 0x46, 0xc2, 0xc2, 0xc2,
0xc2, 0xfe, 0x00, 0x46, 0x46, 0x62, 0x32, 0x36, 0x1c, 0x1c, 0x00,
0x46, 0x46, 0xc2, 0xd2, 0xfe, 0xee, 0xc6, 0x00, 0xc6, 0x6c, 0x38,
0x10, 0x38, 0x6c, 0xc6, 0x00, 0x46, 0x46, 0x7c, 0x38, 0x18, 0x18,
0x18, 0x00, 0x7e, 0x06, 0x3c, 0x30, 0xe0, 0xe6, 0xfe, 0x00, 0x38,
0x20, 0x20, 0x20, 0x20, 0x20, 0x38, 0x00, 0x40, 0x40, 0x20, 0x10,
0x08, 0x04, 0x04, 0x00, 0x38, 0x08, 0x08, 0x08, 0x08, 0x08, 0x38,
0x00, 0x10, 0x28, 0x28, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0xfe, 0x00, 0xff, 0xff, 0xff, 0xff, 0xff,
0xff, 0xff, 0xff, 0x00,
};