1 /* coded by Ketmar // Invisible Vector <ketmar@ketmar.no-ip.org>
2 * Understanding is not required. Only obedience.
4 * This program is free software: you can redistribute it and/or modify
5 * it under the terms of the GNU General Public License as published by
6 * the Free Software Foundation, either version 3 of the License, or
7 * (at your option) any later version.
9 * This program is distributed in the hope that it will be useful,
10 * but WITHOUT ANY WARRANTY; without even the implied warranty of
11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 * GNU General Public License for more details.
14 * You should have received a copy of the GNU General Public License
15 * along with this program. If not, see <http://www.gnu.org/licenses/>.
19 import arsd
.simpledisplay
;
23 // ////////////////////////////////////////////////////////////////////////// //
24 // 0:b; 1:g; 2:r; 3: nothing
25 __gshared
int vbufW
= 256, vbufH
= 192;
26 __gshared
uint[] vbuf
;
27 __gshared
bool blit2x
= true;
28 enum BlitType
{ Normal
, BlackWhite
, Green
}
29 __gshared
int blitType
= BlitType
.Normal
;
30 __gshared Image vbimg
;
31 __gshared SimpleWindow vbwin
;
34 // ////////////////////////////////////////////////////////////////////////// //
35 void x11gfxDeinit () {
37 if (vbimg
!is null) delete vbimg
;
38 if (vbwin
!is null) { if (!vbwin
.closed
) vbwin
.close(); delete vbwin
; }
39 if (vbuf
!is null) delete vbuf
;
47 SimpleWindow
x11gfxInit (string title
) {
48 if (vbufW
< 1 || vbufH
< 1 || vbufW
> 4096 || vbufH
> 4096) assert(0, "invalid dimensions");
50 vbwin
= new SimpleWindow(vbufW
*(blit2x ?
2 : 1), vbufH
*(blit2x ?
2 : 1), title
, OpenGlOptions
.no
, Resizablity
.fixedSize
);
51 vbimg
= new Image(vbufW
*(blit2x ?
2 : 1), vbufH
*(blit2x ?
2 : 1));
57 if (vbwin
is null || vbwin
.closed
) return;
58 auto painter
= vbwin
.draw();
59 painter
.drawImage(Point(0, 0), vbimg
);
63 // ////////////////////////////////////////////////////////////////////////// //
64 final class X11Image
{
69 assert(w
> 0 && w
<= 4096);
70 assert(h
> 0 && h
<= 4096);
77 VColor
getPixel (int x
, int y
) const {
78 return (x
>= 0 && y
>= 0 && x
< width
&& y
< height ? data
[y
*width
+x
] : Transparent
);
81 void setPixel (int x
, int y
, VColor c
) {
82 if (x
>= 0 && y
>= 0 && x
< width
&& y
< height
) data
[y
*width
+x
] = c
;
85 void blitFast (int x
, int y
) const {
86 if (width
< 1 || height
< 1) return;
87 if (x
<= -width || y
<= -height
) return;
88 if (x
>= vbufW || y
>= vbufH
) return;
89 auto src
= cast(const(VColor
)*)data
.ptr
;
90 if (x
>= 0 && y
>= 0 && x
+width
< vbufW
&& y
+height
< vbufH
) {
91 auto d
= cast(uint*)vbuf
.ptr
;
93 foreach (int dy
; 0..height
) {
94 d
[0..width
] = src
[0..width
];
99 foreach (int dy
; 0..height
) {
100 foreach (int dx
; 0..width
) {
101 .setPixel(x
+dx
, y
+dy
, *src
++);
107 void blit (int x
, int y
) const {
108 if (width
< 1 || height
< 1) return;
109 if (x
<= -width || y
<= -height
) return;
110 if (x
>= vbufW || y
>= vbufH
) return;
111 auto src
= cast(const(VColor
)*)data
.ptr
;
112 foreach (int dy
; 0..height
) {
113 foreach (int dx
; 0..width
) {
114 putPixel(x
+dx
, y
+dy
, *src
++);
121 private void initVBuf () {
122 vbuf
.length
= vbufW
*vbufH
;
128 void blit2xImpl(string op
, bool scanlines
=true) (Image img
) {
129 static if (UsingSimpledisplayX11
) {
130 auto s
= cast(const(ubyte)*)vbuf
.ptr
;
131 immutable iw
= img
.width
;
132 auto dd = cast(uint*)img
.getDataPointer
;
133 foreach (immutable int dy
; 0..vbufH
) {
134 if (dy
*2+1 >= img
.height
) return;
135 auto d
= dd+iw
*(dy
*2);
136 foreach (immutable int dx
; 0..vbufW
) {
138 static if (op
.length
) mixin(op
);
139 static if (scanlines
) {
140 immutable uint c1
= ((((c0
&0x00ff00ff)*6)>>3)&0x00ff00ff)|
(((c0
&0x0000ff00)*6)>>3)&0x0000ff00;
145 d
[iw
+0] = d
[iw
+1] = c1
;
153 immutable bpp
= img
.bytesPerPixel();
154 immutable rofs
= img
.redByteOffset
;
155 immutable gofs
= img
.greenByteOffset
;
156 immutable bofs
= img
.blueByteOffset
;
157 immutable nlo
= img
.adjustmentForNextLine
;
158 auto s
= cast(const(ubyte)*)vbuf
.ptr
;
159 immutable iw
= img
.width
;
160 auto dd = cast(ubyte*)img
.getDataPointer
;
161 foreach (immutable int dy
; 0..vbufH
) {
162 if (dy
*2+1 >= img
.height
) return;
163 auto d
= dd+img
.offsetForPixel(0, dy
*2);
164 foreach (immutable int dx
; 0..vbufW
) {
166 static if (op
.length
) mixin(op
);
167 static if (scanlines
) {
168 immutable uint c1
= ((((c0
&0x00ff00ff)*6)>>3)&0x00ff00ff)|
(((c0
&0x0000ff00)*6)>>3)&0x0000ff00;
172 d
[bofs
] = d
[bofs
+bpp
] = c0
&0xff;
173 d
[gofs
] = d
[gofs
+bpp
] = (c0
>>8)&0xff;
174 d
[rofs
] = d
[rofs
+bpp
] = (c0
>>16)&0xff;
175 d
[bofs
+nlo
] = d
[bofs
+nlo
+bpp
] = c0
&0xff;
176 d
[gofs
+nlo
] = d
[gofs
+nlo
+bpp
] = (c0
>>8)&0xff;
177 d
[rofs
+nlo
] = d
[rofs
+nlo
+bpp
] = (c0
>>16)&0xff;
186 alias blit2xTV
= blit2xImpl
!"immutable uint c0 = (cast(immutable(uint)*)s)[0];";
187 alias blit2xTVBW
= blit2xImpl
!"immutable ubyte i = cast(ubyte)((s[0]*28+s[1]*151+s[2]*77)/256); immutable uint c0 = (i<<16)|(i<<8)|i;";
188 alias blit2xTVGreen
= blit2xImpl
!"immutable ubyte i = cast(ubyte)((s[0]*28+s[1]*151+s[2]*77)/256); immutable uint c0 = i<<8;";
192 void realizeVBuf (/*Image img*/) {
193 if (vbimg
is null) return;
197 auto dp = cast(uint*)img.getDataPointer;
198 import core.stdc.string : memcpy;
199 memcpy(dp, sp, vbufW*vbufH*4);
202 if (img
.width
< vbufW
*2 || img
.height
< vbufH
*2) return;
204 case BlitType
.BlackWhite
: blit2xTVBW(img
); break;
205 case BlitType
.Green
: blit2xTVGreen(img
); break;
206 default: blit2xTV(img
); break;
209 if (img
.width
< vbufW || img
.height
< vbufH
) return;
210 static if (UsingSimpledisplayX11
) {
211 auto dp
= cast(uint*)img
.getDataPointer
;
212 dp
[0..vbufW
*vbufH
] = vbuf
.ptr
[0..vbufW
*vbufH
];
215 auto sp
= cast(ubyte*)vbuf
.ptr
;
216 auto dp
= cast(ubyte*)img
.getDataPointer
;
217 immutable bpp
= img
.bytesPerPixel();
218 immutable rofs
= img
.redByteOffset
;
219 immutable gofs
= img
.greenByteOffset
;
220 immutable bofs
= img
.blueByteOffset
;
221 foreach (immutable y
; 0..vbufH
) {
222 auto d
= dp
+img
.offsetForTopLeftPixel
;
223 foreach (immutable x
; 0..vbufW
) {
236 // ////////////////////////////////////////////////////////////////////////// //
237 ubyte clampToByte(T
) (T n
) @safe pure nothrow @nogc
238 if (__traits(isIntegral
, T
) && (T
.sizeof
== 2 || T
.sizeof
== 4))
240 static if (__VERSION__
> 2067) pragma(inline
, true);
241 n
&= -cast(int)(n
>= 0);
242 return cast(ubyte)(n|
((255-cast(int)n
)>>31));
245 ubyte clampToByte(T
) (T n
) @safe pure nothrow @nogc
246 if (__traits(isIntegral
, T
) && T
.sizeof
== 1)
248 static if (__VERSION__
> 2067) pragma(inline
, true);
253 // ////////////////////////////////////////////////////////////////////////// //
256 /// vlRGBA struct to ease color components extraction/replacing
257 align(1) struct vlRGBA
{
261 static assert(vlRGBA
.sizeof
== VColor
.sizeof
);
265 vlAMask
= 0xff000000u
,
266 vlRMask
= 0x00ff0000u
,
267 vlGMask
= 0x0000ff00u
,
268 vlBMask
= 0x000000ffu
279 enum VColor Transparent
= vlAMask
; /// completely transparent pixel color
282 bool isTransparent(T
: VColor
) (T col
) @safe pure nothrow @nogc {
283 static if (__VERSION__
> 2067) pragma(inline
, true);
284 return ((col
&vlAMask
) == vlAMask
);
287 bool isOpaque(T
: VColor
) (T col
) @safe pure nothrow @nogc {
288 static if (__VERSION__
> 2067) pragma(inline
, true);
289 return ((col
&vlAMask
) == 0);
293 VColor
rgbcol(TR
, TG
, TB
, TA
=ubyte) (TR r
, TG g
, TB b
, TA a
=0) @safe pure nothrow @nogc
294 if (__traits(isIntegral
, TR
) && __traits(isIntegral
, TG
) && __traits(isIntegral
, TB
) && __traits(isIntegral
, TA
)) {
295 static if (__VERSION__
> 2067) pragma(inline
, true);
297 (clampToByte(a
)<<vlAShift
)|
298 (clampToByte(r
)<<vlRShift
)|
299 (clampToByte(g
)<<vlGShift
)|
300 (clampToByte(b
)<<vlBShift
);
303 alias rgbacol
= rgbcol
;
306 // generate some templates
307 private enum genRGBGetSet(string cname
) =
308 "ubyte rgb"~cname
~"() (VColor clr) @safe pure nothrow @nogc {\n"~
309 " static if (__VERSION__ > 2067) pragma(inline, true);\n"~
310 " return ((clr>>vl"~cname
[0]~"Shift)&0xff);\n"~
312 "VColor rgbSet"~cname
~"(T) (VColor clr, T v) @safe pure nothrow @nogc if (__traits(isIntegral, T)) {\n"~
313 " static if (__VERSION__ > 2067) pragma(inline, true);\n"~
314 " return (clr&~vl"~cname
[0]~"Mask)|(clampToByte(v)<<vl"~cname
[0]~"Shift);\n"~
317 mixin(genRGBGetSet
!"Alpha");
318 mixin(genRGBGetSet
!"Red");
319 mixin(genRGBGetSet
!"Green");
320 mixin(genRGBGetSet
!"Blue");
323 void putPixel(TX
, TY
) (TX x
, TY y
, VColor col
) @trusted
324 if (__traits(isIntegral
, TX
) && __traits(isIntegral
, TY
))
326 static if (__VERSION__
> 2067) pragma(inline
, true);
327 immutable long xx
= cast(long)x
;
328 immutable long yy
= cast(long)y
;
329 if ((col
&vlAMask
) != vlAMask
&& xx
>= 0 && yy
>= 0 && xx
< vbufW
&& yy
< vbufH
) {
330 uint* da = vbuf
.ptr
+yy
*vbufW
+xx
;
332 immutable uint a
= 256-(col
>>24); // to not loose bits
333 immutable uint dc
= (*da)&0xffffff;
334 immutable uint srb
= (col
&0xff00ff);
335 immutable uint sg
= (col
&0x00ff00);
336 immutable uint drb
= (dc
&0xff00ff);
337 immutable uint dg
= (dc
&0x00ff00);
338 immutable uint orb
= (drb
+(((srb
-drb
)*a
+0x800080)>>8))&0xff00ff;
339 immutable uint og
= (dg
+(((sg
-dg
)*a
+0x008000)>>8))&0x00ff00;
347 void setPixel(TX
, TY
) (TX x
, TY y
, VColor col
) @trusted
348 if (__traits(isIntegral
, TX
) && __traits(isIntegral
, TY
))
350 static if (__VERSION__
> 2067) pragma(inline
, true);
351 immutable long xx
= cast(long)x
;
352 immutable long yy
= cast(long)y
;
353 if (xx
>= 0 && yy
>= 0 && xx
< vbufW
&& yy
< vbufH
) {
354 uint* da = vbuf
.ptr
+yy
*vbufW
+xx
;
360 void drawLine(bool lastPoint
=true) (int x0
, int y0
, int x1
, int y1
, immutable VColor col
) {
361 enum swap(string a
, string b
) = "{int tmp_="~a
~";"~a
~"="~b
~";"~b
~"=tmp_;}";
363 if ((col
&vlAMask
) == vlAMask
) return;
365 if (x0
== x1
&& y0
== y1
) {
366 static if (lastPoint
) putPixel(x0
, y0
, col
);
371 int wx0
= 0, wy0
= 0, wx1
= vbufW
-1, wy1
= vbufH
-1;
373 int stx
, sty
; // "steps" for x and y axes
374 int dsx
, dsy
; // "lengthes" for x and y axes
375 int dx2
, dy2
; // "double lengthes" for x and y axes
376 int xd
, yd
; // current coord
377 int e
; // "error" (as in bresenham algo)
383 // from left to right
384 if (x0
> wx1 || x1
< wx0
) return; // out of screen
385 stx
= 1; // going right
387 // from right to left
388 if (x1
> wx1 || x0
< wx0
) return; // out of screen
389 stx
= -1; // going left
394 mixin(swap
!("wx0", "wx1"));
398 // from top to bottom
399 if (y0
> wy1 || y1
< wy0
) return; // out of screen
400 sty
= 1; // going down
402 // from bottom to top
403 if (y1
> wy1 || y0
< wy0
) return; // out of screen
404 sty
= -1; // going up
409 mixin(swap
!("wy0", "wy1"));
416 mixin(swap
!("x0", "y0"));
417 mixin(swap
!("x1", "y1"));
418 mixin(swap
!("dsx", "dsy"));
419 mixin(swap
!("wx0", "wy0"));
420 mixin(swap
!("wx1", "wy1"));
421 mixin(swap
!("stx", "sty"));
435 int temp
= dx2
*(wy0
-y0
)-dsx
;
438 if (xd
> wx1
) return; // x is moved out of clipping rect, nothing to do
442 if (rem
> 0) { ++xd
; e
+= dy2
; }
446 if (!xfixed
&& x0
< wx0
) {
448 int temp
= dy2
*(wx0
-x0
);
451 if (yd
> wy1 || yd
== wy1
&& rem
>= dsx
) return;
454 if (rem
>= dsx
) { ++yd
; e
-= dx2
; }
458 int temp
= dx2
*(wy1
-y0
)+dsx
;
461 if (rem
== 0) --term
;
463 if (term
> wx1
) term
= wx1
; // clip at right
464 static if (lastPoint
) {
468 if (term
== xd
) return; // this is the only point, get out of here
470 if (sty
== -1) yd
= -yd
;
471 if (stx
== -1) { xd
= -xd
; term
= -term
; }
473 // draw it; `putPixel()` can omit checks
475 // inlined `putPixel(*d0, *d1, col)`
476 // this can be made even faster by precalculating `da` and making
477 // separate code branches for mixing and non-mixing drawing, but...
479 uint* da = vbuf
.ptr
+(*d1
)*vbufW
+(*d0
);
481 immutable uint a
= 256-(col
>>24); // to not loose bits
482 immutable uint dc
= (*da)&0xffffff;
483 immutable uint srb
= (col
&0xff00ff);
484 immutable uint sg
= (col
&0x00ff00);
485 immutable uint drb
= (dc
&0xff00ff);
486 immutable uint dg
= (dc
&0x00ff00);
487 immutable uint orb
= (drb
+(((srb
-drb
)*a
+0x800080)>>8))&0xff00ff;
488 immutable uint og
= (dg
+(((sg
-dg
)*a
+0x008000)>>8))&0x00ff00;
493 // done drawing, move coords
505 // //////////////////////////////////////////////////////////////////////// //
507 * Draw character onto virtual screen in KOI8 encoding.
515 * col = foreground color
516 * bkcol = background color
521 void drawCharWdt (int x
, int y
, int wdt
, int shift
, char ch
, VColor col
, VColor bkcol
=Transparent
) @trusted {
523 if (wdt
< 1 || shift
>= 8) return;
524 if (col
== Transparent
&& bkcol
== Transparent
) return;
525 if (wdt
> 8) wdt
= 8;
526 if (shift
< 0) shift
= 0;
527 foreach (immutable int dy
; 0..8) {
528 ubyte b
= cast(ubyte)(vlFont6
[pos
++]<<shift
);
529 foreach (immutable int dx
; 0..wdt
) {
530 VColor c
= (b
&0x80 ? col
: bkcol
);
531 if (!isTransparent(c
)) putPixel(x
+dx
, y
+dy
, c
);
543 OutLU
= 0x10, // left-up
544 OutRU
= 0x20, // right-up
545 OutLD
= 0x40, // left-down
546 OutRD
= 0x80, // right-down
551 * Draw outlined character onto virtual screen in KOI8 encoding.
559 * col = foreground color
560 * outcol = outline color
561 * ot = outline type, OutXXX, ored
566 void drawCharWdtOut (int x
, int y
, int wdt
, int shift
, char ch
, VColor col
, VColor outcol
=Transparent
, ubyte ot
=0) @trusted {
567 if (col
== Transparent
&& outcol
== Transparent
) return;
568 if (ot
== 0 || outcol
== Transparent
) {
569 // no outline? simple draw
570 drawCharWdt(x
, y
, wdt
, shift
, ch
, col
, Transparent
);
574 if (wdt
< 1 || shift
>= 8) return;
575 if (wdt
> 8) wdt
= 8;
576 if (shift
< 0) shift
= 0;
577 ubyte[8+2][8+2] bmp
= 0; // char bitmap; 0: empty; 1: char; 2: outline
578 foreach (immutable dy
; 1..9) {
579 ubyte b
= cast(ubyte)(vlFont6
[pos
++]<<shift
);
580 foreach (immutable dx
; 1..wdt
+1) {
585 if ((ot
&OutUp
) && bmp
[dy
-1][dx
] == 0) bmp
[dy
-1][dx
] = 2;
586 if ((ot
&OutDown
) && bmp
[dy
+1][dx
] == 0) bmp
[dy
+1][dx
] = 2;
587 if ((ot
&OutLeft
) && bmp
[dy
][dx
-1] == 0) bmp
[dy
][dx
-1] = 2;
588 if ((ot
&OutRight
) && bmp
[dy
][dx
+1] == 0) bmp
[dy
][dx
+1] = 2;
589 if ((ot
&OutLU
) && bmp
[dy
-1][dx
-1] == 0) bmp
[dy
-1][dx
-1] = 2;
590 if ((ot
&OutRU
) && bmp
[dy
-1][dx
+1] == 0) bmp
[dy
-1][dx
+1] = 2;
591 if ((ot
&OutLD
) && bmp
[dy
+1][dx
-1] == 0) bmp
[dy
+1][dx
-1] = 2;
592 if ((ot
&OutRD
) && bmp
[dy
+1][dx
+1] == 0) bmp
[dy
+1][dx
+1] = 2;
600 foreach (immutable int dy
; 0..10) {
601 foreach (immutable int dx
; 0..10) {
602 if (auto t
= bmp
[dy
][dx
]) putPixel(x
+dx
, y
+dy
, (t
== 1 ? col
: outcol
));
608 * Draw 6x8 character onto virtual screen in KOI8 encoding.
614 * col = foreground color
615 * bkcol = background color
620 void drawChar (int x
, int y
, char ch
, VColor col
, VColor bkcol
=Transparent
) @trusted {
621 drawCharWdt(x
, y
, 6, 0, ch
, col
, bkcol
);
624 void drawCharOut (int x
, int y
, char ch
, VColor col
, VColor outcol
=Transparent
, ubyte ot
=OutAll
) @trusted {
625 drawCharWdtOut(x
, y
, 6, 0, ch
, col
, outcol
, ot
);
628 void drawStr (int x
, int y
, string
str, VColor col
, VColor bkcol
=Transparent
) @trusted {
629 foreach (immutable char ch
; str) {
630 drawChar(x
, y
, ch
, col
, bkcol
);
635 void drawStrOut (int x
, int y
, string
str, VColor col
, VColor outcol
=Transparent
, ubyte ot
=OutAll
) @trusted {
636 foreach (immutable char ch
; str) {
637 drawCharOut(x
, y
, ch
, col
, outcol
, ot
);
642 static int charWidthProp (char ch
) @trusted pure { return (vlFontPropWidth
[ch
]&0x0f); }
644 int strWidthProp (string
str) @trusted pure {
646 foreach (immutable char ch
; str) wdt
+= (vlFontPropWidth
[ch
]&0x0f)+1;
647 if (wdt
> 0) --wdt
; // don't count last empty pixel
651 int drawCharProp (int x
, int y
, char ch
, VColor col
, VColor bkcol
=Transparent
) @trusted {
652 immutable int wdt
= (vlFontPropWidth
[ch
]&0x0f);
653 drawCharWdt(x
, y
, wdt
, vlFontPropWidth
[ch
]>>4, ch
, col
, bkcol
);
657 int drawCharPropOut (int x
, int y
, char ch
, VColor col
, VColor outcol
=Transparent
, ubyte ot
=OutAll
) @trusted {
658 immutable int wdt
= (vlFontPropWidth
[ch
]&0x0f);
659 drawCharWdtOut(x
, y
, wdt
, vlFontPropWidth
[ch
]>>4, ch
, col
, outcol
, ot
);
663 int drawStrProp (int x
, int y
, string
str, VColor col
, VColor bkcol
=Transparent
) @trusted {
666 foreach (immutable char ch
; str) {
668 if (!isTransparent(bkcol
)) foreach (int dy
; 0..8) putPixel(x
, y
+dy
, bkcol
);
672 x
+= drawCharProp(x
, y
, ch
, col
, bkcol
);
677 int drawStrPropOut (int x
, int y
, string
str, VColor col
, VColor outcol
=Transparent
, ubyte ot
=OutAll
) @trusted {
679 foreach (immutable char ch
; str) {
680 x
+= drawCharPropOut(x
, y
, ch
, col
, outcol
, ot
)+1;
682 if (x
> sx
) --x
; // don't count last empty pixel
686 // ////////////////////////////////////////////////////////////////////////// //
687 void clear (VColor col
) @trusted {
688 vbuf
.ptr
[0..vbufW
*vbufH
] = col
;
692 // ////////////////////////////////////////////////////////////////////////// //
693 public immutable ubyte[256*8] vlFont6
= [
3002 // bits 4..7: lshift
3003 public immutable ubyte[256] vlFontPropWidth
= () {
3005 foreach (immutable cnum
; 0..256) {
3006 import core
.bitop
: bsf, bsr;
3008 (cnum
>= 32 && cnum
<= 127) ||
3009 (cnum
>= 143 && cnum
<= 144) ||
3010 (cnum
>= 166 && cnum
<= 167) ||
3011 (cnum
>= 192 && cnum
<= 255);
3015 foreach (immutable dy
; 0..8) {
3016 immutable b
= vlFont6
[cnum
*8+dy
];
3018 immutable mn
= 7-bsr(b
);
3019 if (mn
< shift
) shift
= mn
;
3024 foreach (immutable dy
; 0..8) {
3025 immutable b
= (vlFont6
[cnum
*8+dy
]<<shift
);
3026 immutable cwdt
= (b ?
8-bsf(b
) : 0);
3027 if (cwdt
> wdt
) wdt
= cast(ubyte)cwdt
;
3030 case 0: wdt
= 8; break; // 8px space
3031 case 32: wdt
= 5; break; // 5px space
3032 case 17: .. case 27: wdt
= 8; break; // single frames
3033 case 48: .. case 57: wdt
= 5; break; // digits are monospaced
3034 case 127: .. case 142: wdt
= 8; break; // filled frames
3035 case 145: .. case 151: wdt
= 8; break; // filled frames
3036 case 155: .. case 159: wdt
= 8; break; // filled frames
3039 res
[cnum
] = (wdt
&0x0f)|
((shift
<<4)&0xf0);