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