1 /* by julian schroeder <detemp1@germany.cirrus.com>
2 * for Cirrus Logic based on fblin24.c
4 * Copyright (c) 2000 Greg Haerr <greg@censoft.com>
6 * 12bpp Linear Video Driver for Microwindows
16 int gr_mode=MWMODE_XOR;
18 /* Calc linelen and mmap size, return 0 on fail*/
20 linear12_init(PSD psd)
23 psd->size = 960*240/2;
24 /* convert linelen from byte to pixel len for bpp 16, 24, 32*/
26 psd->linelen /= 3; /* /1.5*/
31 static inline void setpix(char *cptr,int x, int y, char c)
35 adr=(x>>1) + (y*480); /* change, julian*/
37 if(gr_mode == MWMODE_XOR)
39 if(x & 0x01) cptr[adr]^=((c << 4) & 0xf0);
40 else cptr[adr]^=(c & 0x0f);
47 cptr[adr]|=((c << 4) & 0xf0);
52 cptr[adr]|=(c & 0x0f);
57 static inline char getpix(char *cptr,int x, int y)
60 adr=(x>>1) + (y*480); /* change, julian*/
62 if(x & 0x01) return (cptr[adr] >> 4) & 0x0f;
63 return cptr[adr] & 0x0f;
67 /* Set pixel at x, y, to pixelval c*/
69 linear12_drawpixel(PSD psd, MWCOORD x, MWCOORD y, MWPIXELVAL c)
71 ADDR8 addr = psd->addr;
75 assert (x >= 0 && x < psd->xres);
76 assert (y >= 0 && y < psd->yres);
77 assert (c < psd->ncolors);
90 /* Read pixel at x, y*/
92 linear12_readpixel(PSD psd, MWCOORD x, MWCOORD y)
94 ADDR8 addr = psd->addr;
97 assert (x >= 0 && x < psd->xres);
98 assert (y >= 0 && y < psd->yres);
100 return RGB2PIXEL444(getpix(addr,x,y),getpix(addr,x+1,y),getpix(addr,x+2,y));
103 /* Draw horizontal line from x1,y to x2,y including final point*/
105 linear12_drawhorzline(PSD psd, MWCOORD x1, MWCOORD x2, MWCOORD y, MWPIXELVAL c)
107 ADDR8 addr = psd->addr;
111 assert (x1 >= 0 && x1 < psd->xres);
112 assert (x2 >= 0 && x2 < psd->xres);
114 assert (y >= 0 && y < psd->yres);
115 assert (c < psd->ncolors);
118 g = PIXEL444GREEN(c);
123 while((x1+=3) <= x2) {
125 setpix(addr,x1+1,y,g);
126 setpix(addr,x1+2,y,b);
131 /* Draw a vertical line from x,y1 to x,y2 including final point*/
133 linear12_drawvertline(PSD psd, MWCOORD x, MWCOORD y1, MWCOORD y2, MWPIXELVAL c)
135 ADDR8 addr = psd->addr;
136 int linelen = psd->linelen * 3;
140 assert (x >= 0 && x < psd->xres);
141 assert (y1 >= 0 && y1 < psd->yres);
142 assert (y2 >= 0 && y2 < psd->yres);
144 assert (c < psd->ncolors);
147 g = PIXEL444GREEN(c);
154 setpix(addr,x+1,y1,g);
155 setpix(addr,x+2,y1,b);
161 /* srccopy bitblt, opcode is currently ignored*/
163 xlinear12_blit(PSD dstpsd, MWCOORD dstx, MWCOORD dsty, MWCOORD w, MWCOORD h,
164 PSD srcpsd, MWCOORD srcx, MWCOORD srcy, long op)
166 ADDR8 dst = dstpsd->addr;
167 ADDR8 src = srcpsd->addr;
169 int dlinelen = dstpsd->linelen * 3;
170 int slinelen = srcpsd->linelen * 3;
171 int dlinelen_minus_w = (dstpsd->linelen - w) * 3;
172 int slinelen_minus_w = (srcpsd->linelen - w) * 3;
178 assert (dstx >= 0 && dstx < dstpsd->xres);
179 assert (dsty >= 0 && dsty < dstpsd->yres);
183 assert (srcx >= 0 && srcx < srcpsd->xres);
184 assert (srcy >= 0 && srcy < srcpsd->yres);
185 assert (dstx+w <= dstpsd->xres);
186 assert (dsty+h <= dstpsd->yres);
187 assert (srcx+w <= srcpsd->xres);
188 assert (srcy+h <= srcpsd->yres);
191 dst += (dstx + dsty * dstpsd->linelen) * 3;
192 src += (srcx + srcy * srcpsd->linelen) * 3;
195 if((op & MWROP_EXTENSION) != MWROP_BLENDCONSTANT)
201 unsigned long s = *src++;
202 unsigned long d = *dst;
203 *dst++ = (unsigned char)(((s - d)*alpha)>>8) + d;
206 *dst++ = (unsigned char)(((s - d)*alpha)>>8) + d;
209 *dst++ = (unsigned char)(((s - d)*alpha)>>8) + d;
211 dst += dlinelen_minus_w;
212 src += slinelen_minus_w;
220 /* a _fast_ memcpy is a _must_ in this routine*/
221 memcpy(dst, src, w*3);
230 dst += dlinelen_minus_w;
231 src += slinelen_minus_w;
238 /* srccopy bitblt, opcode is currently ignored*/
240 linear12_blit(PSD dstpsd, MWCOORD dstx, MWCOORD dsty, MWCOORD w, MWCOORD h,
241 PSD srcpsd, MWCOORD srcx, MWCOORD srcy, long op)
243 ADDR8 dst = dstpsd->addr;
244 ADDR8 src = srcpsd->addr;
246 /*if ((srcx & 0x01) || (dstx & 0x01))*/
247 /* FIXME where is this if supposed to end?? */
250 dst+=((dstx*3+1)/2)+480*dsty;
251 src+=((srcx*3+1)/2)+480*srcx;
254 assert (dstx >= 0 && dstx < dstpsd->xres);
255 assert (dsty >= 0 && dsty < dstpsd->yres);
259 assert (srcx >= 0 && srcx < srcpsd->xres);
260 assert (srcy >= 0 && srcy < srcpsd->yres);
261 assert (dstx+w <= dstpsd->xres);
262 assert (dsty+h <= dstpsd->yres);
263 assert (srcx+w <= srcpsd->xres);
264 assert (srcy+h <= srcpsd->yres);
267 if((srcx & 0x01) && !(dstx & 0x01))
273 if(!(srcx & 0x01) && (dstx & 0x01))
279 if((srcx & 0x01) && (dstx & 0x01))
286 /* a _fast_ memcpy is a _must_ in this routine*/
287 memcpy(dst, src, (w*3+1)/2);
295 SUBDRIVER fblinear12 = {
299 linear12_drawhorzline,
300 linear12_drawvertline,