2004-06-06 19:16:19 +04:00
|
|
|
/*
|
|
|
|
* QEMU Cirrus CLGD 54xx VGA Emulator.
|
2007-09-17 01:08:06 +04:00
|
|
|
*
|
2004-06-06 19:16:19 +04:00
|
|
|
* Copyright (c) 2004 Fabrice Bellard
|
2007-09-17 01:08:06 +04:00
|
|
|
*
|
2004-06-06 19:16:19 +04:00
|
|
|
* Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
|
|
* of this software and associated documentation files (the "Software"), to deal
|
|
|
|
* in the Software without restriction, including without limitation the rights
|
|
|
|
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
|
|
* copies of the Software, and to permit persons to whom the Software is
|
|
|
|
* furnished to do so, subject to the following conditions:
|
|
|
|
*
|
|
|
|
* The above copyright notice and this permission notice shall be included in
|
|
|
|
* all copies or substantial portions of the Software.
|
|
|
|
*
|
|
|
|
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
|
|
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
|
|
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
|
|
|
|
* THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
|
|
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
|
|
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
|
|
|
* THE SOFTWARE.
|
|
|
|
*/
|
|
|
|
|
2017-03-15 13:47:52 +03:00
|
|
|
static inline void glue(rop_8_, ROP_NAME)(CirrusVGAState *s,
|
|
|
|
uint32_t dstaddr, uint8_t src)
|
2010-10-13 22:38:07 +04:00
|
|
|
{
|
2017-03-15 13:47:52 +03:00
|
|
|
uint8_t *dst = &s->vga.vram_ptr[dstaddr & s->cirrus_addr_mask];
|
2010-10-13 22:38:07 +04:00
|
|
|
*dst = ROP_FN(*dst, src);
|
|
|
|
}
|
|
|
|
|
2017-03-15 13:47:52 +03:00
|
|
|
static inline void glue(rop_tr_8_, ROP_NAME)(CirrusVGAState *s,
|
|
|
|
uint32_t dstaddr, uint8_t src,
|
|
|
|
uint8_t transp)
|
2010-10-13 22:38:07 +04:00
|
|
|
{
|
2017-03-15 13:47:52 +03:00
|
|
|
uint8_t *dst = &s->vga.vram_ptr[dstaddr & s->cirrus_addr_mask];
|
|
|
|
uint8_t pixel = ROP_FN(*dst, src);
|
|
|
|
if (pixel != transp) {
|
|
|
|
*dst = pixel;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
static inline void glue(rop_16_, ROP_NAME)(CirrusVGAState *s,
|
|
|
|
uint32_t dstaddr, uint16_t src)
|
|
|
|
{
|
|
|
|
uint16_t *dst = (uint16_t *)
|
|
|
|
(&s->vga.vram_ptr[dstaddr & s->cirrus_addr_mask & ~1]);
|
2010-10-13 22:38:07 +04:00
|
|
|
*dst = ROP_FN(*dst, src);
|
|
|
|
}
|
|
|
|
|
2017-03-15 13:47:52 +03:00
|
|
|
static inline void glue(rop_tr_16_, ROP_NAME)(CirrusVGAState *s,
|
|
|
|
uint32_t dstaddr, uint16_t src,
|
|
|
|
uint16_t transp)
|
|
|
|
{
|
|
|
|
uint16_t *dst = (uint16_t *)
|
|
|
|
(&s->vga.vram_ptr[dstaddr & s->cirrus_addr_mask & ~1]);
|
|
|
|
uint16_t pixel = ROP_FN(*dst, src);
|
|
|
|
if (pixel != transp) {
|
|
|
|
*dst = pixel;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
static inline void glue(rop_32_, ROP_NAME)(CirrusVGAState *s,
|
|
|
|
uint32_t dstaddr, uint32_t src)
|
2010-10-13 22:38:07 +04:00
|
|
|
{
|
2017-03-15 13:47:52 +03:00
|
|
|
uint32_t *dst = (uint32_t *)
|
|
|
|
(&s->vga.vram_ptr[dstaddr & s->cirrus_addr_mask & ~3]);
|
2010-10-13 22:38:07 +04:00
|
|
|
*dst = ROP_FN(*dst, src);
|
|
|
|
}
|
|
|
|
|
2017-03-15 13:47:52 +03:00
|
|
|
#define ROP_OP(st, d, s) glue(rop_8_, ROP_NAME)(st, d, s)
|
|
|
|
#define ROP_OP_TR(st, d, s, t) glue(rop_tr_8_, ROP_NAME)(st, d, s, t)
|
|
|
|
#define ROP_OP_16(st, d, s) glue(rop_16_, ROP_NAME)(st, d, s)
|
|
|
|
#define ROP_OP_TR_16(st, d, s, t) glue(rop_tr_16_, ROP_NAME)(st, d, s, t)
|
|
|
|
#define ROP_OP_32(st, d, s) glue(rop_32_, ROP_NAME)(st, d, s)
|
2010-10-13 22:38:07 +04:00
|
|
|
#undef ROP_FN
|
|
|
|
|
2004-06-06 19:16:19 +04:00
|
|
|
static void
|
|
|
|
glue(cirrus_bitblt_rop_fwd_, ROP_NAME)(CirrusVGAState *s,
|
2017-03-15 13:47:52 +03:00
|
|
|
uint32_t dstaddr,
|
2017-03-15 16:28:07 +03:00
|
|
|
uint32_t srcaddr,
|
2017-03-15 13:47:52 +03:00
|
|
|
int dstpitch, int srcpitch,
|
|
|
|
int bltwidth, int bltheight)
|
2004-06-06 19:16:19 +04:00
|
|
|
{
|
|
|
|
int x,y;
|
|
|
|
dstpitch -= bltwidth;
|
|
|
|
srcpitch -= bltwidth;
|
2008-05-06 01:26:31 +04:00
|
|
|
|
2014-07-07 04:32:34 +04:00
|
|
|
if (bltheight > 1 && (dstpitch < 0 || srcpitch < 0)) {
|
2008-05-06 01:26:31 +04:00
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
2004-06-06 19:16:19 +04:00
|
|
|
for (y = 0; y < bltheight; y++) {
|
|
|
|
for (x = 0; x < bltwidth; x++) {
|
2017-03-15 16:28:07 +03:00
|
|
|
ROP_OP(s, dstaddr, cirrus_src(s, srcaddr));
|
2017-03-15 13:47:52 +03:00
|
|
|
dstaddr++;
|
2017-03-15 16:28:07 +03:00
|
|
|
srcaddr++;
|
2004-06-06 19:16:19 +04:00
|
|
|
}
|
2017-03-15 13:47:52 +03:00
|
|
|
dstaddr += dstpitch;
|
2017-03-15 16:28:07 +03:00
|
|
|
srcaddr += srcpitch;
|
2004-06-06 19:16:19 +04:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
|
|
|
glue(cirrus_bitblt_rop_bkwd_, ROP_NAME)(CirrusVGAState *s,
|
2017-03-15 13:47:52 +03:00
|
|
|
uint32_t dstaddr,
|
2017-03-15 16:28:07 +03:00
|
|
|
uint32_t srcaddr,
|
2017-03-15 13:47:52 +03:00
|
|
|
int dstpitch, int srcpitch,
|
|
|
|
int bltwidth, int bltheight)
|
2004-06-06 19:16:19 +04:00
|
|
|
{
|
|
|
|
int x,y;
|
|
|
|
dstpitch += bltwidth;
|
|
|
|
srcpitch += bltwidth;
|
|
|
|
for (y = 0; y < bltheight; y++) {
|
|
|
|
for (x = 0; x < bltwidth; x++) {
|
2017-03-15 16:28:07 +03:00
|
|
|
ROP_OP(s, dstaddr, cirrus_src(s, srcaddr));
|
2017-03-15 13:47:52 +03:00
|
|
|
dstaddr--;
|
2017-03-15 16:28:07 +03:00
|
|
|
srcaddr--;
|
2004-06-06 19:16:19 +04:00
|
|
|
}
|
2017-03-15 13:47:52 +03:00
|
|
|
dstaddr += dstpitch;
|
2017-03-15 16:28:07 +03:00
|
|
|
srcaddr += srcpitch;
|
2004-06-06 19:16:19 +04:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2007-08-01 03:26:00 +04:00
|
|
|
static void
|
|
|
|
glue(glue(cirrus_bitblt_rop_fwd_transp_, ROP_NAME),_8)(CirrusVGAState *s,
|
2017-03-15 13:47:52 +03:00
|
|
|
uint32_t dstaddr,
|
2017-03-15 16:28:07 +03:00
|
|
|
uint32_t srcaddr,
|
2017-03-15 13:47:52 +03:00
|
|
|
int dstpitch,
|
|
|
|
int srcpitch,
|
|
|
|
int bltwidth,
|
|
|
|
int bltheight)
|
2007-08-01 03:26:00 +04:00
|
|
|
{
|
|
|
|
int x,y;
|
2017-03-15 13:47:52 +03:00
|
|
|
uint8_t transp = s->vga.gr[0x34];
|
2007-08-01 03:26:00 +04:00
|
|
|
dstpitch -= bltwidth;
|
|
|
|
srcpitch -= bltwidth;
|
2017-03-14 09:39:19 +03:00
|
|
|
|
|
|
|
if (bltheight > 1 && (dstpitch < 0 || srcpitch < 0)) {
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
2007-08-01 03:26:00 +04:00
|
|
|
for (y = 0; y < bltheight; y++) {
|
|
|
|
for (x = 0; x < bltwidth; x++) {
|
2017-03-15 16:28:07 +03:00
|
|
|
ROP_OP_TR(s, dstaddr, cirrus_src(s, srcaddr), transp);
|
2017-03-15 13:47:52 +03:00
|
|
|
dstaddr++;
|
2017-03-15 16:28:07 +03:00
|
|
|
srcaddr++;
|
2007-08-01 03:26:00 +04:00
|
|
|
}
|
2017-03-15 13:47:52 +03:00
|
|
|
dstaddr += dstpitch;
|
2017-03-15 16:28:07 +03:00
|
|
|
srcaddr += srcpitch;
|
2007-08-01 03:26:00 +04:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
|
|
|
glue(glue(cirrus_bitblt_rop_bkwd_transp_, ROP_NAME),_8)(CirrusVGAState *s,
|
2017-03-15 13:47:52 +03:00
|
|
|
uint32_t dstaddr,
|
2017-03-15 16:28:07 +03:00
|
|
|
uint32_t srcaddr,
|
2017-03-15 13:47:52 +03:00
|
|
|
int dstpitch,
|
|
|
|
int srcpitch,
|
|
|
|
int bltwidth,
|
|
|
|
int bltheight)
|
2007-08-01 03:26:00 +04:00
|
|
|
{
|
|
|
|
int x,y;
|
2017-03-15 13:47:52 +03:00
|
|
|
uint8_t transp = s->vga.gr[0x34];
|
2007-08-01 03:26:00 +04:00
|
|
|
dstpitch += bltwidth;
|
|
|
|
srcpitch += bltwidth;
|
|
|
|
for (y = 0; y < bltheight; y++) {
|
|
|
|
for (x = 0; x < bltwidth; x++) {
|
2017-03-15 16:28:07 +03:00
|
|
|
ROP_OP_TR(s, dstaddr, cirrus_src(s, srcaddr), transp);
|
2017-03-15 13:47:52 +03:00
|
|
|
dstaddr--;
|
2017-03-15 16:28:07 +03:00
|
|
|
srcaddr--;
|
2007-08-01 03:26:00 +04:00
|
|
|
}
|
2017-03-15 13:47:52 +03:00
|
|
|
dstaddr += dstpitch;
|
2017-03-15 16:28:07 +03:00
|
|
|
srcaddr += srcpitch;
|
2007-08-01 03:26:00 +04:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
|
|
|
glue(glue(cirrus_bitblt_rop_fwd_transp_, ROP_NAME),_16)(CirrusVGAState *s,
|
2017-03-15 13:47:52 +03:00
|
|
|
uint32_t dstaddr,
|
2017-03-15 16:28:07 +03:00
|
|
|
uint32_t srcaddr,
|
2017-03-15 13:47:52 +03:00
|
|
|
int dstpitch,
|
|
|
|
int srcpitch,
|
|
|
|
int bltwidth,
|
|
|
|
int bltheight)
|
2007-08-01 03:26:00 +04:00
|
|
|
{
|
|
|
|
int x,y;
|
2017-03-15 13:47:52 +03:00
|
|
|
uint16_t transp = s->vga.gr[0x34] | (uint16_t)s->vga.gr[0x35] << 8;
|
2007-08-01 03:26:00 +04:00
|
|
|
dstpitch -= bltwidth;
|
|
|
|
srcpitch -= bltwidth;
|
2017-03-14 09:39:19 +03:00
|
|
|
|
|
|
|
if (bltheight > 1 && (dstpitch < 0 || srcpitch < 0)) {
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
2007-08-01 03:26:00 +04:00
|
|
|
for (y = 0; y < bltheight; y++) {
|
|
|
|
for (x = 0; x < bltwidth; x+=2) {
|
2017-03-15 16:28:07 +03:00
|
|
|
ROP_OP_TR_16(s, dstaddr, cirrus_src16(s, srcaddr), transp);
|
2017-03-15 13:47:52 +03:00
|
|
|
dstaddr += 2;
|
2017-03-15 16:28:07 +03:00
|
|
|
srcaddr += 2;
|
2007-08-01 03:26:00 +04:00
|
|
|
}
|
2017-03-15 13:47:52 +03:00
|
|
|
dstaddr += dstpitch;
|
2017-03-15 16:28:07 +03:00
|
|
|
srcaddr += srcpitch;
|
2007-08-01 03:26:00 +04:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
|
|
|
glue(glue(cirrus_bitblt_rop_bkwd_transp_, ROP_NAME),_16)(CirrusVGAState *s,
|
2017-03-15 13:47:52 +03:00
|
|
|
uint32_t dstaddr,
|
2017-03-15 16:28:07 +03:00
|
|
|
uint32_t srcaddr,
|
2017-03-15 13:47:52 +03:00
|
|
|
int dstpitch,
|
|
|
|
int srcpitch,
|
|
|
|
int bltwidth,
|
|
|
|
int bltheight)
|
2007-08-01 03:26:00 +04:00
|
|
|
{
|
|
|
|
int x,y;
|
2017-03-15 13:47:52 +03:00
|
|
|
uint16_t transp = s->vga.gr[0x34] | (uint16_t)s->vga.gr[0x35] << 8;
|
2007-08-01 03:26:00 +04:00
|
|
|
dstpitch += bltwidth;
|
|
|
|
srcpitch += bltwidth;
|
|
|
|
for (y = 0; y < bltheight; y++) {
|
|
|
|
for (x = 0; x < bltwidth; x+=2) {
|
2017-03-17 10:21:36 +03:00
|
|
|
ROP_OP_TR_16(s, dstaddr - 1, cirrus_src16(s, srcaddr - 1), transp);
|
2017-03-15 13:47:52 +03:00
|
|
|
dstaddr -= 2;
|
2017-03-15 16:28:07 +03:00
|
|
|
srcaddr -= 2;
|
2007-08-01 03:26:00 +04:00
|
|
|
}
|
2017-03-15 13:47:52 +03:00
|
|
|
dstaddr += dstpitch;
|
2017-03-15 16:28:07 +03:00
|
|
|
srcaddr += srcpitch;
|
2007-08-01 03:26:00 +04:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2004-06-06 19:16:19 +04:00
|
|
|
#define DEPTH 8
|
2013-03-18 20:36:02 +04:00
|
|
|
#include "cirrus_vga_rop2.h"
|
2004-06-06 19:16:19 +04:00
|
|
|
|
|
|
|
#define DEPTH 16
|
2013-03-18 20:36:02 +04:00
|
|
|
#include "cirrus_vga_rop2.h"
|
2004-06-06 19:16:19 +04:00
|
|
|
|
|
|
|
#define DEPTH 24
|
2013-03-18 20:36:02 +04:00
|
|
|
#include "cirrus_vga_rop2.h"
|
2004-06-06 19:16:19 +04:00
|
|
|
|
|
|
|
#define DEPTH 32
|
2013-03-18 20:36:02 +04:00
|
|
|
#include "cirrus_vga_rop2.h"
|
2004-06-06 19:16:19 +04:00
|
|
|
|
|
|
|
#undef ROP_NAME
|
|
|
|
#undef ROP_OP
|
2010-10-13 22:38:07 +04:00
|
|
|
#undef ROP_OP_16
|
|
|
|
#undef ROP_OP_32
|