Statistics
| Branch: | Revision:

root / hw / cirrus_vga_rop.h @ e62b5b13

History | View | Annotate | Download (4.8 kB)

1 a5082316 bellard
/*
2 a5082316 bellard
 * QEMU Cirrus CLGD 54xx VGA Emulator.
3 5fafdf24 ths
 *
4 a5082316 bellard
 * Copyright (c) 2004 Fabrice Bellard
5 5fafdf24 ths
 *
6 a5082316 bellard
 * Permission is hereby granted, free of charge, to any person obtaining a copy
7 a5082316 bellard
 * of this software and associated documentation files (the "Software"), to deal
8 a5082316 bellard
 * in the Software without restriction, including without limitation the rights
9 a5082316 bellard
 * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
10 a5082316 bellard
 * copies of the Software, and to permit persons to whom the Software is
11 a5082316 bellard
 * furnished to do so, subject to the following conditions:
12 a5082316 bellard
 *
13 a5082316 bellard
 * The above copyright notice and this permission notice shall be included in
14 a5082316 bellard
 * all copies or substantial portions of the Software.
15 a5082316 bellard
 *
16 a5082316 bellard
 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
17 a5082316 bellard
 * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
18 a5082316 bellard
 * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
19 a5082316 bellard
 * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
20 a5082316 bellard
 * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
21 a5082316 bellard
 * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
22 a5082316 bellard
 * THE SOFTWARE.
23 a5082316 bellard
 */
24 a5082316 bellard
25 a5082316 bellard
static void
26 a5082316 bellard
glue(cirrus_bitblt_rop_fwd_, ROP_NAME)(CirrusVGAState *s,
27 a5082316 bellard
                             uint8_t *dst,const uint8_t *src,
28 a5082316 bellard
                             int dstpitch,int srcpitch,
29 a5082316 bellard
                             int bltwidth,int bltheight)
30 a5082316 bellard
{
31 a5082316 bellard
    int x,y;
32 a5082316 bellard
    dstpitch -= bltwidth;
33 a5082316 bellard
    srcpitch -= bltwidth;
34 a5082316 bellard
    for (y = 0; y < bltheight; y++) {
35 a5082316 bellard
        for (x = 0; x < bltwidth; x++) {
36 a5082316 bellard
            ROP_OP(*dst, *src);
37 a5082316 bellard
            dst++;
38 a5082316 bellard
            src++;
39 a5082316 bellard
        }
40 a5082316 bellard
        dst += dstpitch;
41 a5082316 bellard
        src += srcpitch;
42 a5082316 bellard
    }
43 a5082316 bellard
}
44 a5082316 bellard
45 a5082316 bellard
static void
46 a5082316 bellard
glue(cirrus_bitblt_rop_bkwd_, ROP_NAME)(CirrusVGAState *s,
47 a5082316 bellard
                                        uint8_t *dst,const uint8_t *src,
48 a5082316 bellard
                                        int dstpitch,int srcpitch,
49 a5082316 bellard
                                        int bltwidth,int bltheight)
50 a5082316 bellard
{
51 a5082316 bellard
    int x,y;
52 a5082316 bellard
    dstpitch += bltwidth;
53 a5082316 bellard
    srcpitch += bltwidth;
54 a5082316 bellard
    for (y = 0; y < bltheight; y++) {
55 a5082316 bellard
        for (x = 0; x < bltwidth; x++) {
56 a5082316 bellard
            ROP_OP(*dst, *src);
57 a5082316 bellard
            dst--;
58 a5082316 bellard
            src--;
59 a5082316 bellard
        }
60 a5082316 bellard
        dst += dstpitch;
61 a5082316 bellard
        src += srcpitch;
62 a5082316 bellard
    }
63 a5082316 bellard
}
64 a5082316 bellard
65 96cf2df8 ths
static void
66 96cf2df8 ths
glue(glue(cirrus_bitblt_rop_fwd_transp_, ROP_NAME),_8)(CirrusVGAState *s,
67 96cf2df8 ths
                                                       uint8_t *dst,const uint8_t *src,
68 96cf2df8 ths
                                                       int dstpitch,int srcpitch,
69 96cf2df8 ths
                                                       int bltwidth,int bltheight)
70 96cf2df8 ths
{
71 96cf2df8 ths
    int x,y;
72 96cf2df8 ths
    uint8_t p;
73 96cf2df8 ths
    dstpitch -= bltwidth;
74 96cf2df8 ths
    srcpitch -= bltwidth;
75 96cf2df8 ths
    for (y = 0; y < bltheight; y++) {
76 96cf2df8 ths
        for (x = 0; x < bltwidth; x++) {
77 96cf2df8 ths
            p = *dst;
78 96cf2df8 ths
            ROP_OP(p, *src);
79 96cf2df8 ths
            if (p != s->gr[0x34]) *dst = p;
80 96cf2df8 ths
            dst++;
81 96cf2df8 ths
            src++;
82 96cf2df8 ths
        }
83 96cf2df8 ths
        dst += dstpitch;
84 96cf2df8 ths
        src += srcpitch;
85 96cf2df8 ths
    }
86 96cf2df8 ths
}
87 96cf2df8 ths
88 96cf2df8 ths
static void
89 96cf2df8 ths
glue(glue(cirrus_bitblt_rop_bkwd_transp_, ROP_NAME),_8)(CirrusVGAState *s,
90 96cf2df8 ths
                                                        uint8_t *dst,const uint8_t *src,
91 96cf2df8 ths
                                                        int dstpitch,int srcpitch,
92 96cf2df8 ths
                                                        int bltwidth,int bltheight)
93 96cf2df8 ths
{
94 96cf2df8 ths
    int x,y;
95 96cf2df8 ths
    uint8_t p;
96 96cf2df8 ths
    dstpitch += bltwidth;
97 96cf2df8 ths
    srcpitch += bltwidth;
98 96cf2df8 ths
    for (y = 0; y < bltheight; y++) {
99 96cf2df8 ths
        for (x = 0; x < bltwidth; x++) {
100 96cf2df8 ths
            p = *dst;
101 96cf2df8 ths
            ROP_OP(p, *src);
102 96cf2df8 ths
            if (p != s->gr[0x34]) *dst = p;
103 96cf2df8 ths
            dst--;
104 96cf2df8 ths
            src--;
105 96cf2df8 ths
        }
106 96cf2df8 ths
        dst += dstpitch;
107 96cf2df8 ths
        src += srcpitch;
108 96cf2df8 ths
    }
109 96cf2df8 ths
}
110 96cf2df8 ths
111 96cf2df8 ths
static void
112 96cf2df8 ths
glue(glue(cirrus_bitblt_rop_fwd_transp_, ROP_NAME),_16)(CirrusVGAState *s,
113 96cf2df8 ths
                                                        uint8_t *dst,const uint8_t *src,
114 96cf2df8 ths
                                                        int dstpitch,int srcpitch,
115 96cf2df8 ths
                                                        int bltwidth,int bltheight)
116 96cf2df8 ths
{
117 96cf2df8 ths
    int x,y;
118 96cf2df8 ths
    uint8_t p1, p2;
119 96cf2df8 ths
    dstpitch -= bltwidth;
120 96cf2df8 ths
    srcpitch -= bltwidth;
121 96cf2df8 ths
    for (y = 0; y < bltheight; y++) {
122 96cf2df8 ths
        for (x = 0; x < bltwidth; x+=2) {
123 96cf2df8 ths
            p1 = *dst;
124 96cf2df8 ths
            p2 = *(dst+1);
125 96cf2df8 ths
            ROP_OP(p1, *src);
126 96cf2df8 ths
            ROP_OP(p2, *(src+1));
127 96cf2df8 ths
            if ((p1 != s->gr[0x34]) || (p2 != s->gr[0x35])) {
128 96cf2df8 ths
                *dst = p1;
129 96cf2df8 ths
                *(dst+1) = p2;
130 96cf2df8 ths
            }
131 96cf2df8 ths
            dst+=2;
132 96cf2df8 ths
            src+=2;
133 96cf2df8 ths
        }
134 96cf2df8 ths
        dst += dstpitch;
135 96cf2df8 ths
        src += srcpitch;
136 96cf2df8 ths
    }
137 96cf2df8 ths
}
138 96cf2df8 ths
139 96cf2df8 ths
static void
140 96cf2df8 ths
glue(glue(cirrus_bitblt_rop_bkwd_transp_, ROP_NAME),_16)(CirrusVGAState *s,
141 96cf2df8 ths
                                                         uint8_t *dst,const uint8_t *src,
142 96cf2df8 ths
                                                         int dstpitch,int srcpitch,
143 96cf2df8 ths
                                                         int bltwidth,int bltheight)
144 96cf2df8 ths
{
145 96cf2df8 ths
    int x,y;
146 96cf2df8 ths
    uint8_t p1, p2;
147 96cf2df8 ths
    dstpitch += bltwidth;
148 96cf2df8 ths
    srcpitch += bltwidth;
149 96cf2df8 ths
    for (y = 0; y < bltheight; y++) {
150 96cf2df8 ths
        for (x = 0; x < bltwidth; x+=2) {
151 96cf2df8 ths
            p1 = *(dst-1);
152 96cf2df8 ths
            p2 = *dst;
153 96cf2df8 ths
            ROP_OP(p1, *(src-1));
154 96cf2df8 ths
            ROP_OP(p2, *src);
155 96cf2df8 ths
            if ((p1 != s->gr[0x34]) || (p2 != s->gr[0x35])) {
156 96cf2df8 ths
                *(dst-1) = p1;
157 96cf2df8 ths
                *dst = p2;
158 96cf2df8 ths
            }
159 96cf2df8 ths
            dst-=2;
160 96cf2df8 ths
            src-=2;
161 96cf2df8 ths
        }
162 96cf2df8 ths
        dst += dstpitch;
163 96cf2df8 ths
        src += srcpitch;
164 96cf2df8 ths
    }
165 96cf2df8 ths
}
166 96cf2df8 ths
167 a5082316 bellard
#define DEPTH 8
168 a5082316 bellard
#include "cirrus_vga_rop2.h"
169 a5082316 bellard
170 a5082316 bellard
#define DEPTH 16
171 a5082316 bellard
#include "cirrus_vga_rop2.h"
172 a5082316 bellard
173 a5082316 bellard
#define DEPTH 24
174 a5082316 bellard
#include "cirrus_vga_rop2.h"
175 a5082316 bellard
176 a5082316 bellard
#define DEPTH 32
177 a5082316 bellard
#include "cirrus_vga_rop2.h"
178 a5082316 bellard
179 a5082316 bellard
#undef ROP_NAME
180 a5082316 bellard
#undef ROP_OP