-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathrastafont8x12.c
91 lines (86 loc) · 5.17 KB
/
rastafont8x12.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
#include "rastafont.h"
#if defined(_MSC_VER)
#elif defined(__GNUC__)
#define __forceinline inline __attribute__((always_inline))
#else
#define __forceinline
#endif
static const unsigned rastafont8x12_bitmap[] =
{
0xffffffff,0xffffffff,0xffffffff,0xe1e1f3ff,0xfff3f3e1,0xfffff3f3,0x999999ff,0xffffffdb,
0xffffffff,0x80c9c9ff,0x80c9c9c9,0xffffc9c9,0xfcc1f3f3,0xcfcfe1fc,0xfff3f3e0,0xdcffffff,
0xf9f3e7cc,0xffffcecc,0xe4e4f1ff,0xcc84a0f1,0xffff91c4,0xf3f3f3ff,0xfffffff9,0xffffffff,
0xf3e7cfff,0xf3f9f9f9,0xffffcfe7,0xe7f3f9ff,0xe7cfcfcf,0xfffff9f3,0x99ffffff,0x99c300c3,
0xffffffff,0xe7ffffff,0xe7e781e7,0xffffffff,0xffffffff,0xffffffff,0xfff9e3e3,0xffffffff,
0xffff80ff,0xffffffff,0xffffffff,0xffffffff,0xffffe3e3,0x9fbfffff,0xf9f3e7cf,0xfffffefc,
0x8c9cc1ff,0x98909484,0xffffc19c,0xf0f3f7ff,0xf3f3f3f3,0xffffc0f3,0xcccce1ff,0xf9f3e7cf,
0xffffc0cc,0xcfcce1ff,0xcfcfe3cf,0xffffe1cc,0xc3c7cfff,0xcf80ccc9,0xffff87cf,0xfcfcc0ff,
0xcfcfe0fc,0xffffe1cc,0xfcf9e3ff,0xcccce0fc,0xffffe1cc,0x9c9c80ff,0xf3e7cf9f,0xfffff3f3,
0xcccce1ff,0xcccce1cc,0xffffe1cc,0xcccce1ff,0xe7e7c1cc,0xfffff1f3,0xe3ffffff,0xe3ffffe3,
0xffffffe3,0xe3ffffff,0xe3ffffe3,0xfff3e7e3,0xf3e7cfff,0xf3f9fcf9,0xffffcfe7,0xffffffff,
0xff81ff81,0xffffffff,0xe7f3f9ff,0xe7cf9fcf,0xfffff9f3,0xcfcce1ff,0xfff3f3e7,0xfffff3f3,
0x9c9cc1ff,0xfc848484,0xffffc1fc,0xcce1f3ff,0xccc0cccc,0xffffcccc,0x9999c0ff,0x9999c199,
0xffffc099,0x9c99c3ff,0x9cfcfcfc,0xffffc399,0x99c9e0ff,0x99999999,0xffffe0c9,0xf9b980ff,
0xf9d9c1d9,0xffff80b9,0xb99980ff,0xf9d9c1d9,0xfffff0f9,0x9c99c3ff,0x9c8cfcfc,0xffff8399,
0xccccccff,0xccccc0cc,0xffffcccc,0xf3f3e1ff,0xf3f3f3f3,0xffffe1f3,0xcfcf87ff,0xcccccfcf,
0xffffe1cc,0xc99998ff,0xc9c9e1c9,0xffff9899,0xf9f9f0ff,0x99b9f9f9,0xffff8099,0x80889cff,
0x9c9c9480,0xffff9c9c,0x989c9cff,0x8c848090,0xffff9c9c,0x9cc9e3ff,0x9c9c9c9c,0xffffe3c9,
0x9999c0ff,0xf9f9c199,0xfffff0f9,0x9cc9e3ff,0x848c9c9c,0xff87cfc1,0x9999c0ff,0x99c9c199,
0xffff9899,0xcccce1ff,0xcce7f1fc,0xffffe1cc,0xf3d2c0ff,0xf3f3f3f3,0xffffe1f3,0xccccccff,
0xcccccccc,0xffffe1cc,0xccccccff,0xcccccccc,0xfffff3e1,0x9c9c9cff,0xc994949c,0xffffc9c9,
0xccccccff,0xcce1f3e1,0xffffcccc,0xccccccff,0xf3f3e1cc,0xffffe1f3,0xe68c80ff,0xb9f9f3e7,
0xffff809c,0xf3f3c3ff,0xf3f3f3f3,0xffffc3f3,0xfcfeffff,0xcfe7f3f9,0xffffbf9f,0xcfcfc3ff,
0xcfcfcfcf,0xffffc3cf,0x9cc9e3f7,0xffffffff,0xffffffff,0xffffffff,0xffffffff,0xff00ffff,
0xffe7f3f3,0xffffffff,0xffffffff,0xffffffff,0xccc1cfe1,0xffff91cc,0xf9f9f8ff,0x999999c1,
0xffffc499,0xffffffff,0xfcfccce1,0xffffe1cc,0xcfcfc7ff,0xccccccc1,0xffff91cc,0xffffffff,
0xfcc0cce1,0xffffe1cc,0xf9c9e3ff,0xf9f9e0f9,0xfffff0f9,0xffffffff,0xcccccc91,0xe1cccfc1,
0xf9f9f8ff,0x999991c9,0xffff9899,0xffe7e7ff,0xe7e7e7e1,0xffff81e7,0xffcfcfff,0xcfcfcfc3,
0xe1cccccf,0xf9f9f8ff,0xc9e1c999,0xffff9899,0xe7e7e1ff,0xe7e7e7e7,0xffff81e7,0xffffffff,
0x949494c0,0xffff9c94,0xffffffff,0xcccccce0,0xffffcccc,0xffffffff,0xcccccce1,0xffffe1cc,
0xffffffff,0x999999c4,0xf0f9c199,0xffffffff,0xcccccc91,0x87cfc1cc,0xffffffff,0xf99189c8,
0xfffff0f9,0xffffffff,0xe7f9cce1,0xffffe1cc,0xf9fbffff,0xf9f9f9c0,0xffffe3c9,0xffffffff,
0xcccccccc,0xffff91cc,0xffffffff,0xcccccccc,0xfffff3e1,0xffffffff,0x94949c9c,0xffffc9c9,
0xffffffff,0xe3e3c99c,0xffff9cc9,0xffffffff,0x99999999,0xf0e7cfc3,0xffffffff,0xf9e7cec0,
0xffffc0dc,0xf3f3c7ff,0xf3f9fcf9,0xffffc7f3,0xe7e7e7ff,0xe7e7ffe7,0xffffe7e7,0xf3f3f8ff,
0xf3e7cfe7,0xfffff8f3,0x8ca431ff,0xffffffff,0xffffffff,
};
__forceinline static unsigned rastafont8x12_select(unsigned a, unsigned b, unsigned m) { return ((b^a)&m)^b; }
__forceinline static void rastafont8x12_blit8(unsigned* output, unsigned colour, unsigned m, unsigned b)
{
output[0] = rastafont8x12_select(output[0], colour, (int)(m<<(31-b))>>31);
output[1] = rastafont8x12_select(output[1], colour, (int)(m<<(30-b))>>31);
output[2] = rastafont8x12_select(output[2], colour, (int)(m<<(29-b))>>31);
output[3] = rastafont8x12_select(output[3], colour, (int)(m<<(28-b))>>31);
output[4] = rastafont8x12_select(output[4], colour, (int)(m<<(27-b))>>31);
output[5] = rastafont8x12_select(output[5], colour, (int)(m<<(26-b))>>31);
output[6] = rastafont8x12_select(output[6], colour, (int)(m<<(25-b))>>31);
output[7] = rastafont8x12_select(output[7], colour, (int)(m<<(24-b))>>31);
}
void rastafont8x12_blit_string(unsigned* output, unsigned pitch, unsigned colour, const char* str)
{
unsigned id, m0, m1, m2;
while(*str)
{
id = *str-' ';
if( id <= '~'-' ' )
{
m0 = rastafont8x12_bitmap[id*3 + 0];
m1 = rastafont8x12_bitmap[id*3 + 1];
m2 = rastafont8x12_bitmap[id*3 + 2];
rastafont8x12_blit8(output+0*pitch/4, colour, m0, 0);
rastafont8x12_blit8(output+1*pitch/4, colour, m0, 8);
rastafont8x12_blit8(output+2*pitch/4, colour, m0, 16);
rastafont8x12_blit8(output+3*pitch/4, colour, m0, 24);
rastafont8x12_blit8(output+4*pitch/4, colour, m1, 0);
rastafont8x12_blit8(output+5*pitch/4, colour, m1, 8);
rastafont8x12_blit8(output+6*pitch/4, colour, m1, 16);
rastafont8x12_blit8(output+7*pitch/4, colour, m1, 24);
rastafont8x12_blit8(output+8*pitch/4, colour, m2, 0);
rastafont8x12_blit8(output+9*pitch/4, colour, m2, 8);
rastafont8x12_blit8(output+10*pitch/4, colour, m2, 16);
rastafont8x12_blit8(output+11*pitch/4, colour, m2, 24);
}
str += 1;
output += 8;
}
}