exec: remove ram_addr argument from qemu_ram_block_from_host
[qemu.git] / hw / display / cirrus_vga_rop.h
blob0925a009fefd958d4c893a5f4c99e0d63075dd45
1 /*
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
22 * THE SOFTWARE.
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)
43 #undef ROP_FN
45 static void
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)
51 int x,y;
52 dstpitch -= bltwidth;
53 srcpitch -= bltwidth;
55 if (bltheight > 1 && (dstpitch < 0 || srcpitch < 0)) {
56 return;
59 for (y = 0; y < bltheight; y++) {
60 for (x = 0; x < bltwidth; x++) {
61 ROP_OP(dst, *src);
62 dst++;
63 src++;
65 dst += dstpitch;
66 src += srcpitch;
70 static void
71 glue(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)
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--;
85 dst += dstpitch;
86 src += srcpitch;
90 static void
91 glue(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)
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++;
108 dst += dstpitch;
109 src += srcpitch;
113 static void
114 glue(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)
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--;
131 dst += dstpitch;
132 src += srcpitch;
136 static void
137 glue(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)
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;
156 dst+=2;
157 src+=2;
159 dst += dstpitch;
160 src += srcpitch;
164 static void
165 glue(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)
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;
184 dst-=2;
185 src-=2;
187 dst += dstpitch;
188 src += srcpitch;
192 #define DEPTH 8
193 #include "cirrus_vga_rop2.h"
195 #define DEPTH 16
196 #include "cirrus_vga_rop2.h"
198 #define DEPTH 24
199 #include "cirrus_vga_rop2.h"
201 #define DEPTH 32
202 #include "cirrus_vga_rop2.h"
204 #undef ROP_NAME
205 #undef ROP_OP
206 #undef ROP_OP_16
207 #undef ROP_OP_32