2 * Copyright (c) 1999 Greg Haerr <greg@censoft.com>
4 * 2bpp Packed Linear Video Driver for Microwindows
5 * This driver is written for the Vr41xx Palm PC machines
6 * The screen is 320x240x4
8 * In this driver, psd->linelen is line byte length, not line pixel length
16 static unsigned char notmask[4] = { 0x3f, 0xcf, 0xf3, 0xfc};
18 /* Calc linelen and mmap size, return 0 on fail*/
23 psd->size = psd->yres * psd->linelen;
24 /* linelen in bytes for bpp 1, 2, 4, 8 so no change*/
28 /* Set pixel at x, y, to pixelval c*/
30 linear2_drawpixel(PSD psd, MWCOORD x, MWCOORD y, MWPIXELVAL c)
32 ADDR8 addr = psd->addr;
35 assert (x >= 0 && x < psd->xres);
36 assert (y >= 0 && y < psd->yres);
37 assert (c < psd->ncolors);
40 addr += (x>>2) + y * psd->linelen;
41 if(gr_mode == MWMODE_XOR)
42 *addr ^= c << ((3-(x&3))<<1);
44 *addr = (*addr & notmask[x&3]) | (c << ((3-(x&3))<<1));
48 /* Read pixel at x, y*/
50 linear2_readpixel(PSD psd, MWCOORD x, MWCOORD y)
52 ADDR8 addr = psd->addr;
55 assert (x >= 0 && x < psd->xres);
56 assert (y >= 0 && y < psd->yres);
58 return (addr[(x>>2) + y * psd->linelen] >> ((3-(x&3))<<1) ) & 0x03;
61 /* Draw horizontal line from x1,y to x2,y including final point*/
63 linear2_drawhorzline(PSD psd, MWCOORD x1, MWCOORD x2, MWCOORD y, MWPIXELVAL c)
65 ADDR8 addr = psd->addr;
68 assert (x1 >= 0 && x1 < psd->xres);
69 assert (x2 >= 0 && x2 < psd->xres);
71 assert (y >= 0 && y < psd->yres);
72 assert (c < psd->ncolors);
75 addr += (x1>>2) + y * psd->linelen;
76 if(gr_mode == MWMODE_XOR) {
78 *addr ^= c << ((3-(x1&3))<<1);
84 *addr = (*addr & notmask[x1&3]) | (c << ((3-(x1&3))<<1));
92 /* Draw a vertical line from x,y1 to x,y2 including final point*/
94 linear2_drawvertline(PSD psd, MWCOORD x, MWCOORD y1, MWCOORD y2, MWPIXELVAL c)
96 ADDR8 addr = psd->addr;
97 int linelen = psd->linelen;
100 assert (x >= 0 && x < psd->xres);
101 assert (y1 >= 0 && y1 < psd->yres);
102 assert (y2 >= 0 && y2 < psd->yres);
104 assert (c < psd->ncolors);
107 addr += (x>>2) + y1 * linelen;
108 if(gr_mode == MWMODE_XOR)
110 *addr ^= c << ((3-(x&3))<<1);
115 *addr = (*addr & notmask[x&3]) | (c << ((3-(x&3))<<1));
121 /* srccopy bitblt, opcode is currently ignored*/
123 linear2_blit(PSD dstpsd, MWCOORD dstx, MWCOORD dsty, MWCOORD w, MWCOORD h,
124 PSD srcpsd, MWCOORD srcx, MWCOORD srcy, long op)
129 int dlinelen = dstpsd->linelen;
130 int slinelen = srcpsd->linelen;
132 assert (dstpsd->addr != 0);
133 assert (dstx >= 0 && dstx < dstpsd->xres);
134 assert (dsty >= 0 && dsty < dstpsd->yres);
137 assert (srcpsd->addr != 0);
138 assert (srcx >= 0 && srcx < srcpsd->xres);
139 assert (srcy >= 0 && srcy < srcpsd->yres);
140 assert (dstx+w <= dstpsd->xres);
141 assert (dsty+h <= dstpsd->yres);
142 assert (srcx+w <= srcpsd->xres);
143 assert (srcy+h <= srcpsd->yres);
146 dst = dstpsd->addr + (dstx>>2) + dsty * dlinelen;
147 src = srcpsd->addr + (srcx>>2) + srcy * slinelen;
154 *d = (*d & notmask[dx&3]) |
155 ((*s >> ((3-(sx&3))<<1) & 0x03) << ((3-(dx&3))<<1));
167 SUBDRIVER fblinear2 = {
171 linear2_drawhorzline,
172 linear2_drawvertline,