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)(uint8_t *dst, uint8_t src)
27 *dst = ROP_FN(*dst, src);
30 static inline void glue(rop_16_,ROP_NAME)(uint16_t *dst, uint16_t src)
32 *dst = ROP_FN(*dst, src);
35 static inline void glue(rop_32_,ROP_NAME)(uint32_t *dst, uint32_t src)
37 *dst = ROP_FN(*dst, src);
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)
46 glue(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)
55 if (dstpitch < 0 || srcpitch < 0) {
56 /* is 0 valid? srcpitch == 0 could be useful */
60 for (y = 0; y < bltheight; y++) {
61 for (x = 0; x < bltwidth; x++) {
72 glue(cirrus_bitblt_rop_bkwd_, ROP_NAME)(CirrusVGAState *s,
73 uint8_t *dst,const uint8_t *src,
74 int dstpitch,int srcpitch,
75 int bltwidth,int bltheight)
80 for (y = 0; y < bltheight; y++) {
81 for (x = 0; x < bltwidth; x++) {
92 glue(glue(cirrus_bitblt_rop_fwd_transp_, ROP_NAME),_8)(CirrusVGAState *s,
93 uint8_t *dst,const uint8_t *src,
94 int dstpitch,int srcpitch,
95 int bltwidth,int bltheight)
100 srcpitch -= bltwidth;
101 for (y = 0; y < bltheight; y++) {
102 for (x = 0; x < bltwidth; x++) {
105 if (p != s->vga.gr[0x34]) *dst = p;
115 glue(glue(cirrus_bitblt_rop_bkwd_transp_, ROP_NAME),_8)(CirrusVGAState *s,
116 uint8_t *dst,const uint8_t *src,
117 int dstpitch,int srcpitch,
118 int bltwidth,int bltheight)
122 dstpitch += bltwidth;
123 srcpitch += bltwidth;
124 for (y = 0; y < bltheight; y++) {
125 for (x = 0; x < bltwidth; x++) {
128 if (p != s->vga.gr[0x34]) *dst = p;
138 glue(glue(cirrus_bitblt_rop_fwd_transp_, ROP_NAME),_16)(CirrusVGAState *s,
139 uint8_t *dst,const uint8_t *src,
140 int dstpitch,int srcpitch,
141 int bltwidth,int bltheight)
145 dstpitch -= bltwidth;
146 srcpitch -= bltwidth;
147 for (y = 0; y < bltheight; y++) {
148 for (x = 0; x < bltwidth; x+=2) {
152 ROP_OP(&p2, *(src + 1));
153 if ((p1 != s->vga.gr[0x34]) || (p2 != s->vga.gr[0x35])) {
166 glue(glue(cirrus_bitblt_rop_bkwd_transp_, ROP_NAME),_16)(CirrusVGAState *s,
167 uint8_t *dst,const uint8_t *src,
168 int dstpitch,int srcpitch,
169 int bltwidth,int bltheight)
173 dstpitch += bltwidth;
174 srcpitch += bltwidth;
175 for (y = 0; y < bltheight; y++) {
176 for (x = 0; x < bltwidth; x+=2) {
179 ROP_OP(&p1, *(src - 1));
181 if ((p1 != s->vga.gr[0x34]) || (p2 != s->vga.gr[0x35])) {
194 #include "cirrus_vga_rop2.h"
197 #include "cirrus_vga_rop2.h"
200 #include "cirrus_vga_rop2.h"
203 #include "cirrus_vga_rop2.h"