00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00024
00025 #if DEPTH == 8
00026 #define PUTPIXEL() ROP_OP(d[0], col)
00027 #elif DEPTH == 16
00028 #define PUTPIXEL() ROP_OP(((uint16_t *)d)[0], col);
00029 #elif DEPTH == 24
00030 #define PUTPIXEL() ROP_OP(d[0], col); \
00031 ROP_OP(d[1], (col >> 8)); \
00032 ROP_OP(d[2], (col >> 16))
00033 #elif DEPTH == 32
00034 #define PUTPIXEL() ROP_OP(((uint32_t *)d)[0], col)
00035 #else
00036 #error unsupported DEPTH
00037 #endif
00038
00039 static void
00040 glue(glue(glue(cirrus_patternfill_, ROP_NAME), _),DEPTH)
00041 (CirrusVGAState * s, uint8_t * dst,
00042 const uint8_t * src,
00043 int dstpitch, int srcpitch,
00044 int bltwidth, int bltheight)
00045 {
00046 uint8_t *d;
00047 int x, y, pattern_y, pattern_pitch, pattern_x;
00048 unsigned int col;
00049 const uint8_t *src1;
00050 #if DEPTH == 24
00051 int skipleft = s->gr[0x2f] & 0x1f;
00052 #else
00053 int skipleft = (s->gr[0x2f] & 0x07) * (DEPTH / 8);
00054 #endif
00055
00056 #if DEPTH == 8
00057 pattern_pitch = 8;
00058 #elif DEPTH == 16
00059 pattern_pitch = 16;
00060 #else
00061 pattern_pitch = 32;
00062 #endif
00063 pattern_y = s->cirrus_blt_srcaddr & 7;
00064 for(y = 0; y < bltheight; y++) {
00065 pattern_x = skipleft;
00066 d = dst + skipleft;
00067 src1 = src + pattern_y * pattern_pitch;
00068 for (x = skipleft; x < bltwidth; x += (DEPTH / 8)) {
00069 #if DEPTH == 8
00070 col = src1[pattern_x];
00071 pattern_x = (pattern_x + 1) & 7;
00072 #elif DEPTH == 16
00073 col = ((uint16_t *)(src1 + pattern_x))[0];
00074 pattern_x = (pattern_x + 2) & 15;
00075 #elif DEPTH == 24
00076 {
00077 const uint8_t *src2 = src1 + pattern_x * 3;
00078 col = src2[0] | (src2[1] << 8) | (src2[2] << 16);
00079 pattern_x = (pattern_x + 1) & 7;
00080 }
00081 #else
00082 col = ((uint32_t *)(src1 + pattern_x))[0];
00083 pattern_x = (pattern_x + 4) & 31;
00084 #endif
00085 PUTPIXEL();
00086 d += (DEPTH / 8);
00087 }
00088 pattern_y = (pattern_y + 1) & 7;
00089 dst += dstpitch;
00090 }
00091 }
00092
00093
00094 static void
00095 glue(glue(glue(cirrus_colorexpand_transp_, ROP_NAME), _),DEPTH)
00096 (CirrusVGAState * s, uint8_t * dst,
00097 const uint8_t * src,
00098 int dstpitch, int srcpitch,
00099 int bltwidth, int bltheight)
00100 {
00101 uint8_t *d;
00102 int x, y;
00103 unsigned bits, bits_xor;
00104 unsigned int col;
00105 unsigned bitmask;
00106 unsigned index;
00107 #if DEPTH == 24
00108 int dstskipleft = s->gr[0x2f] & 0x1f;
00109 int srcskipleft = dstskipleft / 3;
00110 #else
00111 int srcskipleft = s->gr[0x2f] & 0x07;
00112 int dstskipleft = srcskipleft * (DEPTH / 8);
00113 #endif
00114
00115 if (s->cirrus_blt_modeext & CIRRUS_BLTMODEEXT_COLOREXPINV) {
00116 bits_xor = 0xff;
00117 col = s->cirrus_blt_bgcol;
00118 } else {
00119 bits_xor = 0x00;
00120 col = s->cirrus_blt_fgcol;
00121 }
00122
00123 for(y = 0; y < bltheight; y++) {
00124 bitmask = 0x80 >> srcskipleft;
00125 bits = *src++ ^ bits_xor;
00126 d = dst + dstskipleft;
00127 for (x = dstskipleft; x < bltwidth; x += (DEPTH / 8)) {
00128 if ((bitmask & 0xff) == 0) {
00129 bitmask = 0x80;
00130 bits = *src++ ^ bits_xor;
00131 }
00132 index = (bits & bitmask);
00133 if (index) {
00134 PUTPIXEL();
00135 }
00136 d += (DEPTH / 8);
00137 bitmask >>= 1;
00138 }
00139 dst += dstpitch;
00140 }
00141 }
00142
00143 static void
00144 glue(glue(glue(cirrus_colorexpand_, ROP_NAME), _),DEPTH)
00145 (CirrusVGAState * s, uint8_t * dst,
00146 const uint8_t * src,
00147 int dstpitch, int srcpitch,
00148 int bltwidth, int bltheight)
00149 {
00150 uint32_t colors[2];
00151 uint8_t *d;
00152 int x, y;
00153 unsigned bits;
00154 unsigned int col;
00155 unsigned bitmask;
00156 int srcskipleft = s->gr[0x2f] & 0x07;
00157 int dstskipleft = srcskipleft * (DEPTH / 8);
00158
00159 colors[0] = s->cirrus_blt_bgcol;
00160 colors[1] = s->cirrus_blt_fgcol;
00161 for(y = 0; y < bltheight; y++) {
00162 bitmask = 0x80 >> srcskipleft;
00163 bits = *src++;
00164 d = dst + dstskipleft;
00165 for (x = dstskipleft; x < bltwidth; x += (DEPTH / 8)) {
00166 if ((bitmask & 0xff) == 0) {
00167 bitmask = 0x80;
00168 bits = *src++;
00169 }
00170 col = colors[!!(bits & bitmask)];
00171 PUTPIXEL();
00172 d += (DEPTH / 8);
00173 bitmask >>= 1;
00174 }
00175 dst += dstpitch;
00176 }
00177 }
00178
00179 static void
00180 glue(glue(glue(cirrus_colorexpand_pattern_transp_, ROP_NAME), _),DEPTH)
00181 (CirrusVGAState * s, uint8_t * dst,
00182 const uint8_t * src,
00183 int dstpitch, int srcpitch,
00184 int bltwidth, int bltheight)
00185 {
00186 uint8_t *d;
00187 int x, y, bitpos, pattern_y;
00188 unsigned int bits, bits_xor;
00189 unsigned int col;
00190 #if DEPTH == 24
00191 int dstskipleft = s->gr[0x2f] & 0x1f;
00192 int srcskipleft = dstskipleft / 3;
00193 #else
00194 int srcskipleft = s->gr[0x2f] & 0x07;
00195 int dstskipleft = srcskipleft * (DEPTH / 8);
00196 #endif
00197
00198 if (s->cirrus_blt_modeext & CIRRUS_BLTMODEEXT_COLOREXPINV) {
00199 bits_xor = 0xff;
00200 col = s->cirrus_blt_bgcol;
00201 } else {
00202 bits_xor = 0x00;
00203 col = s->cirrus_blt_fgcol;
00204 }
00205 pattern_y = s->cirrus_blt_srcaddr & 7;
00206
00207 for(y = 0; y < bltheight; y++) {
00208 bits = src[pattern_y] ^ bits_xor;
00209 bitpos = 7 - srcskipleft;
00210 d = dst + dstskipleft;
00211 for (x = dstskipleft; x < bltwidth; x += (DEPTH / 8)) {
00212 if ((bits >> bitpos) & 1) {
00213 PUTPIXEL();
00214 }
00215 d += (DEPTH / 8);
00216 bitpos = (bitpos - 1) & 7;
00217 }
00218 pattern_y = (pattern_y + 1) & 7;
00219 dst += dstpitch;
00220 }
00221 }
00222
00223 static void
00224 glue(glue(glue(cirrus_colorexpand_pattern_, ROP_NAME), _),DEPTH)
00225 (CirrusVGAState * s, uint8_t * dst,
00226 const uint8_t * src,
00227 int dstpitch, int srcpitch,
00228 int bltwidth, int bltheight)
00229 {
00230 uint32_t colors[2];
00231 uint8_t *d;
00232 int x, y, bitpos, pattern_y;
00233 unsigned int bits;
00234 unsigned int col;
00235 int srcskipleft = s->gr[0x2f] & 0x07;
00236 int dstskipleft = srcskipleft * (DEPTH / 8);
00237
00238 colors[0] = s->cirrus_blt_bgcol;
00239 colors[1] = s->cirrus_blt_fgcol;
00240 pattern_y = s->cirrus_blt_srcaddr & 7;
00241
00242 for(y = 0; y < bltheight; y++) {
00243 bits = src[pattern_y];
00244 bitpos = 7 - srcskipleft;
00245 d = dst + dstskipleft;
00246 for (x = dstskipleft; x < bltwidth; x += (DEPTH / 8)) {
00247 col = colors[(bits >> bitpos) & 1];
00248 PUTPIXEL();
00249 d += (DEPTH / 8);
00250 bitpos = (bitpos - 1) & 7;
00251 }
00252 pattern_y = (pattern_y + 1) & 7;
00253 dst += dstpitch;
00254 }
00255 }
00256
00257 static void
00258 glue(glue(glue(cirrus_fill_, ROP_NAME), _),DEPTH)
00259 (CirrusVGAState *s,
00260 uint8_t *dst, int dst_pitch,
00261 int width, int height)
00262 {
00263 uint8_t *d, *d1;
00264 uint32_t col;
00265 int x, y;
00266
00267 col = s->cirrus_blt_fgcol;
00268
00269 d1 = dst;
00270 for(y = 0; y < height; y++) {
00271 d = d1;
00272 for(x = 0; x < width; x += (DEPTH / 8)) {
00273 PUTPIXEL();
00274 d += (DEPTH / 8);
00275 }
00276 d1 += dst_pitch;
00277 }
00278 }
00279
00280 #undef DEPTH
00281 #undef PUTPIXEL