1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25static inline void glue(rop_8_,ROP_NAME)(uint8_t *dst, uint8_t src)
26{
27 *dst = ROP_FN(*dst, src);
28}
29
30static inline void glue(rop_16_,ROP_NAME)(uint16_t *dst, uint16_t src)
31{
32 *dst = ROP_FN(*dst, src);
33}
34
35static inline void glue(rop_32_,ROP_NAME)(uint32_t *dst, uint32_t src)
36{
37 *dst = ROP_FN(*dst, src);
38}
39
40#define ROP_OP(d, s) glue(rop_8_,ROP_NAME)(d, s)
41#define ROP_OP_16(d, s) glue(rop_16_,ROP_NAME)(d, s)
42#define ROP_OP_32(d, s) glue(rop_32_,ROP_NAME)(d, s)
43#undef ROP_FN
44
45static void
46glue(cirrus_bitblt_rop_fwd_, ROP_NAME)(CirrusVGAState *s,
47 uint8_t *dst,const uint8_t *src,
48 int dstpitch,int srcpitch,
49 int bltwidth,int bltheight)
50{
51 int x,y;
52 dstpitch -= bltwidth;
53 srcpitch -= bltwidth;
54
55 if (bltheight > 1 && (dstpitch < 0 || srcpitch < 0)) {
56 return;
57 }
58
59 for (y = 0; y < bltheight; y++) {
60 for (x = 0; x < bltwidth; x++) {
61 ROP_OP(dst, *src);
62 dst++;
63 src++;
64 }
65 dst += dstpitch;
66 src += srcpitch;
67 }
68}
69
70static void
71glue(cirrus_bitblt_rop_bkwd_, ROP_NAME)(CirrusVGAState *s,
72 uint8_t *dst,const uint8_t *src,
73 int dstpitch,int srcpitch,
74 int bltwidth,int bltheight)
75{
76 int x,y;
77 dstpitch += bltwidth;
78 srcpitch += bltwidth;
79 for (y = 0; y < bltheight; y++) {
80 for (x = 0; x < bltwidth; x++) {
81 ROP_OP(dst, *src);
82 dst--;
83 src--;
84 }
85 dst += dstpitch;
86 src += srcpitch;
87 }
88}
89
90static void
91glue(glue(cirrus_bitblt_rop_fwd_transp_, ROP_NAME),_8)(CirrusVGAState *s,
92 uint8_t *dst,const uint8_t *src,
93 int dstpitch,int srcpitch,
94 int bltwidth,int bltheight)
95{
96 int x,y;
97 uint8_t p;
98 dstpitch -= bltwidth;
99 srcpitch -= bltwidth;
100 for (y = 0; y < bltheight; y++) {
101 for (x = 0; x < bltwidth; x++) {
102 p = *dst;
103 ROP_OP(&p, *src);
104 if (p != s->vga.gr[0x34]) *dst = p;
105 dst++;
106 src++;
107 }
108 dst += dstpitch;
109 src += srcpitch;
110 }
111}
112
113static void
114glue(glue(cirrus_bitblt_rop_bkwd_transp_, ROP_NAME),_8)(CirrusVGAState *s,
115 uint8_t *dst,const uint8_t *src,
116 int dstpitch,int srcpitch,
117 int bltwidth,int bltheight)
118{
119 int x,y;
120 uint8_t p;
121 dstpitch += bltwidth;
122 srcpitch += bltwidth;
123 for (y = 0; y < bltheight; y++) {
124 for (x = 0; x < bltwidth; x++) {
125 p = *dst;
126 ROP_OP(&p, *src);
127 if (p != s->vga.gr[0x34]) *dst = p;
128 dst--;
129 src--;
130 }
131 dst += dstpitch;
132 src += srcpitch;
133 }
134}
135
136static void
137glue(glue(cirrus_bitblt_rop_fwd_transp_, ROP_NAME),_16)(CirrusVGAState *s,
138 uint8_t *dst,const uint8_t *src,
139 int dstpitch,int srcpitch,
140 int bltwidth,int bltheight)
141{
142 int x,y;
143 uint8_t p1, p2;
144 dstpitch -= bltwidth;
145 srcpitch -= bltwidth;
146 for (y = 0; y < bltheight; y++) {
147 for (x = 0; x < bltwidth; x+=2) {
148 p1 = *dst;
149 p2 = *(dst+1);
150 ROP_OP(&p1, *src);
151 ROP_OP(&p2, *(src + 1));
152 if ((p1 != s->vga.gr[0x34]) || (p2 != s->vga.gr[0x35])) {
153 *dst = p1;
154 *(dst+1) = p2;
155 }
156 dst+=2;
157 src+=2;
158 }
159 dst += dstpitch;
160 src += srcpitch;
161 }
162}
163
164static void
165glue(glue(cirrus_bitblt_rop_bkwd_transp_, ROP_NAME),_16)(CirrusVGAState *s,
166 uint8_t *dst,const uint8_t *src,
167 int dstpitch,int srcpitch,
168 int bltwidth,int bltheight)
169{
170 int x,y;
171 uint8_t p1, p2;
172 dstpitch += bltwidth;
173 srcpitch += bltwidth;
174 for (y = 0; y < bltheight; y++) {
175 for (x = 0; x < bltwidth; x+=2) {
176 p1 = *(dst-1);
177 p2 = *dst;
178 ROP_OP(&p1, *(src - 1));
179 ROP_OP(&p2, *src);
180 if ((p1 != s->vga.gr[0x34]) || (p2 != s->vga.gr[0x35])) {
181 *(dst-1) = p1;
182 *dst = p2;
183 }
184 dst-=2;
185 src-=2;
186 }
187 dst += dstpitch;
188 src += srcpitch;
189 }
190}
191
192#define DEPTH 8
193#include "cirrus_vga_rop2.h"
194
195#define DEPTH 16
196#include "cirrus_vga_rop2.h"
197
198#define DEPTH 24
199#include "cirrus_vga_rop2.h"
200
201#define DEPTH 32
202#include "cirrus_vga_rop2.h"
203
204#undef ROP_NAME
205#undef ROP_OP
206#undef ROP_OP_16
207#undef ROP_OP_32
208