From 49232557d741c34e69f853272f0f9af3ac69d663 Mon Sep 17 00:00:00 2001 From: OBattler Date: Fri, 9 Jul 2021 23:58:56 +0200 Subject: [PATCH] TGUI96x0 banking fixes. --- src/video/vid_tgui9440.c | 27 ++++++++++++++------------- 1 file changed, 14 insertions(+), 13 deletions(-) diff --git a/src/video/vid_tgui9440.c b/src/video/vid_tgui9440.c index 2429f52b1..0405ec6a5 100644 --- a/src/video/vid_tgui9440.c +++ b/src/video/vid_tgui9440.c @@ -275,7 +275,9 @@ tgui_out(uint16_t addr, uint8_t val, void *p) { tgui_t *tgui = (tgui_t *)p; svga_t *svga = &tgui->svga; - uint8_t old; + uint8_t old, mask; + + mask = (tgui->type >= TGUI_9680) ? 0x3f : 0x1f; if (((addr&0xFFF0) == 0x3D0 || (addr&0xFFF0) == 0x3B0) && !(svga->miscout & 1)) addr ^= 0x60; @@ -457,19 +459,18 @@ tgui_out(uint16_t addr, uint8_t val, void *p) return; case 0x3D8: - tgui->tgui_3d8 = val; - if (svga->gdcreg[0xf] & 4) - { - svga->write_bank = (val & 0x1f) * 65536; - if (!(svga->gdcreg[0xf] & 1)) - svga->read_bank = (val & 0x1f) * 65536; - } - return; + tgui->tgui_3d8 = val; + if (svga->gdcreg[0xf] & 4) { + svga->write_bank = (val & mask) * 65536; + if (!(svga->gdcreg[0xf] & 1)) + svga->read_bank = (val & mask) * 65536; + } + return; case 0x3D9: - tgui->tgui_3d9 = val; - if ((svga->gdcreg[0xf] & 5) == 5) - svga->read_bank = (val & 0x1F) * 65536; - return; + tgui->tgui_3d9 = val; + if ((svga->gdcreg[0xf] & 5) == 5) + svga->read_bank = (val & mask) * 65536; + return; case 0x43c8: tgui->clock_n = val & 0x7f;