From e507ae5e73da443157d98d3ba59591a6caf2860c Mon Sep 17 00:00:00 2001 From: Jonathan Campbell Date: Thu, 6 Jun 2024 01:21:30 -0700 Subject: [PATCH] Fix EGA port 3C2h readback of switches for machine=ega200 [https://github.com/joncampbell123/dosbox-x/issues/5036] --- CHANGELOG | 4 +++- src/hardware/vga_misc.cpp | 13 +++++-------- 2 files changed, 8 insertions(+), 9 deletions(-) diff --git a/CHANGELOG b/CHANGELOG index 588c6b27c97..c712eacbda2 100644 --- a/CHANGELOG +++ b/CHANGELOG @@ -1,6 +1,8 @@ Next: + - Correct EGA switch readback from port 3C2h to reflect a value of 0x8 + instead of 0x9 when machine=ega200 (joncampbell123). - Correct BIOS data area value that holds the "EGA switches" to reflect - 200-line EGA "emulation" when machine=ega200. Value 0x08 instead of 0x09. + 200-line EGA "emulation" when machine=ega200. Value 0x08 instead of 0x09 (joncampbell123). - Correct mode parameters for CGA 640x200 2-color mode when using machine=ega200 so that it displays correctly. (joncampbell123) diff --git a/src/hardware/vga_misc.cpp b/src/hardware/vga_misc.cpp index e836d6394aa..1471ff7ea1f 100644 --- a/src/hardware/vga_misc.cpp +++ b/src/hardware/vga_misc.cpp @@ -159,6 +159,8 @@ static Bitu read_p3c8(Bitu port,Bitu iolen) { return 0x10; } +extern bool ega200; + static Bitu read_p3c2(Bitu port,Bitu iolen) { (void)port;//UNUSED (void)iolen;//UNUSED @@ -168,14 +170,9 @@ static Bitu read_p3c2(Bitu port,Bitu iolen) { else if (IS_VGA_ARCH) retval = 0x60; if(IS_EGAVGA_ARCH) { - switch((vga.misc_output>>2)&3) { - case 0: - case 3: - retval |= 0x10; // 0110 switch positions - break; - default: - break; - } + uint8_t setting = ~((!IS_VGA_ARCH && ega200)?0x08:0x09)/*bits are inverted*/; + const uint8_t bit = (vga.misc_output>>2)&3; + if (setting & (1 << bit)) retval |= 0x10; } if (vga.draw.vret_triggered) retval |= 0x80;