2 * Copyright (c) 1999 Greg Haerr <greg@censoft.com>
4 * 4bpp Packed Linear SH3 Video Driver for Microwindows
6 * In this driver, psd->linelen is line byte length, not line pixel length
9 This is modified for SH3 LittleEndian system.
10 4bpp linear video driver,
11 Frame buffer sturcture and LCD Pixel is
14 -----------------------------------------
15 | P0 | P1 | P2 | P3 | P4 | P5 | P6 | P7 |
16 -----------------------------------------
26 static unsigned char notmask[2] = { 0x0f, 0xf0};
28 /* Calc linelen and mmap size, return 0 on fail*/
33 psd->size = psd->yres * psd->linelen;
34 /* linelen in bytes for bpp 1, 2, 4, 8 so no change*/
38 /* Set pixel at x, y, to pixelval c*/
40 linear4_drawpixel(PSD psd, MWCOORD x, MWCOORD y, MWPIXELVAL c)
42 ADDR8 addr = psd->addr;
45 assert (x >= 0 && x < psd->xres);
46 assert (y >= 0 && y < psd->yres);
47 assert (c < psd->ncolors);
50 addr += ((x>>1)^3) + 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;
65 assert (x >= 0 && x < psd->xres);
66 assert (y >= 0 && y < psd->yres);
68 return (addr[((x>>1)^3) + y * psd->linelen] >> ((1-(x&1))<<2) ) & 0x0f;
71 /* Draw horizontal line from x1,y to x2,y including final point*/
73 linear4_drawhorzline(PSD psd, MWCOORD x1, MWCOORD x2, MWCOORD y, MWPIXELVAL c)
75 ADDR8 addr = psd->addr;
78 assert (x1 >= 0 && x1 < psd->xres);
79 assert (x2 >= 0 && x2 < psd->xres);
81 assert (y >= 0 && y < psd->yres);
82 assert (c < psd->ncolors);
85 addr += ( (x1>>1)^3 ) + y * psd->linelen;
86 if(gr_mode == MWMODE_XOR) {
88 *addr ^= c << ((1-(x1&1))<<2);
91 addr = psd->addr + ( (x1>>1)^3 ) + y * psd->linelen;
96 *addr = (*addr & notmask[x1&1]) | (c << ((1-(x1&1))<<2));
99 addr = psd->addr + ( (x1>>1)^3 ) + y * psd->linelen;
106 /* Draw a vertical line from x,y1 to x,y2 including final point*/
108 linear4_drawvertline(PSD psd, MWCOORD x, MWCOORD y1, MWCOORD y2, MWPIXELVAL c)
110 ADDR8 addr = psd->addr;
111 int linelen = psd->linelen;
114 assert (x >= 0 && x < psd->xres);
115 assert (y1 >= 0 && y1 < psd->yres);
116 assert (y2 >= 0 && y2 < psd->yres);
118 assert (c < psd->ncolors);
121 addr += ( (x>>1)^3 ) + y1 * linelen;
122 if(gr_mode == MWMODE_XOR)
124 *addr ^= c << ((1-(x&1))<<2);
129 *addr = (*addr & notmask[x&1]) | (c << ((1-(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 #ifdef SH3_LITTLE_ENDIAN /* not used */
161 dst = dstpsd->addr + ( (dstx>>1)^3 ) + dsty * dlinelen;
162 src = srcpsd->addr + ( (srcx>>1)^3 ) + srcy * slinelen;
169 *d = (*d & notmask[dx&1]) |
170 ((*s >> ((1-(sx&1))<<2) & 0x0f) << ((1-(dx&1))<<2));
180 dst = dstpsd->addr + dsty * dlinelen;
181 src = srcpsd->addr + srcy * slinelen;
183 ADDR8 d = dst + ( (dstx>>1)^3 );
184 ADDR8 s = src + ( (srcx>>1)^3 );
188 *d = (*d & notmask[dx&1]) |
189 ((*s >> ((1-(sx&1))<<2) & 0x0f) << ((1-(dx&1))<<2));
191 d = dst + ( (dx >> 1)^3 );
193 s = src + ( (sx >> 1)^3 );
202 SUBDRIVER fblinear4 = {
206 linear4_drawhorzline,
207 linear4_drawvertline,