DevVGATmpl.h revision f7f5cd7b1e530eb5636da51c974b48ae0c1775b3
/* $Id$ */
/** @file
*/
/*
* Copyright (C) 2006-2007 Oracle Corporation
*
* This file is part of VirtualBox Open Source Edition (OSE), as
* available from http://www.virtualbox.org. This file is free software;
* General Public License (GPL) as published by the Free Software
* Foundation, in version 2 as it comes in the "COPYING" file of the
* VirtualBox OSE distribution. VirtualBox OSE is distributed in the
* hope that it will be useful, but WITHOUT ANY WARRANTY of any kind.
* --------------------------------------------------------------------
*
* This code is based on:
*
* QEMU VGA Emulator templates
*
* Copyright (c) 2003 Fabrice Bellard
*
* 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
* 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.
*/
#if DEPTH == 8
#define BPP 1
#define PIXEL_TYPE uint8_t
#define BPP 2
#define PIXEL_TYPE uint16_t
#define BPP 4
#define PIXEL_TYPE uint32_t
#else
#endif
#if DEPTH != 15
int font_data,
int dscan,
int linesize)
{
#if BPP == 1
if (dscan) {
}
if (dscan)
#else
if (dscan)
#endif
}
{
int font_data;
do {
font_ptr += 4;
} while (--h);
}
{
int font_data;
do {
font_ptr += 4;
} while (--h);
}
{
int font_data;
do {
#if BPP == 1
if (dup9)
else
if (dup9)
else
#else
((uint32_t *)d)[7] = v;
if (dup9)
((uint32_t *)d)[8] = v;
else
#endif
font_ptr += 4;
d += linesize;
} while (--h);
}
/*
* 4 color mode
*/
{
int x;
width >>= 3;
for(x = 0; x < width; x++) {
data &= plane_mask;
d += BPP * 8;
s += src_inc;
}
}
#if BPP == 1
#define PUT_PIXEL2(d, n, v) ((uint16_t *)d)[(n)] = (v)
#define PUT_PIXEL2(d, n, v) ((uint32_t *)d)[(n)] = (v)
#else
#define PUT_PIXEL2(d, n, v) \
#endif
/*
* 4 color mode, dup2 horizontal
*/
{
int x;
width >>= 3;
for(x = 0; x < width; x++) {
data &= plane_mask;
d += BPP * 16;
s += src_inc;
}
}
/*
* 16 color mode
*/
{
int x;
width >>= 3;
for(x = 0; x < width; x++) {
data &= plane_mask;
d += BPP * 8;
s += 4;
}
}
/*
* 16 color mode, dup2 horizontal
*/
{
int x;
width >>= 3;
for(x = 0; x < width; x++) {
data &= plane_mask;
d += BPP * 16;
s += 4;
}
}
/*
* 256 color mode, double pixels
*
* XXX: add plane_mask support (never used in standard VGA modes)
*/
{
int x;
width >>= 3;
for(x = 0; x < width; x++) {
PUT_PIXEL2(d, 0, palette[s[0]]);
d += BPP * 8;
s += 4;
}
}
/*
* standard 256 color mode
*
* XXX: add plane_mask support (never used in standard VGA modes)
*/
{
int x;
width >>= 3;
for(x = 0; x < width; x++) {
((PIXEL_TYPE *)d)[0] = palette[s[0]];
d += BPP * 8;
s += 8;
}
}
#endif /* DEPTH != 15 */
/* XXX: optimize */
/*
* 15 bit color
*/
{
#else
int w;
uint32_t v, r, g, b;
w = width;
do {
v = lduw_raw((void *)s);
r = (v >> 7) & 0xf8;
g = (v >> 2) & 0xf8;
b = (v << 3) & 0xf8;
s += 2;
d += BPP;
} while (--w != 0);
#endif
}
/*
* 16 bit color
*/
{
#else
int w;
uint32_t v, r, g, b;
w = width;
do {
v = lduw_raw((void *)s);
r = (v >> 8) & 0xf8;
g = (v >> 3) & 0xfc;
b = (v << 3) & 0xf8;
s += 2;
d += BPP;
} while (--w != 0);
#endif
}
/*
* 24 bit color
*/
{
int w;
uint32_t r, g, b;
w = width;
do {
#if defined(TARGET_WORDS_BIGENDIAN)
r = s[0];
g = s[1];
b = s[2];
#else
b = s[0];
g = s[1];
r = s[2];
#endif
s += 3;
d += BPP;
} while (--w != 0);
}
/*
* 32 bit color
*/
{
#else
int w;
uint32_t r, g, b;
w = width;
do {
#if defined(TARGET_WORDS_BIGENDIAN)
r = s[1];
g = s[2];
b = s[3];
#else
b = s[0];
g = s[1];
r = s[2];
#endif
s += 4;
d += BPP;
} while (--w != 0);
#endif
}
#if DEPTH != 15
#ifndef VBOX
#ifdef VBOX
static
#endif/* VBOX */
int poffset, int w,
unsigned int color0,
unsigned int color1,
unsigned int color_xor)
{
uint8_t *d;
d = d1;
for(x = 0; x < w; x++) {
#if DEPTH == 8
case 0:
break;
case 1:
d[0] ^= color_xor;
break;
case 2:
d[0] = color0;
break;
case 3:
d[0] = color1;
break;
}
case 0:
break;
case 1:
break;
case 2:
break;
case 3:
break;
}
case 0:
break;
case 1:
break;
case 2:
break;
case 3:
break;
}
#else
#endif
d += BPP;
}
}
#endif /* !VBOX */
#endif