2003-08-05 01:30:47 +02:00
|
|
|
/*
|
|
|
|
* QEMU VGA Emulator templates
|
2007-09-16 23:08:06 +02:00
|
|
|
*
|
2003-08-05 01:30:47 +02:00
|
|
|
* Copyright (c) 2003 Fabrice Bellard
|
2007-09-16 23:08:06 +02:00
|
|
|
*
|
2003-08-05 01:30:47 +02: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.
|
|
|
|
*/
|
|
|
|
|
|
|
|
#if DEPTH == 8
|
|
|
|
#define BPP 1
|
2007-09-16 23:08:06 +02:00
|
|
|
#define PIXEL_TYPE uint8_t
|
2003-08-05 01:30:47 +02:00
|
|
|
#elif DEPTH == 15 || DEPTH == 16
|
|
|
|
#define BPP 2
|
2007-09-16 23:08:06 +02:00
|
|
|
#define PIXEL_TYPE uint16_t
|
2003-08-05 01:30:47 +02:00
|
|
|
#elif DEPTH == 32
|
|
|
|
#define BPP 4
|
2007-09-16 23:08:06 +02:00
|
|
|
#define PIXEL_TYPE uint32_t
|
2003-08-05 01:30:47 +02:00
|
|
|
#else
|
|
|
|
#error unsupport depth
|
|
|
|
#endif
|
|
|
|
|
2006-05-11 00:17:36 +02:00
|
|
|
#ifdef BGR_FORMAT
|
|
|
|
#define PIXEL_NAME glue(DEPTH, bgr)
|
|
|
|
#else
|
|
|
|
#define PIXEL_NAME DEPTH
|
|
|
|
#endif /* BGR_FORMAT */
|
|
|
|
|
|
|
|
#if DEPTH != 15 && !defined(BGR_FORMAT)
|
2003-08-05 01:30:47 +02:00
|
|
|
|
2007-09-16 23:08:06 +02:00
|
|
|
static inline void glue(vga_draw_glyph_line_, DEPTH)(uint8_t *d,
|
2003-08-09 01:50:57 +02:00
|
|
|
uint32_t font_data,
|
2007-09-16 23:08:06 +02:00
|
|
|
uint32_t xorcol,
|
2003-08-09 01:50:57 +02:00
|
|
|
uint32_t bgcol)
|
2003-08-05 01:30:47 +02:00
|
|
|
{
|
|
|
|
#if BPP == 1
|
|
|
|
((uint32_t *)d)[0] = (dmask16[(font_data >> 4)] & xorcol) ^ bgcol;
|
2004-10-10 17:44:19 +02:00
|
|
|
((uint32_t *)d)[1] = (dmask16[(font_data >> 0) & 0xf] & xorcol) ^ bgcol;
|
2003-08-05 01:30:47 +02:00
|
|
|
#elif BPP == 2
|
|
|
|
((uint32_t *)d)[0] = (dmask4[(font_data >> 6)] & xorcol) ^ bgcol;
|
|
|
|
((uint32_t *)d)[1] = (dmask4[(font_data >> 4) & 3] & xorcol) ^ bgcol;
|
|
|
|
((uint32_t *)d)[2] = (dmask4[(font_data >> 2) & 3] & xorcol) ^ bgcol;
|
|
|
|
((uint32_t *)d)[3] = (dmask4[(font_data >> 0) & 3] & xorcol) ^ bgcol;
|
|
|
|
#else
|
2003-09-16 23:47:08 +02:00
|
|
|
((uint32_t *)d)[0] = (-((font_data >> 7)) & xorcol) ^ bgcol;
|
|
|
|
((uint32_t *)d)[1] = (-((font_data >> 6) & 1) & xorcol) ^ bgcol;
|
|
|
|
((uint32_t *)d)[2] = (-((font_data >> 5) & 1) & xorcol) ^ bgcol;
|
|
|
|
((uint32_t *)d)[3] = (-((font_data >> 4) & 1) & xorcol) ^ bgcol;
|
|
|
|
((uint32_t *)d)[4] = (-((font_data >> 3) & 1) & xorcol) ^ bgcol;
|
|
|
|
((uint32_t *)d)[5] = (-((font_data >> 2) & 1) & xorcol) ^ bgcol;
|
|
|
|
((uint32_t *)d)[6] = (-((font_data >> 1) & 1) & xorcol) ^ bgcol;
|
|
|
|
((uint32_t *)d)[7] = (-((font_data >> 0) & 1) & xorcol) ^ bgcol;
|
2003-08-05 01:30:47 +02:00
|
|
|
#endif
|
2003-08-09 01:50:57 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
static void glue(vga_draw_glyph8_, DEPTH)(uint8_t *d, int linesize,
|
|
|
|
const uint8_t *font_ptr, int h,
|
|
|
|
uint32_t fgcol, uint32_t bgcol)
|
|
|
|
{
|
|
|
|
uint32_t font_data, xorcol;
|
2007-09-17 10:09:54 +02:00
|
|
|
|
2003-08-09 01:50:57 +02:00
|
|
|
xorcol = bgcol ^ fgcol;
|
|
|
|
do {
|
|
|
|
font_data = font_ptr[0];
|
|
|
|
glue(vga_draw_glyph_line_, DEPTH)(d, font_data, xorcol, bgcol);
|
|
|
|
font_ptr += 4;
|
|
|
|
d += linesize;
|
|
|
|
} while (--h);
|
|
|
|
}
|
|
|
|
|
|
|
|
static void glue(vga_draw_glyph16_, DEPTH)(uint8_t *d, int linesize,
|
|
|
|
const uint8_t *font_ptr, int h,
|
|
|
|
uint32_t fgcol, uint32_t bgcol)
|
|
|
|
{
|
|
|
|
uint32_t font_data, xorcol;
|
2007-09-17 10:09:54 +02:00
|
|
|
|
2003-08-09 01:50:57 +02:00
|
|
|
xorcol = bgcol ^ fgcol;
|
|
|
|
do {
|
|
|
|
font_data = font_ptr[0];
|
2007-09-16 23:08:06 +02:00
|
|
|
glue(vga_draw_glyph_line_, DEPTH)(d,
|
|
|
|
expand4to8[font_data >> 4],
|
2003-08-09 01:50:57 +02:00
|
|
|
xorcol, bgcol);
|
2007-09-16 23:08:06 +02:00
|
|
|
glue(vga_draw_glyph_line_, DEPTH)(d + 8 * BPP,
|
|
|
|
expand4to8[font_data & 0x0f],
|
2003-08-09 01:50:57 +02:00
|
|
|
xorcol, bgcol);
|
2003-08-05 01:30:47 +02:00
|
|
|
font_ptr += 4;
|
|
|
|
d += linesize;
|
|
|
|
} while (--h);
|
|
|
|
}
|
|
|
|
|
|
|
|
static void glue(vga_draw_glyph9_, DEPTH)(uint8_t *d, int linesize,
|
2007-09-16 23:08:06 +02:00
|
|
|
const uint8_t *font_ptr, int h,
|
2003-08-05 01:30:47 +02:00
|
|
|
uint32_t fgcol, uint32_t bgcol, int dup9)
|
|
|
|
{
|
|
|
|
uint32_t font_data, xorcol, v;
|
2007-09-17 10:09:54 +02:00
|
|
|
|
2003-08-05 01:30:47 +02:00
|
|
|
xorcol = bgcol ^ fgcol;
|
|
|
|
do {
|
|
|
|
font_data = font_ptr[0];
|
|
|
|
#if BPP == 1
|
2004-10-10 17:44:19 +02:00
|
|
|
cpu_to_32wu((uint32_t *)d, (dmask16[(font_data >> 4)] & xorcol) ^ bgcol);
|
2003-08-05 01:30:47 +02:00
|
|
|
v = (dmask16[(font_data >> 0) & 0xf] & xorcol) ^ bgcol;
|
2004-10-10 17:44:19 +02:00
|
|
|
cpu_to_32wu(((uint32_t *)d)+1, v);
|
2003-08-05 01:30:47 +02:00
|
|
|
if (dup9)
|
2003-08-06 01:06:22 +02:00
|
|
|
((uint8_t *)d)[8] = v >> (24 * (1 - BIG));
|
2003-08-05 01:30:47 +02:00
|
|
|
else
|
2003-08-06 01:06:22 +02:00
|
|
|
((uint8_t *)d)[8] = bgcol;
|
2007-09-17 10:09:54 +02:00
|
|
|
|
2003-08-05 01:30:47 +02:00
|
|
|
#elif BPP == 2
|
2004-10-10 17:44:19 +02:00
|
|
|
cpu_to_32wu(((uint32_t *)d)+0, (dmask4[(font_data >> 6)] & xorcol) ^ bgcol);
|
|
|
|
cpu_to_32wu(((uint32_t *)d)+1, (dmask4[(font_data >> 4) & 3] & xorcol) ^ bgcol);
|
|
|
|
cpu_to_32wu(((uint32_t *)d)+2, (dmask4[(font_data >> 2) & 3] & xorcol) ^ bgcol);
|
2003-08-05 01:30:47 +02:00
|
|
|
v = (dmask4[(font_data >> 0) & 3] & xorcol) ^ bgcol;
|
2004-10-10 17:44:19 +02:00
|
|
|
cpu_to_32wu(((uint32_t *)d)+3, v);
|
2003-08-05 01:30:47 +02:00
|
|
|
if (dup9)
|
2003-08-06 01:06:22 +02:00
|
|
|
((uint16_t *)d)[8] = v >> (16 * (1 - BIG));
|
2003-08-05 01:30:47 +02:00
|
|
|
else
|
2003-08-06 01:06:22 +02:00
|
|
|
((uint16_t *)d)[8] = bgcol;
|
2003-08-05 01:30:47 +02:00
|
|
|
#else
|
2004-04-07 22:31:38 +02:00
|
|
|
((uint32_t *)d)[0] = (-((font_data >> 7)) & xorcol) ^ bgcol;
|
|
|
|
((uint32_t *)d)[1] = (-((font_data >> 6) & 1) & xorcol) ^ bgcol;
|
|
|
|
((uint32_t *)d)[2] = (-((font_data >> 5) & 1) & xorcol) ^ bgcol;
|
|
|
|
((uint32_t *)d)[3] = (-((font_data >> 4) & 1) & xorcol) ^ bgcol;
|
|
|
|
((uint32_t *)d)[4] = (-((font_data >> 3) & 1) & xorcol) ^ bgcol;
|
|
|
|
((uint32_t *)d)[5] = (-((font_data >> 2) & 1) & xorcol) ^ bgcol;
|
|
|
|
((uint32_t *)d)[6] = (-((font_data >> 1) & 1) & xorcol) ^ bgcol;
|
|
|
|
v = (-((font_data >> 0) & 1) & xorcol) ^ bgcol;
|
2003-08-05 01:30:47 +02:00
|
|
|
((uint32_t *)d)[7] = v;
|
|
|
|
if (dup9)
|
2003-08-06 01:06:22 +02:00
|
|
|
((uint32_t *)d)[8] = v;
|
2003-08-05 01:30:47 +02:00
|
|
|
else
|
2003-08-06 01:06:22 +02:00
|
|
|
((uint32_t *)d)[8] = bgcol;
|
2003-08-05 01:30:47 +02:00
|
|
|
#endif
|
|
|
|
font_ptr += 4;
|
|
|
|
d += linesize;
|
|
|
|
} while (--h);
|
|
|
|
}
|
|
|
|
|
2007-09-16 23:08:06 +02:00
|
|
|
/*
|
2003-08-05 01:30:47 +02:00
|
|
|
* 4 color mode
|
|
|
|
*/
|
2009-08-31 16:07:24 +02:00
|
|
|
static void glue(vga_draw_line2_, DEPTH)(VGACommonState *s1, uint8_t *d,
|
2003-08-05 01:30:47 +02:00
|
|
|
const uint8_t *s, int width)
|
|
|
|
{
|
|
|
|
uint32_t plane_mask, *palette, data, v;
|
|
|
|
int x;
|
|
|
|
|
|
|
|
palette = s1->last_palette;
|
2012-01-29 18:02:07 +01:00
|
|
|
plane_mask = mask16[s1->ar[VGA_ATC_PLANE_ENABLE] & 0xf];
|
2003-08-05 01:30:47 +02:00
|
|
|
width >>= 3;
|
|
|
|
for(x = 0; x < width; x++) {
|
|
|
|
data = ((uint32_t *)s)[0];
|
|
|
|
data &= plane_mask;
|
|
|
|
v = expand2[GET_PLANE(data, 0)];
|
|
|
|
v |= expand2[GET_PLANE(data, 2)] << 2;
|
|
|
|
((PIXEL_TYPE *)d)[0] = palette[v >> 12];
|
|
|
|
((PIXEL_TYPE *)d)[1] = palette[(v >> 8) & 0xf];
|
|
|
|
((PIXEL_TYPE *)d)[2] = palette[(v >> 4) & 0xf];
|
|
|
|
((PIXEL_TYPE *)d)[3] = palette[(v >> 0) & 0xf];
|
|
|
|
|
|
|
|
v = expand2[GET_PLANE(data, 1)];
|
|
|
|
v |= expand2[GET_PLANE(data, 3)] << 2;
|
|
|
|
((PIXEL_TYPE *)d)[4] = palette[v >> 12];
|
|
|
|
((PIXEL_TYPE *)d)[5] = palette[(v >> 8) & 0xf];
|
|
|
|
((PIXEL_TYPE *)d)[6] = palette[(v >> 4) & 0xf];
|
|
|
|
((PIXEL_TYPE *)d)[7] = palette[(v >> 0) & 0xf];
|
|
|
|
d += BPP * 8;
|
|
|
|
s += 4;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2003-08-09 01:50:57 +02:00
|
|
|
#if BPP == 1
|
|
|
|
#define PUT_PIXEL2(d, n, v) ((uint16_t *)d)[(n)] = (v)
|
|
|
|
#elif BPP == 2
|
|
|
|
#define PUT_PIXEL2(d, n, v) ((uint32_t *)d)[(n)] = (v)
|
|
|
|
#else
|
|
|
|
#define PUT_PIXEL2(d, n, v) \
|
|
|
|
((uint32_t *)d)[2*(n)] = ((uint32_t *)d)[2*(n)+1] = (v)
|
|
|
|
#endif
|
|
|
|
|
2007-09-16 23:08:06 +02:00
|
|
|
/*
|
2003-08-09 01:50:57 +02:00
|
|
|
* 4 color mode, dup2 horizontal
|
|
|
|
*/
|
2009-08-31 16:07:24 +02:00
|
|
|
static void glue(vga_draw_line2d2_, DEPTH)(VGACommonState *s1, uint8_t *d,
|
2003-08-09 01:50:57 +02:00
|
|
|
const uint8_t *s, int width)
|
|
|
|
{
|
|
|
|
uint32_t plane_mask, *palette, data, v;
|
|
|
|
int x;
|
|
|
|
|
|
|
|
palette = s1->last_palette;
|
2012-01-29 18:02:07 +01:00
|
|
|
plane_mask = mask16[s1->ar[VGA_ATC_PLANE_ENABLE] & 0xf];
|
2003-08-09 01:50:57 +02:00
|
|
|
width >>= 3;
|
|
|
|
for(x = 0; x < width; x++) {
|
|
|
|
data = ((uint32_t *)s)[0];
|
|
|
|
data &= plane_mask;
|
|
|
|
v = expand2[GET_PLANE(data, 0)];
|
|
|
|
v |= expand2[GET_PLANE(data, 2)] << 2;
|
|
|
|
PUT_PIXEL2(d, 0, palette[v >> 12]);
|
|
|
|
PUT_PIXEL2(d, 1, palette[(v >> 8) & 0xf]);
|
|
|
|
PUT_PIXEL2(d, 2, palette[(v >> 4) & 0xf]);
|
|
|
|
PUT_PIXEL2(d, 3, palette[(v >> 0) & 0xf]);
|
|
|
|
|
|
|
|
v = expand2[GET_PLANE(data, 1)];
|
|
|
|
v |= expand2[GET_PLANE(data, 3)] << 2;
|
|
|
|
PUT_PIXEL2(d, 4, palette[v >> 12]);
|
|
|
|
PUT_PIXEL2(d, 5, palette[(v >> 8) & 0xf]);
|
|
|
|
PUT_PIXEL2(d, 6, palette[(v >> 4) & 0xf]);
|
|
|
|
PUT_PIXEL2(d, 7, palette[(v >> 0) & 0xf]);
|
|
|
|
d += BPP * 16;
|
|
|
|
s += 4;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2007-09-16 23:08:06 +02:00
|
|
|
/*
|
2003-08-05 01:30:47 +02:00
|
|
|
* 16 color mode
|
|
|
|
*/
|
2009-08-31 16:07:24 +02:00
|
|
|
static void glue(vga_draw_line4_, DEPTH)(VGACommonState *s1, uint8_t *d,
|
2003-08-05 01:30:47 +02:00
|
|
|
const uint8_t *s, int width)
|
|
|
|
{
|
|
|
|
uint32_t plane_mask, data, v, *palette;
|
|
|
|
int x;
|
|
|
|
|
|
|
|
palette = s1->last_palette;
|
2012-01-29 18:02:07 +01:00
|
|
|
plane_mask = mask16[s1->ar[VGA_ATC_PLANE_ENABLE] & 0xf];
|
2003-08-05 01:30:47 +02:00
|
|
|
width >>= 3;
|
|
|
|
for(x = 0; x < width; x++) {
|
|
|
|
data = ((uint32_t *)s)[0];
|
|
|
|
data &= plane_mask;
|
|
|
|
v = expand4[GET_PLANE(data, 0)];
|
|
|
|
v |= expand4[GET_PLANE(data, 1)] << 1;
|
|
|
|
v |= expand4[GET_PLANE(data, 2)] << 2;
|
|
|
|
v |= expand4[GET_PLANE(data, 3)] << 3;
|
|
|
|
((PIXEL_TYPE *)d)[0] = palette[v >> 28];
|
|
|
|
((PIXEL_TYPE *)d)[1] = palette[(v >> 24) & 0xf];
|
|
|
|
((PIXEL_TYPE *)d)[2] = palette[(v >> 20) & 0xf];
|
|
|
|
((PIXEL_TYPE *)d)[3] = palette[(v >> 16) & 0xf];
|
|
|
|
((PIXEL_TYPE *)d)[4] = palette[(v >> 12) & 0xf];
|
|
|
|
((PIXEL_TYPE *)d)[5] = palette[(v >> 8) & 0xf];
|
|
|
|
((PIXEL_TYPE *)d)[6] = palette[(v >> 4) & 0xf];
|
|
|
|
((PIXEL_TYPE *)d)[7] = palette[(v >> 0) & 0xf];
|
|
|
|
d += BPP * 8;
|
|
|
|
s += 4;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2007-09-16 23:08:06 +02:00
|
|
|
/*
|
2003-08-09 01:50:57 +02:00
|
|
|
* 16 color mode, dup2 horizontal
|
|
|
|
*/
|
2009-08-31 16:07:24 +02:00
|
|
|
static void glue(vga_draw_line4d2_, DEPTH)(VGACommonState *s1, uint8_t *d,
|
2003-08-09 01:50:57 +02:00
|
|
|
const uint8_t *s, int width)
|
|
|
|
{
|
|
|
|
uint32_t plane_mask, data, v, *palette;
|
|
|
|
int x;
|
|
|
|
|
|
|
|
palette = s1->last_palette;
|
2012-01-29 18:02:07 +01:00
|
|
|
plane_mask = mask16[s1->ar[VGA_ATC_PLANE_ENABLE] & 0xf];
|
2003-08-09 01:50:57 +02:00
|
|
|
width >>= 3;
|
|
|
|
for(x = 0; x < width; x++) {
|
|
|
|
data = ((uint32_t *)s)[0];
|
|
|
|
data &= plane_mask;
|
|
|
|
v = expand4[GET_PLANE(data, 0)];
|
|
|
|
v |= expand4[GET_PLANE(data, 1)] << 1;
|
|
|
|
v |= expand4[GET_PLANE(data, 2)] << 2;
|
|
|
|
v |= expand4[GET_PLANE(data, 3)] << 3;
|
|
|
|
PUT_PIXEL2(d, 0, palette[v >> 28]);
|
|
|
|
PUT_PIXEL2(d, 1, palette[(v >> 24) & 0xf]);
|
|
|
|
PUT_PIXEL2(d, 2, palette[(v >> 20) & 0xf]);
|
|
|
|
PUT_PIXEL2(d, 3, palette[(v >> 16) & 0xf]);
|
|
|
|
PUT_PIXEL2(d, 4, palette[(v >> 12) & 0xf]);
|
|
|
|
PUT_PIXEL2(d, 5, palette[(v >> 8) & 0xf]);
|
|
|
|
PUT_PIXEL2(d, 6, palette[(v >> 4) & 0xf]);
|
|
|
|
PUT_PIXEL2(d, 7, palette[(v >> 0) & 0xf]);
|
|
|
|
d += BPP * 16;
|
|
|
|
s += 4;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2007-09-16 23:08:06 +02:00
|
|
|
/*
|
2003-08-09 01:50:57 +02:00
|
|
|
* 256 color mode, double pixels
|
|
|
|
*
|
|
|
|
* XXX: add plane_mask support (never used in standard VGA modes)
|
|
|
|
*/
|
2009-08-31 16:07:24 +02:00
|
|
|
static void glue(vga_draw_line8d2_, DEPTH)(VGACommonState *s1, uint8_t *d,
|
2003-08-09 01:50:57 +02:00
|
|
|
const uint8_t *s, int width)
|
|
|
|
{
|
|
|
|
uint32_t *palette;
|
|
|
|
int x;
|
|
|
|
|
|
|
|
palette = s1->last_palette;
|
|
|
|
width >>= 3;
|
|
|
|
for(x = 0; x < width; x++) {
|
|
|
|
PUT_PIXEL2(d, 0, palette[s[0]]);
|
|
|
|
PUT_PIXEL2(d, 1, palette[s[1]]);
|
|
|
|
PUT_PIXEL2(d, 2, palette[s[2]]);
|
|
|
|
PUT_PIXEL2(d, 3, palette[s[3]]);
|
|
|
|
d += BPP * 8;
|
|
|
|
s += 4;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2007-09-16 23:08:06 +02:00
|
|
|
/*
|
2003-08-09 01:50:57 +02:00
|
|
|
* standard 256 color mode
|
2003-08-05 01:30:47 +02:00
|
|
|
*
|
|
|
|
* XXX: add plane_mask support (never used in standard VGA modes)
|
|
|
|
*/
|
2009-08-31 16:07:24 +02:00
|
|
|
static void glue(vga_draw_line8_, DEPTH)(VGACommonState *s1, uint8_t *d,
|
2003-08-05 01:30:47 +02:00
|
|
|
const uint8_t *s, int width)
|
|
|
|
{
|
|
|
|
uint32_t *palette;
|
|
|
|
int x;
|
|
|
|
|
|
|
|
palette = s1->last_palette;
|
|
|
|
width >>= 3;
|
|
|
|
for(x = 0; x < width; x++) {
|
|
|
|
((PIXEL_TYPE *)d)[0] = palette[s[0]];
|
|
|
|
((PIXEL_TYPE *)d)[1] = palette[s[1]];
|
|
|
|
((PIXEL_TYPE *)d)[2] = palette[s[2]];
|
|
|
|
((PIXEL_TYPE *)d)[3] = palette[s[3]];
|
|
|
|
((PIXEL_TYPE *)d)[4] = palette[s[4]];
|
|
|
|
((PIXEL_TYPE *)d)[5] = palette[s[5]];
|
|
|
|
((PIXEL_TYPE *)d)[6] = palette[s[6]];
|
|
|
|
((PIXEL_TYPE *)d)[7] = palette[s[7]];
|
|
|
|
d += BPP * 8;
|
|
|
|
s += 8;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
#endif /* DEPTH != 15 */
|
|
|
|
|
|
|
|
|
|
|
|
/* XXX: optimize */
|
|
|
|
|
2007-09-16 23:08:06 +02:00
|
|
|
/*
|
2003-08-05 01:30:47 +02:00
|
|
|
* 15 bit color
|
|
|
|
*/
|
2009-08-31 16:07:24 +02:00
|
|
|
static void glue(vga_draw_line15_, PIXEL_NAME)(VGACommonState *s1, uint8_t *d,
|
2003-08-05 01:30:47 +02:00
|
|
|
const uint8_t *s, int width)
|
|
|
|
{
|
2009-07-27 16:13:06 +02:00
|
|
|
#if DEPTH == 15 && defined(HOST_WORDS_BIGENDIAN) == defined(TARGET_WORDS_BIGENDIAN)
|
2003-08-05 01:30:47 +02:00
|
|
|
memcpy(d, s, width * 2);
|
|
|
|
#else
|
|
|
|
int w;
|
|
|
|
uint32_t v, r, g, b;
|
|
|
|
|
|
|
|
w = width;
|
|
|
|
do {
|
2003-10-27 22:22:23 +01:00
|
|
|
v = lduw_raw((void *)s);
|
2003-08-05 01:30:47 +02:00
|
|
|
r = (v >> 7) & 0xf8;
|
|
|
|
g = (v >> 2) & 0xf8;
|
|
|
|
b = (v << 3) & 0xf8;
|
2006-05-11 00:17:36 +02:00
|
|
|
((PIXEL_TYPE *)d)[0] = glue(rgb_to_pixel, PIXEL_NAME)(r, g, b);
|
2003-08-05 01:30:47 +02:00
|
|
|
s += 2;
|
|
|
|
d += BPP;
|
|
|
|
} while (--w != 0);
|
2007-09-17 10:09:54 +02:00
|
|
|
#endif
|
2003-08-05 01:30:47 +02:00
|
|
|
}
|
|
|
|
|
2007-09-16 23:08:06 +02:00
|
|
|
/*
|
2003-08-05 01:30:47 +02:00
|
|
|
* 16 bit color
|
|
|
|
*/
|
2009-08-31 16:07:24 +02:00
|
|
|
static void glue(vga_draw_line16_, PIXEL_NAME)(VGACommonState *s1, uint8_t *d,
|
2003-08-05 01:30:47 +02:00
|
|
|
const uint8_t *s, int width)
|
|
|
|
{
|
2009-07-27 16:13:06 +02:00
|
|
|
#if DEPTH == 16 && defined(HOST_WORDS_BIGENDIAN) == defined(TARGET_WORDS_BIGENDIAN)
|
2003-08-05 01:30:47 +02:00
|
|
|
memcpy(d, s, width * 2);
|
|
|
|
#else
|
|
|
|
int w;
|
|
|
|
uint32_t v, r, g, b;
|
|
|
|
|
|
|
|
w = width;
|
|
|
|
do {
|
2003-10-27 22:22:23 +01:00
|
|
|
v = lduw_raw((void *)s);
|
2003-08-05 01:30:47 +02:00
|
|
|
r = (v >> 8) & 0xf8;
|
|
|
|
g = (v >> 3) & 0xfc;
|
|
|
|
b = (v << 3) & 0xf8;
|
2006-05-11 00:17:36 +02:00
|
|
|
((PIXEL_TYPE *)d)[0] = glue(rgb_to_pixel, PIXEL_NAME)(r, g, b);
|
2003-08-05 01:30:47 +02:00
|
|
|
s += 2;
|
|
|
|
d += BPP;
|
|
|
|
} while (--w != 0);
|
2007-09-17 10:09:54 +02:00
|
|
|
#endif
|
2003-08-05 01:30:47 +02:00
|
|
|
}
|
|
|
|
|
2007-09-16 23:08:06 +02:00
|
|
|
/*
|
2004-02-06 20:47:52 +01:00
|
|
|
* 24 bit color
|
|
|
|
*/
|
2009-08-31 16:07:24 +02:00
|
|
|
static void glue(vga_draw_line24_, PIXEL_NAME)(VGACommonState *s1, uint8_t *d,
|
2004-02-06 20:47:52 +01:00
|
|
|
const uint8_t *s, int width)
|
|
|
|
{
|
|
|
|
int w;
|
|
|
|
uint32_t r, g, b;
|
|
|
|
|
|
|
|
w = width;
|
|
|
|
do {
|
2004-06-21 18:56:45 +02:00
|
|
|
#if defined(TARGET_WORDS_BIGENDIAN)
|
|
|
|
r = s[0];
|
|
|
|
g = s[1];
|
|
|
|
b = s[2];
|
|
|
|
#else
|
2004-02-06 20:47:52 +01:00
|
|
|
b = s[0];
|
|
|
|
g = s[1];
|
|
|
|
r = s[2];
|
2004-06-21 18:56:45 +02:00
|
|
|
#endif
|
2006-05-11 00:17:36 +02:00
|
|
|
((PIXEL_TYPE *)d)[0] = glue(rgb_to_pixel, PIXEL_NAME)(r, g, b);
|
2004-02-06 20:47:52 +01:00
|
|
|
s += 3;
|
|
|
|
d += BPP;
|
|
|
|
} while (--w != 0);
|
|
|
|
}
|
|
|
|
|
2007-09-16 23:08:06 +02:00
|
|
|
/*
|
2003-08-05 01:30:47 +02:00
|
|
|
* 32 bit color
|
|
|
|
*/
|
2009-08-31 16:07:24 +02:00
|
|
|
static void glue(vga_draw_line32_, PIXEL_NAME)(VGACommonState *s1, uint8_t *d,
|
2003-08-05 01:30:47 +02:00
|
|
|
const uint8_t *s, int width)
|
|
|
|
{
|
2009-07-27 16:13:06 +02:00
|
|
|
#if DEPTH == 32 && defined(HOST_WORDS_BIGENDIAN) == defined(TARGET_WORDS_BIGENDIAN) && !defined(BGR_FORMAT)
|
2003-08-05 01:30:47 +02:00
|
|
|
memcpy(d, s, width * 4);
|
|
|
|
#else
|
|
|
|
int w;
|
|
|
|
uint32_t r, g, b;
|
|
|
|
|
|
|
|
w = width;
|
|
|
|
do {
|
2004-06-21 18:56:45 +02:00
|
|
|
#if defined(TARGET_WORDS_BIGENDIAN)
|
|
|
|
r = s[1];
|
|
|
|
g = s[2];
|
|
|
|
b = s[3];
|
|
|
|
#else
|
2003-08-05 01:30:47 +02:00
|
|
|
b = s[0];
|
|
|
|
g = s[1];
|
|
|
|
r = s[2];
|
2004-06-21 18:56:45 +02:00
|
|
|
#endif
|
2006-05-11 00:17:36 +02:00
|
|
|
((PIXEL_TYPE *)d)[0] = glue(rgb_to_pixel, PIXEL_NAME)(r, g, b);
|
2003-08-05 01:30:47 +02:00
|
|
|
s += 4;
|
|
|
|
d += BPP;
|
|
|
|
} while (--w != 0);
|
|
|
|
#endif
|
|
|
|
}
|
|
|
|
|
2003-08-09 01:50:57 +02:00
|
|
|
#undef PUT_PIXEL2
|
2003-08-05 01:30:47 +02:00
|
|
|
#undef DEPTH
|
|
|
|
#undef BPP
|
|
|
|
#undef PIXEL_TYPE
|
2006-05-11 00:17:36 +02:00
|
|
|
#undef PIXEL_NAME
|
|
|
|
#undef BGR_FORMAT
|