2003-08-04 23:30:47 +00:00
|
|
|
/*
|
|
|
|
* QEMU VGA Emulator templates
|
2007-09-16 21:08:06 +00:00
|
|
|
*
|
2003-08-04 23:30:47 +00:00
|
|
|
* Copyright (c) 2003 Fabrice Bellard
|
2007-09-16 21:08:06 +00:00
|
|
|
*
|
2003-08-04 23:30:47 +00: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.
|
|
|
|
*/
|
|
|
|
|
2014-06-21 05:51:52 +00:00
|
|
|
static inline void vga_draw_glyph_line(uint8_t *d, uint32_t font_data,
|
|
|
|
uint32_t xorcol, uint32_t bgcol)
|
2003-08-04 23:30:47 +00:00
|
|
|
{
|
2003-09-16 21:47:08 +00: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-08 23:50:57 +00:00
|
|
|
}
|
|
|
|
|
2014-06-21 05:51:52 +00:00
|
|
|
static void vga_draw_glyph8(uint8_t *d, int linesize,
|
|
|
|
const uint8_t *font_ptr, int h,
|
|
|
|
uint32_t fgcol, uint32_t bgcol)
|
2003-08-08 23:50:57 +00:00
|
|
|
{
|
|
|
|
uint32_t font_data, xorcol;
|
2007-09-17 08:09:54 +00:00
|
|
|
|
2003-08-08 23:50:57 +00:00
|
|
|
xorcol = bgcol ^ fgcol;
|
|
|
|
do {
|
|
|
|
font_data = font_ptr[0];
|
2014-06-21 05:51:52 +00:00
|
|
|
vga_draw_glyph_line(d, font_data, xorcol, bgcol);
|
2003-08-08 23:50:57 +00:00
|
|
|
font_ptr += 4;
|
|
|
|
d += linesize;
|
|
|
|
} while (--h);
|
|
|
|
}
|
|
|
|
|
2014-06-21 05:51:52 +00:00
|
|
|
static void vga_draw_glyph16(uint8_t *d, int linesize,
|
2003-08-08 23:50:57 +00:00
|
|
|
const uint8_t *font_ptr, int h,
|
|
|
|
uint32_t fgcol, uint32_t bgcol)
|
|
|
|
{
|
|
|
|
uint32_t font_data, xorcol;
|
2007-09-17 08:09:54 +00:00
|
|
|
|
2003-08-08 23:50:57 +00:00
|
|
|
xorcol = bgcol ^ fgcol;
|
|
|
|
do {
|
|
|
|
font_data = font_ptr[0];
|
2014-06-21 05:51:52 +00:00
|
|
|
vga_draw_glyph_line(d, expand4to8[font_data >> 4],
|
|
|
|
xorcol, bgcol);
|
|
|
|
vga_draw_glyph_line(d + 32, expand4to8[font_data & 0x0f],
|
|
|
|
xorcol, bgcol);
|
2003-08-04 23:30:47 +00:00
|
|
|
font_ptr += 4;
|
|
|
|
d += linesize;
|
|
|
|
} while (--h);
|
|
|
|
}
|
|
|
|
|
2014-06-21 05:51:52 +00:00
|
|
|
static void vga_draw_glyph9(uint8_t *d, int linesize,
|
|
|
|
const uint8_t *font_ptr, int h,
|
|
|
|
uint32_t fgcol, uint32_t bgcol, int dup9)
|
2003-08-04 23:30:47 +00:00
|
|
|
{
|
|
|
|
uint32_t font_data, xorcol, v;
|
2007-09-17 08:09:54 +00:00
|
|
|
|
2003-08-04 23:30:47 +00:00
|
|
|
xorcol = bgcol ^ fgcol;
|
|
|
|
do {
|
|
|
|
font_data = font_ptr[0];
|
2004-04-07 20:31:38 +00: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-04 23:30:47 +00:00
|
|
|
((uint32_t *)d)[7] = v;
|
|
|
|
if (dup9)
|
2003-08-05 23:06:22 +00:00
|
|
|
((uint32_t *)d)[8] = v;
|
2003-08-04 23:30:47 +00:00
|
|
|
else
|
2003-08-05 23:06:22 +00:00
|
|
|
((uint32_t *)d)[8] = bgcol;
|
2003-08-04 23:30:47 +00:00
|
|
|
font_ptr += 4;
|
|
|
|
d += linesize;
|
|
|
|
} while (--h);
|
|
|
|
}
|
|
|
|
|
2007-09-16 21:08:06 +00:00
|
|
|
/*
|
2003-08-04 23:30:47 +00:00
|
|
|
* 4 color mode
|
|
|
|
*/
|
2017-08-28 12:29:06 +00:00
|
|
|
static void vga_draw_line2(VGACommonState *vga, uint8_t *d,
|
|
|
|
uint32_t addr, int width)
|
2003-08-04 23:30:47 +00:00
|
|
|
{
|
|
|
|
uint32_t plane_mask, *palette, data, v;
|
|
|
|
int x;
|
|
|
|
|
2017-08-28 12:29:06 +00:00
|
|
|
palette = vga->last_palette;
|
|
|
|
plane_mask = mask16[vga->ar[VGA_ATC_PLANE_ENABLE] & 0xf];
|
2003-08-04 23:30:47 +00:00
|
|
|
width >>= 3;
|
|
|
|
for(x = 0; x < width; x++) {
|
2017-08-28 12:29:06 +00:00
|
|
|
data = vga_read_dword_le(vga, addr);
|
2003-08-04 23:30:47 +00:00
|
|
|
data &= plane_mask;
|
|
|
|
v = expand2[GET_PLANE(data, 0)];
|
|
|
|
v |= expand2[GET_PLANE(data, 2)] << 2;
|
2014-06-21 05:51:52 +00:00
|
|
|
((uint32_t *)d)[0] = palette[v >> 12];
|
|
|
|
((uint32_t *)d)[1] = palette[(v >> 8) & 0xf];
|
|
|
|
((uint32_t *)d)[2] = palette[(v >> 4) & 0xf];
|
|
|
|
((uint32_t *)d)[3] = palette[(v >> 0) & 0xf];
|
2003-08-04 23:30:47 +00:00
|
|
|
|
|
|
|
v = expand2[GET_PLANE(data, 1)];
|
|
|
|
v |= expand2[GET_PLANE(data, 3)] << 2;
|
2014-06-21 05:51:52 +00:00
|
|
|
((uint32_t *)d)[4] = palette[v >> 12];
|
|
|
|
((uint32_t *)d)[5] = palette[(v >> 8) & 0xf];
|
|
|
|
((uint32_t *)d)[6] = palette[(v >> 4) & 0xf];
|
|
|
|
((uint32_t *)d)[7] = palette[(v >> 0) & 0xf];
|
|
|
|
d += 32;
|
2017-08-28 12:29:06 +00:00
|
|
|
addr += 4;
|
2003-08-04 23:30:47 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2003-08-08 23:50:57 +00:00
|
|
|
#define PUT_PIXEL2(d, n, v) \
|
|
|
|
((uint32_t *)d)[2*(n)] = ((uint32_t *)d)[2*(n)+1] = (v)
|
|
|
|
|
2007-09-16 21:08:06 +00:00
|
|
|
/*
|
2003-08-08 23:50:57 +00:00
|
|
|
* 4 color mode, dup2 horizontal
|
|
|
|
*/
|
2017-08-28 12:29:06 +00:00
|
|
|
static void vga_draw_line2d2(VGACommonState *vga, uint8_t *d,
|
|
|
|
uint32_t addr, int width)
|
2003-08-08 23:50:57 +00:00
|
|
|
{
|
|
|
|
uint32_t plane_mask, *palette, data, v;
|
|
|
|
int x;
|
|
|
|
|
2017-08-28 12:29:06 +00:00
|
|
|
palette = vga->last_palette;
|
|
|
|
plane_mask = mask16[vga->ar[VGA_ATC_PLANE_ENABLE] & 0xf];
|
2003-08-08 23:50:57 +00:00
|
|
|
width >>= 3;
|
|
|
|
for(x = 0; x < width; x++) {
|
2017-08-28 12:29:06 +00:00
|
|
|
data = vga_read_dword_le(vga, addr);
|
2003-08-08 23:50:57 +00:00
|
|
|
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]);
|
2014-06-21 05:51:52 +00:00
|
|
|
d += 64;
|
2017-08-28 12:29:06 +00:00
|
|
|
addr += 4;
|
2003-08-08 23:50:57 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2007-09-16 21:08:06 +00:00
|
|
|
/*
|
2003-08-04 23:30:47 +00:00
|
|
|
* 16 color mode
|
|
|
|
*/
|
2017-08-28 12:29:06 +00:00
|
|
|
static void vga_draw_line4(VGACommonState *vga, uint8_t *d,
|
|
|
|
uint32_t addr, int width)
|
2003-08-04 23:30:47 +00:00
|
|
|
{
|
|
|
|
uint32_t plane_mask, data, v, *palette;
|
|
|
|
int x;
|
|
|
|
|
2017-08-28 12:29:06 +00:00
|
|
|
palette = vga->last_palette;
|
|
|
|
plane_mask = mask16[vga->ar[VGA_ATC_PLANE_ENABLE] & 0xf];
|
2003-08-04 23:30:47 +00:00
|
|
|
width >>= 3;
|
|
|
|
for(x = 0; x < width; x++) {
|
2017-08-28 12:29:06 +00:00
|
|
|
data = vga_read_dword_le(vga, addr);
|
2003-08-04 23:30:47 +00:00
|
|
|
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;
|
2014-06-21 05:51:52 +00:00
|
|
|
((uint32_t *)d)[0] = palette[v >> 28];
|
|
|
|
((uint32_t *)d)[1] = palette[(v >> 24) & 0xf];
|
|
|
|
((uint32_t *)d)[2] = palette[(v >> 20) & 0xf];
|
|
|
|
((uint32_t *)d)[3] = palette[(v >> 16) & 0xf];
|
|
|
|
((uint32_t *)d)[4] = palette[(v >> 12) & 0xf];
|
|
|
|
((uint32_t *)d)[5] = palette[(v >> 8) & 0xf];
|
|
|
|
((uint32_t *)d)[6] = palette[(v >> 4) & 0xf];
|
|
|
|
((uint32_t *)d)[7] = palette[(v >> 0) & 0xf];
|
|
|
|
d += 32;
|
2017-08-28 12:29:06 +00:00
|
|
|
addr += 4;
|
2003-08-04 23:30:47 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2007-09-16 21:08:06 +00:00
|
|
|
/*
|
2003-08-08 23:50:57 +00:00
|
|
|
* 16 color mode, dup2 horizontal
|
|
|
|
*/
|
2017-08-28 12:29:06 +00:00
|
|
|
static void vga_draw_line4d2(VGACommonState *vga, uint8_t *d,
|
|
|
|
uint32_t addr, int width)
|
2003-08-08 23:50:57 +00:00
|
|
|
{
|
|
|
|
uint32_t plane_mask, data, v, *palette;
|
|
|
|
int x;
|
|
|
|
|
2017-08-28 12:29:06 +00:00
|
|
|
palette = vga->last_palette;
|
|
|
|
plane_mask = mask16[vga->ar[VGA_ATC_PLANE_ENABLE] & 0xf];
|
2003-08-08 23:50:57 +00:00
|
|
|
width >>= 3;
|
|
|
|
for(x = 0; x < width; x++) {
|
2017-08-28 12:29:06 +00:00
|
|
|
data = vga_read_dword_le(vga, addr);
|
2003-08-08 23:50:57 +00:00
|
|
|
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]);
|
2014-06-21 05:51:52 +00:00
|
|
|
d += 64;
|
2017-08-28 12:29:06 +00:00
|
|
|
addr += 4;
|
2003-08-08 23:50:57 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2007-09-16 21:08:06 +00:00
|
|
|
/*
|
2003-08-08 23:50:57 +00:00
|
|
|
* 256 color mode, double pixels
|
|
|
|
*
|
|
|
|
* XXX: add plane_mask support (never used in standard VGA modes)
|
|
|
|
*/
|
2017-08-28 12:29:06 +00:00
|
|
|
static void vga_draw_line8d2(VGACommonState *vga, uint8_t *d,
|
|
|
|
uint32_t addr, int width)
|
2003-08-08 23:50:57 +00:00
|
|
|
{
|
|
|
|
uint32_t *palette;
|
|
|
|
int x;
|
|
|
|
|
2017-08-28 12:29:06 +00:00
|
|
|
palette = vga->last_palette;
|
2003-08-08 23:50:57 +00:00
|
|
|
width >>= 3;
|
|
|
|
for(x = 0; x < width; x++) {
|
2017-08-28 12:29:06 +00:00
|
|
|
PUT_PIXEL2(d, 0, palette[vga_read_byte(vga, addr + 0)]);
|
|
|
|
PUT_PIXEL2(d, 1, palette[vga_read_byte(vga, addr + 1)]);
|
|
|
|
PUT_PIXEL2(d, 2, palette[vga_read_byte(vga, addr + 2)]);
|
|
|
|
PUT_PIXEL2(d, 3, palette[vga_read_byte(vga, addr + 3)]);
|
2014-06-21 05:51:52 +00:00
|
|
|
d += 32;
|
2017-08-28 12:29:06 +00:00
|
|
|
addr += 4;
|
2003-08-08 23:50:57 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2007-09-16 21:08:06 +00:00
|
|
|
/*
|
2003-08-08 23:50:57 +00:00
|
|
|
* standard 256 color mode
|
2003-08-04 23:30:47 +00:00
|
|
|
*
|
|
|
|
* XXX: add plane_mask support (never used in standard VGA modes)
|
|
|
|
*/
|
2017-08-28 12:29:06 +00:00
|
|
|
static void vga_draw_line8(VGACommonState *vga, uint8_t *d,
|
|
|
|
uint32_t addr, int width)
|
2003-08-04 23:30:47 +00:00
|
|
|
{
|
|
|
|
uint32_t *palette;
|
|
|
|
int x;
|
|
|
|
|
2017-08-28 12:29:06 +00:00
|
|
|
palette = vga->last_palette;
|
2003-08-04 23:30:47 +00:00
|
|
|
width >>= 3;
|
|
|
|
for(x = 0; x < width; x++) {
|
2017-08-28 12:29:06 +00:00
|
|
|
((uint32_t *)d)[0] = palette[vga_read_byte(vga, addr + 0)];
|
|
|
|
((uint32_t *)d)[1] = palette[vga_read_byte(vga, addr + 1)];
|
|
|
|
((uint32_t *)d)[2] = palette[vga_read_byte(vga, addr + 2)];
|
|
|
|
((uint32_t *)d)[3] = palette[vga_read_byte(vga, addr + 3)];
|
|
|
|
((uint32_t *)d)[4] = palette[vga_read_byte(vga, addr + 4)];
|
|
|
|
((uint32_t *)d)[5] = palette[vga_read_byte(vga, addr + 5)];
|
|
|
|
((uint32_t *)d)[6] = palette[vga_read_byte(vga, addr + 6)];
|
|
|
|
((uint32_t *)d)[7] = palette[vga_read_byte(vga, addr + 7)];
|
2014-06-21 05:51:52 +00:00
|
|
|
d += 32;
|
2017-08-28 12:29:06 +00:00
|
|
|
addr += 8;
|
2003-08-04 23:30:47 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2007-09-16 21:08:06 +00:00
|
|
|
/*
|
2003-08-04 23:30:47 +00:00
|
|
|
* 15 bit color
|
|
|
|
*/
|
2017-08-28 12:29:06 +00:00
|
|
|
static void vga_draw_line15_le(VGACommonState *vga, uint8_t *d,
|
|
|
|
uint32_t addr, int width)
|
2003-08-04 23:30:47 +00:00
|
|
|
{
|
|
|
|
int w;
|
|
|
|
uint32_t v, r, g, b;
|
|
|
|
|
|
|
|
w = width;
|
|
|
|
do {
|
2017-08-28 12:29:06 +00:00
|
|
|
v = vga_read_word_le(vga, addr);
|
2014-07-06 23:48:28 +00:00
|
|
|
r = (v >> 7) & 0xf8;
|
|
|
|
g = (v >> 2) & 0xf8;
|
|
|
|
b = (v << 3) & 0xf8;
|
|
|
|
((uint32_t *)d)[0] = rgb_to_pixel32(r, g, b);
|
2017-08-28 12:29:06 +00:00
|
|
|
addr += 2;
|
2014-07-06 23:48:28 +00:00
|
|
|
d += 4;
|
|
|
|
} while (--w != 0);
|
|
|
|
}
|
|
|
|
|
2017-08-28 12:29:06 +00:00
|
|
|
static void vga_draw_line15_be(VGACommonState *vga, uint8_t *d,
|
|
|
|
uint32_t addr, int width)
|
2014-07-06 23:48:28 +00:00
|
|
|
{
|
|
|
|
int w;
|
|
|
|
uint32_t v, r, g, b;
|
|
|
|
|
|
|
|
w = width;
|
|
|
|
do {
|
2017-08-28 12:29:06 +00:00
|
|
|
v = vga_read_word_be(vga, addr);
|
2003-08-04 23:30:47 +00:00
|
|
|
r = (v >> 7) & 0xf8;
|
|
|
|
g = (v >> 2) & 0xf8;
|
|
|
|
b = (v << 3) & 0xf8;
|
2014-06-21 05:51:52 +00:00
|
|
|
((uint32_t *)d)[0] = rgb_to_pixel32(r, g, b);
|
2017-08-28 12:29:06 +00:00
|
|
|
addr += 2;
|
2014-06-21 05:51:52 +00:00
|
|
|
d += 4;
|
2003-08-04 23:30:47 +00:00
|
|
|
} while (--w != 0);
|
|
|
|
}
|
|
|
|
|
2007-09-16 21:08:06 +00:00
|
|
|
/*
|
2003-08-04 23:30:47 +00:00
|
|
|
* 16 bit color
|
|
|
|
*/
|
2017-08-28 12:29:06 +00:00
|
|
|
static void vga_draw_line16_le(VGACommonState *vga, uint8_t *d,
|
|
|
|
uint32_t addr, int width)
|
2003-08-04 23:30:47 +00:00
|
|
|
{
|
|
|
|
int w;
|
|
|
|
uint32_t v, r, g, b;
|
|
|
|
|
|
|
|
w = width;
|
|
|
|
do {
|
2017-08-28 12:29:06 +00:00
|
|
|
v = vga_read_word_le(vga, addr);
|
2014-07-06 23:48:28 +00:00
|
|
|
r = (v >> 8) & 0xf8;
|
|
|
|
g = (v >> 3) & 0xfc;
|
|
|
|
b = (v << 3) & 0xf8;
|
|
|
|
((uint32_t *)d)[0] = rgb_to_pixel32(r, g, b);
|
2017-08-28 12:29:06 +00:00
|
|
|
addr += 2;
|
2014-07-06 23:48:28 +00:00
|
|
|
d += 4;
|
|
|
|
} while (--w != 0);
|
|
|
|
}
|
|
|
|
|
2017-08-28 12:29:06 +00:00
|
|
|
static void vga_draw_line16_be(VGACommonState *vga, uint8_t *d,
|
|
|
|
uint32_t addr, int width)
|
2014-07-06 23:48:28 +00:00
|
|
|
{
|
|
|
|
int w;
|
|
|
|
uint32_t v, r, g, b;
|
|
|
|
|
|
|
|
w = width;
|
|
|
|
do {
|
2017-08-28 12:29:06 +00:00
|
|
|
v = vga_read_word_be(vga, addr);
|
2003-08-04 23:30:47 +00:00
|
|
|
r = (v >> 8) & 0xf8;
|
|
|
|
g = (v >> 3) & 0xfc;
|
|
|
|
b = (v << 3) & 0xf8;
|
2014-06-21 05:51:52 +00:00
|
|
|
((uint32_t *)d)[0] = rgb_to_pixel32(r, g, b);
|
2017-08-28 12:29:06 +00:00
|
|
|
addr += 2;
|
2014-06-21 05:51:52 +00:00
|
|
|
d += 4;
|
2003-08-04 23:30:47 +00:00
|
|
|
} while (--w != 0);
|
|
|
|
}
|
|
|
|
|
2007-09-16 21:08:06 +00:00
|
|
|
/*
|
2004-02-06 19:47:52 +00:00
|
|
|
* 24 bit color
|
|
|
|
*/
|
2017-08-28 12:29:06 +00:00
|
|
|
static void vga_draw_line24_le(VGACommonState *vga, uint8_t *d,
|
|
|
|
uint32_t addr, int width)
|
2004-02-06 19:47:52 +00:00
|
|
|
{
|
|
|
|
int w;
|
|
|
|
uint32_t r, g, b;
|
|
|
|
|
|
|
|
w = width;
|
|
|
|
do {
|
2017-08-28 12:29:06 +00:00
|
|
|
b = vga_read_byte(vga, addr + 0);
|
|
|
|
g = vga_read_byte(vga, addr + 1);
|
|
|
|
r = vga_read_byte(vga, addr + 2);
|
2014-07-06 23:48:28 +00:00
|
|
|
((uint32_t *)d)[0] = rgb_to_pixel32(r, g, b);
|
2017-08-28 12:29:06 +00:00
|
|
|
addr += 3;
|
2014-07-06 23:48:28 +00:00
|
|
|
d += 4;
|
|
|
|
} while (--w != 0);
|
|
|
|
}
|
|
|
|
|
2017-08-28 12:29:06 +00:00
|
|
|
static void vga_draw_line24_be(VGACommonState *vga, uint8_t *d,
|
|
|
|
uint32_t addr, int width)
|
2014-07-06 23:48:28 +00:00
|
|
|
{
|
|
|
|
int w;
|
|
|
|
uint32_t r, g, b;
|
|
|
|
|
|
|
|
w = width;
|
|
|
|
do {
|
2017-08-28 12:29:06 +00:00
|
|
|
r = vga_read_byte(vga, addr + 0);
|
|
|
|
g = vga_read_byte(vga, addr + 1);
|
|
|
|
b = vga_read_byte(vga, addr + 2);
|
2014-06-21 05:51:52 +00:00
|
|
|
((uint32_t *)d)[0] = rgb_to_pixel32(r, g, b);
|
2017-08-28 12:29:06 +00:00
|
|
|
addr += 3;
|
2014-06-21 05:51:52 +00:00
|
|
|
d += 4;
|
2004-02-06 19:47:52 +00:00
|
|
|
} while (--w != 0);
|
|
|
|
}
|
|
|
|
|
2007-09-16 21:08:06 +00:00
|
|
|
/*
|
2003-08-04 23:30:47 +00:00
|
|
|
* 32 bit color
|
|
|
|
*/
|
2017-08-28 12:29:06 +00:00
|
|
|
static void vga_draw_line32_le(VGACommonState *vga, uint8_t *d,
|
|
|
|
uint32_t addr, int width)
|
2003-08-04 23:30:47 +00:00
|
|
|
{
|
|
|
|
int w;
|
|
|
|
uint32_t r, g, b;
|
|
|
|
|
|
|
|
w = width;
|
|
|
|
do {
|
2017-08-28 12:29:06 +00:00
|
|
|
b = vga_read_byte(vga, addr + 0);
|
|
|
|
g = vga_read_byte(vga, addr + 1);
|
|
|
|
r = vga_read_byte(vga, addr + 2);
|
2014-07-06 23:48:28 +00:00
|
|
|
((uint32_t *)d)[0] = rgb_to_pixel32(r, g, b);
|
2017-08-28 12:29:06 +00:00
|
|
|
addr += 4;
|
2014-07-06 23:48:28 +00:00
|
|
|
d += 4;
|
|
|
|
} while (--w != 0);
|
|
|
|
}
|
|
|
|
|
2017-08-28 12:29:06 +00:00
|
|
|
static void vga_draw_line32_be(VGACommonState *vga, uint8_t *d,
|
|
|
|
uint32_t addr, int width)
|
2014-07-06 23:48:28 +00:00
|
|
|
{
|
|
|
|
int w;
|
|
|
|
uint32_t r, g, b;
|
|
|
|
|
|
|
|
w = width;
|
|
|
|
do {
|
2017-08-28 12:29:06 +00:00
|
|
|
r = vga_read_byte(vga, addr + 1);
|
|
|
|
g = vga_read_byte(vga, addr + 2);
|
|
|
|
b = vga_read_byte(vga, addr + 3);
|
2014-06-21 05:51:52 +00:00
|
|
|
((uint32_t *)d)[0] = rgb_to_pixel32(r, g, b);
|
2017-08-28 12:29:06 +00:00
|
|
|
addr += 4;
|
2014-06-21 05:51:52 +00:00
|
|
|
d += 4;
|
2003-08-04 23:30:47 +00:00
|
|
|
} while (--w != 0);
|
|
|
|
}
|