2 * Copyright (c) 1999, 2000 Greg Haerr <greg@censoft.com>
4 * 4bpp Packed Linear Video Driver (reversed nibble order)
7 * If INVERT4BPP is defined, then the values are inverted before drawing.
9 * In this driver, psd->linelen is line byte length, not line pixel length
18 #define INVERT(c) ((c) = (~c & 0x0f))
23 static unsigned char notmask[2] = { 0xf0, 0x0f};
25 /* Calc linelen and mmap size, return 0 on fail*/
30 psd->size = psd->yres * psd->linelen;
31 /* linelen in bytes for bpp 1, 2, 4, 8 so no change*/
35 /* Set pixel at x, y, to pixelval c*/
37 linear4_drawpixel(PSD psd, MWCOORD x, MWCOORD y, MWPIXELVAL c)
39 ADDR8 addr = psd->addr;
42 assert (x >= 0 && x < psd->xres);
43 assert (y >= 0 && y < psd->yres);
44 assert (c < psd->ncolors);
48 addr += (x>>1) + y * psd->linelen;
49 if(gr_mode == MWMODE_XOR)
50 *addr ^= c << ((x&1)<<2);
52 *addr = (*addr & notmask[x&1]) | (c << ((x&1)<<2));
56 /* Read pixel at x, y*/
58 linear4_readpixel(PSD psd, MWCOORD x, MWCOORD y)
60 ADDR8 addr = psd->addr;
64 assert (x >= 0 && x < psd->xres);
65 assert (y >= 0 && y < psd->yres);
67 c = (addr[(x>>1) + y * psd->linelen] >> ((x&1)<<2) ) & 0x0f;
73 /* Draw horizontal line from x1,y to x2,y including final point*/
75 linear4_drawhorzline(PSD psd, MWCOORD x1, MWCOORD x2, MWCOORD y, MWPIXELVAL c)
77 ADDR8 addr = psd->addr;
80 assert (x1 >= 0 && x1 < psd->xres);
81 assert (x2 >= 0 && x2 < psd->xres);
83 assert (y >= 0 && y < psd->yres);
84 assert (c < psd->ncolors);
88 addr += (x1>>1) + y * psd->linelen;
89 if(gr_mode == MWMODE_XOR) {
91 *addr ^= c << ((x1&1)<<2);
97 *addr = (*addr & notmask[x1&1]) | (c << ((x1&1)<<2));
105 /* Draw a vertical line from x,y1 to x,y2 including final point*/
107 linear4_drawvertline(PSD psd, MWCOORD x, MWCOORD y1, MWCOORD y2, MWPIXELVAL c)
109 ADDR8 addr = psd->addr;
110 int linelen = psd->linelen;
113 assert (x >= 0 && x < psd->xres);
114 assert (y1 >= 0 && y1 < psd->yres);
115 assert (y2 >= 0 && y2 < psd->yres);
117 assert (c < psd->ncolors);
121 addr += (x>>1) + y1 * linelen;
122 if(gr_mode == MWMODE_XOR)
124 *addr ^= c << ((x&1)<<2);
129 *addr = (*addr & notmask[x&1]) | (c << ((x&1)<<2));
135 /* srccopy bitblt, opcode is currently ignored*/
137 linear4_blit(PSD dstpsd, MWCOORD dstx, MWCOORD dsty, MWCOORD w, MWCOORD h,
138 PSD srcpsd, MWCOORD srcx, MWCOORD srcy, long op)
143 int dlinelen = dstpsd->linelen;
144 int slinelen = srcpsd->linelen;
146 assert (dstpsd->addr != 0);
147 assert (dstx >= 0 && dstx < dstpsd->xres);
148 assert (dsty >= 0 && dsty < dstpsd->yres);
151 assert (srcpsd->addr != 0);
152 assert (srcx >= 0 && srcx < srcpsd->xres);
153 assert (srcy >= 0 && srcy < srcpsd->yres);
154 assert (dstx+w <= dstpsd->xres);
155 assert (dsty+h <= dstpsd->yres);
156 assert (srcx+w <= srcpsd->xres);
157 assert (srcy+h <= srcpsd->yres);
160 dst = dstpsd->addr + (dstx>>1) + dsty * dlinelen;
161 src = srcpsd->addr + (srcx>>1) + srcy * slinelen;
169 unsigned char c = *s;
171 *d = (*d & notmask[dx&1]) |
172 ((c >> ((sx&1)<<2) & 0x0f) << ((dx&1)<<2));
174 *d = (*d & notmask[dx&1]) |
175 ((*s >> ((sx&1)<<2) & 0x0f) << ((dx&1)<<2));
188 SUBDRIVER fblinear4 = {
192 linear4_drawhorzline,
193 linear4_drawvertline,