Revision b30d4608 hw/cirrus_vga_rop2.h

b/hw/cirrus_vga_rop2.h
67 67
#elif DEPTH == 16
68 68
            col = ((uint16_t *)(src1 + pattern_x))[0];
69 69
            pattern_x = (pattern_x + 2) & 15;
70
#elif DEPTH == 24
71
            {
72
                const uint8_t *src2 = src1 + pattern_x * 3;
73
                col = src2[0] | (src2[1] << 8) | (src2[2] << 16);
74
                pattern_x = (pattern_x + 1) & 7;
75
            }
70 76
#else
71 77
            col = ((uint32_t *)(src1 + pattern_x))[0];
72 78
            pattern_x = (pattern_x + 4) & 31;
......
89 95
{
90 96
    uint8_t *d;
91 97
    int x, y;
92
    unsigned bits;
98
    unsigned bits, bits_xor;
93 99
    unsigned int col;
94 100
    unsigned bitmask;
95 101
    unsigned index;
96 102
    int srcskipleft = 0;
97 103

  
98
    col = s->cirrus_blt_fgcol;
104
    if (s->cirrus_blt_modeext & CIRRUS_BLTMODEEXT_COLOREXPINV) {
105
        bits_xor = 0xff;
106
        col = s->cirrus_blt_bgcol;
107
    } else {
108
        bits_xor = 0x00;
109
        col = s->cirrus_blt_fgcol;
110
    }
111

  
99 112
    for(y = 0; y < bltheight; y++) {
100 113
        bitmask = 0x80 >> srcskipleft;
101
        bits = *src++;
114
        bits = *src++ ^ bits_xor;
102 115
        d = dst;
103 116
        for (x = 0; x < bltwidth; x += (DEPTH / 8)) {
104 117
            if ((bitmask & 0xff) == 0) {
105 118
                bitmask = 0x80;
106
                bits = *src++;
119
                bits = *src++ ^ bits_xor;
107 120
            }
108 121
            index = (bits & bitmask);
109 122
            if (index) {
......
116 129
    }
117 130
}
118 131

  
119
/* NOTE: srcpitch is ignored */
120 132
static void
121
glue(glue(glue(cirrus_colorexpand_transp_inv_, ROP_NAME), _),DEPTH)
133
glue(glue(glue(cirrus_colorexpand_, ROP_NAME), _),DEPTH)
122 134
     (CirrusVGAState * s, uint8_t * dst,
123 135
      const uint8_t * src, 
124 136
      int dstpitch, int srcpitch, 
125 137
      int bltwidth, int bltheight)
126 138
{
139
    uint32_t colors[2];
127 140
    uint8_t *d;
128 141
    int x, y;
129 142
    unsigned bits;
130 143
    unsigned int col;
131 144
    unsigned bitmask;
132
    unsigned index;
133 145
    int srcskipleft = 0;
134 146

  
135
    col = s->cirrus_blt_bgcol;
147
    colors[0] = s->cirrus_blt_bgcol;
148
    colors[1] = s->cirrus_blt_fgcol;
136 149
    for(y = 0; y < bltheight; y++) {
137 150
        bitmask = 0x80 >> srcskipleft;
138 151
        bits = *src++;
......
142 155
                bitmask = 0x80;
143 156
                bits = *src++;
144 157
            }
145
            index = (bits & bitmask);
146
            if (!index) {
158
            col = colors[!!(bits & bitmask)];
159
            PUTPIXEL();
160
            d += (DEPTH / 8);
161
            bitmask >>= 1;
162
        }
163
        dst += dstpitch;
164
    }
165
}
166

  
167
static void
168
glue(glue(glue(cirrus_colorexpand_pattern_transp_, ROP_NAME), _),DEPTH)
169
     (CirrusVGAState * s, uint8_t * dst,
170
      const uint8_t * src, 
171
      int dstpitch, int srcpitch, 
172
      int bltwidth, int bltheight)
173
{
174
    uint8_t *d;
175
    int x, y, bitpos, pattern_y;
176
    unsigned int bits, bits_xor;
177
    unsigned int col;
178

  
179
    if (s->cirrus_blt_modeext & CIRRUS_BLTMODEEXT_COLOREXPINV) {
180
        bits_xor = 0xff;
181
        col = s->cirrus_blt_bgcol;
182
    } else {
183
        bits_xor = 0x00;
184
        col = s->cirrus_blt_fgcol;
185
    }
186
    pattern_y = s->cirrus_blt_srcaddr & 7;
187

  
188
    for(y = 0; y < bltheight; y++) {
189
        bits = src[pattern_y] ^ bits_xor;
190
        bitpos = 7;
191
        d = dst;
192
        for (x = 0; x < bltwidth; x += (DEPTH / 8)) {
193
            if ((bits >> bitpos) & 1) {
147 194
                PUTPIXEL();
148 195
            }
149 196
            d += (DEPTH / 8);
150
            bitmask >>= 1;
197
            bitpos = (bitpos - 1) & 7;
151 198
        }
199
        pattern_y = (pattern_y + 1) & 7;
152 200
        dst += dstpitch;
153 201
    }
154 202
}
155 203

  
156 204
static void
157
glue(glue(glue(cirrus_colorexpand_, ROP_NAME), _),DEPTH)
205
glue(glue(glue(cirrus_colorexpand_pattern_, ROP_NAME), _),DEPTH)
158 206
     (CirrusVGAState * s, uint8_t * dst,
159 207
      const uint8_t * src, 
160 208
      int dstpitch, int srcpitch, 
......
162 210
{
163 211
    uint32_t colors[2];
164 212
    uint8_t *d;
165
    int x, y;
166
    unsigned bits;
213
    int x, y, bitpos, pattern_y;
214
    unsigned int bits;
167 215
    unsigned int col;
168
    unsigned bitmask;
169
    int srcskipleft = 0;
170 216

  
171 217
    colors[0] = s->cirrus_blt_bgcol;
172 218
    colors[1] = s->cirrus_blt_fgcol;
219
    pattern_y = s->cirrus_blt_srcaddr & 7;
220

  
173 221
    for(y = 0; y < bltheight; y++) {
174
        bitmask = 0x80 >> srcskipleft;
175
        bits = *src++;
222
        bits = src[pattern_y];
223
        bitpos = 7;
176 224
        d = dst;
177 225
        for (x = 0; x < bltwidth; x += (DEPTH / 8)) {
178
            if ((bitmask & 0xff) == 0) {
179
                bitmask = 0x80;
180
                bits = *src++;
181
            }
182
            col = colors[!!(bits & bitmask)];
226
            col = colors[(bits >> bitpos) & 1];
183 227
            PUTPIXEL();
184 228
            d += (DEPTH / 8);
185
            bitmask >>= 1;
229
            bitpos = (bitpos - 1) & 7;
186 230
        }
231
        pattern_y = (pattern_y + 1) & 7;
187 232
        dst += dstpitch;
188 233
    }
189 234
}

Also available in: Unified diff