2 * Copyright (c) 1999, 2000 Greg Haerr <greg@censoft.com>
4 * 4bpp Packed Linear Video Driver for Microwindows
5 * This driver is written for the Vr41xx Palm PC machines
6 * Hopefully, we can get the 4bpp mode running 320x240x16
8 * If INVERT4BPP is defined, then the values are inverted before drawing.
9 * This is used for the VTech Helio
11 * In this driver, psd->linelen is line byte length, not line pixel length
20 #define INVERT(c) ((c) = (~c & 0x0f))
25 static unsigned char notmask[2] = { 0x0f, 0xf0};
27 /* Calc linelen and mmap size, return 0 on fail*/
32 psd->size = psd->yres * psd->linelen;
33 /* linelen in bytes for bpp 1, 2, 4, 8 so no change*/
37 /* Set pixel at x, y, to pixelval c*/
39 linear4_drawpixel(PSD psd, MWCOORD x, MWCOORD y, MWPIXELVAL c)
41 ADDR8 addr = psd->addr;
44 assert (x >= 0 && x < psd->xres);
45 assert (y >= 0 && y < psd->yres);
46 assert (c < psd->ncolors);
50 addr += (x>>1) + y * psd->linelen;
51 if(gr_mode == MWMODE_XOR)
52 *addr ^= c << ((1-(x&1))<<2);
54 *addr = (*addr & notmask[x&1]) | (c << ((1-(x&1))<<2));
58 /* Read pixel at x, y*/
60 linear4_readpixel(PSD psd, MWCOORD x, MWCOORD y)
62 ADDR8 addr = psd->addr;
66 assert (x >= 0 && x < psd->xres);
67 assert (y >= 0 && y < psd->yres);
69 c = (addr[(x>>1) + y * psd->linelen] >> ((1-(x&1))<<2) ) & 0x0f;
75 /* Draw horizontal line from x1,y to x2,y including final point*/
77 linear4_drawhorzline(PSD psd, MWCOORD x1, MWCOORD x2, MWCOORD y, MWPIXELVAL c)
79 ADDR8 addr = psd->addr;
82 assert (x1 >= 0 && x1 < psd->xres);
83 assert (x2 >= 0 && x2 < psd->xres);
85 assert (y >= 0 && y < psd->yres);
86 assert (c < psd->ncolors);
90 addr += (x1>>1) + y * psd->linelen;
91 if(gr_mode == MWMODE_XOR) {
93 *addr ^= c << ((1-(x1&1))<<2);
99 *addr = (*addr & notmask[x1&1]) | (c << ((1-(x1&1))<<2));
107 /* Draw a vertical line from x,y1 to x,y2 including final point*/
109 linear4_drawvertline(PSD psd, MWCOORD x, MWCOORD y1, MWCOORD y2, MWPIXELVAL c)
111 ADDR8 addr = psd->addr;
112 int linelen = psd->linelen;
115 assert (x >= 0 && x < psd->xres);
116 assert (y1 >= 0 && y1 < psd->yres);
117 assert (y2 >= 0 && y2 < psd->yres);
119 assert (c < psd->ncolors);
123 addr += (x>>1) + y1 * linelen;
124 if(gr_mode == MWMODE_XOR)
126 *addr ^= c << ((1-(x&1))<<2);
131 *addr = (*addr & notmask[x&1]) | (c << ((1-(x&1))<<2));
137 /* srccopy bitblt, opcode is currently ignored*/
139 linear4_blit(PSD dstpsd, MWCOORD dstx, MWCOORD dsty, MWCOORD w, MWCOORD h,
140 PSD srcpsd, MWCOORD srcx, MWCOORD srcy, long op)
145 int dlinelen = dstpsd->linelen;
146 int slinelen = srcpsd->linelen;
148 assert (dstpsd->addr != 0);
149 assert (dstx >= 0 && dstx < dstpsd->xres);
150 assert (dsty >= 0 && dsty < dstpsd->yres);
153 assert (srcpsd->addr != 0);
154 assert (srcx >= 0 && srcx < srcpsd->xres);
155 assert (srcy >= 0 && srcy < srcpsd->yres);
156 assert (dstx+w <= dstpsd->xres);
157 assert (dsty+h <= dstpsd->yres);
158 assert (srcx+w <= srcpsd->xres);
159 assert (srcy+h <= srcpsd->yres);
162 dst = dstpsd->addr + (dstx>>1) + dsty * dlinelen;
163 src = srcpsd->addr + (srcx>>1) + srcy * slinelen;
171 unsigned char c = *s;
173 *d = (*d & notmask[dx&1]) |
174 ((c >> ((1-(sx&1))<<2) & 0x0f) << ((1-(dx&1))<<2));
176 *d = (*d & notmask[dx&1]) |
177 ((*s >> ((1-(sx&1))<<2) & 0x0f) << ((1-(dx&1))<<2));
190 SUBDRIVER fblinear4 = {
194 linear4_drawhorzline,
195 linear4_drawvertline,