From 77ba033fd9f6ac4587b9c2971795f6de129b3efd Mon Sep 17 00:00:00 2001 From: Ben Russell Date: Mon, 20 Mar 2023 19:32:10 +0000 Subject: [PATCH] vid_ega: Fix CCLK/2 rendering in 4bpp graphics modes Required for 64KB-variant 640x350 2bpp modes (BIOS modes 0x0F, 0x10). This does need some address decoding fixes to break the 16K-word barrier, though - those are coming. --- src/video/vid_ega_render.c | 35 ++++++++++++++++++++--------------- 1 file changed, 20 insertions(+), 15 deletions(-) diff --git a/src/video/vid_ega_render.c b/src/video/vid_ega_render.c index b2d5cb5c1..d4ccc31cf 100644 --- a/src/video/vid_ega_render.c +++ b/src/video/vid_ega_render.c @@ -336,7 +336,7 @@ ega_render_2bpp_highres(ega_t *ega) void ega_render_4bpp_lowres(ega_t *ega) { - int x, oddeven; + int x, secondcclk; uint8_t dat, edat[4]; uint32_t addr, *p; @@ -349,16 +349,19 @@ ega_render_4bpp_lowres(ega_t *ega) ega->firstline_draw = ega->displine; ega->lastline_draw = ega->displine; + secondcclk = 0; for (x = 0; x <= (ega->hdisp + ega->scrollcache); x += 16) { addr = ega->remap_func(ega, ega->ma); - oddeven = 0; if (ega->seqregs[1] & 4) { - oddeven = (addr & 4) ? 1 : 0; - edat[0] = ega->vram[addr | oddeven]; - edat[2] = ega->vram[addr | oddeven | 0x2]; - edat[1] = edat[3] = 0; - ega->ma += 2; + // FIXME: Verify the behaviour of planes 1,3 on actual hardware + edat[0] = ega->vram[(addr | 0) ^ secondcclk]; + edat[1] = ega->vram[(addr | 1) ^ secondcclk]; + edat[2] = ega->vram[(addr | 2) ^ secondcclk]; + edat[3] = ega->vram[(addr | 3) ^ secondcclk]; + secondcclk = (secondcclk + 1) & 1; + if (secondcclk == 0) + ega->ma += 4; } else { *(uint32_t *) (&edat[0]) = *(uint32_t *) (&ega->vram[addr]); ega->ma += 4; @@ -388,7 +391,7 @@ ega_render_4bpp_lowres(ega_t *ega) void ega_render_4bpp_highres(ega_t *ega) { - int x, oddeven; + int x, secondcclk; uint8_t dat, edat[4]; uint32_t addr, *p; @@ -401,16 +404,18 @@ ega_render_4bpp_highres(ega_t *ega) ega->firstline_draw = ega->displine; ega->lastline_draw = ega->displine; + secondcclk = 0; for (x = 0; x <= (ega->hdisp + ega->scrollcache); x += 8) { addr = ega->remap_func(ega, ega->ma); - oddeven = 0; - if (ega->seqregs[1] & 4) { - oddeven = (addr & 4) ? 1 : 0; - edat[0] = ega->vram[addr | oddeven]; - edat[2] = ega->vram[addr | oddeven | 0x2]; - edat[1] = edat[3] = 0; - ega->ma += 2; + // FIXME: Verify the behaviour of planes 1,3 on actual hardware + edat[0] = ega->vram[(addr | 0) ^ secondcclk]; + edat[1] = ega->vram[(addr | 1) ^ secondcclk]; + edat[2] = ega->vram[(addr | 2) ^ secondcclk]; + edat[3] = ega->vram[(addr | 3) ^ secondcclk]; + secondcclk = (secondcclk + 1) & 1; + if (secondcclk == 0) + ega->ma += 4; } else { *(uint32_t *) (&edat[0]) = *(uint32_t *) (&ega->vram[addr]); ega->ma += 4;