OpenCores
URL https://opencores.org/ocsvn/openrisc_me/openrisc_me/trunk

Subversion Repositories openrisc_me

[/] [openrisc/] [trunk/] [rtos/] [ecos-2.0/] [packages/] [services/] [gfx/] [mw/] [v2_0/] [src/] [drivers/] [fblin2rev.c] - Blame information for rev 174

Details | Compare with Previous | View Log

Line No. Rev Author Line
1 27 unneback
/*
2
* Copyright (c) 1999 Greg Haerr <greg@censoft.com>
3
*
4
* 2bpp Packed Linear Video Driver (reversed bit order)
5
* For Psion S5
6
*
7
*       In this driver, psd->linelen is line byte length, not line pixel length
8
*/
9
/*#define NDEBUG*/
10
#include <assert.h>
11
#include <string.h>
12
#include "device.h"
13
#include "fb.h"
14
 
15
static unsigned char notmask[4] = { 0xfc, 0xf3, 0xcf, 0x3f };
16
 
17
/* Calc linelen and mmap size, return 0 on fail*/
18
static int
19
linear2_init(PSD psd)
20
{
21
        if (!psd->size)
22
                psd->size = psd->yres * psd->linelen;
23
        /* linelen in bytes for bpp 1, 2, 4, 8 so no change*/
24
        return 1;
25
}
26
 
27
/* Set pixel at x, y, to pixelval c*/
28
static void
29
linear2_drawpixel(PSD psd, MWCOORD x, MWCOORD y, MWPIXELVAL c)
30
{
31
        ADDR8   addr = psd->addr;
32
 
33
        assert (addr != 0);
34
        assert (x >= 0 && x < psd->xres);
35
        assert (y >= 0 && y < psd->yres);
36
        assert (c < psd->ncolors);
37
 
38
        DRAWON;
39
        addr += (x>>2) + y * psd->linelen;
40
        if(gr_mode == MWMODE_XOR)
41
                *addr ^= c << ((x&3)<<1);
42
        else
43
                *addr = (*addr & notmask[x&3]) | (c << ((x&3)<<1));
44
        DRAWOFF;
45
}
46
 
47
/* Read pixel at x, y*/
48
static MWPIXELVAL
49
linear2_readpixel(PSD psd, MWCOORD x, MWCOORD y)
50
{
51
        ADDR8   addr = psd->addr;
52
 
53
        assert (addr != 0);
54
        assert (x >= 0 && x < psd->xres);
55
        assert (y >= 0 && y < psd->yres);
56
 
57
        return (addr[(x>>2) + y * psd->linelen] >> ((x&3)<<1) ) & 0x03;
58
}
59
 
60
/* Draw horizontal line from x1,y to x2,y including final point*/
61
static void
62
linear2_drawhorzline(PSD psd, MWCOORD x1, MWCOORD x2, MWCOORD y, MWPIXELVAL c)
63
{
64
        ADDR8   addr = psd->addr;
65
 
66
        assert (addr != 0);
67
        assert (x1 >= 0 && x1 < psd->xres);
68
        assert (x2 >= 0 && x2 < psd->xres);
69
        assert (x2 >= x1);
70
        assert (y >= 0 && y < psd->yres);
71
        assert (c < psd->ncolors);
72
 
73
        DRAWON;
74
        addr += (x1>>2) + y * psd->linelen;
75
        if(gr_mode == MWMODE_XOR) {
76
                while(x1 <= x2) {
77
                        *addr ^= c << ((x1&3)<<1);
78
                        if((++x1 & 3) == 0)
79
                                ++addr;
80
                }
81
        } else {
82
                while(x1 <= x2) {
83
                        *addr = (*addr & notmask[x1&3]) | (c << ((x1&3)<<1));
84
                        if((++x1 & 3) == 0)
85
                                ++addr;
86
                }
87
        }
88
        DRAWOFF;
89
}
90
 
91
/* Draw a vertical line from x,y1 to x,y2 including final point*/
92
static void
93
linear2_drawvertline(PSD psd, MWCOORD x, MWCOORD y1, MWCOORD y2, MWPIXELVAL c)
94
{
95
        ADDR8   addr = psd->addr;
96
        int     linelen = psd->linelen;
97
 
98
        assert (addr != 0);
99
        assert (x >= 0 && x < psd->xres);
100
        assert (y1 >= 0 && y1 < psd->yres);
101
        assert (y2 >= 0 && y2 < psd->yres);
102
        assert (y2 >= y1);
103
        assert (c < psd->ncolors);
104
 
105
        DRAWON;
106
        addr += (x>>2) + y1 * linelen;
107
        if(gr_mode == MWMODE_XOR)
108
                while(y1++ <= y2) {
109
                        *addr ^= c << ((x&3)<<1);
110
                        addr += linelen;
111
                }
112
        else
113
                while(y1++ <= y2) {
114
                        *addr = (*addr & notmask[x&3]) | (c << ((x&3)<<1));
115
                        addr += linelen;
116
                }
117
        DRAWOFF;
118
}
119
 
120
/* srccopy bitblt, opcode is currently ignored*/
121
static void
122
linear2_blit(PSD dstpsd, MWCOORD dstx, MWCOORD dsty, MWCOORD w, MWCOORD h,
123
        PSD srcpsd, MWCOORD srcx, MWCOORD srcy, long op)
124
{
125
        ADDR8   dst;
126
        ADDR8   src;
127
        int     i;
128
        int     dlinelen = dstpsd->linelen;
129
        int     slinelen = srcpsd->linelen;
130
 
131
        assert (dstpsd->addr != 0);
132
        assert (dstx >= 0 && dstx < dstpsd->xres);
133
        assert (dsty >= 0 && dsty < dstpsd->yres);
134
        assert (w > 0);
135
        assert (h > 0);
136
        assert (srcpsd->addr != 0);
137
        assert (srcx >= 0 && srcx < srcpsd->xres);
138
        assert (srcy >= 0 && srcy < srcpsd->yres);
139
        assert (dstx+w <= dstpsd->xres);
140
        assert (dsty+h <= dstpsd->yres);
141
        assert (srcx+w <= srcpsd->xres);
142
        assert (srcy+h <= srcpsd->yres);
143
 
144
        DRAWON;
145
        dst = dstpsd->addr + (dstx>>2) + dsty * dlinelen;
146
        src = srcpsd->addr + (srcx>>2) + srcy * slinelen;
147
        while(--h >= 0) {
148
                ADDR8   d = dst;
149
                ADDR8   s = src;
150
                MWCOORD dx = dstx;
151
                MWCOORD sx = srcx;
152
                for(i=0; i<w; ++i) {
153
                        *d = (*d & notmask[dx&3]) |
154
                           ((*s >> ((sx&3)<<1) & 0x03) << ((dx&3)<<1));
155
                        if((++dx & 3) == 0)
156
                                ++d;
157
                        if((++sx & 3) == 0)
158
                                ++s;
159
                }
160
                dst += dlinelen;
161
                src += slinelen;
162
        }
163
        DRAWOFF;
164
}
165
 
166
SUBDRIVER fblinear2 = {
167
        linear2_init,
168
        linear2_drawpixel,
169
        linear2_readpixel,
170
        linear2_drawhorzline,
171
        linear2_drawvertline,
172
        gen_fillrect,
173
        linear2_blit
174
};

powered by: WebSVN 2.1.0

© copyright 1999-2024 OpenCores.org, equivalent to Oliscience, all rights reserved. OpenCores®, registered trademark.