-
Notifications
You must be signed in to change notification settings - Fork 12
/
bit_map.c
247 lines (221 loc) · 11.9 KB
/
bit_map.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
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
/* Bit_Map Image Uncompressor (C)Copyright 1992 by Noah Spurrier */
#include <stdlib.h>
#include "handy.h"
#include "bit_map.h"
/* Bit Map is 2 Bits per pixel, with 4 pixels per byte. The 4 pixels are
* in a horizontal row. I.e. 1234 NOT 1 NOR 4
* 2 3
* 3 2
* 4 1
*/
static UCHAR TITLE_DATA [(X_TITLE * Y_TITLE / 4)] =
{
85, 85, 85, 85, 85, 85, 85, 85, 85, 85, 85, 85, 85, 85, 85, 85, 85, 85, 85, 85,
85, 85, 85, 85, 85, 85, 85, 85, 85, 85, 85, 85, 85, 85, 85, 85, 85, 85, 85, 85,
85, 85, 85, 85, 85, 85,117, 85, 85, 85,117, 85, 85, 85,117, 85, 85,213, 85, 85,
85, 85, 85, 85, 85, 87,213, 85, 85, 87,213, 85, 85, 87,213, 85, 95, 85, 85, 85,
85, 85, 85, 85, 85,127,213, 85, 85,127, 85, 85, 85,127, 85, 85,255, 85, 85, 85,
85, 85, 85, 85, 85,255,213, 85, 85,253, 85, 85, 85,253, 85, 87,255, 85, 85, 85,
85, 85, 85, 85, 87,247,213, 85, 87,245, 85, 85, 87,245, 85, 95,223, 85, 85, 85,
85, 85, 85, 85,127,215,213, 85,127,213, 85, 85,127,213, 85,255, 95, 85, 85, 85,
85, 85, 85, 85,255, 87,213, 85,255, 85, 85, 85,255, 85, 87,253, 95, 85, 85, 85,
85, 85, 85, 87,253, 87,213, 87,253, 85, 85, 87,253, 85, 95,245, 95, 85, 85, 85,
85, 85, 85, 95,245, 87,213, 95,245, 85, 85, 95,245, 85,127,213, 95, 85, 85, 85,
85, 85, 85,127,245, 87,213,127,245, 85, 85,127,245, 85,255,213, 95, 85, 85, 85,
85, 85, 85,255,255,255,213,255,213, 85, 85,255,213, 87,255, 85, 95, 85, 85, 85,
85, 85, 85,255,255,255,213,255,213, 85, 85,255,213, 87,255, 85, 95, 85, 85, 85,
85, 85, 87,255,213, 87,215,255,213, 85, 87,255,213, 95,255, 85, 95, 85, 85, 85,
85, 85, 87,255,213, 87,215,255,213, 85, 87,255,213, 95,255, 85, 95, 85, 85, 85,
85, 85, 87,255,213, 87,215,255,213, 85, 87,255,213, 95,255, 85, 95, 85, 85, 85,
85, 85, 87,255,213, 87,215,255,255,255,215,255,213, 95,255,255,255, 85, 85, 85,
85, 85, 87,255,213, 87,215,255,255,255,215,255,213, 95,255,255,255, 85, 85, 85,
85, 85, 85, 85, 85, 85, 85, 85, 85, 85, 85, 85, 85, 85, 85, 85, 85, 85, 85, 85,
85, 85, 85, 85, 85, 85, 85, 85, 85, 85, 85, 85, 85, 85, 85, 85, 85, 85, 85, 85,
170,170,170,170,170,170,170,170,170,170,170,170,170,170,170,170,170,170,170,170,
170,170,170,170,170,170,170,170,170,170,170,170,170,170,170,170,170,170,170,170,
170,170,170,170,170,170,170,170,170,128, 0, 0, 0,170,170,170,170,170,170,170,
170,170,170,170,170,170,170,168, 0, 0, 0, 0, 0, 0, 2,170,170,170,170,170,
170,170,170,170,170,170,168, 0, 0, 0, 0, 0, 0, 0, 0, 0,170,170,170,170,
170,170,170,170,170,170, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 10,170,170,170,
170,170,170,170,170,160, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 42,170,170,170,
170,170,170,170,168, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,170,170,170,170,
170,170,170,170,128, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 2,170,170,170,170,
170,170,170,170, 0, 0, 0, 0, 0,170,168, 0, 0, 0, 0, 0,170,170,170,170,
170,170,170,160, 0, 0, 0, 10,170,171,255,252, 0,255,255, 0, 42,170,170,170,
170,170,170,128, 0, 0, 22,170,171,255,255,255,255,255,255,233, 10,170,170,170,
170,170,170, 0, 0, 1,106,170,255,255,255,255,255,255,255,255,146,170,170,170,
170,170,168, 0, 0, 22,170,175,255,255,255,255,255,255,255,255,228,170,170,170,
170,170,160, 0, 0, 90,170,191,255,255,255,255,255,255,255,255,254,170,170,170,
170,170,160, 0, 1,106,170,255,255,255,255,255,255,255,255,255,255,170,170,170,
170,170,160, 0, 5,106,170,255,255,255,255,255,255,255,255,255,255,234,170,170,
170,170,160, 0, 5,106,170,255,255,255,255,255,255,255,255,255,255,234,170,170,
170,170,160, 0, 5, 90,170,255,255,255,255,255,255,255,255,255,255,234,170,170,
170,170,160, 0, 5, 86,170,191,255,255,255,255,255,255,255,255,255,234,170,170,
170,170,160, 0, 5, 85,170, 0, 0, 3,255,255,255,255,255,255,255,234,170,170,
170,170,160, 0, 1, 85, 0, 0, 0, 0, 63,255,255,192, 0, 0, 47,234,170,170,
170,170,160, 0, 0, 80, 2,170,169, 85,107,255,255, 0, 85, 85, 2,170,170,170,
170,170,160, 0, 0, 0, 22,169, 85, 85, 90,255,253, 86,191,255,226,170,170,170,
170,170,160, 0, 1, 80, 85, 85, 21, 85, 90,191,253, 85, 69,255,232,170,170,170,
170,170,134,144, 5, 85, 85, 80, 2,149,106,191,254,149, 0, 90,170,170,170,170,
170,170, 6, 96, 21, 90,149,104, 10,191,170,191,255,175, 66,165,170,250,170,170,
170,170, 6, 0, 21,106,170,170,170,255,170,191,255,234,170,170,255,234,170,170,
170,170, 8, 36, 21,106,191,255,255,255,170,255,255,255,255,255,254,170,170,170,
170,170,138,170, 5, 90,255,255,255,255,170,255,255,255,255,255,254,170,170,170,
170,170,138, 2, 0, 90,191,255,255,255,171,255,255,255,255,255,254,170,170,170,
170,170,133, 40, 0, 22,175,255,255,250,171,255,255,255,255,255,255,170,170,170,
170,170,160,170, 0, 22,175,255,255,245, 86,175,235,255,255,255,251,170,170,170,
170,170,168,170, 0, 85,171,255,255,233,106, 86,150,255,255,255,239,170,170,170,
170,170,170, 1, 65, 85,170,255,255,234,170,175,255,255,255,255,239,170,170,170,
170,170,170,170,129, 85,106,191,255,234,175,255,255,255,255,255,174,170,170,170,
170,170,170,170,161, 85,106,171,255,170,255,255,255,255,255,255,170,170,170,170,
170,170,170,170,160, 85, 90,170,170,165, 85, 85,175,255,255,254,170,170,170,170,
170,170,170,170,168, 21, 86,170,168, 0, 0, 0, 0, 43,255,250,170,170,170,170,
170,170,170,170,170, 5, 85,170,170,170,191,255,254,255,255,234,170,170,170,170,
170,170,170,170,170,160, 85, 90,170,170, 85, 86,170,255,254,170,170,170,170,170,
170,170,170,170,170,170, 5, 85,170,170,170,170,175,255,250,170,170,170,170,170,
170,170,170,170,170,170,160, 85,106,175,255,255,255,255,168,170,170,170,170,170,
170,170,170,170,170,170,170, 5, 90,191,255,255,255,250,138,170,170,170,170,170,
170,170,170,170,170,170,170,160, 85,175,255,255,255,232,170,170,170,170,170,170,
170,170,170,170,170,170,170,170, 1,106,191,255,252, 10,170,170,170,170,170,170,
170,170,170,170,170,170,170,170,168, 0, 0, 0, 2,170,170,170,170,170,170,170,
170,170,170,170,170,170,170,170,170,160, 0, 0,170,170,170,170,170,170,170,170,
170,170,170,170,170,170,170,170,170,170,170,170,170,170,170,170,170,170,170,170,
170,170,170,170,170,170,170,170,170,170,170,170,170,170,170,170,170,170,170,170,
85, 85, 85, 85, 85, 85, 85, 85, 85, 85, 85, 85, 85, 85, 85, 85, 85, 85, 85, 85,
85, 85, 85, 85, 85, 85, 85, 85, 85, 85, 85, 85, 85, 85, 85, 85, 85, 85, 85, 85,
85, 85, 85, 85,213, 85, 85, 85,117, 85, 85,213, 85, 85, 85,213, 85, 85, 85,213,
85, 85, 85, 95, 85, 85, 85, 87,213, 85, 95, 85, 85, 85, 95, 85, 85, 85, 95, 85,
85, 85, 85,253, 85, 85, 85,127, 85, 85,255, 85, 85, 85,255, 85, 85, 85,255, 85,
85, 85, 87,245, 85, 85, 85,253, 85, 87,255, 85, 85, 87,255, 85, 85, 87,255, 85,
85, 85, 95,213, 85, 85, 87,245, 85, 95,223, 85, 85, 95,223, 85, 85, 95,223, 85,
85, 85,255, 85, 85, 85,127,213, 85,255, 95, 85, 85,255, 95, 85, 85,255, 95, 85,
85, 87,253, 85, 85, 85,255, 85, 87,253, 95, 85, 87,253, 95, 85, 87,253, 95, 85,
85, 95,245, 85, 85, 87,253, 85, 95,245, 95, 85, 95,245, 95, 85, 95,245, 95, 85,
85,127,213, 85, 85, 95,245, 85,127,213, 95, 85,127,213, 95, 85,127,213, 95, 85,
85,255,213, 85, 85,127,245, 85,255,213, 95, 85,255,213, 95, 85,255,213, 95, 85,
87,255, 85, 85,213,255,213, 87,255,255,255, 87,255,255,255, 87,255,255,255, 85,
87,255, 85,127, 85,255,213, 87,255,255,255, 87,255,255,255, 87,255,255,255, 85,
95,255, 87,255,215,255,213, 95,255, 85, 95, 95,255,253, 85, 95,255, 85, 85, 85,
95,255,127,215,247,255,213, 95,255, 85, 95, 95,255, 95,213, 95,255, 85, 85, 85,
95,255,253, 85,127,255,213, 95,255, 85, 95, 95,255, 85,253, 95,255, 85, 85, 85,
95,255,245, 85, 95,255,213, 95,255, 85, 95, 95,255, 85,127, 95,255, 85, 85, 85,
95,255, 85, 85, 87,255,213, 95,255, 85, 95, 95,255, 85,127, 95,255, 85, 85, 85,
85, 85, 85, 85, 85, 85, 85, 85, 85, 85, 85, 85, 85, 85, 85, 85, 85, 85, 85, 85,
85, 85, 85, 85, 85, 85, 85, 85, 85, 85, 85, 85, 85, 85, 85, 85, 85, 85, 85, 85,
87,247,255,127, 93, 85, 95,215,245,215, 85,127,245,245, 85,255,117,119,127,245,
93, 85,117,117,221, 85, 93,119, 93,221, 85, 87, 87, 93, 85,213, 93,215, 87, 85,
93, 85,117,127, 93, 95,223,215,245,245, 85, 87, 87, 93, 85,253, 87, 87, 87, 85,
93, 85,117,119, 93, 85, 93,119, 93,221, 85, 87, 87, 93, 85,213, 93,215, 87, 85,
87,245,117,117,223,213, 95,215, 93,215, 85, 87, 85,245, 85,255,117,119, 87, 85,
85, 85, 85, 85, 85, 85, 85, 85, 85, 85, 85, 85, 85, 85, 85, 85, 85, 85, 85, 85,
};
/* This function assumes that the colors 0, 9, 17, and 25 will be
* appropriate for the current palette. See 'switch (bits)' below.
*/
static void bit_map_uncompress (UCHAR *buf_graf, UCHAR *bit_data,
int x_map, int y_map,
int xmax, int ymax, int xsize)
{
int x, y, tx, ty;
int beg_x, beg_y, end_x, end_y;
int bits2;
beg_x = (xmax - 2 * x_map) / 2;
beg_y = (ymax - 2 * y_map) / 2;
end_x = 2 * x_map + beg_x;
end_y = 2 * y_map + beg_y;
if (beg_x < 0 || beg_y < 0 || end_x >= xmax || end_y >= ymax)
return;
for (y = beg_y; y < end_y; y += 2)
{
for (x = beg_x; x < end_x; x += 2)
{
tx = (x - beg_x) / 2;
ty = (y - beg_y) / 2;
bits2 = *(bit_data + ((x_map * ty + tx) / 4) );
switch ((x_map * ty + tx) % 4)
{
case 0:
bits2 &= 0xc0;
bits2 >>= 6;
break;
case 1:
bits2 &= 0x30;
bits2 >>= 4;
break;
case 2:
bits2 &= 0x0c;
bits2 >>= 2;
break;
case 3:
bits2 &= 0x03;
break;
}
switch (bits2)
{
/* case 0 :
writePixel(x, y, RANDOM(8) + 192 + 0);
writePixel(x+1, y, RANDOM(8) + 192 + 0);
writePixel(x, y+1, RANDOM(8) + 192 + 0);
writePixel(x+1, y+1, RANDOM(8) + 192 + 0);
break;
case 1 :
writePixel(x, y, RANDOM(8) + 192 + 9);
writePixel(x+1, y, RANDOM(8) + 192 + 9);
writePixel(x, y+1, RANDOM(8) + 192 + 9);
writePixel(x+1, y+1, RANDOM(8) + 192 + 9);
break;
case 2 :
writePixel(x, y, RANDOM(8) + 192 + 17);
writePixel(x+1, y, RANDOM(8) + 192 + 17);
writePixel(x, y+1, RANDOM(8) + 192 + 17);
writePixel(x+1, y+1, RANDOM(8) + 192 + 17);
break;
case 3 :
writePixel(x, y, RANDOM(8) + 192 + 25);
writePixel(x+1, y, RANDOM(8) + 192 + 25);
writePixel(x, y+1, RANDOM(8) + 192 + 25);
writePixel(x+1, y+1, RANDOM(8) + 192 + 25);
break;
}
*/
case 0 :
*(buf_graf + xsize * (y+0) + (x+0)) = (UCHAR)RANDOM(8) + 192 + 0;
*(buf_graf + xsize * (y+1) + (x+0)) = (UCHAR)RANDOM(8) + 192 + 0;
*(buf_graf + xsize * (y+0) + (x+1)) = (UCHAR)RANDOM(8) + 192 + 0;
*(buf_graf + xsize * (y+1) + (x+1)) = (UCHAR)RANDOM(8) + 192 + 0;
break;
case 1 :
*(buf_graf + xsize * (y+0) + (x+0)) = (UCHAR)RANDOM(8) + 192 + 9;
*(buf_graf + xsize * (y+1) + (x+0)) = (UCHAR)RANDOM(8) + 192 + 9;
*(buf_graf + xsize * (y+0) + (x+1)) = (UCHAR)RANDOM(8) + 192 + 9;
*(buf_graf + xsize * (y+1) + (x+1)) = (UCHAR)RANDOM(8) + 192 + 9;
break;
case 2 :
*(buf_graf + xsize * (y+0) + (x+0)) = (UCHAR)RANDOM(8) + 192 + 17;
*(buf_graf + xsize * (y+1) + (x+0)) = (UCHAR)RANDOM(8) + 192 + 17;
*(buf_graf + xsize * (y+0) + (x+1)) = (UCHAR)RANDOM(8) + 192 + 17;
*(buf_graf + xsize * (y+1) + (x+1)) = (UCHAR)RANDOM(8) + 192 + 17;
break;
case 3 :
*(buf_graf + xsize * (y+0) + (x+0)) = (UCHAR)RANDOM(8) + 192 + 25;
*(buf_graf + xsize * (y+1) + (x+0)) = (UCHAR)RANDOM(8) + 192 + 25;
*(buf_graf + xsize * (y+0) + (x+1)) = (UCHAR)RANDOM(8) + 192 + 25;
*(buf_graf + xsize * (y+1) + (x+1)) = (UCHAR)RANDOM(8) + 192 + 25;
break;
}
}
}
}
void writeBitmapImageToArray (UCHAR *buf_graf, int image_number,
int xmax, int ymax, int stride)
{
switch (image_number)
{
case NOAHS_FACE: /* TITLE IMAGE */
bit_map_uncompress (buf_graf, TITLE_DATA,
X_TITLE, Y_TITLE, xmax, ymax, stride);
break;
default:
break;
}
}