]>
Commit | Line | Data |
---|---|---|
a5082316 FB |
1 | /* |
2 | * QEMU Cirrus CLGD 54xx VGA Emulator. | |
5fafdf24 | 3 | * |
a5082316 | 4 | * Copyright (c) 2004 Fabrice Bellard |
5fafdf24 | 5 | * |
a5082316 FB |
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 | static void | |
26 | glue(cirrus_bitblt_rop_fwd_, ROP_NAME)(CirrusVGAState *s, | |
27 | uint8_t *dst,const uint8_t *src, | |
28 | int dstpitch,int srcpitch, | |
29 | int bltwidth,int bltheight) | |
30 | { | |
31 | int x,y; | |
32 | dstpitch -= bltwidth; | |
33 | srcpitch -= bltwidth; | |
b2eb849d AJ |
34 | |
35 | if (dstpitch < 0 || srcpitch < 0) { | |
36 | /* is 0 valid? srcpitch == 0 could be useful */ | |
37 | return; | |
38 | } | |
39 | ||
a5082316 FB |
40 | for (y = 0; y < bltheight; y++) { |
41 | for (x = 0; x < bltwidth; x++) { | |
42 | ROP_OP(*dst, *src); | |
43 | dst++; | |
44 | src++; | |
45 | } | |
46 | dst += dstpitch; | |
47 | src += srcpitch; | |
48 | } | |
49 | } | |
50 | ||
51 | static void | |
52 | glue(cirrus_bitblt_rop_bkwd_, ROP_NAME)(CirrusVGAState *s, | |
53 | uint8_t *dst,const uint8_t *src, | |
54 | int dstpitch,int srcpitch, | |
55 | int bltwidth,int bltheight) | |
56 | { | |
57 | int x,y; | |
58 | dstpitch += bltwidth; | |
59 | srcpitch += bltwidth; | |
60 | for (y = 0; y < bltheight; y++) { | |
61 | for (x = 0; x < bltwidth; x++) { | |
62 | ROP_OP(*dst, *src); | |
63 | dst--; | |
64 | src--; | |
65 | } | |
66 | dst += dstpitch; | |
67 | src += srcpitch; | |
68 | } | |
69 | } | |
70 | ||
96cf2df8 TS |
71 | static void |
72 | glue(glue(cirrus_bitblt_rop_fwd_transp_, ROP_NAME),_8)(CirrusVGAState *s, | |
73 | uint8_t *dst,const uint8_t *src, | |
74 | int dstpitch,int srcpitch, | |
75 | int bltwidth,int bltheight) | |
76 | { | |
77 | int x,y; | |
78 | uint8_t p; | |
79 | dstpitch -= bltwidth; | |
80 | srcpitch -= bltwidth; | |
81 | for (y = 0; y < bltheight; y++) { | |
82 | for (x = 0; x < bltwidth; x++) { | |
83 | p = *dst; | |
84 | ROP_OP(p, *src); | |
4e12cd94 | 85 | if (p != s->vga.gr[0x34]) *dst = p; |
96cf2df8 TS |
86 | dst++; |
87 | src++; | |
88 | } | |
89 | dst += dstpitch; | |
90 | src += srcpitch; | |
91 | } | |
92 | } | |
93 | ||
94 | static void | |
95 | glue(glue(cirrus_bitblt_rop_bkwd_transp_, ROP_NAME),_8)(CirrusVGAState *s, | |
96 | uint8_t *dst,const uint8_t *src, | |
97 | int dstpitch,int srcpitch, | |
98 | int bltwidth,int bltheight) | |
99 | { | |
100 | int x,y; | |
101 | uint8_t p; | |
102 | dstpitch += bltwidth; | |
103 | srcpitch += bltwidth; | |
104 | for (y = 0; y < bltheight; y++) { | |
105 | for (x = 0; x < bltwidth; x++) { | |
106 | p = *dst; | |
107 | ROP_OP(p, *src); | |
4e12cd94 | 108 | if (p != s->vga.gr[0x34]) *dst = p; |
96cf2df8 TS |
109 | dst--; |
110 | src--; | |
111 | } | |
112 | dst += dstpitch; | |
113 | src += srcpitch; | |
114 | } | |
115 | } | |
116 | ||
117 | static void | |
118 | glue(glue(cirrus_bitblt_rop_fwd_transp_, ROP_NAME),_16)(CirrusVGAState *s, | |
119 | uint8_t *dst,const uint8_t *src, | |
120 | int dstpitch,int srcpitch, | |
121 | int bltwidth,int bltheight) | |
122 | { | |
123 | int x,y; | |
124 | uint8_t p1, p2; | |
125 | dstpitch -= bltwidth; | |
126 | srcpitch -= bltwidth; | |
127 | for (y = 0; y < bltheight; y++) { | |
128 | for (x = 0; x < bltwidth; x+=2) { | |
129 | p1 = *dst; | |
130 | p2 = *(dst+1); | |
131 | ROP_OP(p1, *src); | |
132 | ROP_OP(p2, *(src+1)); | |
4e12cd94 | 133 | if ((p1 != s->vga.gr[0x34]) || (p2 != s->vga.gr[0x35])) { |
96cf2df8 TS |
134 | *dst = p1; |
135 | *(dst+1) = p2; | |
136 | } | |
137 | dst+=2; | |
138 | src+=2; | |
139 | } | |
140 | dst += dstpitch; | |
141 | src += srcpitch; | |
142 | } | |
143 | } | |
144 | ||
145 | static void | |
146 | glue(glue(cirrus_bitblt_rop_bkwd_transp_, ROP_NAME),_16)(CirrusVGAState *s, | |
147 | uint8_t *dst,const uint8_t *src, | |
148 | int dstpitch,int srcpitch, | |
149 | int bltwidth,int bltheight) | |
150 | { | |
151 | int x,y; | |
152 | uint8_t p1, p2; | |
153 | dstpitch += bltwidth; | |
154 | srcpitch += bltwidth; | |
155 | for (y = 0; y < bltheight; y++) { | |
156 | for (x = 0; x < bltwidth; x+=2) { | |
157 | p1 = *(dst-1); | |
158 | p2 = *dst; | |
159 | ROP_OP(p1, *(src-1)); | |
160 | ROP_OP(p2, *src); | |
4e12cd94 | 161 | if ((p1 != s->vga.gr[0x34]) || (p2 != s->vga.gr[0x35])) { |
96cf2df8 TS |
162 | *(dst-1) = p1; |
163 | *dst = p2; | |
164 | } | |
165 | dst-=2; | |
166 | src-=2; | |
167 | } | |
168 | dst += dstpitch; | |
169 | src += srcpitch; | |
170 | } | |
171 | } | |
172 | ||
a5082316 FB |
173 | #define DEPTH 8 |
174 | #include "cirrus_vga_rop2.h" | |
175 | ||
176 | #define DEPTH 16 | |
177 | #include "cirrus_vga_rop2.h" | |
178 | ||
179 | #define DEPTH 24 | |
180 | #include "cirrus_vga_rop2.h" | |
181 | ||
182 | #define DEPTH 32 | |
183 | #include "cirrus_vga_rop2.h" | |
184 | ||
185 | #undef ROP_NAME | |
186 | #undef ROP_OP |