Moved macros SET_TILE_UPDATED and GET_TILE_UPDATED to vgacore.h to reduce code

duplication.
This commit is contained in:
Volker Ruppert 2017-10-22 10:09:32 +00:00
parent 8261a91ce9
commit 26c6c3bfca
4 changed files with 48 additions and 78 deletions

View File

@ -44,21 +44,6 @@
#if BX_SUPPORT_CLGD54XX
// Only reference the array if the tile numbers are within the bounds
// of the array. If out of bounds, do nothing.
#define SET_TILE_UPDATED(xtile, ytile, value) \
do { \
if (((xtile) < BX_CIRRUS_THIS s.num_x_tiles) && ((ytile) < BX_CIRRUS_THIS s.num_y_tiles)) \
BX_CIRRUS_THIS s.vga_tile_updated[(xtile)+(ytile)*BX_CIRRUS_THIS s.num_x_tiles] = value; \
} while (0)
// Only reference the array if the tile numbers are within the bounds
// of the array. If out of bounds, return 0.
#define GET_TILE_UPDATED(xtile,ytile) \
((((xtile) < BX_CIRRUS_THIS s.num_x_tiles) && ((ytile) < BX_CIRRUS_THIS s.num_y_tiles))? \
BX_CIRRUS_THIS s.vga_tile_updated[(xtile)+(ytile)*BX_CIRRUS_THIS s.num_x_tiles] \
: 0)
#define LOG_THIS BX_CIRRUS_THIS
#if BX_USE_CIRRUS_SMF
@ -467,7 +452,7 @@ void bx_svga_cirrus_c::redraw_area(unsigned x0, unsigned y0, unsigned width,
}
for (yti=yt0; yti<=yt1; yti++) {
for (xti=xt0; xti<=xt1; xti++) {
SET_TILE_UPDATED (xti, yti, 1);
SET_TILE_UPDATED(BX_CIRRUS_THIS, xti, yti, 1);
}
}
}
@ -716,7 +701,7 @@ void bx_svga_cirrus_c::mem_write(bx_phy_address addr, Bit8u value)
}
}
BX_CIRRUS_THIS svga_needs_update_tile = 1;
SET_TILE_UPDATED(((offset % BX_CIRRUS_THIS svga_pitch) / (BX_CIRRUS_THIS svga_bpp / 8)) / X_TILESIZE,
SET_TILE_UPDATED(BX_CIRRUS_THIS, ((offset % BX_CIRRUS_THIS svga_pitch) / (BX_CIRRUS_THIS svga_bpp / 8)) / X_TILESIZE,
(offset / BX_CIRRUS_THIS svga_pitch) / Y_TILESIZE, 1);
return;
} else if ((addr >= BX_CIRRUS_THIS pci_base_address[1]) &&
@ -770,7 +755,7 @@ void bx_svga_cirrus_c::mem_write(bx_phy_address addr, Bit8u value)
}
}
BX_CIRRUS_THIS svga_needs_update_tile = 1;
SET_TILE_UPDATED(((offset % BX_CIRRUS_THIS svga_pitch) / (BX_CIRRUS_THIS svga_bpp / 8)) / X_TILESIZE,
SET_TILE_UPDATED(BX_CIRRUS_THIS, ((offset % BX_CIRRUS_THIS svga_pitch) / (BX_CIRRUS_THIS svga_bpp / 8)) / X_TILESIZE,
(offset / BX_CIRRUS_THIS svga_pitch) / Y_TILESIZE, 1);
}
} else if (addr >= 0xB8000 && addr < 0xB8100) {
@ -1259,7 +1244,7 @@ void bx_svga_cirrus_c::update(void)
}
draw_hardware_cursor(xc, yc, &info);
bx_gui->graphics_tile_update_in_place(xc, yc, w, h);
SET_TILE_UPDATED (xti, yti, 0);
SET_TILE_UPDATED(BX_CIRRUS_THIS, xti, yti, 0);
}
}
}
@ -1308,7 +1293,7 @@ void bx_svga_cirrus_c::update(void)
}
draw_hardware_cursor(xc, yc, &info);
bx_gui->graphics_tile_update_in_place(xc, yc, w, h);
SET_TILE_UPDATED (xti, yti, 0);
SET_TILE_UPDATED(BX_CIRRUS_THIS, xti, yti, 0);
}
}
}
@ -1345,7 +1330,7 @@ void bx_svga_cirrus_c::update(void)
}
draw_hardware_cursor(xc, yc, &info);
bx_gui->graphics_tile_update_in_place(xc, yc, w, h);
SET_TILE_UPDATED (xti, yti, 0);
SET_TILE_UPDATED(BX_CIRRUS_THIS, xti, yti, 0);
}
}
}
@ -1382,7 +1367,7 @@ void bx_svga_cirrus_c::update(void)
}
draw_hardware_cursor(xc, yc, &info);
bx_gui->graphics_tile_update_in_place(xc, yc, w, h);
SET_TILE_UPDATED (xti, yti, 0);
SET_TILE_UPDATED(BX_CIRRUS_THIS, xti, yti, 0);
}
}
}
@ -1420,7 +1405,7 @@ void bx_svga_cirrus_c::update(void)
}
draw_hardware_cursor(xc, yc, &info);
bx_gui->graphics_tile_update_in_place(xc, yc, w, h);
SET_TILE_UPDATED (xti, yti, 0);
SET_TILE_UPDATED(BX_CIRRUS_THIS, xti, yti, 0);
}
}
}
@ -1459,7 +1444,7 @@ void bx_svga_cirrus_c::update(void)
}
draw_hardware_cursor(xc, yc, &info);
bx_gui->graphics_tile_update_in_place(xc, yc, w, h);
SET_TILE_UPDATED (xti, yti, 0);
SET_TILE_UPDATED(BX_CIRRUS_THIS, xti, yti, 0);
}
}
}

View File

@ -41,21 +41,6 @@
#define LOG_THIS theVga->
// Only reference the array if the tile numbers are within the bounds
// of the array. If out of bounds, do nothing.
#define SET_TILE_UPDATED(xtile, ytile, value) \
do { \
if (((xtile) < BX_VGA_THIS s.num_x_tiles) && ((ytile) < BX_VGA_THIS s.num_y_tiles)) \
BX_VGA_THIS s.vga_tile_updated[(xtile)+(ytile)*BX_VGA_THIS s.num_x_tiles] = value; \
} while (0)
// Only reference the array if the tile numbers are within the bounds
// of the array. If out of bounds, return 0.
#define GET_TILE_UPDATED(xtile,ytile) \
((((xtile) < BX_VGA_THIS s.num_x_tiles) && ((ytile) < BX_VGA_THIS s.num_y_tiles))? \
BX_VGA_THIS s.vga_tile_updated[(xtile)+(ytile)*BX_VGA_THIS s.num_x_tiles] \
: 0)
bx_vga_c *theVga = NULL;
int CDECL libvga_LTX_plugin_init(plugin_t *plugin, plugintype_t type)
@ -407,7 +392,7 @@ void bx_vga_c::update(void)
tile_ptr += info.pitch;
}
bx_gui->graphics_tile_update_in_place(xc, yc, w, h);
SET_TILE_UPDATED (xti, yti, 0);
SET_TILE_UPDATED(BX_VGA_THIS, xti, yti, 0);
}
}
}
@ -447,7 +432,7 @@ void bx_vga_c::update(void)
tile_ptr += info.pitch;
}
bx_gui->graphics_tile_update_in_place(xc, yc, w, h);
SET_TILE_UPDATED (xti, yti, 0);
SET_TILE_UPDATED(BX_VGA_THIS, xti, yti, 0);
}
}
}
@ -482,7 +467,7 @@ void bx_vga_c::update(void)
tile_ptr += info.pitch;
}
bx_gui->graphics_tile_update_in_place(xc, yc, w, h);
SET_TILE_UPDATED (xti, yti, 0);
SET_TILE_UPDATED(BX_VGA_THIS, xti, yti, 0);
}
}
}
@ -517,7 +502,7 @@ void bx_vga_c::update(void)
tile_ptr += info.pitch;
}
bx_gui->graphics_tile_update_in_place(xc, yc, w, h);
SET_TILE_UPDATED (xti, yti, 0);
SET_TILE_UPDATED(BX_VGA_THIS, xti, yti, 0);
}
}
}
@ -553,7 +538,7 @@ void bx_vga_c::update(void)
tile_ptr += info.pitch;
}
bx_gui->graphics_tile_update_in_place(xc, yc, w, h);
SET_TILE_UPDATED (xti, yti, 0);
SET_TILE_UPDATED(BX_VGA_THIS, xti, yti, 0);
}
}
}
@ -590,7 +575,7 @@ void bx_vga_c::update(void)
tile_ptr += info.pitch;
}
bx_gui->graphics_tile_update_in_place(xc, yc, w, h);
SET_TILE_UPDATED (xti, yti, 0);
SET_TILE_UPDATED(BX_VGA_THIS, xti, yti, 0);
}
}
}
@ -634,7 +619,7 @@ void bx_vga_c::update(void)
BX_VGA_THIS get_vga_pixel(x, y, BX_VGA_THIS vbe.virtual_start, 0xffff, 0, plane);
}
}
SET_TILE_UPDATED (xti, yti, 0);
SET_TILE_UPDATED(BX_VGA_THIS, xti, yti, 0);
bx_gui->graphics_tile_update_common(BX_VGA_THIS s.tile, xc, yc);
}
}
@ -745,7 +730,7 @@ void bx_vga_c::redraw_area(unsigned x0, unsigned y0, unsigned width,
}
for (yti=yt0; yti<=yt1; yti++) {
for (xti=xt0; xti<=xt1; xti++) {
SET_TILE_UPDATED(xti, yti, 1);
SET_TILE_UPDATED(BX_VGA_THIS, xti, yti, 1);
}
}
@ -844,7 +829,7 @@ bx_vga_c::vbe_mem_write(bx_phy_address addr, Bit8u value)
if ((y_tileno < BX_VGA_THIS s.num_y_tiles) && (x_tileno < BX_VGA_THIS s.num_x_tiles))
{
BX_VGA_THIS s.vga_mem_updated = 1;
SET_TILE_UPDATED (x_tileno, y_tileno, 1);
SET_TILE_UPDATED(BX_VGA_THIS, x_tileno, y_tileno, 1);
}
}
}
@ -1288,7 +1273,7 @@ Bit32u bx_vga_c::vbe_write(Bit32u address, Bit32u value, unsigned io_len)
BX_VGA_THIS s.vga_mem_updated = 1;
for (unsigned xti = 0; xti < BX_VGA_THIS s.num_x_tiles; xti++) {
for (unsigned yti = 0; yti < BX_VGA_THIS s.num_y_tiles; yti++) {
SET_TILE_UPDATED (xti, yti, 1);
SET_TILE_UPDATED(BX_VGA_THIS, xti, yti, 1);
}
}
}

View File

@ -37,21 +37,6 @@
#define VGA_TRACE_FEATURE
// Only reference the array if the tile numbers are within the bounds
// of the array. If out of bounds, do nothing.
#define SET_TILE_UPDATED(xtile, ytile, value) \
do { \
if (((xtile) < s.num_x_tiles) && ((ytile) < s.num_y_tiles)) \
s.vga_tile_updated[(xtile)+(ytile)* s.num_x_tiles] = value; \
} while (0)
// Only reference the array if the tile numbers are within the bounds
// of the array. If out of bounds, return 0.
#define GET_TILE_UPDATED(xtile,ytile) \
((((xtile) < s.num_x_tiles) && ((ytile) < s.num_y_tiles))? \
s.vga_tile_updated[(xtile)+(ytile)* s.num_x_tiles] \
: 0)
static const Bit16u charmap_offset[8] = {
0x0000, 0x4000, 0x8000, 0xc000,
0x2000, 0x6000, 0xa000, 0xe000
@ -120,7 +105,7 @@ void bx_vgacore_c::init(void)
BX_VGA_THIS s.vga_tile_updated = new bx_bool[BX_VGA_THIS s.num_x_tiles * BX_VGA_THIS s.num_y_tiles];
for (y = 0; y < BX_VGA_THIS s.num_y_tiles; y++)
for (x = 0; x < BX_VGA_THIS s.num_x_tiles; x++)
SET_TILE_UPDATED(x, y, 0);
SET_TILE_UPDATED(BX_VGA_THIS, x, y, 0);
if (!BX_VGA_THIS pci_enabled) {
BX_MEM(0)->load_ROM(SIM->get_param_string(BXPN_VGA_ROM_PATH)->getptr(), 0xc0000, 1);
@ -1463,7 +1448,7 @@ void bx_vgacore_c::update(void)
BX_VGA_THIS s.tile[r*X_TILESIZE + c] = DAC_regno;
}
}
SET_TILE_UPDATED (xti, yti, 0);
SET_TILE_UPDATED(BX_VGA_THIS, xti, yti, 0);
bx_gui->graphics_tile_update_common(BX_VGA_THIS s.tile, xc, yc);
}
}
@ -1490,7 +1475,7 @@ void bx_vgacore_c::update(void)
BX_VGA_THIS get_vga_pixel(x, y, start_addr, line_compare, cs_visible, plane);
}
}
SET_TILE_UPDATED (xti, yti, 0);
SET_TILE_UPDATED(BX_VGA_THIS, xti, yti, 0);
bx_gui->graphics_tile_update_common(BX_VGA_THIS s.tile, xc, yc);
}
}
@ -1527,7 +1512,7 @@ void bx_vgacore_c::update(void)
BX_VGA_THIS s.tile[r*X_TILESIZE + c] = DAC_regno;
}
}
SET_TILE_UPDATED (xti, yti, 0);
SET_TILE_UPDATED(BX_VGA_THIS, xti, yti, 0);
bx_gui->graphics_tile_update_common(BX_VGA_THIS s.tile, xc, yc);
}
}
@ -1561,7 +1546,7 @@ void bx_vgacore_c::update(void)
BX_VGA_THIS s.tile[r*X_TILESIZE + c] = color;
}
}
SET_TILE_UPDATED (xti, yti, 0);
SET_TILE_UPDATED(BX_VGA_THIS, xti, yti, 0);
bx_gui->graphics_tile_update_common(BX_VGA_THIS s.tile, xc, yc);
}
}
@ -1585,7 +1570,7 @@ void bx_vgacore_c::update(void)
BX_VGA_THIS s.tile[r*X_TILESIZE + c] = color;
}
}
SET_TILE_UPDATED (xti, yti, 0);
SET_TILE_UPDATED(BX_VGA_THIS, xti, yti, 0);
bx_gui->graphics_tile_update_common(BX_VGA_THIS s.tile, xc, yc);
}
}
@ -1609,7 +1594,7 @@ void bx_vgacore_c::update(void)
BX_VGA_THIS s.tile[r*X_TILESIZE + c] = color;
}
}
SET_TILE_UPDATED (xti, yti, 0);
SET_TILE_UPDATED(BX_VGA_THIS, xti, yti, 0);
bx_gui->graphics_tile_update_common(BX_VGA_THIS s.tile, xc, yc);
}
}
@ -1906,9 +1891,9 @@ void bx_vgacore_c::mem_write(bx_phy_address addr, Bit8u value)
y_tileno/=Y_TILESIZE;
}
BX_VGA_THIS s.vga_mem_updated = 1;
SET_TILE_UPDATED (x_tileno, y_tileno, 1);
SET_TILE_UPDATED(BX_VGA_THIS, x_tileno, y_tileno, 1);
if (x_tileno2!=x_tileno) {
SET_TILE_UPDATED (x_tileno2, y_tileno, 1);
SET_TILE_UPDATED(BX_VGA_THIS, x_tileno2, y_tileno, 1);
}
return;
/* CGA 320x200x4 / 640x200x2 end */
@ -1934,7 +1919,7 @@ void bx_vgacore_c::mem_write(bx_phy_address addr, Bit8u value)
y_tileno = (offset / BX_VGA_THIS s.line_offset) / Y_TILESIZE;
}
BX_VGA_THIS s.vga_mem_updated = 1;
SET_TILE_UPDATED (x_tileno, y_tileno, 1);
SET_TILE_UPDATED(BX_VGA_THIS, x_tileno, y_tileno, 1);
}
return;
}
@ -2215,7 +2200,7 @@ void bx_vgacore_c::mem_write(bx_phy_address addr, Bit8u value)
} else {
y_tileno = (offset / BX_VGA_THIS s.line_offset) / Y_TILESIZE;
}
SET_TILE_UPDATED (x_tileno, y_tileno, 1);
SET_TILE_UPDATED(BX_VGA_THIS, x_tileno, y_tileno, 1);
} else {
if (BX_VGA_THIS s.line_compare < BX_VGA_THIS s.vertical_display_end) {
if (BX_VGA_THIS s.line_offset > 0) {
@ -2229,7 +2214,7 @@ void bx_vgacore_c::mem_write(bx_phy_address addr, Bit8u value)
} else {
y_tileno = ((offset / BX_VGA_THIS s.line_offset) + BX_VGA_THIS s.line_compare + 1) / Y_TILESIZE;
}
SET_TILE_UPDATED (x_tileno, y_tileno, 1);
SET_TILE_UPDATED(BX_VGA_THIS, x_tileno, y_tileno, 1);
}
}
if (offset >= start_addr) {
@ -2245,7 +2230,7 @@ void bx_vgacore_c::mem_write(bx_phy_address addr, Bit8u value)
} else {
y_tileno = (offset / BX_VGA_THIS s.line_offset) / Y_TILESIZE;
}
SET_TILE_UPDATED (x_tileno, y_tileno, 1);
SET_TILE_UPDATED(BX_VGA_THIS, x_tileno, y_tileno, 1);
}
}
}
@ -2373,7 +2358,7 @@ void bx_vgacore_c::redraw_area(unsigned x0, unsigned y0, unsigned width, unsigne
}
for (yti=yt0; yti<=yt1; yti++) {
for (xti=xt0; xti<=xt1; xti++) {
SET_TILE_UPDATED(xti, yti, 1);
SET_TILE_UPDATED(BX_VGA_THIS, xti, yti, 1);
}
}

View File

@ -45,6 +45,21 @@
#define X_TILESIZE 16
#define Y_TILESIZE 24
// Only reference the array if the tile numbers are within the bounds
// of the array. If out of bounds, do nothing.
#define SET_TILE_UPDATED(thisp, xtile, ytile, value) \
do { \
if (((xtile) < thisp s.num_x_tiles) && ((ytile) < thisp s.num_y_tiles)) \
thisp s.vga_tile_updated[(xtile)+(ytile)* thisp s.num_x_tiles] = value; \
} while (0)
// Only reference the array if the tile numbers are within the bounds
// of the array. If out of bounds, return 0.
#define GET_TILE_UPDATED(xtile,ytile) \
((((xtile) < s.num_x_tiles) && ((ytile) < s.num_y_tiles))? \
s.vga_tile_updated[(xtile)+(ytile)* s.num_x_tiles] \
: 0)
#if BX_SUPPORT_PCI
class bx_nonvga_device_c : public bx_pci_device_c {
public: