From 8b63f5995e44c2d3b221d8ed04b11e0a15cbbf28 Mon Sep 17 00:00:00 2001 From: OBattler Date: Sun, 6 Nov 2022 00:15:30 +0100 Subject: [PATCH] Correctly clear all extensions when extended write modes are disabled, fixes #2800. --- src/video/vid_cl54xx.c | 19 ++++++++++++++----- 1 file changed, 14 insertions(+), 5 deletions(-) diff --git a/src/video/vid_cl54xx.c b/src/video/vid_cl54xx.c index 16839d93a..04791cb19 100644 --- a/src/video/vid_cl54xx.c +++ b/src/video/vid_cl54xx.c @@ -670,7 +670,8 @@ gd54xx_out(uint16_t addr, uint8_t val, void *p) if ((svga->seqaddr == 2) && !gd54xx->unlocked) { o = svga->seqregs[svga->seqaddr & 0x1f]; svga_out(addr, val, svga); - svga->seqregs[svga->seqaddr & 0x1f] = (o & 0xf0) | (val & 0x0f); + if (svga->gdcreg[0xb] & 0x04) + svga->seqregs[svga->seqaddr & 0x1f] = (o & 0xf0) | (val & 0x0f); return; } else if ((svga->seqaddr > 6) && !gd54xx->unlocked) return; @@ -878,10 +879,6 @@ gd54xx_out(uint16_t addr, uint8_t val, void *p) case 0x09: case 0x0a: case 0x0b: - if (svga->gdcreg[0xb] & 0x04) - svga->writemode = svga->gdcreg[5] & 7; - else - svga->writemode = svga->gdcreg[5] & 3; svga->adv_flags = 0; if (svga->gdcreg[0xb] & 0x01) svga->adv_flags = FLAG_EXTRA_BANKS; @@ -893,6 +890,18 @@ gd54xx_out(uint16_t addr, uint8_t val, void *p) svga->adv_flags |= FLAG_LATCH8; if (svga->gdcreg[0xb] & 0x10) svga->adv_flags |= FLAG_ADDR_BY16; + if (svga->gdcreg[0xb] & 0x04) + svga->writemode = svga->gdcreg[5] & 7; + else { + svga->gdcreg[5] &= ~0x04; + svga->writemode = svga->gdcreg[5] & 3; + svga->adv_flags = 0; + svga->gdcreg[0] &= 0x0f; + gd543x_mmio_write(0xb8000, svga->gdcreg[0], gd54xx); + svga->gdcreg[1] &= 0x0f; + gd543x_mmio_write(0xb8004, svga->gdcreg[1], gd54xx); + svga->seqregs[2] &= 0x0f; + } gd54xx_recalc_banking(gd54xx); break;