2 * Copyright (c) 1999 Martin Jolicoeur <martinj@visuaide.com>
4 * 4bpp Packed Linear Video Driver for Microwindows
5 * Designed for the arm SA1100 lcd controller with 16 bits access
8 * In this driver, psd->linelen is line byte length, not line pixel length
16 static unsigned short notmask[4] = { 0x0fff, 0xf0ff, 0xff0f, 0xfff0};
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*/
29 /* Set pixel at x, y, to pixelval c*/
31 linear4_drawpixel(PSD psd, MWCOORD x, MWCOORD y, MWPIXELVAL c)
33 ADDR8 addr = psd->addr;
36 assert (x >= 0 && x < psd->xres);
37 assert (y >= 0 && y < psd->yres);
38 assert (c < psd->ncolors);
41 addr += (x>>1) + y * psd->linelen;
42 if(gr_mode == MWMODE_XOR)
43 *(ADDR16)addr ^= c << ((3-(x&3))<<2);
45 *(ADDR16)addr = (*(ADDR16)addr & notmask[x&3]) | (c << ((3-(x&3))<<2));
49 /* Read pixel at x, y*/
51 linear4_readpixel(PSD psd, MWCOORD x, MWCOORD y)
53 ADDR8 addr = psd->addr;
56 assert (x >= 0 && x < psd->xres);
57 assert (y >= 0 && y < psd->yres);
59 return (addr[(x>>1) + y * psd->linelen] >> ((1-(x&1))<<2) ) & 0x0f;
62 /* Draw horizontal line from x1,y to x2,y including final point*/
64 linear4_drawhorzline(PSD psd, MWCOORD x1, MWCOORD x2, MWCOORD y, MWPIXELVAL c)
66 ADDR8 addr = psd->addr;
69 assert (x1 >= 0 && x1 < psd->xres);
70 assert (x2 >= 0 && x2 < psd->xres);
72 assert (y >= 0 && y < psd->yres);
73 assert (c < psd->ncolors);
76 addr += (x1>>1) + y * psd->linelen;
77 if(gr_mode == MWMODE_XOR) {
79 *(ADDR16)addr ^= c << ((3-(x1&3))<<2);
85 *(ADDR16)addr = (*(ADDR16)addr & notmask[x1&3]) | (c << ((3-(x1&3))<<2));
93 /* Draw a vertical line from x,y1 to x,y2 including final point*/
95 linear4_drawvertline(PSD psd, MWCOORD x, MWCOORD y1, MWCOORD y2, MWPIXELVAL c)
97 ADDR8 addr = psd->addr;
98 int linelen = psd->linelen;
101 assert (x >= 0 && x < psd->xres);
102 assert (y1 >= 0 && y1 < psd->yres);
103 assert (y2 >= 0 && y2 < psd->yres);
105 assert (c < psd->ncolors);
108 addr += (x>>1) + y1 * linelen;
109 if(gr_mode == MWMODE_XOR)
111 *(ADDR16)addr ^= c << ((3-(x&3))<<2);
116 *(ADDR16)addr = (*(ADDR16)addr & notmask[x&3]) | (c << ((3-(x&3))<<2));
122 /* srccopy bitblt, opcode is currently ignored*/
124 linear4_blit(PSD dstpsd, MWCOORD dstx, MWCOORD dsty, MWCOORD w, MWCOORD h,
125 PSD srcpsd, MWCOORD srcx, MWCOORD srcy, long op)
130 int dlinelen = dstpsd->linelen;
131 int slinelen = srcpsd->linelen;
133 assert (dstpsd->addr != 0);
134 assert (dstx >= 0 && dstx < dstpsd->xres);
135 assert (dsty >= 0 && dsty < dstpsd->yres);
138 assert (srcpsd->addr != 0);
139 assert (srcx >= 0 && srcx < srcpsd->xres);
140 assert (srcy >= 0 && srcy < srcpsd->yres);
141 assert (dstx+w <= dstpsd->xres);
142 assert (dsty+h <= dstpsd->yres);
143 assert (srcx+w <= srcpsd->xres);
144 assert (srcy+h <= srcpsd->yres);
147 dst = dstpsd->addr + (dstx>>1) + dsty * dlinelen;
148 src = srcpsd->addr + (srcx>>1) + srcy * slinelen;
155 *(ADDR16)d = (*(ADDR16)d & notmask[dx&3]) |
156 ((*(ADDR16)s >> ((3-(sx&3))<<2) & 0x000f) << ((3-(dx&3))<<2));
168 SUBDRIVER fblinear4 = {
172 linear4_drawhorzline,
173 linear4_drawvertline,