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
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
|
#!/usr/bin/perl
open TABLE, ">", "table/linedraw.h";
select TABLE;
my $ch = 0x2500;
# coordinate system:
#
# 0..8 (equally spaced) 9,11 mid-1,mid+1, makes 4 bit
# one point = 8 bit, two points = 16 bit
# 8 bit opcode 0 line, 1 rect, 2 arc
# 8 bit opcode arg
# OOOOOOOO AAAABBBB X1X1Y1Y1 X2X2Y2Y2
my $offs = 0;
my @offs;
sub emit {
my ($code, $x1, $y1, $x2, $y2, $a, $b) = @_;
$offs++;
printf " 0x%08lx,", ($code << 24)
| ($x1 << 12)
| ($y1 << 8)
| ($x2 << 4)
| ($y2 << 0)
| ($a << 20)
| ($b << 16);
}
print "static uint32_t linedraw_command[] = {\n";
while (<DATA>) {
next if /^\//;
next unless /\S/;
push @offs, $offs;
my ($v, $V, $h, $H, $s);
for (;;) {
/\G-/gc and last;
/\G$/gc and last;
/\G([123])/gc and $w = $1;
/\Gh/gc and $h = $w;
/\GH/gc and $H = $w;
/\Gv/gc and $v = $w;
/\GV/gc and $V = $w;
/\G\//gc and emit 0, 0, 8, 8, 0;
/\G\\/gc and emit 0, 0, 0, 8, 8;
/\GA/gc and emit 2, 8, 8, 0, 0, 2, 2;
/\GB/gc and emit 2, 0, 8, 0, 0, 1, 2;
/\GC/gc and emit 2, 0, 0, 0, 0, 1, 0;
/\GD/gc and emit 2, 8, 0, 0, 0, 0, 0;
/\Gi/gc and emit 1, 0, 0, 4, 4;
/\Gj/gc and emit 1, 4, 0, 8, 4;
/\Gk/gc and emit 1, 0, 4, 4, 8;
/\Gl/gc and emit 1, 4, 4, 8, 8;
/\Gs(\d)/gc and $s = $1;
/\Gr(\d+),(\d+),(\d+),(\d+)/gc and emit 1, $1, $2, $3, $4, $s;
/\G\s/gc;
}
if ($h) {
emit 0, 0, 9,10, 9 if $h > 1;
emit 0, 0, 10,10, 10 if $h & 1;
emit 0, 0, 11,10, 11 if $h > 1;
}
if ($H) {
emit 0,10, 9, 8, 9 if $H > 1;
emit 0,10, 10, 8, 10 if $H & 1;
emit 0,10, 11, 8, 11 if $H > 1;
}
if ($v) {
emit 0, 9, 0, 9, 10 if $v > 1;
emit 0,10, 0,10, 10 if $v & 1;
emit 0,11, 0,11, 10 if $v > 1;
}
if ($V) {
emit 0, 9, 10, 9, 8 if $V > 1;
emit 0,10, 10,10, 8 if $V & 1;
emit 0,11, 10,11, 8 if $V > 1;
}
$offs[-1] = ($offs[-1] << 4) | ($offs - $offs[-1]);
printf " // %04x\n", $ch;
$ch++;
}
print <<EOF;
};
static uint16_t linedraw_offs[] = {
EOF
for (@offs) {
printf " 0x%04x,", $_;
print "\n" if ++$cnt % 5 == 0;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