root / hw / cirrus_vga_rop2.h @ a5082316
History | View | Annotate | Download (3.9 kB)
1 |
/*
|
---|---|
2 |
* QEMU Cirrus CLGD 54xx VGA Emulator.
|
3 |
*
|
4 |
* Copyright (c) 2004 Fabrice Bellard
|
5 |
*
|
6 |
* Permission is hereby granted, free of charge, to any person obtaining a copy
|
7 |
* of this software and associated documentation files (the "Software"), to deal
|
8 |
* in the Software without restriction, including without limitation the rights
|
9 |
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
10 |
* copies of the Software, and to permit persons to whom the Software is
|
11 |
* furnished to do so, subject to the following conditions:
|
12 |
*
|
13 |
* The above copyright notice and this permission notice shall be included in
|
14 |
* all copies or substantial portions of the Software.
|
15 |
*
|
16 |
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
17 |
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
18 |
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
|
19 |
* THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
20 |
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
21 |
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
22 |
* THE SOFTWARE.
|
23 |
*/
|
24 |
|
25 |
#if DEPTH == 8 |
26 |
#define PUTPIXEL() ROP_OP(d[0], col) |
27 |
#elif DEPTH == 16 |
28 |
#define PUTPIXEL() ROP_OP(((uint16_t *)d)[0], col); |
29 |
#elif DEPTH == 24 |
30 |
#define PUTPIXEL() ROP_OP(d[0], col); \ |
31 |
ROP_OP(d[1], (col >> 8)); \ |
32 |
ROP_OP(d[2], (col >> 16)) |
33 |
#elif DEPTH == 32 |
34 |
#define PUTPIXEL() ROP_OP(((uint32_t *)d)[0], col) |
35 |
#else
|
36 |
#error unsupported DEPTH
|
37 |
#endif
|
38 |
|
39 |
static void |
40 |
glue(glue(glue(cirrus_colorexpand_transp_, ROP_NAME), _),DEPTH) |
41 |
(CirrusVGAState * s, uint8_t * dst, |
42 |
const uint8_t * src1,
|
43 |
int dstpitch, int srcpitch, |
44 |
int bltwidth, int bltheight) |
45 |
{ |
46 |
const uint8_t *src;
|
47 |
uint8_t *d; |
48 |
int x, y;
|
49 |
unsigned bits;
|
50 |
unsigned int col; |
51 |
unsigned bitmask;
|
52 |
unsigned index;
|
53 |
int srcskipleft = 0; |
54 |
|
55 |
col = s->cirrus_blt_fgcol; |
56 |
for(y = 0; y < bltheight; y++) { |
57 |
src = src1; |
58 |
bitmask = 0x80 >> srcskipleft;
|
59 |
bits = *src++; |
60 |
d = dst; |
61 |
for (x = 0; x < bltwidth; x += (DEPTH / 8)) { |
62 |
if ((bitmask & 0xff) == 0) { |
63 |
bitmask = 0x80;
|
64 |
bits = *src++; |
65 |
} |
66 |
index = (bits & bitmask); |
67 |
if (index) {
|
68 |
PUTPIXEL(); |
69 |
} |
70 |
d += (DEPTH / 8);
|
71 |
bitmask >>= 1;
|
72 |
} |
73 |
src1 += srcpitch; |
74 |
dst += dstpitch; |
75 |
} |
76 |
} |
77 |
|
78 |
static void |
79 |
glue(glue(glue(cirrus_colorexpand_, ROP_NAME), _),DEPTH) |
80 |
(CirrusVGAState * s, uint8_t * dst, |
81 |
const uint8_t * src1,
|
82 |
int dstpitch, int srcpitch, |
83 |
int bltwidth, int bltheight) |
84 |
{ |
85 |
const uint8_t *src;
|
86 |
uint32_t colors[2];
|
87 |
uint8_t *d; |
88 |
int x, y;
|
89 |
unsigned bits;
|
90 |
unsigned int col; |
91 |
unsigned bitmask;
|
92 |
int srcskipleft = 0; |
93 |
|
94 |
colors[0] = s->cirrus_blt_bgcol;
|
95 |
colors[1] = s->cirrus_blt_fgcol;
|
96 |
for(y = 0; y < bltheight; y++) { |
97 |
src = src1; |
98 |
bitmask = 0x80 >> srcskipleft;
|
99 |
bits = *src++; |
100 |
d = dst; |
101 |
for (x = 0; x < bltwidth; x += (DEPTH / 8)) { |
102 |
if ((bitmask & 0xff) == 0) { |
103 |
bitmask = 0x80;
|
104 |
bits = *src++; |
105 |
} |
106 |
col = colors[!!(bits & bitmask)]; |
107 |
PUTPIXEL(); |
108 |
d += (DEPTH / 8);
|
109 |
bitmask >>= 1;
|
110 |
} |
111 |
src1 += srcpitch; |
112 |
dst += dstpitch; |
113 |
} |
114 |
} |
115 |
|
116 |
static void |
117 |
glue(glue(glue(cirrus_fill_, ROP_NAME), _),DEPTH) |
118 |
(CirrusVGAState *s, |
119 |
uint8_t *dst, int dst_pitch,
|
120 |
int width, int height) |
121 |
{ |
122 |
uint8_t *d, *d1; |
123 |
uint32_t col; |
124 |
int x, y;
|
125 |
|
126 |
col = s->cirrus_blt_fgcol; |
127 |
|
128 |
d1 = dst; |
129 |
for(y = 0; y < height; y++) { |
130 |
d = d1; |
131 |
for(x = 0; x < width; x += (DEPTH / 8)) { |
132 |
PUTPIXEL(); |
133 |
d += (DEPTH / 8);
|
134 |
} |
135 |
d1 += dst_pitch; |
136 |
} |
137 |
} |
138 |
|
139 |
#undef DEPTH
|
140 |
#undef PUTPIXEL
|