- skip screen update if video is unchanged
- some work on save/restore support (not yet complete) - changed some variable types to bx_bool
This commit is contained in:
parent
3a6f649b18
commit
54063b3e0b
@ -187,7 +187,24 @@ void bx_voodoo_c::register_state(void)
|
||||
bx_list_c *list = new bx_list_c(SIM->get_bochs_root(), "voodoo", "Voodoo State");
|
||||
bx_list_c *vstate = new bx_list_c(list, "vstate", "Voodoo Device State");
|
||||
new bx_shadow_data_c(vstate, "reg", (Bit8u*)v->reg, sizeof(v->reg));
|
||||
new bx_shadow_data_c(vstate, "fbi_ram", v->fbi.ram, (4 << 20));
|
||||
new bx_shadow_num_c(vstate, "pci_init_enable", &v->pci.init_enable, BASE_HEX);
|
||||
bx_list_c *fbi = new bx_list_c(vstate, "fbi", "framebuffer");
|
||||
new bx_shadow_data_c(fbi, "ram", v->fbi.ram, (4 << 20));
|
||||
new bx_shadow_num_c(fbi, "mask", &v->fbi.mask, BASE_HEX);
|
||||
new bx_shadow_num_c(fbi, "rgboffs0", &v->fbi.rgboffs[0], BASE_HEX);
|
||||
new bx_shadow_num_c(fbi, "rgboffs1", &v->fbi.rgboffs[1], BASE_HEX);
|
||||
new bx_shadow_num_c(fbi, "rgboffs2", &v->fbi.rgboffs[2], BASE_HEX);
|
||||
new bx_shadow_num_c(fbi, "auxoffs", &v->fbi.auxoffs, BASE_HEX);
|
||||
new bx_shadow_num_c(fbi, "frontbuf", &v->fbi.frontbuf);
|
||||
new bx_shadow_num_c(fbi, "backbuf", &v->fbi.backbuf);
|
||||
new bx_shadow_num_c(fbi, "swaps_pending", &v->fbi.swaps_pending);
|
||||
new bx_shadow_num_c(fbi, "width", &v->fbi.width);
|
||||
new bx_shadow_num_c(fbi, "height", &v->fbi.height);
|
||||
new bx_shadow_num_c(fbi, "rowpixels", &v->fbi.rowpixels);
|
||||
new bx_shadow_bool_c(fbi, "vblank_swap_pending", &v->fbi.vblank_swap_pending);
|
||||
new bx_shadow_bool_c(fbi, "cheating_allowed", &v->fbi.cheating_allowed);
|
||||
new bx_shadow_data_c(fbi, "clut", (Bit8u*)v->fbi.clut, sizeof(v->fbi.clut));
|
||||
new bx_shadow_bool_c(fbi, "clut_dirty", &v->fbi.clut_dirty);
|
||||
new bx_shadow_data_c(vstate, "tmu0_ram", v->tmu[0].ram, (4 << 20));
|
||||
new bx_shadow_data_c(vstate, "tmu1_ram", v->tmu[1].ram, (4 << 20));
|
||||
// TODO
|
||||
@ -207,7 +224,9 @@ void bx_voodoo_c::after_restore_state(void)
|
||||
0x1000000)) {
|
||||
BX_INFO(("new mem base address: 0x%08x", BX_VOODOO_THIS pci_base_address[0]));
|
||||
}
|
||||
BX_VOODOO_THIS s.vdraw.override_on = !BX_VOODOO_THIS s.vdraw.override_on; // force update
|
||||
// force update
|
||||
v->fbi.video_changed = 1;
|
||||
BX_VOODOO_THIS s.vdraw.override_on = !BX_VOODOO_THIS s.vdraw.override_on;
|
||||
BX_VOODOO_THIS s.vdraw.frame_start = bx_pc_system.time_usec();
|
||||
mode_change_timer_handler(NULL);
|
||||
}
|
||||
@ -297,7 +316,7 @@ void bx_voodoo_c::update(void)
|
||||
|
||||
BX_VOODOO_THIS s.vdraw.frame_start = bx_pc_system.time_usec();
|
||||
|
||||
if (v->fbi.vblank_swap_pending == TRUE) {
|
||||
if (v->fbi.vblank_swap_pending) {
|
||||
swap_buffers(v);
|
||||
}
|
||||
|
||||
@ -305,7 +324,9 @@ void bx_voodoo_c::update(void)
|
||||
re.min_x = re.min_y = 0;
|
||||
re.max_x = v->fbi.width;
|
||||
re.max_y = v->fbi.height;
|
||||
voodoo_update(&re);
|
||||
if (!voodoo_update(&re))
|
||||
return;
|
||||
|
||||
Bit8u *disp_ptr = (Bit8u*)(v->fbi.ram + v->fbi.rgboffs[v->fbi.frontbuf]);
|
||||
pitch = v->fbi.rowpixels * 2;
|
||||
|
||||
|
@ -1572,7 +1572,7 @@ struct _fbi_state
|
||||
Bit8u frontbuf; /* front buffer index */
|
||||
Bit8u backbuf; /* back buffer index */
|
||||
Bit8u swaps_pending; /* number of pending swaps */
|
||||
Bit8u video_changed; /* did the frontbuffer video change? */
|
||||
bx_bool video_changed; /* did the frontbuffer video change? */
|
||||
|
||||
Bit32u yorigin; /* Y origin subtract value */
|
||||
Bit32u lfb_base; /* base of LFB in memory */
|
||||
@ -1591,13 +1591,13 @@ struct _fbi_state
|
||||
// emu_timer * vblank_timer /* VBLANK timer */
|
||||
Bit8u vblank; /* VBLANK state */
|
||||
Bit8u vblank_count; /* number of VBLANKs since last swap */
|
||||
Bit8u vblank_swap_pending; /* a swap is pending, waiting for a vblank */
|
||||
bx_bool vblank_swap_pending; /* a swap is pending, waiting for a vblank */
|
||||
Bit8u vblank_swap; /* swap when we hit this count */
|
||||
Bit8u vblank_dont_swap; /* don't actually swap when we hit this point */
|
||||
// voodoo_vblank_func vblank_client; /* client callback */
|
||||
|
||||
/* triangle setup info */
|
||||
Bit8u cheating_allowed; /* allow cheating? */
|
||||
bx_bool cheating_allowed; /* allow cheating? */
|
||||
Bit32s sign; /* triangle sign */
|
||||
Bit16s ax, ay; /* vertex A x,y (12.4) */
|
||||
Bit16s bx, by; /* vertex B x,y (12.4) */
|
||||
@ -1626,7 +1626,7 @@ struct _fbi_state
|
||||
|
||||
rgb_t pen[65536]; /* mapping from pixels to pens */
|
||||
rgb_t clut[512]; /* clut gamma data */
|
||||
Bit8u clut_dirty; /* do we need to recompute? */
|
||||
bx_bool clut_dirty; /* do we need to recompute? */
|
||||
};
|
||||
|
||||
|
||||
|
@ -836,7 +836,7 @@ Bit32s triangle(voodoo_state *v)
|
||||
{
|
||||
case 0: /* front buffer */
|
||||
drawbuf = (Bit16u *)(v->fbi.ram + v->fbi.rgboffs[v->fbi.frontbuf]);
|
||||
v->fbi.video_changed = TRUE;
|
||||
v->fbi.video_changed = 1;
|
||||
break;
|
||||
|
||||
case 1: /* back buffer */
|
||||
@ -1098,7 +1098,7 @@ void swap_buffers(voodoo_state *v)
|
||||
|
||||
/* force a partial update */
|
||||
// video_screen_update_partial(v->screen, video_screen_get_vpos(v->screen));
|
||||
v->fbi.video_changed = TRUE;
|
||||
v->fbi.video_changed = 1;
|
||||
|
||||
/* keep a history of swap intervals */
|
||||
count = v->fbi.vblank_count;
|
||||
@ -1130,7 +1130,7 @@ void swap_buffers(voodoo_state *v)
|
||||
if (v->fbi.swaps_pending)
|
||||
v->fbi.swaps_pending--;
|
||||
v->fbi.vblank_count = 0;
|
||||
v->fbi.vblank_swap_pending = FALSE;
|
||||
v->fbi.vblank_swap_pending = 0;
|
||||
|
||||
/* reset the last_op_time to now and start processing the next command */
|
||||
if (v->pci.op_pending)
|
||||
@ -1214,7 +1214,7 @@ bool dump_tmu=false;
|
||||
Bit32s swapbuffer(voodoo_state *v, Bit32u data)
|
||||
{
|
||||
/* set the don't swap value for Voodoo 2 */
|
||||
v->fbi.vblank_swap_pending = TRUE;
|
||||
v->fbi.vblank_swap_pending = 1;
|
||||
v->fbi.vblank_swap = (data >> 1) & 0xff;
|
||||
v->fbi.vblank_dont_swap = (data >> 9) & 1;
|
||||
|
||||
@ -1742,7 +1742,7 @@ void register_w(Bit32u offset, Bit32u data) {
|
||||
break;
|
||||
|
||||
case ftriangleCMD:
|
||||
v->fbi.cheating_allowed = TRUE;
|
||||
v->fbi.cheating_allowed = 1;
|
||||
v->fbi.sign = data;
|
||||
/* cycles = */ triangle(v);
|
||||
break;
|
||||
@ -1775,7 +1775,7 @@ void register_w(Bit32u offset, Bit32u data) {
|
||||
if (index <= 32)
|
||||
{
|
||||
v->fbi.clut[index] = data;
|
||||
v->fbi.clut_dirty = TRUE;
|
||||
v->fbi.clut_dirty = 1;
|
||||
}
|
||||
}
|
||||
else
|
||||
@ -1904,12 +1904,11 @@ void register_w(Bit32u offset, Bit32u data) {
|
||||
case fbiInit4:
|
||||
poly_wait(v->poly, v->regnames[regnum]);
|
||||
|
||||
|
||||
if (v->type <= VOODOO_2 && (chips & 1) && INITEN_ENABLE_HW_INIT(v->pci.init_enable))
|
||||
{
|
||||
v->reg[regnum].u = data;
|
||||
recompute_video_memory(v);
|
||||
v->fbi.video_changed = true;
|
||||
v->fbi.video_changed = 1;
|
||||
}
|
||||
break;
|
||||
|
||||
@ -2396,7 +2395,7 @@ Bit32s texture_w(Bit32u offset, Bit32u data)
|
||||
case 0: /* front buffer */
|
||||
dest = (Bit16u *)(v->fbi.ram + v->fbi.rgboffs[v->fbi.frontbuf]);
|
||||
destmax = (v->fbi.mask + 1 - v->fbi.rgboffs[v->fbi.frontbuf]) / 2;
|
||||
v->fbi.video_changed = TRUE;
|
||||
v->fbi.video_changed = 1;
|
||||
break;
|
||||
|
||||
case 1: /* back buffer */
|
||||
@ -2886,7 +2885,7 @@ void voodoo_init()
|
||||
}
|
||||
|
||||
/* init the pens */
|
||||
v->fbi.clut_dirty = TRUE;
|
||||
v->fbi.clut_dirty = 1;
|
||||
if (v->type <= VOODOO_2)
|
||||
{
|
||||
for (pen = 0; pen < 32; pen++)
|
||||
@ -2928,39 +2927,35 @@ void voodoo_init()
|
||||
soft_reset(v);
|
||||
}
|
||||
|
||||
int voodoo_update(/*running_device *device, bitmap_t *bitmap, */const rectangle *cliprect)
|
||||
bx_bool voodoo_update(/*running_device *device, bitmap_t *bitmap, */const rectangle *cliprect)
|
||||
{
|
||||
// voodoo_state *v = get_safe_token(device);
|
||||
int changed = v->fbi.video_changed;
|
||||
bx_bool changed = v->fbi.video_changed;
|
||||
// int drawbuf = v->fbi.frontbuf;
|
||||
// int statskey;
|
||||
int x, y;
|
||||
|
||||
/* reset the video changed flag */
|
||||
v->fbi.video_changed = FALSE;
|
||||
v->fbi.video_changed = 0;
|
||||
|
||||
/* if we are blank, just fill with black */
|
||||
if (v->type <= VOODOO_2 && FBIINIT1_SOFTWARE_BLANK(v->reg[fbiInit1].u))
|
||||
{
|
||||
if (v->type <= VOODOO_2 && FBIINIT1_SOFTWARE_BLANK(v->reg[fbiInit1].u)) {
|
||||
// bitmap_fill(bitmap, cliprect, 0);
|
||||
return changed;
|
||||
}
|
||||
|
||||
/* if the CLUT is dirty, recompute the pens array */
|
||||
if (v->fbi.clut_dirty)
|
||||
{
|
||||
if (v->fbi.clut_dirty) {
|
||||
Bit8u rtable[32], gtable[64], btable[32];
|
||||
|
||||
/* Voodoo/Voodoo-2 have an internal 33-entry CLUT */
|
||||
if (v->type <= VOODOO_2)
|
||||
{
|
||||
if (v->type <= VOODOO_2) {
|
||||
/* kludge: some of the Midway games write 0 to the last entry when they obviously mean FF */
|
||||
if ((v->fbi.clut[32] & 0xffffff) == 0 && (v->fbi.clut[31] & 0xffffff) != 0)
|
||||
v->fbi.clut[32] = 0x20ffffff;
|
||||
|
||||
/* compute the R/G/B pens first */
|
||||
for (x = 0; x < 32; x++)
|
||||
{
|
||||
for (x = 0; x < 32; x++) {
|
||||
/* treat X as a 5-bit value, scale up to 8 bits, and linear interpolate for red/blue */
|
||||
y = (x << 3) | (x >> 2);
|
||||
rtable[x] = (RGB_RED(v->fbi.clut[y >> 3]) * (8 - (y & 7)) + RGB_RED(v->fbi.clut[(y >> 3) + 1]) * (y & 7)) >> 3;
|
||||
@ -2985,8 +2980,7 @@ int voodoo_update(/*running_device *device, bitmap_t *bitmap, */const rectangle
|
||||
int bypass = (v->banshee.io[io_vidProcCfg] >> 11) & 1;
|
||||
|
||||
/* compute R/G/B pens first */
|
||||
for (x = 0; x < 32; x++)
|
||||
{
|
||||
for (x = 0; x < 32; x++) {
|
||||
/* treat X as a 5-bit value, scale up to 8 bits */
|
||||
y = (x << 3) | (x >> 2);
|
||||
rtable[x] = bypass ? y : RGB_RED(v->fbi.clut[which * 256 + y]);
|
||||
@ -3005,8 +2999,7 @@ int voodoo_update(/*running_device *device, bitmap_t *bitmap, */const rectangle
|
||||
}
|
||||
|
||||
/* now compute the actual pens array */
|
||||
for (x = 0; x < 65536; x++)
|
||||
{
|
||||
for (x = 0; x < 65536; x++) {
|
||||
int r = rtable[(x >> 11) & 0x1f];
|
||||
int g = gtable[(x >> 5) & 0x3f];
|
||||
int b = btable[x & 0x1f];
|
||||
@ -3014,8 +3007,8 @@ int voodoo_update(/*running_device *device, bitmap_t *bitmap, */const rectangle
|
||||
}
|
||||
|
||||
/* no longer dirty */
|
||||
v->fbi.clut_dirty = FALSE;
|
||||
changed = TRUE;
|
||||
v->fbi.clut_dirty = 0;
|
||||
changed = 1;
|
||||
}
|
||||
|
||||
/* debugging! */
|
||||
|
Loading…
Reference in New Issue
Block a user