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

Subversion Repositories or1k

[/] [or1k/] [tags/] [MW_0_8_9PRE7/] [mw/] [src/] [drivers/] [fblin1rev.c] - Blame information for rev 1765

Details | Compare with Previous | View Log

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

powered by: WebSVN 2.1.0

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