From 2166ae0fb7b6f02d7a2aaccd65d60a7fb8f9099a Mon Sep 17 00:00:00 2001 From: GreaseMonkey Date: Tue, 21 Nov 2023 16:54:45 +1300 Subject: [PATCH] Get S3 Trio working in mode 13h + Mode-X again Outside of that, we're now using the remappers properly. --- src/include/86box/vid_svga_render.h | 2 ++ src/video/vid_svga_render.c | 23 ++++++++++------------- 2 files changed, 12 insertions(+), 13 deletions(-) diff --git a/src/include/86box/vid_svga_render.h b/src/include/86box/vid_svga_render.h index 3ad9e401c..8a93b4089 100644 --- a/src/include/86box/vid_svga_render.h +++ b/src/include/86box/vid_svga_render.h @@ -53,6 +53,8 @@ void svga_render_4bpp_lowres(svga_t *svga); void svga_render_4bpp_highres(svga_t *svga); void svga_render_8bpp_lowres(svga_t *svga); void svga_render_8bpp_highres(svga_t *svga); +void svga_render_8bpp_s3_lowres(svga_t *svga); +void svga_render_8bpp_s3_highres(svga_t *svga); void svga_render_8bpp_tseng_lowres(svga_t *svga); void svga_render_8bpp_tseng_highres(svga_t *svga); void svga_render_8bpp_gs_lowres(svga_t *svga); diff --git a/src/video/vid_svga_render.c b/src/video/vid_svga_render.c index 79ca2418e..afeddef85 100644 --- a/src/video/vid_svga_render.c +++ b/src/video/vid_svga_render.c @@ -461,19 +461,18 @@ svga_render_indexed_gfx(svga_t *svga, bool highres, bool combine8bits) const bool blinked = svga->blink & 0x10; const bool attrblink = ((svga->attrregs[0x10] & 0x08) != 0); - // FIXME: // The following is likely how it works on an IBM VGA - that is, it works with its BIOS. // But on an S3 Trio, mode 13h is broken - seemingly accepting the address shift but ignoring the increment. - const bool is_s3 = true; + // Forcing it to use incbypow2=0, incevery=1, loadevery=1 makes it behave. const bool dwordload = ((svga->seqregs[0x01] & 0x10) != 0); const bool wordload = ((svga->seqregs[0x01] & 0x04) != 0) && !dwordload; const bool wordincr = ((svga->crtc[0x17] & 0x08) != 0); const bool dwordincr = ((svga->crtc[0x14] & 0x20) != 0) && !wordincr; const bool dwordshift = ((svga->crtc[0x14] & 0x40) != 0); const bool wordshift = ((svga->crtc[0x17] & 0x40) == 0) && !dwordshift; - const uint32_t incbypow2 = (dwordshift ? 2 : wordshift ? 1 : 0); - const uint32_t incevery = (dwordincr ? 4 : wordincr ? 2 : 1); - const uint32_t loadevery = (dwordload ? 4 : wordload ? 2 : 1); + const uint32_t incbypow2 = combine8bits && svga->force_old_addr ? 0 : (dwordshift ? 2 : wordshift ? 1 : 0); + const uint32_t incevery = combine8bits && svga->force_old_addr ? 1 : (dwordincr ? 4 : wordincr ? 2 : 1); + const uint32_t loadevery = combine8bits && svga->force_old_addr ? 1 : (dwordload ? 4 : wordload ? 2 : 1); const bool shift2bit = ((svga->gdcreg[0x05] & 0x60) == 0x20 ); const bool shift4bit = ((svga->gdcreg[0x05] & 0x40) == 0x40 ); @@ -486,8 +485,7 @@ svga_render_indexed_gfx(svga_t *svga, bool highres, bool combine8bits) if ((svga->displine + svga->y_add) < 0) return; - // FIXME look into SVGA remap func to see what we actually need to do here --GM - if (true || svga->force_old_addr) { + if (svga->force_old_addr) { changed_offset = (svga->ma + (svga->sc & ~svga->crtc[0x17] & 3) * 0x8000) >> 12; } else { changed_offset = svga->remap_func(svga, svga->ma) >> 12; @@ -507,13 +505,12 @@ svga_render_indexed_gfx(svga_t *svga, bool highres, bool combine8bits) for (x = 0; x <= (svga->hdisp + svga->scrollcache); x += charwidth) { if (load_counter == 0) { // Find our address - if (true || svga->force_old_addr) { - addr = ((svga->ma & ~0x3) << incbypow2) & svga->vram_display_mask; + if (svga->force_old_addr) { + addr = ((svga->ma & ~0x3) << incbypow2); if (incbypow2 == 2) { - // Mapping is from the 82C451 datasheet, minus the chip-specific extensions. - // if (svga->ma & (4<<13)) addr |= 0x8; - // if (svga->ma & (4<<12)) addr |= 0x4; + if (svga->ma & (4<<15)) addr |= 0x8; + if (svga->ma & (4<<14)) addr |= 0x4; } else if (incbypow2 == 1) { if ((svga->crtc[0x17] & 0x20)) { if (svga->ma & (4<<15)) addr |= 0x4; @@ -531,6 +528,7 @@ svga_render_indexed_gfx(svga_t *svga, bool highres, bool combine8bits) } else { addr = svga->remap_func(svga, svga->ma); } + addr &= svga->vram_display_mask; // Load VRAM *(uint32_t *)&edat[0] = *(uint32_t *)&svga->vram[addr]; @@ -781,7 +779,6 @@ svga_render_8bpp_highres(svga_t *svga) } #endif - void svga_render_8bpp_tseng_lowres(svga_t *svga) {