From e2fbf5df3ff0e24e3770c19cf5d7184e662984da Mon Sep 17 00:00:00 2001 From: TC1995 Date: Wed, 23 Aug 2023 19:58:18 +0200 Subject: [PATCH] Assorted TGUI9440/96x0 fixes: Fixed the Win98 Trident PCI (and 9440 VLB) card accelerator pitch while maintaining compatibility with other OSes, despite being undocumented (this is at least an attempt to fix it properly based on the logs). --- src/video/vid_tgui9440.c | 23 ++++++++++++++++++++--- 1 file changed, 20 insertions(+), 3 deletions(-) diff --git a/src/video/vid_tgui9440.c b/src/video/vid_tgui9440.c index 98f295e45..0b0687326 100644 --- a/src/video/vid_tgui9440.c +++ b/src/video/vid_tgui9440.c @@ -628,6 +628,7 @@ void tgui_recalctimings(svga_t *svga) { tgui_t *tgui = (tgui_t *) svga->priv; + uint8_t ger22lower = (tgui->accel.ger22 & 0xff); uint8_t ger22upper = (tgui->accel.ger22 >> 8); if (!svga->rowoffset) @@ -750,7 +751,8 @@ tgui_recalctimings(svga_t *svga) } switch (svga->hdisp) { case 640: - svga->rowoffset = 80; + if (!ger22lower) + svga->rowoffset = 80; break; } } @@ -1991,17 +1993,25 @@ tgui_accel_out(uint16_t addr, uint8_t val, void *priv) break; case 0x2123: + //pclog("Pitch IO23: val = %02x, rowoffset = %x, pitch = %d.\n", val, svga->rowoffset, tgui->accel.pitch); tgui->accel.ger22 = (tgui->accel.ger22 & 0xff) | (val << 8); if ((val & 0x80) || (((val & 0xc0) == 0x40))) tgui->accel.pitch = svga->rowoffset << 3; - else if (tgui->accel.pitch <= 1024) + else if (tgui->accel.pitch <= 1024) { tgui->accel.pitch = svga->rowoffset << 3; + if (!val) + tgui->accel.pitch = 1024; + } if (tgui->accel.bpp == 1) tgui->accel.pitch >>= 1; else if (tgui->accel.bpp == 3) tgui->accel.pitch >>= 2; + + if (tgui->accel.pitch == 800) + tgui->accel.pitch += 32; + svga_recalctimings(svga); break; @@ -2631,17 +2641,24 @@ tgui_accel_write(uint32_t addr, uint8_t val, void *priv) break; case 0x23: + //pclog("Pitch MM23: val = %02x, rowoffset = %x, pitch = %d.\n", val, svga->rowoffset, tgui->accel.pitch); tgui->accel.ger22 = (tgui->accel.ger22 & 0xff) | (val << 8); if ((val & 0x80) || (((val & 0xc0) == 0x40))) tgui->accel.pitch = svga->rowoffset << 3; - else if (tgui->accel.pitch <= 1024) + else if (tgui->accel.pitch <= 1024) { tgui->accel.pitch = svga->rowoffset << 3; + if (!val) + tgui->accel.pitch = 1024; + } if (tgui->accel.bpp == 1) tgui->accel.pitch >>= 1; else if (tgui->accel.bpp == 3) tgui->accel.pitch >>= 2; + if (tgui->accel.pitch == 800) + tgui->accel.pitch += 32; + svga_recalctimings(svga); break;