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.
|
|
|
|
*/
|
|
|
|
|
2010-10-13 22:38:07 +04:00
|
|
|
static inline void glue(rop_8_,ROP_NAME)(uint8_t *dst, uint8_t src)
|
|
|
|
{
|
|
|
|
*dst = ROP_FN(*dst, src);
|
|
|
|
}
|
|
|
|
|
|
|
|
static inline void glue(rop_16_,ROP_NAME)(uint16_t *dst, uint16_t src)
|
|
|
|
{
|
|
|
|
*dst = ROP_FN(*dst, src);
|
|
|
|
}
|
|
|
|
|
|
|
|
static inline void glue(rop_32_,ROP_NAME)(uint32_t *dst, uint32_t src)
|
|
|
|
{
|
|
|
|
*dst = ROP_FN(*dst, src);
|
|
|
|
}
|
|
|
|
|
|
|
|
#define ROP_OP(d, s) glue(rop_8_,ROP_NAME)(d, s)
|
|
|
|
#define ROP_OP_16(d, s) glue(rop_16_,ROP_NAME)(d, s)
|
|
|
|
#define ROP_OP_32(d, s) glue(rop_32_,ROP_NAME)(d, s)
|
|
|
|
#undef ROP_FN
|
|
|
|
|
2004-06-06 19:16:19 +04:00
|
|
|
static void
|
|
|
|
glue(cirrus_bitblt_rop_fwd_, ROP_NAME)(CirrusVGAState *s,
|
|
|
|
uint8_t *dst,const uint8_t *src,
|
|
|
|
int dstpitch,int srcpitch,
|
|
|
|
int bltwidth,int bltheight)
|
|
|
|
{
|
|
|
|
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++) {
|
2010-10-13 22:38:07 +04:00
|
|
|
ROP_OP(dst, *src);
|
2004-06-06 19:16:19 +04:00
|
|
|
dst++;
|
|
|
|
src++;
|
|
|
|
}
|
|
|
|
dst += dstpitch;
|
|
|
|
src += srcpitch;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
|
|
|
glue(cirrus_bitblt_rop_bkwd_, ROP_NAME)(CirrusVGAState *s,
|
|
|
|
uint8_t *dst,const uint8_t *src,
|
|
|
|
int dstpitch,int srcpitch,
|
|
|
|
int bltwidth,int bltheight)
|
|
|
|
{
|
|
|
|
int x,y;
|
|
|
|
dstpitch += bltwidth;
|
|
|
|
srcpitch += bltwidth;
|
|
|
|
for (y = 0; y < bltheight; y++) {
|
|
|
|
for (x = 0; x < bltwidth; x++) {
|
2010-10-13 22:38:07 +04:00
|
|
|
ROP_OP(dst, *src);
|
2004-06-06 19:16:19 +04:00
|
|
|
dst--;
|
|
|
|
src--;
|
|
|
|
}
|
|
|
|
dst += dstpitch;
|
|
|
|
src += srcpitch;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2007-08-01 03:26:00 +04:00
|
|
|
static void
|
|
|
|
glue(glue(cirrus_bitblt_rop_fwd_transp_, ROP_NAME),_8)(CirrusVGAState *s,
|
|
|
|
uint8_t *dst,const uint8_t *src,
|
|
|
|
int dstpitch,int srcpitch,
|
|
|
|
int bltwidth,int bltheight)
|
|
|
|
{
|
|
|
|
int x,y;
|
|
|
|
uint8_t p;
|
|
|
|
dstpitch -= bltwidth;
|
|
|
|
srcpitch -= bltwidth;
|
|
|
|
for (y = 0; y < bltheight; y++) {
|
|
|
|
for (x = 0; x < bltwidth; x++) {
|
|
|
|
p = *dst;
|
2010-10-13 22:38:07 +04:00
|
|
|
ROP_OP(&p, *src);
|
2009-05-03 23:25:16 +04:00
|
|
|
if (p != s->vga.gr[0x34]) *dst = p;
|
2007-08-01 03:26:00 +04:00
|
|
|
dst++;
|
|
|
|
src++;
|
|
|
|
}
|
|
|
|
dst += dstpitch;
|
|
|
|
src += srcpitch;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
|
|
|
glue(glue(cirrus_bitblt_rop_bkwd_transp_, ROP_NAME),_8)(CirrusVGAState *s,
|
|
|
|
uint8_t *dst,const uint8_t *src,
|
|
|
|
int dstpitch,int srcpitch,
|
|
|
|
int bltwidth,int bltheight)
|
|
|
|
{
|
|
|
|
int x,y;
|
|
|
|
uint8_t p;
|
|
|
|
dstpitch += bltwidth;
|
|
|
|
srcpitch += bltwidth;
|
|
|
|
for (y = 0; y < bltheight; y++) {
|
|
|
|
for (x = 0; x < bltwidth; x++) {
|
|
|
|
p = *dst;
|
2010-10-13 22:38:07 +04:00
|
|
|
ROP_OP(&p, *src);
|
2009-05-03 23:25:16 +04:00
|
|
|
if (p != s->vga.gr[0x34]) *dst = p;
|
2007-08-01 03:26:00 +04:00
|
|
|
dst--;
|
|
|
|
src--;
|
|
|
|
}
|
|
|
|
dst += dstpitch;
|
|
|
|
src += srcpitch;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
|
|
|
glue(glue(cirrus_bitblt_rop_fwd_transp_, ROP_NAME),_16)(CirrusVGAState *s,
|
|
|
|
uint8_t *dst,const uint8_t *src,
|
|
|
|
int dstpitch,int srcpitch,
|
|
|
|
int bltwidth,int bltheight)
|
|
|
|
{
|
|
|
|
int x,y;
|
|
|
|
uint8_t p1, p2;
|
|
|
|
dstpitch -= bltwidth;
|
|
|
|
srcpitch -= bltwidth;
|
|
|
|
for (y = 0; y < bltheight; y++) {
|
|
|
|
for (x = 0; x < bltwidth; x+=2) {
|
|
|
|
p1 = *dst;
|
|
|
|
p2 = *(dst+1);
|
2010-10-13 22:38:07 +04:00
|
|
|
ROP_OP(&p1, *src);
|
|
|
|
ROP_OP(&p2, *(src + 1));
|
2009-05-03 23:25:16 +04:00
|
|
|
if ((p1 != s->vga.gr[0x34]) || (p2 != s->vga.gr[0x35])) {
|
2007-08-01 03:26:00 +04:00
|
|
|
*dst = p1;
|
|
|
|
*(dst+1) = p2;
|
|
|
|
}
|
|
|
|
dst+=2;
|
|
|
|
src+=2;
|
|
|
|
}
|
|
|
|
dst += dstpitch;
|
|
|
|
src += srcpitch;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
|
|
|
glue(glue(cirrus_bitblt_rop_bkwd_transp_, ROP_NAME),_16)(CirrusVGAState *s,
|
|
|
|
uint8_t *dst,const uint8_t *src,
|
|
|
|
int dstpitch,int srcpitch,
|
|
|
|
int bltwidth,int bltheight)
|
|
|
|
{
|
|
|
|
int x,y;
|
|
|
|
uint8_t p1, p2;
|
|
|
|
dstpitch += bltwidth;
|
|
|
|
srcpitch += bltwidth;
|
|
|
|
for (y = 0; y < bltheight; y++) {
|
|
|
|
for (x = 0; x < bltwidth; x+=2) {
|
|
|
|
p1 = *(dst-1);
|
|
|
|
p2 = *dst;
|
2010-10-13 22:38:07 +04:00
|
|
|
ROP_OP(&p1, *(src - 1));
|
|
|
|
ROP_OP(&p2, *src);
|
2009-05-03 23:25:16 +04:00
|
|
|
if ((p1 != s->vga.gr[0x34]) || (p2 != s->vga.gr[0x35])) {
|
2007-08-01 03:26:00 +04:00
|
|
|
*(dst-1) = p1;
|
|
|
|
*dst = p2;
|
|
|
|
}
|
|
|
|
dst-=2;
|
|
|
|
src-=2;
|
|
|
|
}
|
|
|
|
dst += dstpitch;
|
|
|
|
src += srcpitch;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
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
|