From f5642ab1c3f10e40004f0945c3cffa37e413455c Mon Sep 17 00:00:00 2001 From: TC1995 Date: Mon, 18 Dec 2023 13:42:32 +0100 Subject: [PATCH 1/2] MGA fixes 2: 1. Reverted the packed chain4 and fb_only sides to 1 when extended mode is set, but with the call to svga_recalctimings removed from port 0x3df due to mode issues, this should fix all the MGA mode issues I know. 2. Cleaned up the rendering order in svga_recalctimings, especially 4bpp and 8bpp. --- src/video/vid_mga.c | 12 +++--------- src/video/vid_svga.c | 32 +++++++++----------------------- 2 files changed, 12 insertions(+), 32 deletions(-) diff --git a/src/video/vid_mga.c b/src/video/vid_mga.c index c505b5cc2..9289c83ce 100644 --- a/src/video/vid_mga.c +++ b/src/video/vid_mga.c @@ -721,12 +721,6 @@ mystique_out(uint16_t addr, uint8_t val, void *priv) mystique->crtcext_regs[mystique->crtcext_idx] = val; if (mystique->crtcext_idx == 1) svga->dpms = !!(val & 0x30); - if (mystique->crtcext_idx < 4) { - if (mystique->crtcext_idx != 3) { - svga->fullchange = changeframecount; - svga_recalctimings(svga); - } - } if (mystique->crtcext_idx == 4) { if (svga->gdcreg[6] & 0xc) { /*64k banks*/ @@ -947,8 +941,8 @@ mystique_recalctimings(svga_t *svga) break; } } + svga->packed_chain4 = 1; svga->line_compare = mystique_line_compare; - svga->packed_chain4 = !svga->chain4; } else { svga->packed_chain4 = 0; svga->line_compare = NULL; @@ -958,8 +952,8 @@ mystique_recalctimings(svga_t *svga) svga->fb_only = svga->packed_chain4; svga->disable_blink = (svga->bpp > 4); -#if 0 - pclog("PackedChain4=%d, chain4=%x, fast=%x, bit6 attrreg10=%02x, bits 5-6 gdcreg5=%02x.\n", svga->packed_chain4, svga->chain4, svga->fast, svga->attrregs[0x10] & 0x40, svga->gdcreg[5] & 0x60); +#if 1 + pclog("PackedChain4=%d, chain4=%x, fast=%x, bit6 attrreg10=%02x, bits 5-6 gdcreg5=%02x, extmode=%02x.\n", svga->packed_chain4, svga->chain4, svga->fast, svga->attrregs[0x10] & 0x40, svga->gdcreg[5] & 0x60, mystique->pci_regs[0x41] & 1, mystique->crtcext_regs[3] & CRTCX_R3_MGAMODE); #endif } diff --git a/src/video/vid_svga.c b/src/video/vid_svga.c index 5f5efcd9e..1479ea718 100644 --- a/src/video/vid_svga.c +++ b/src/video/vid_svga.c @@ -639,27 +639,21 @@ svga_recalctimings(svga_t *svga) svga->hdisp *= (svga->seqregs[1] & 8) ? 16 : 8; svga->hdisp_old = svga->hdisp; - if (svga->bpp <= 8) { - if (svga->attrregs[0x10] & 0x40) { /*8bpp mode*/ - svga->map8 = svga->pallook; - if (svga->lowres) /*Low res (320)*/ - svga->render = svga_render_8bpp_lowres; - else - svga->render = svga_render_8bpp_highres; - } else { + if ((svga->bpp <= 8) || ((svga->gdcreg[5] & 0x60) == 0x00)) { + if ((svga->gdcreg[5] & 0x60) == 0x00) { if (svga->seqregs[1] & 8) /*Low res (320)*/ svga->render = svga_render_4bpp_lowres; else svga->render = svga_render_4bpp_highres; + } else { + svga->map8 = svga->pallook; + if (svga->attrregs[0x10] & 0x40) /*Low res (320)*/ + svga->render = svga_render_8bpp_lowres; + else + svga->render = svga_render_8bpp_highres; } } else { switch (svga->gdcreg[5] & 0x60) { - case 0x00: - if (svga->seqregs[1] & 8) /*Low res (320)*/ - svga->render = svga_render_4bpp_lowres; - else - svga->render = svga_render_4bpp_highres; - break; case 0x20: /*4 colours*/ if (svga->seqregs[1] & 8) /*Low res (320)*/ svga->render = svga_render_2bpp_lowres; @@ -669,13 +663,6 @@ svga_recalctimings(svga_t *svga) case 0x40: case 0x60: /*256+ colours*/ switch (svga->bpp) { - case 8: - svga->map8 = svga->pallook; - if (svga->lowres) - svga->render = svga_render_8bpp_lowres; - else - svga->render = svga_render_8bpp_highres; - break; case 15: if (svga->lowres) svga->render = svga_render_15bpp_lowres; @@ -1920,9 +1907,8 @@ svga_readl_common(uint32_t addr, uint8_t linear, void *priv) { svga_t *svga = (svga_t *) priv; - if (!svga->fast) { + if (!svga->fast) return svga_read_common(addr, linear, priv) | (svga_read_common(addr + 1, linear, priv) << 8) | (svga_read_common(addr + 2, linear, priv) << 16) | (svga_read_common(addr + 3, linear, priv) << 24); - } cycles -= svga->monitor->mon_video_timing_read_l; From 718fb759af92681644f354f68dccf9c5fe88e695 Mon Sep 17 00:00:00 2001 From: TC1995 Date: Mon, 18 Dec 2023 13:47:23 +0100 Subject: [PATCH 2/2] There, log excess disabled. --- src/video/vid_mga.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/video/vid_mga.c b/src/video/vid_mga.c index 9289c83ce..b2212d268 100644 --- a/src/video/vid_mga.c +++ b/src/video/vid_mga.c @@ -952,7 +952,7 @@ mystique_recalctimings(svga_t *svga) svga->fb_only = svga->packed_chain4; svga->disable_blink = (svga->bpp > 4); -#if 1 +#if 0 pclog("PackedChain4=%d, chain4=%x, fast=%x, bit6 attrreg10=%02x, bits 5-6 gdcreg5=%02x, extmode=%02x.\n", svga->packed_chain4, svga->chain4, svga->fast, svga->attrregs[0x10] & 0x40, svga->gdcreg[5] & 0x60, mystique->pci_regs[0x41] & 1, mystique->crtcext_regs[3] & CRTCX_R3_MGAMODE); #endif }