From 646e25f1bc524f21fc6a74045986142652c1cb21 Mon Sep 17 00:00:00 2001 From: OBattler Date: Sun, 23 Mar 2025 02:22:10 +0100 Subject: [PATCH] EGA: Implement monochrome attributes for text mode. --- src/video/vid_ega.c | 20 ++++++++++++++++++++ src/video/vid_ega_render.c | 12 ++++++++++-- 2 files changed, 30 insertions(+), 2 deletions(-) diff --git a/src/video/vid_ega.c b/src/video/vid_ega.c index c7345cd00..438d5c98d 100644 --- a/src/video/vid_ega.c +++ b/src/video/vid_ega.c @@ -1447,6 +1447,26 @@ ega_init(ega_t *ega, int monitor_type, int is_mono) ega->pallook = pallook16; + for (uint16_t c = 0; c < 256; c++) { + ega->mdacols[c][0][0] = ega->mdacols[c][1][0] = ega->mdacols[c][1][1] = 16; + if (c & 8) + ega->mdacols[c][0][1] = 15 + 16; + else + ega->mdacols[c][0][1] = 7 + 16; + } + ega->mdacols[0x70][0][1] = 16; + ega->mdacols[0x70][0][0] = ega->mdacols[0x70][1][0] = ega->mdacols[0x70][1][1] = 16 + 15; + ega->mdacols[0xF0][0][1] = 16; + ega->mdacols[0xF0][0][0] = ega->mdacols[0xF0][1][0] = ega->mdacols[0xF0][1][1] = 16 + 15; + ega->mdacols[0x78][0][1] = 16 + 7; + ega->mdacols[0x78][0][0] = ega->mdacols[0x78][1][0] = ega->mdacols[0x78][1][1] = 16 + 15; + ega->mdacols[0xF8][0][1] = 16 + 7; + ega->mdacols[0xF8][0][0] = ega->mdacols[0xF8][1][0] = ega->mdacols[0xF8][1][1] = 16 + 15; + ega->mdacols[0x00][0][1] = ega->mdacols[0x00][1][1] = 16; + ega->mdacols[0x08][0][1] = ega->mdacols[0x08][1][1] = 16; + ega->mdacols[0x80][0][1] = ega->mdacols[0x80][1][1] = 16; + ega->mdacols[0x88][0][1] = ega->mdacols[0x88][1][1] = 16; + egaswitches = monitor_type & 0xf; ega->vram_limit = 256 * 1024; diff --git a/src/video/vid_ega_render.c b/src/video/vid_ega_render.c index fe2632574..d499154e6 100644 --- a/src/video/vid_ega_render.c +++ b/src/video/vid_ega_render.c @@ -118,6 +118,7 @@ ega_render_text(ega_t *ega) const bool doublewidth = ((ega->seqregs[1] & 8) != 0); const bool attrblink = ((ega->attrregs[0x10] & 8) != 0); const bool attrlinechars = (ega->attrregs[0x10] & 4); + const bool monoattrs = (ega->attrregs[0x10] & 2); const bool crtcreset = ((ega->crtc[0x17] & 0x80) == 0); const bool seq9dot = ((ega->seqregs[1] & 1) == 0); const int dwshift = doublewidth ? 1 : 0; @@ -174,8 +175,15 @@ ega_render_text(ega_t *ega) if ((chr & ~0x1F) == 0xC0 && attrlinechars) dat |= (dat >> 1) & 1; - for (int xx = 0; xx < charwidth; xx++) - p[xx] = (dat & (0x100 >> (xx >> dwshift))) ? fg : bg; + for (int xx = 0; xx < charwidth; xx++) { + if (monoattrs) { + if ((ega->sc == (ega->crtc[0x14] + 1)) && ((attr & 7) == 1)) + p[xx] = ega->mdacols[attr][attrblink][1]; + else + p[xx] = ega->mdacols[attr][attrblink][dat & (0x100 >> (xx >> dwshift))]; + } else + p[xx] = (dat & (0x100 >> (xx >> dwshift))) ? fg : bg; + } ega->ma += 4; p += charwidth;