-
Notifications
You must be signed in to change notification settings - Fork 0
/
x68k-ite-sixel.diff
761 lines (726 loc) · 20.1 KB
/
x68k-ite-sixel.diff
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
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
NetBSD/x68k のコンソール ite(4) で SIXEL 画像を表示できるようにする
ネタパッチ 20161201 版です。
このパッチをあてて GENERIC カーネルをビルドするだけで使えるように
なります。
o ITE_SIXEL を定義すると SIXEL 画像のデコードをサポートします。
o ITE_16COLOR を定義すると、ite を 16色モードにします。
今のところ前半8色は変更なし、後半8色を拡張していますので、
従来の x68k 8色モードとは互換性がありますが、逆に世間の16色モードとは
互換性がありません。
16色モードといいつつ、カラーパレット0は黒(透明)のまま、カラーパレット8を
黒(不透明)としているため、実際には15色です。
o ITE_SYSCTL を定義すると、テキストパレットを sysctl で取得・変更
できるようになります。sysctl hw.ite.tpalette[0-F] です。
ただし廃止予定です。
注意点など:
o SIXEL データのうちパレット定義は無視してパレット番号 = カラーコードと
と解釈して使用しています。テキストVRAMのパレットを変えると、この画像
以外の部分の色も変わってしまうためです。
ITE_16COLOR オプションを定義しない場合は、デフォルトの ANSI(8色)を使用
してください。sayaka ちゃん同梱の sixelv で減色する際は -p 8 オプションです。
o ITE_16COLOR オプションを定義した場合は sixelv で -p x68k オプションで
減色します。
o 異常系はほとんど実装してません。お手製のシーケンスを食わせたりしない
ように :-)
前回 (20161101) からの変更点:
o SIXEL 展開中のカーネルメッセージの出力に対応。
o SIXEL 展開中のカーソルの点滅を抑制。
o カラーパレット 8 を黒(不透明) に変更。
o バグ修正。
diff --git a/conf/GENERIC b/conf/GENERIC
index c3389a7..8709705 100644
--- sys/arch/x68k/conf/GENERIC
+++ sys/arch/x68k/conf/GENERIC
@@ -247,6 +247,9 @@ kbd0 at mfp0 # standard keyboard
ite0 at grf0 grfaddr 0 # internal terminal emulator
options ITE_KERNEL_ATTR=4 # bold for kernel messages
# see /sys/arch/x68k/dev/itevar.h
+options ITE_SIXEL
+options ITE_16COLOR
+options ITE_SYSCTL
## floppy disks
fdc0 at intio0 addr 0xe94000 intr 96 dma 0 dmaintr 100 # floppy controller
diff --git a/conf/files.x68k b/conf/files.x68k
index 86dab41..eaeb5c2 100644
--- sys/arch/x68k/conf/files.x68k
+++ sys/arch/x68k/conf/files.x68k
@@ -66,6 +66,9 @@ file arch/x68k/dev/grf_tv.c grf | ite
file arch/x68k/dev/grf_gv.c grf | ite
defparam opt_ite.h ITE_KERNEL_ATTR
+defflag opt_ite.h ITE_SIXEL
+defflag opt_ite.h ITE_16COLOR
+defflag opt_ite.h ITE_SYSCTL
device ite : tty
attach ite at grf
file arch/x68k/dev/ite.c ite needs-flag
diff --git a/dev/ite.c b/dev/ite.c
index 2e254c8..a7c13eb 100644
--- sys/arch/x68k/dev/ite.c
+++ sys/arch/x68k/dev/ite.c
@@ -87,6 +87,9 @@ void opm_bell(void);
#define SUBR_CLEAR(ip,sy,sx,h,w) ip->isw->ite_clear(ip,sy,sx,h,w)
#define SUBR_SCROLL(ip,sy,sx,count,dir) \
ip->isw->ite_scroll(ip,sy,sx,count,dir)
+#if defined(ITE_SIXEL)
+#define SUBR_SIXEL(ip,sy,sx) ip->isw->ite_sixel(ip,sy,sx)
+#endif
struct consdev;
@@ -1180,10 +1183,18 @@ ite_putstr(const u_char *s, int len, dev_t dev)
if ((ip->flags & (ITE_ACTIVE|ITE_INGRF)) != ITE_ACTIVE)
return;
+#if defined(ITE_SIXEL)
+ /* avoid flicking cursor */
+ if (!ip->escape)
+#endif
SUBR_CURSOR(ip, START_CURSOROPT);
for (i = 0; i < len; i++)
if (s[i])
iteputchar(s[i], ip);
+#if defined(ITE_SIXEL)
+ /* avoid flicking cursor */
+ if (!ip->escape)
+#endif
SUBR_CURSOR(ip, END_CURSOROPT);
}
@@ -1192,8 +1203,24 @@ iteputchar(int c, struct ite_softc *ip)
{
int n, x, y;
char *cp;
+#if defined(ITE_SIXEL)
+ const uint32_t table[64] = {
+ 0x000000,0x000001,0x000010,0x000011,0x000100,0x000101,0x000110,0x000111,
+ 0x001000,0x001001,0x001010,0x001011,0x001100,0x001101,0x001110,0x001111,
+ 0x010000,0x010001,0x010010,0x010011,0x010100,0x010101,0x010110,0x010111,
+ 0x011000,0x011001,0x011010,0x011011,0x011100,0x011101,0x011110,0x011111,
+ 0x100000,0x100001,0x100010,0x100011,0x100100,0x100101,0x100110,0x100111,
+ 0x101000,0x101001,0x101010,0x101011,0x101100,0x101101,0x101110,0x101111,
+ 0x110000,0x110001,0x110010,0x110011,0x110100,0x110101,0x110110,0x110111,
+ 0x111000,0x111001,0x111010,0x111011,0x111100,0x111101,0x111110,0x111111,
+ };
+#endif
+#if defined(ITE_SIXEL)
+ if ((c >= 0x20 && ip->escape) || ip->escape == DCS) {
+#else
if (c >= 0x20 && ip->escape) {
+#endif
switch (ip->escape) {
case ESC:
@@ -1250,6 +1277,11 @@ iteputchar(int c, struct ite_softc *ip)
/* String Terminator */
c = ST;
ip->escape = 0;
+#if defined(ITE_SIXEL)
+ if (ip->decsixel_y != 0) {
+ ite_lf(ip);
+ }
+#endif
break;
case ']':
@@ -1893,9 +1925,29 @@ iteputchar(int c, struct ite_softc *ip)
break;
case '1':
+#if defined(ITE_16COLOR)
+ if (c_p[1] == '0') {
+ switch (c_p[2]) {
+ case '0': case '1': case '2': case '3':
+ case '4': case '5': case '6': case '7':
+ /* background colors */
+ ip->bgcolor = c_p[2] - '0' + 8;
+ c_p += 3;
+ break;
+ default:
+ c_p += 3;
+ break;
+ }
+ } else {
+ set_attr(ip, ATTR_BOLD);
+ c_p++;
+ }
+ break;
+#else
set_attr(ip, ATTR_BOLD);
c_p++;
break;
+#endif
case '2':
switch (c_p[1]) {
@@ -1964,6 +2016,22 @@ iteputchar(int c, struct ite_softc *ip)
c_p++;
break;
+#if defined(ITE_16COLOR)
+ case '9':
+ switch (c_p[1]) {
+ case '0': case '1': case '2': case '3':
+ case '4': case '5': case '6': case '7':
+ /* foreground colors */
+ ip->fgcolor = c_p[1] - '0' + 8;
+ c_p += 2;
+ break;
+ default:
+ c_p++;
+ break;
+ }
+ break;
+#endif
+
default:
c_p++;
break;
@@ -2080,6 +2148,225 @@ iteputchar(int c, struct ite_softc *ip)
}
break;
+#if defined(ITE_SIXEL)
+ case DCS:
+ switch (ip->dcs_cmd) {
+ case DCS_DISCARD:
+ /* discard sixel cause kernel message interrupted */
+ switch (c) {
+ case '-':
+ /* restart from next SIXEL line */
+ ite_lf(ip);
+ goto sixel_restart;
+
+ case CAN:
+ case SUB:
+ /* SUB should also display a reverse question mark... */
+ ip->escape = 0;
+ return;
+
+ case ESC:
+ ip->escape = ESC;
+ return;
+ default:
+ return;
+ }
+ break;
+
+ case DCS_START:
+ /* the biggie... */
+ switch (c) {
+ case '0': case '1': case '2': case '3': case '4':
+ case '5': case '6': case '7': case '8': case '9':
+ case ';': case '$':
+ if (ip->ap < ip->argbuf + MAX_ARGSIZE)
+ *ip->ap++ = c;
+ return;
+
+ case 'q':
+ /* init sixel */
+ /*
+ * DCS <P1> ; <P2> ; <P3> q
+ * P1 is aspect ratio, XXX not supported.
+ * P2 is bgcolor mode.
+ * 0..2: bgcolor mode, XXX not supported here.
+ * bit2 means 'OR'ed color mode. it's original extension.
+ */
+ ip->ap = ip->argbuf;
+ cp = strchr(ip->ap, ';');
+ if (cp != NULL) {
+ int mode;
+ mode = atoi(cp + 1) - '0';
+ ip->decsixel_ormode = (mode & 4);
+ } else {
+ ip->decsixel_ormode = 0;
+ }
+ sixel_restart:
+ ip->dcs_cmd = DCS_SIXEL;
+ ip->decsixel_state = DECSIXEL_INIT;
+ ip->decsixel_ph = MAX_SIXEL_WIDTH;
+ ip->decsixel_x = 0;
+ ip->decsixel_y = 0;
+ ip->decsixel_repcount = 0;
+ ip->decsixel_color = ip->fgcolor;
+ memset(ip->decsixel_buf, 0, sizeof(ip->decsixel_buf));
+ return;
+
+ case CAN:
+ case SUB:
+ /* SUB should also display a reverse question mark... */
+ ip->escape = 0;
+ return;
+
+ case ESC:
+ ip->escape = ESC;
+ return;
+
+ default:
+ return;
+ }
+ break;
+
+ case DCS_SIXEL:
+ sixel_loop:
+ switch (ip->decsixel_state) {
+ case DECSIXEL_INIT:
+ switch (c) {
+ case CAN:
+ case SUB:
+ /* SUB should also display a reverse question mark... */
+ ip->escape = 0;
+ return;
+ case ESC:
+ ip->escape = ESC;
+ return;
+ case DECSIXEL_REPEAT:
+ ip->decsixel_state = c;
+ ip->decsixel_repcount = 0;
+ return;
+ case DECSIXEL_RASTER:
+ case DECSIXEL_COLOR:
+ ip->decsixel_state = c;
+ ip->ap = ip->argbuf;
+ return;
+ case '$': // CR
+ ip->decsixel_x = 0;
+ return;
+ case '-': // LF
+ /* XXX FONTHEIGHT is defined in ite_tv.c, not here... */
+ if (ip->decsixel_y + 6 > 15) {
+ ite_lf(ip);
+ ip->decsixel_y -= 16;
+ }
+ SUBR_SIXEL(ip, ip->cury, ip->curx);
+ memset(ip->decsixel_buf, 0, sizeof(ip->decsixel_buf));
+ ip->decsixel_x = 0;
+ ip->decsixel_y += 6;
+ return;
+ default:
+ if ('?' <= c && c <= '~'
+ && ip->decsixel_x < MAX_SIXEL_WIDTH) {
+ uint32_t d;
+ d = table[c - '?'] * ip->decsixel_color;
+ ip->decsixel_buf[ip->decsixel_x] |= d;
+ ip->decsixel_x++;
+ } else {
+ /* ignore */
+ }
+ return;
+ }
+ break;
+ case DECSIXEL_REPEAT:
+ if ('0' <= c && c <= '9') {
+ ip->decsixel_repcount = ip->decsixel_repcount * 10
+ + (c - '0');
+ } else if ('?' <= c && c <= '~') {
+ int cnt = MIN(ip->decsixel_repcount,
+ MAX_SIXEL_WIDTH - ip->decsixel_x);
+ uint32_t d;
+ int i;
+ d = table[c - '?'] * ip->decsixel_color;
+ for (i = 0; i < cnt; i++) {
+ ip->decsixel_buf[ip->decsixel_x + i] |= d;
+ }
+ ip->decsixel_x += cnt;
+ ip->decsixel_state = DECSIXEL_INIT;
+ } else {
+ /* invalid ? */
+ ip->decsixel_state = DECSIXEL_INIT;
+ }
+ return;
+ case DECSIXEL_RASTER:
+ case DECSIXEL_RASTER_PAD:
+ case DECSIXEL_RASTER_PH:
+ case DECSIXEL_RASTER_PV:
+ switch (c) {
+ case '0': case '1': case '2': case '3': case '4':
+ case '5': case '6': case '7': case '8': case '9':
+ if (ip->ap < ip->argbuf + MAX_ARGSIZE)
+ *ip->ap++ = c;
+ return;
+ case ';':
+ default:
+ switch (ip->decsixel_state) {
+ case DECSIXEL_RASTER:
+ /* ignore PAN */
+ ip->ap = ip->argbuf;
+ ip->decsixel_state = DECSIXEL_RASTER_PAD;
+ return;
+ case DECSIXEL_RASTER_PAD:
+ /* ignore PAD */
+ ip->ap = ip->argbuf;
+ ip->decsixel_state = DECSIXEL_RASTER_PH;
+ return;
+ case DECSIXEL_RASTER_PH:
+ ip->decsixel_ph = ite_zargnum(ip);
+ ip->ap = ip->argbuf;
+ ip->decsixel_state = DECSIXEL_RASTER_PV;
+ return;
+ case DECSIXEL_RASTER_PV:
+ /* ignore PV */
+ ip->decsixel_state = DECSIXEL_INIT;
+ /* c is a next sequence char */
+ goto sixel_loop;
+ default:
+ /* NOTREACHED */
+ return;
+ }
+ }
+ return;
+ case DECSIXEL_COLOR:
+ switch (c) {
+ case '0': case '1': case '2': case '3': case '4':
+ case '5': case '6': case '7': case '8': case '9':
+ case ';':
+ if (ip->ap < ip->argbuf + MAX_ARGSIZE)
+ *ip->ap++ = c;
+ return;
+ default:
+ *ip->ap = '\0';
+ if (strchr(ip->argbuf, ';')) {
+ /* ignore the palette definition */
+ } else {
+ /* otherwise, it specifies color */
+#if defined(ITE_16COLOR)
+ ip->decsixel_color = ite_zargnum(ip) & 15;
+#else
+ ip->decsixel_color = ite_zargnum(ip) & 7;
+#endif
+ }
+ ip->decsixel_state = DECSIXEL_INIT;
+ ip->ap = ip->argbuf;
+ /* c is a next sequence char */
+ goto sixel_loop;
+ }
+ return;
+ }
+ break;
+ }
+ break;
+#endif /* ITE_SIXEL */
+
default:
ip->escape = 0;
@@ -2207,6 +2494,9 @@ iteputchar(int c, struct ite_softc *ip)
case DCS: /* device control string introducer */
ip->escape = DCS;
+#if defined(ITE_SIXEL)
+ ip->dcs_cmd = DCS_START;
+#endif
ip->ap = ip->argbuf;
break;
@@ -2403,12 +2693,23 @@ itecnputc(dev_t dev, int c)
#ifdef ITE_KERNEL_ATTR
short save_attribute;
#endif
+#if defined(ITE_SIXEL)
+ int save_escape;
+#endif
if (panicstr && !paniced &&
(ip->flags & (ITE_ACTIVE|ITE_INGRF)) != ITE_ACTIVE) {
(void) iteon(dev, 3);
paniced = 1;
}
+
+#if defined(ITE_SIXEL)
+ save_escape = ip->escape;
+ if (ip->escape == DCS) {
+ ip->escape = 0;
+ ip->dcs_cmd = DCS_DISCARD;
+ }
+#endif
#ifdef ITE_KERNEL_ATTR
save_attribute = ip->attribute;
ip->attribute = ITE_KERNEL_ATTR;
@@ -2417,5 +2718,10 @@ itecnputc(dev_t dev, int c)
#ifdef ITE_KERNEL_ATTR
ip->attribute = save_attribute;
#endif
+#if defined(ITE_SIXEL)
+ if (ip->escape == 0) {
+ ip->escape = save_escape;
+ }
+#endif
}
#endif
diff --git a/dev/ite_tv.c b/dev/ite_tv.c
index aae754a..9069386 100644
--- sys/arch/x68k/dev/ite_tv.c
+++ sys/arch/x68k/dev/ite_tv.c
@@ -33,10 +33,15 @@
#include <sys/cdefs.h>
__KERNEL_RCSID(0, "$NetBSD: ite_tv.c,v 1.16 2013/04/28 14:44:46 isaki Exp $");
+#include "opt_ite.h"
+
#include <sys/param.h>
#include <sys/device.h>
#include <sys/proc.h>
#include <sys/systm.h>
+#if defined(ITE_SYSCTL)
+#include <sys/sysctl.h>
+#endif
#include <machine/bus.h>
#include <machine/grfioctl.h>
@@ -71,6 +76,9 @@ __KERNEL_RCSID(0, "$NetBSD: ite_tv.c,v 1.16 2013/04/28 14:44:46 isaki Exp $");
u_int tv_top;
u_char *tv_row[PLANELINES];
+#if defined(ITE_SIXEL)
+u_char *tv_end;
+#endif
char *tv_font[256];
volatile char *tv_kfont[0x7f];
@@ -90,6 +98,9 @@ void tv_putc(struct ite_softc *, int, int, int, int);
void tv_cursor(struct ite_softc *, int);
void tv_clear(struct ite_softc *, int, int, int, int);
void tv_scroll(struct ite_softc *, int, int, int, int);
+#if defined(ITE_SIXEL)
+void tv_sixel(struct ite_softc *, int, int);
+#endif
inline static int expbits(int);
inline static void txrascpy(u_char, u_char, short, signed short);
@@ -166,6 +177,9 @@ tv_init(struct ite_softc *ip)
tv_top = 0;
for (i = 0; i < PLANELINES; i++)
tv_row[i] = (void *)__UNVOLATILE(&IODEVbase->tvram[ROWOFFSET(i)]);
+#if defined(ITE_SIXEL)
+ tv_end = (void *)__UNVOLATILE(&IODEVbase->tvram[ROWOFFSET(i)]);
+#endif
/* shadow ANK font */
memcpy(kern_font, (void *)&IODEVbase->cgrom0_8x16, 256 * FONTHEIGHT);
ite_set_glyph();
@@ -189,6 +203,9 @@ tv_init(struct ite_softc *ip)
ip->isw->ite_cursor = tv_cursor;
ip->isw->ite_clear = tv_clear;
ip->isw->ite_scroll = tv_scroll;
+#if defined(ITE_SIXEL)
+ ip->isw->ite_sixel = tv_sixel;
+#endif
/*
* Intialize colormap
@@ -196,7 +213,7 @@ tv_init(struct ite_softc *ip)
#define RED (0x1f << 6)
#define BLUE (0x1f << 1)
#define GREEN (0x1f << 11)
- IODEVbase->tpalet[0] = 0; /* black */
+ IODEVbase->tpalet[0] = 0; /* transparent */
IODEVbase->tpalet[1] = 1 | RED; /* red */
IODEVbase->tpalet[2] = 1 | GREEN; /* green */
IODEVbase->tpalet[3] = 1 | RED | GREEN; /* yellow */
@@ -204,6 +221,20 @@ tv_init(struct ite_softc *ip)
IODEVbase->tpalet[5] = 1 | BLUE | RED; /* magenta */
IODEVbase->tpalet[6] = 1 | BLUE | GREEN; /* cyan */
IODEVbase->tpalet[7] = 1 | BLUE | RED | GREEN; /* white */
+
+#if defined(ITE_16COLOR)
+#define hRED (0x0f << 6)
+#define hBLUE (0x0f << 1)
+#define hGREEN (0x0f << 11)
+ IODEVbase->tpalet[8] = 1; /* black */
+ IODEVbase->tpalet[9] = 1 | hRED;
+ IODEVbase->tpalet[10] = 1 | hGREEN;
+ IODEVbase->tpalet[11] = 1 | hRED | hGREEN;
+ IODEVbase->tpalet[12] = 1 | hBLUE;
+ IODEVbase->tpalet[13] = 1 | hBLUE | hRED;
+ IODEVbase->tpalet[14] = 1 | hBLUE | hGREEN;
+ IODEVbase->tpalet[15] = 1 | hBLUE | hRED | hGREEN;
+#endif /* ITE_16COLOR */
}
/*
@@ -726,3 +757,169 @@ tv_scroll(struct ite_softc *ip, int srcy, int srcx, int count, int dir)
break;
}
}
+
+#if defined(ITE_SIXEL)
+/*
+ * put SIXEL graphics
+ */
+void
+tv_sixel(struct ite_softc *ip, int sy, int sx)
+{
+ uint8_t *p;
+ int width;
+ int y;
+ int cx;
+ int px;
+#if defined(ITE_16COLOR)
+ uint16_t data[4];
+#else
+ uint16_t data[3];
+#endif
+ uint8_t color;
+
+ width = MIN(ip->decsixel_ph, MAX_SIXEL_WIDTH);
+ width = MIN(width, PLANEWIDTH - sx * FONTWIDTH);
+
+ p = CHADDR(sy, sx);
+ p += ROWBYTES * ip->decsixel_y;
+ /* boundary check */
+ if (p < tv_row[0]) {
+ p = tv_end + (p - tv_row[0]);
+ }
+
+ for (y = 0; y < 6; y++) {
+ /* for each 16dot word */
+ for (cx = 0; cx < howmany(width, 16); cx++) {
+ data[0] = 0;
+ data[1] = 0;
+ data[2] = 0;
+#if defined(ITE_16COLOR)
+ data[3] = 0;
+#endif
+ for (px = 0; px < 16; px++) {
+ color = ip->decsixel_buf[cx * 16 + px] >> (y * 4);
+ /* x68k console is 8 colors */
+ data[0] = (data[0] << 1) | ((color >> 0) & 1);
+ data[1] = (data[1] << 1) | ((color >> 1) & 1);
+ data[2] = (data[2] << 1) | ((color >> 2) & 1);
+#if defined(ITE_16COLOR)
+ data[3] = (data[3] << 1) | ((color >> 3) & 1);
+#endif
+ }
+ *(uint16_t *)(p + cx * 2 ) = data[0];
+ *(uint16_t *)(p + cx * 2 + 0x20000) = data[1];
+ *(uint16_t *)(p + cx * 2 + 0x40000) = data[2];
+#if defined(ITE_16COLOR)
+ *(uint16_t *)(p + cx * 2 + 0x60000) = data[3];
+#endif
+ }
+
+ p += ROWBYTES;
+ if (p >= tv_end) {
+ p = tv_row[0] + (p - tv_end);
+ }
+ }
+}
+#endif /* ITE_SIXEL */
+
+#if defined(ITE_SYSCTL)
+static int
+sysctl_hw_ite_textpalette(SYSCTLFN_ARGS)
+{
+ struct sysctlnode node;
+ int idx;
+ int error;
+ int t;
+
+ node = *rnode;
+ idx = node.sysctl_name[strlen("tpalette")] - '0';
+ if (idx > 9)
+ idx -= 7;
+ t = (int)(IODEVbase->tpalet[idx]);
+
+ node.sysctl_data = &t;
+
+ error = sysctl_lookup(SYSCTLFN_CALL(&node));
+ if (error || newp == NULL)
+ return error;
+
+ if (t < 0 || t > 65535)
+ return EINVAL;
+
+ IODEVbase->tpalet[idx] = t;
+
+ return 0;
+}
+
+SYSCTL_SETUP(sysctl_ite_setup, "sysctl hw.ite setup")
+{
+ char name[16];
+ const struct sysctlnode *node;
+ int i;
+
+ sysctl_createv(NULL, 0, NULL, &node,
+ CTLFLAG_PERMANENT, CTLTYPE_NODE,
+ "ite", SYSCTL_DESCR("ite"),
+ NULL, 0, NULL, 0,
+ CTL_HW, CTL_CREATE, CTL_EOL);
+ if (node == NULL)
+ return;
+
+ for (i = 0; i < 16; i++) {
+ snprintf(name, sizeof(name), "tpalette%X", i);
+ sysctl_createv(NULL, 0, NULL, NULL,
+ CTLFLAG_PERMANENT | CTLFLAG_READWRITE,
+ CTLTYPE_INT,
+ name, SYSCTL_DESCR("text palette"),
+ sysctl_hw_ite_textpalette, 0, NULL, 0,
+ CTL_HW, node->sysctl_num, CTL_CREATE, CTL_EOL);
+ }
+}
+#endif /* ITE_SYSCTL */
+
+#if defined(ITE_SYSCTL)
+static int sysctl_hw_sysport_contrast(SYSCTLFN_PROTO);
+static int
+sysctl_hw_sysport_contrast(SYSCTLFN_ARGS)
+{
+ struct sysctlnode node;
+ int error;
+ int t;
+
+ node = *rnode;
+ t = (int)(IODEVbase->io_sysport.contrast);
+
+ node.sysctl_data = &t;
+
+ error = sysctl_lookup(SYSCTLFN_CALL(&node));
+ if (error || newp == NULL)
+ return error;
+
+ if (t < 0 || t > 15)
+ return EINVAL;
+
+ IODEVbase->io_sysport.contrast = t;
+
+ return 0;
+}
+
+SYSCTL_SETUP(sysctl_sysport, "sysctl sysport.contrast")
+{
+ const struct sysctlnode *node;
+
+ sysctl_createv(NULL, 0, NULL, &node,
+ CTLFLAG_PERMANENT, CTLTYPE_NODE,
+ "sysport", SYSCTL_DESCR("sysport"),
+ NULL, 0, NULL, 0,
+ CTL_HW, CTL_CREATE, CTL_EOL);
+ if (node == NULL)
+ return;
+
+ sysctl_createv(NULL, 0, NULL, NULL,
+ CTLFLAG_PERMANENT | CTLFLAG_READWRITE,
+ CTLTYPE_INT,
+ "contrast", SYSCTL_DESCR("contrast"),
+ sysctl_hw_sysport_contrast, 0, NULL, 0,
+ CTL_HW, node->sysctl_num, CTL_CREATE, CTL_EOL);
+}
+#endif
diff --git a/dev/itevar.h b/dev/itevar.h
index b8dbf31..a74c881 100644
--- sys/arch/x68k/dev/itevar.h
+++ sys/arch/x68k/dev/itevar.h
@@ -50,6 +50,7 @@ struct itesw {
void (*ite_putc)(struct ite_softc *, int, int, int, int);
void (*ite_cursor)(struct ite_softc *, int);
void (*ite_scroll)(struct ite_softc *, int, int, int, int);
+ void (*ite_sixel)(struct ite_softc *, int, int);
};
enum ite_arraymaxs {
@@ -94,6 +95,28 @@ struct ite_softc {
short save_curx, save_cury, save_attribute, save_char;
char sc_G0, sc_G1, sc_G2, sc_G3;
char *sc_GL, *sc_GR;
+ enum {
+ DCS_START = 0,
+ DCS_SIXEL = 'q', // DECRQSS also use 'q'...
+ DCS_DISCARD = -1,
+ } dcs_cmd;
+ enum {
+ DECSIXEL_INIT = 0,
+ DECSIXEL_RASTER_PAD,
+ DECSIXEL_RASTER_PH,
+ DECSIXEL_RASTER_PV,
+ DECSIXEL_REPEAT = '!',
+ DECSIXEL_RASTER = '\"',
+ DECSIXEL_COLOR = '#',
+ } decsixel_state;
+ int decsixel_ph;
+ int decsixel_x;
+ int decsixel_y;
+ int decsixel_repcount;
+ int decsixel_color;
+ int decsixel_ormode;
+#define MAX_SIXEL_WIDTH (768)
+ uint32_t decsixel_buf[MAX_SIXEL_WIDTH];
};
enum emul_level {