2 * QEMU Cirrus CLGD 54xx VGA Emulator.
4 * Copyright (c) 2004 Fabrice Bellard
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:
13 * The above copyright notice and this permission notice shall be included in
14 * all copies or substantial portions of the Software.
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
25 static inline void glue(rop_8_
, ROP_NAME
)(CirrusVGAState
*s
,
26 uint32_t dstaddr
, uint8_t src
)
28 uint8_t *dst
= &s
->vga
.vram_ptr
[dstaddr
& s
->cirrus_addr_mask
];
29 *dst
= ROP_FN(*dst
, src
);
32 static inline void glue(rop_tr_8_
, ROP_NAME
)(CirrusVGAState
*s
,
33 uint32_t dstaddr
, uint8_t src
,
36 uint8_t *dst
= &s
->vga
.vram_ptr
[dstaddr
& s
->cirrus_addr_mask
];
37 uint8_t pixel
= ROP_FN(*dst
, src
);
38 if (pixel
!= transp
) {
43 static inline void glue(rop_16_
, ROP_NAME
)(CirrusVGAState
*s
,
44 uint32_t dstaddr
, uint16_t src
)
46 uint16_t *dst
= (uint16_t *)
47 (&s
->vga
.vram_ptr
[dstaddr
& s
->cirrus_addr_mask
& ~1]);
48 *dst
= ROP_FN(*dst
, src
);
51 static inline void glue(rop_tr_16_
, ROP_NAME
)(CirrusVGAState
*s
,
52 uint32_t dstaddr
, uint16_t src
,
55 uint16_t *dst
= (uint16_t *)
56 (&s
->vga
.vram_ptr
[dstaddr
& s
->cirrus_addr_mask
& ~1]);
57 uint16_t pixel
= ROP_FN(*dst
, src
);
58 if (pixel
!= transp
) {
63 static inline void glue(rop_32_
, ROP_NAME
)(CirrusVGAState
*s
,
64 uint32_t dstaddr
, uint32_t src
)
66 uint32_t *dst
= (uint32_t *)
67 (&s
->vga
.vram_ptr
[dstaddr
& s
->cirrus_addr_mask
& ~3]);
68 *dst
= ROP_FN(*dst
, src
);
71 #define ROP_OP(st, d, s) glue(rop_8_, ROP_NAME)(st, d, s)
72 #define ROP_OP_TR(st, d, s, t) glue(rop_tr_8_, ROP_NAME)(st, d, s, t)
73 #define ROP_OP_16(st, d, s) glue(rop_16_, ROP_NAME)(st, d, s)
74 #define ROP_OP_TR_16(st, d, s, t) glue(rop_tr_16_, ROP_NAME)(st, d, s, t)
75 #define ROP_OP_32(st, d, s) glue(rop_32_, ROP_NAME)(st, d, s)
79 glue(cirrus_bitblt_rop_fwd_
, ROP_NAME
)(CirrusVGAState
*s
,
82 int dstpitch
, int srcpitch
,
83 int bltwidth
, int bltheight
)
89 if (bltheight
> 1 && (dstpitch
< 0 || srcpitch
< 0)) {
93 for (y
= 0; y
< bltheight
; y
++) {
94 for (x
= 0; x
< bltwidth
; x
++) {
95 ROP_OP(s
, dstaddr
, cirrus_src(s
, srcaddr
));
105 glue(cirrus_bitblt_rop_bkwd_
, ROP_NAME
)(CirrusVGAState
*s
,
108 int dstpitch
, int srcpitch
,
109 int bltwidth
, int bltheight
)
112 dstpitch
+= bltwidth
;
113 srcpitch
+= bltwidth
;
114 for (y
= 0; y
< bltheight
; y
++) {
115 for (x
= 0; x
< bltwidth
; x
++) {
116 ROP_OP(s
, dstaddr
, cirrus_src(s
, srcaddr
));
126 glue(glue(cirrus_bitblt_rop_fwd_transp_
, ROP_NAME
),_8
)(CirrusVGAState
*s
,
135 uint8_t transp
= s
->vga
.gr
[0x34];
136 dstpitch
-= bltwidth
;
137 srcpitch
-= bltwidth
;
139 if (bltheight
> 1 && (dstpitch
< 0 || srcpitch
< 0)) {
143 for (y
= 0; y
< bltheight
; y
++) {
144 for (x
= 0; x
< bltwidth
; x
++) {
145 ROP_OP_TR(s
, dstaddr
, cirrus_src(s
, srcaddr
), transp
);
155 glue(glue(cirrus_bitblt_rop_bkwd_transp_
, ROP_NAME
),_8
)(CirrusVGAState
*s
,
164 uint8_t transp
= s
->vga
.gr
[0x34];
165 dstpitch
+= bltwidth
;
166 srcpitch
+= bltwidth
;
167 for (y
= 0; y
< bltheight
; y
++) {
168 for (x
= 0; x
< bltwidth
; x
++) {
169 ROP_OP_TR(s
, dstaddr
, cirrus_src(s
, srcaddr
), transp
);
179 glue(glue(cirrus_bitblt_rop_fwd_transp_
, ROP_NAME
),_16
)(CirrusVGAState
*s
,
188 uint16_t transp
= s
->vga
.gr
[0x34] | (uint16_t)s
->vga
.gr
[0x35] << 8;
189 dstpitch
-= bltwidth
;
190 srcpitch
-= bltwidth
;
192 if (bltheight
> 1 && (dstpitch
< 0 || srcpitch
< 0)) {
196 for (y
= 0; y
< bltheight
; y
++) {
197 for (x
= 0; x
< bltwidth
; x
+=2) {
198 ROP_OP_TR_16(s
, dstaddr
, cirrus_src16(s
, srcaddr
), transp
);
208 glue(glue(cirrus_bitblt_rop_bkwd_transp_
, ROP_NAME
),_16
)(CirrusVGAState
*s
,
217 uint16_t transp
= s
->vga
.gr
[0x34] | (uint16_t)s
->vga
.gr
[0x35] << 8;
218 dstpitch
+= bltwidth
;
219 srcpitch
+= bltwidth
;
220 for (y
= 0; y
< bltheight
; y
++) {
221 for (x
= 0; x
< bltwidth
; x
+=2) {
222 ROP_OP_TR_16(s
, dstaddr
- 1, cirrus_src16(s
, srcaddr
- 1), transp
);
232 #include "cirrus_vga_rop2.h"
235 #include "cirrus_vga_rop2.h"
238 #include "cirrus_vga_rop2.h"
241 #include "cirrus_vga_rop2.h"