diff options
author | bellard <bellard@c046a42c-6fe2-441c-8c8c-71466251a162> | 2004-07-06 01:50:49 +0000 |
---|---|---|
committer | bellard <bellard@c046a42c-6fe2-441c-8c8c-71466251a162> | 2004-07-06 01:50:49 +0000 |
commit | b30d4608dae994cf57cab4824f3307de026fd373 (patch) | |
tree | ab3606f5f3fa32ca982b61828e38447c2e3d62c4 /hw | |
parent | 81ca79911ae0ade4b802331f18623c0eed1891ef (diff) |
24 bpp fixes
git-svn-id: svn://svn.savannah.nongnu.org/qemu/trunk@984 c046a42c-6fe2-441c-8c8c-71466251a162
Diffstat (limited to 'hw')
-rw-r--r-- | hw/cirrus_vga.c | 105 | ||||
-rw-r--r-- | hw/cirrus_vga_rop2.h | 93 |
2 files changed, 129 insertions, 69 deletions
diff --git a/hw/cirrus_vga.c b/hw/cirrus_vga.c index 8ec63d3c2c..d354fadd25 100644 --- a/hw/cirrus_vga.c +++ b/hw/cirrus_vga.c @@ -456,25 +456,6 @@ static const cirrus_bitblt_rop_t cirrus_colorexpand_transp[16][4] = { ROP2(cirrus_colorexpand_transp_notsrc_and_notdst), }; -static const cirrus_bitblt_rop_t cirrus_colorexpand_transp_inv[16][4] = { - ROP2(cirrus_colorexpand_transp_inv_0), - ROP2(cirrus_colorexpand_transp_inv_src_and_dst), - ROP_NOP2(cirrus_bitblt_rop_nop), - ROP2(cirrus_colorexpand_transp_inv_src_and_notdst), - ROP2(cirrus_colorexpand_transp_inv_notdst), - ROP2(cirrus_colorexpand_transp_inv_src), - ROP2(cirrus_colorexpand_transp_inv_1), - ROP2(cirrus_colorexpand_transp_inv_notsrc_and_dst), - ROP2(cirrus_colorexpand_transp_inv_src_xor_dst), - ROP2(cirrus_colorexpand_transp_inv_src_or_dst), - ROP2(cirrus_colorexpand_transp_inv_notsrc_or_notdst), - ROP2(cirrus_colorexpand_transp_inv_src_notxor_dst), - ROP2(cirrus_colorexpand_transp_inv_src_or_notdst), - ROP2(cirrus_colorexpand_transp_inv_notsrc), - ROP2(cirrus_colorexpand_transp_inv_notsrc_or_dst), - ROP2(cirrus_colorexpand_transp_inv_notsrc_and_notdst), -}; - static const cirrus_bitblt_rop_t cirrus_colorexpand[16][4] = { ROP2(cirrus_colorexpand_0), ROP2(cirrus_colorexpand_src_and_dst), @@ -494,6 +475,44 @@ static const cirrus_bitblt_rop_t cirrus_colorexpand[16][4] = { ROP2(cirrus_colorexpand_notsrc_and_notdst), }; +static const cirrus_bitblt_rop_t cirrus_colorexpand_pattern_transp[16][4] = { + ROP2(cirrus_colorexpand_pattern_transp_0), + ROP2(cirrus_colorexpand_pattern_transp_src_and_dst), + ROP_NOP2(cirrus_bitblt_rop_nop), + ROP2(cirrus_colorexpand_pattern_transp_src_and_notdst), + ROP2(cirrus_colorexpand_pattern_transp_notdst), + ROP2(cirrus_colorexpand_pattern_transp_src), + ROP2(cirrus_colorexpand_pattern_transp_1), + ROP2(cirrus_colorexpand_pattern_transp_notsrc_and_dst), + ROP2(cirrus_colorexpand_pattern_transp_src_xor_dst), + ROP2(cirrus_colorexpand_pattern_transp_src_or_dst), + ROP2(cirrus_colorexpand_pattern_transp_notsrc_or_notdst), + ROP2(cirrus_colorexpand_pattern_transp_src_notxor_dst), + ROP2(cirrus_colorexpand_pattern_transp_src_or_notdst), + ROP2(cirrus_colorexpand_pattern_transp_notsrc), + ROP2(cirrus_colorexpand_pattern_transp_notsrc_or_dst), + ROP2(cirrus_colorexpand_pattern_transp_notsrc_and_notdst), +}; + +static const cirrus_bitblt_rop_t cirrus_colorexpand_pattern[16][4] = { + ROP2(cirrus_colorexpand_pattern_0), + ROP2(cirrus_colorexpand_pattern_src_and_dst), + ROP_NOP2(cirrus_bitblt_rop_nop), + ROP2(cirrus_colorexpand_pattern_src_and_notdst), + ROP2(cirrus_colorexpand_pattern_notdst), + ROP2(cirrus_colorexpand_pattern_src), + ROP2(cirrus_colorexpand_pattern_1), + ROP2(cirrus_colorexpand_pattern_notsrc_and_dst), + ROP2(cirrus_colorexpand_pattern_src_xor_dst), + ROP2(cirrus_colorexpand_pattern_src_or_dst), + ROP2(cirrus_colorexpand_pattern_notsrc_or_notdst), + ROP2(cirrus_colorexpand_pattern_src_notxor_dst), + ROP2(cirrus_colorexpand_pattern_src_or_notdst), + ROP2(cirrus_colorexpand_pattern_notsrc), + ROP2(cirrus_colorexpand_pattern_notsrc_or_dst), + ROP2(cirrus_colorexpand_pattern_notsrc_and_notdst), +}; + static const cirrus_fill_t cirrus_fill[16][4] = { ROP2(cirrus_fill_0), ROP2(cirrus_fill_src_and_dst), @@ -584,27 +603,8 @@ static void cirrus_invalidate_region(CirrusVGAState * s, int off_begin, static int cirrus_bitblt_common_patterncopy(CirrusVGAState * s, const uint8_t * src) { - uint8_t work_colorexp[256]; uint8_t *dst; - int patternbytes = s->cirrus_blt_pixelwidth * 8; - if (s->cirrus_blt_mode & CIRRUS_BLTMODE_COLOREXPAND) { - cirrus_bitblt_rop_t rop_func; - cirrus_bitblt_fgcol(s); - cirrus_bitblt_bgcol(s); - rop_func = cirrus_colorexpand[CIRRUS_ROP_SRC_INDEX][s->cirrus_blt_pixelwidth - 1]; - rop_func(s, work_colorexp, src, patternbytes, 1, patternbytes, 8); - src = work_colorexp; - s->cirrus_blt_mode &= ~CIRRUS_BLTMODE_COLOREXPAND; - } - if (s->cirrus_blt_mode & ~CIRRUS_BLTMODE_PATTERNCOPY) { -#ifdef DEBUG_BITBLT - printf("cirrus: blt mode %02x (pattercopy) - unimplemented\n", - s->cirrus_blt_mode); -#endif - return 0; - } - dst = s->vram_ptr + s->cirrus_blt_dstaddr; (*s->cirrus_rop) (s, dst, src, s->cirrus_blt_dstpitch, 0, @@ -728,6 +728,7 @@ static int cirrus_bitblt_cputovideo(CirrusVGAState * s) if (s->cirrus_blt_mode & CIRRUS_BLTMODE_COLOREXPAND) { s->cirrus_blt_srcpitch = 8; } else { + /* XXX: check for 24 bpp */ s->cirrus_blt_srcpitch = 8 * 8 * s->cirrus_blt_pixelwidth; } s->cirrus_srccounter = s->cirrus_blt_srcpitch; @@ -848,20 +849,32 @@ static void cirrus_bitblt_start(CirrusVGAState * s) CIRRUS_BLTMODE_COLOREXPAND) { if (s->cirrus_blt_mode & CIRRUS_BLTMODE_TRANSPARENTCOMP) { - if (s->cirrus_blt_modeext & CIRRUS_BLTMODEEXT_COLOREXPINV) { + if (s->cirrus_blt_modeext & CIRRUS_BLTMODEEXT_COLOREXPINV) cirrus_bitblt_bgcol(s); - s->cirrus_rop = cirrus_colorexpand_transp_inv[rop_to_index[blt_rop]][s->cirrus_blt_pixelwidth - 1]; - } else { + else cirrus_bitblt_fgcol(s); - s->cirrus_rop = cirrus_colorexpand_transp[rop_to_index[blt_rop]][s->cirrus_blt_pixelwidth - 1]; - } + s->cirrus_rop = cirrus_colorexpand_transp[rop_to_index[blt_rop]][s->cirrus_blt_pixelwidth - 1]; } else { cirrus_bitblt_fgcol(s); cirrus_bitblt_bgcol(s); s->cirrus_rop = cirrus_colorexpand[rop_to_index[blt_rop]][s->cirrus_blt_pixelwidth - 1]; } } else if (s->cirrus_blt_mode & CIRRUS_BLTMODE_PATTERNCOPY) { - s->cirrus_rop = cirrus_patternfill[rop_to_index[blt_rop]][s->cirrus_blt_pixelwidth - 1]; + if (s->cirrus_blt_mode & CIRRUS_BLTMODE_COLOREXPAND) { + if (s->cirrus_blt_mode & CIRRUS_BLTMODE_TRANSPARENTCOMP) { + if (s->cirrus_blt_modeext & CIRRUS_BLTMODEEXT_COLOREXPINV) + cirrus_bitblt_bgcol(s); + else + cirrus_bitblt_fgcol(s); + s->cirrus_rop = cirrus_colorexpand_pattern_transp[rop_to_index[blt_rop]][s->cirrus_blt_pixelwidth - 1]; + } else { + cirrus_bitblt_fgcol(s); + cirrus_bitblt_bgcol(s); + s->cirrus_rop = cirrus_colorexpand_pattern[rop_to_index[blt_rop]][s->cirrus_blt_pixelwidth - 1]; + } + } else { + s->cirrus_rop = cirrus_patternfill[rop_to_index[blt_rop]][s->cirrus_blt_pixelwidth - 1]; + } } else { if (s->cirrus_blt_mode & CIRRUS_BLTMODE_BACKWARDS) { s->cirrus_blt_dstpitch = -s->cirrus_blt_dstpitch; @@ -2793,9 +2806,10 @@ static void cirrus_init_common(CirrusVGAState * s, int device_id, int is_pci) vga_io_memory); s->sr[0x06] = 0x0f; - s->sr[0x1F] = 0x22; // MemClock if (device_id == CIRRUS_ID_CLGD5446) { /* 4MB 64 bit memory config, always PCI */ + s->sr[0x1F] = 0x2d; // MemClock + s->gr[0x18] = 0x0f; // fastest memory configuration #if 1 s->sr[0x0f] = 0x98; s->sr[0x17] = 0x20; @@ -2808,6 +2822,7 @@ static void cirrus_init_common(CirrusVGAState * s, int device_id, int is_pci) s->real_vram_size = 2048 * 1024; #endif } else { + s->sr[0x1F] = 0x22; // MemClock s->sr[0x0F] = CIRRUS_MEMSIZE_2M; if (is_pci) s->sr[0x17] = CIRRUS_BUSTYPE_PCI; diff --git a/hw/cirrus_vga_rop2.h b/hw/cirrus_vga_rop2.h index 540e308e89..5521870c8b 100644 --- a/hw/cirrus_vga_rop2.h +++ b/hw/cirrus_vga_rop2.h @@ -67,6 +67,12 @@ glue(glue(glue(cirrus_patternfill_, ROP_NAME), _),DEPTH) #elif DEPTH == 16 col = ((uint16_t *)(src1 + pattern_x))[0]; pattern_x = (pattern_x + 2) & 15; +#elif DEPTH == 24 + { + const uint8_t *src2 = src1 + pattern_x * 3; + col = src2[0] | (src2[1] << 8) | (src2[2] << 16); + pattern_x = (pattern_x + 1) & 7; + } #else col = ((uint32_t *)(src1 + pattern_x))[0]; pattern_x = (pattern_x + 4) & 31; @@ -89,21 +95,28 @@ glue(glue(glue(cirrus_colorexpand_transp_, ROP_NAME), _),DEPTH) { uint8_t *d; int x, y; - unsigned bits; + unsigned bits, bits_xor; unsigned int col; unsigned bitmask; unsigned index; int srcskipleft = 0; - col = s->cirrus_blt_fgcol; + if (s->cirrus_blt_modeext & CIRRUS_BLTMODEEXT_COLOREXPINV) { + bits_xor = 0xff; + col = s->cirrus_blt_bgcol; + } else { + bits_xor = 0x00; + col = s->cirrus_blt_fgcol; + } + for(y = 0; y < bltheight; y++) { bitmask = 0x80 >> srcskipleft; - bits = *src++; + bits = *src++ ^ bits_xor; d = dst; for (x = 0; x < bltwidth; x += (DEPTH / 8)) { if ((bitmask & 0xff) == 0) { bitmask = 0x80; - bits = *src++; + bits = *src++ ^ bits_xor; } index = (bits & bitmask); if (index) { @@ -116,23 +129,23 @@ glue(glue(glue(cirrus_colorexpand_transp_, ROP_NAME), _),DEPTH) } } -/* NOTE: srcpitch is ignored */ static void -glue(glue(glue(cirrus_colorexpand_transp_inv_, ROP_NAME), _),DEPTH) +glue(glue(glue(cirrus_colorexpand_, ROP_NAME), _),DEPTH) (CirrusVGAState * s, uint8_t * dst, const uint8_t * src, int dstpitch, int srcpitch, int bltwidth, int bltheight) { + uint32_t colors[2]; uint8_t *d; int x, y; unsigned bits; unsigned int col; unsigned bitmask; - unsigned index; int srcskipleft = 0; - col = s->cirrus_blt_bgcol; + colors[0] = s->cirrus_blt_bgcol; + colors[1] = s->cirrus_blt_fgcol; for(y = 0; y < bltheight; y++) { bitmask = 0x80 >> srcskipleft; bits = *src++; @@ -142,19 +155,54 @@ glue(glue(glue(cirrus_colorexpand_transp_inv_, ROP_NAME), _),DEPTH) bitmask = 0x80; bits = *src++; } - index = (bits & bitmask); - if (!index) { + col = colors[!!(bits & bitmask)]; + PUTPIXEL(); + d += (DEPTH / 8); + bitmask >>= 1; + } + dst += dstpitch; + } +} + +static void +glue(glue(glue(cirrus_colorexpand_pattern_transp_, ROP_NAME), _),DEPTH) + (CirrusVGAState * s, uint8_t * dst, + const uint8_t * src, + int dstpitch, int srcpitch, + int bltwidth, int bltheight) +{ + uint8_t *d; + int x, y, bitpos, pattern_y; + unsigned int bits, bits_xor; + unsigned int col; + + if (s->cirrus_blt_modeext & CIRRUS_BLTMODEEXT_COLOREXPINV) { + bits_xor = 0xff; + col = s->cirrus_blt_bgcol; + } else { + bits_xor = 0x00; + col = s->cirrus_blt_fgcol; + } + pattern_y = s->cirrus_blt_srcaddr & 7; + + for(y = 0; y < bltheight; y++) { + bits = src[pattern_y] ^ bits_xor; + bitpos = 7; + d = dst; + for (x = 0; x < bltwidth; x += (DEPTH / 8)) { + if ((bits >> bitpos) & 1) { PUTPIXEL(); } d += (DEPTH / 8); - bitmask >>= 1; + bitpos = (bitpos - 1) & 7; } + pattern_y = (pattern_y + 1) & 7; dst += dstpitch; } } static void -glue(glue(glue(cirrus_colorexpand_, ROP_NAME), _),DEPTH) +glue(glue(glue(cirrus_colorexpand_pattern_, ROP_NAME), _),DEPTH) (CirrusVGAState * s, uint8_t * dst, const uint8_t * src, int dstpitch, int srcpitch, @@ -162,28 +210,25 @@ glue(glue(glue(cirrus_colorexpand_, ROP_NAME), _),DEPTH) { uint32_t colors[2]; uint8_t *d; - int x, y; - unsigned bits; + int x, y, bitpos, pattern_y; + unsigned int bits; unsigned int col; - unsigned bitmask; - int srcskipleft = 0; colors[0] = s->cirrus_blt_bgcol; colors[1] = s->cirrus_blt_fgcol; + pattern_y = s->cirrus_blt_srcaddr & 7; + for(y = 0; y < bltheight; y++) { - bitmask = 0x80 >> srcskipleft; - bits = *src++; + bits = src[pattern_y]; + bitpos = 7; d = dst; for (x = 0; x < bltwidth; x += (DEPTH / 8)) { - if ((bitmask & 0xff) == 0) { - bitmask = 0x80; - bits = *src++; - } - col = colors[!!(bits & bitmask)]; + col = colors[(bits >> bitpos) & 1]; PUTPIXEL(); d += (DEPTH / 8); - bitmask >>= 1; + bitpos = (bitpos - 1) & 7; } + pattern_y = (pattern_y + 1) & 7; dst += dstpitch; } } |