joncampbell123 / dosbox-x

DOSBox-X fork of the DOSBox project
GNU General Public License v2.0
2.53k stars 369 forks source link

Mode 0x06 has wrong parameters for ega200 machine #5036

Closed MrMadguy64 closed 2 weeks ago

MrMadguy64 commented 3 weeks ago

Describe the bug

int10_modes.cpp, line 472. Mode 0x06 has hde=40 and isn't marked as _REPEAT1.

As result: Mode 0x06

P.S. I also have suggestion, that may be it would be good idea to report EGA config switches as 7 or 8 instead of 9, because: 1) Real EGA BIOS uses CGA emulation mode as default one in this case only 2) It's only way for application to detect, if CGA monitor is used instead of EGA

Steps to reproduce the behaviour

1) Set machine=ega200 in config 2) Run any application, that uses mode 0x06

Expected behavior

Mode 0x06

What operating system(s) this bug have occurred on?

Windows

What version(s) of DOSBox-X have this bug?

Current

Used configuration

No response

Output log

No response

Additional information

No response

Have you checked that no similar bug report(s) exist?

Code of Conduct & Contributing Guidelines

joncampbell123 commented 2 weeks ago

_REPEAT1 tells the INT 10h emulation to set the max scanline to an odd value, which makes sense because CGA uses maxscanline=1 as part of the scheme. Normally this would result in a 320x100 or 640x100 display, but then the bit to use the low bit of the row counter as bit 13 of the address kicks in to faithfully emulate that interleaved memory layout of the CGA. Mode 6 should have the same, obviously. I'll add that now.

joncampbell123 commented 2 weeks ago

It looks like from IBM's reference, 08h means EGA in "emulation mode" while 09h means EGA in "hi res mode".

Note that the bits are inverted so ON=0 and OFF=1.

SW4-3-2-1 = OFF ON ON ON = 1 0 0 0 = 08h

image

http://hackipedia.org/browse.cgi/Computer/Platform/PC%2c%20IBM%20compatible/Video/EGA/IBM/IBM%20Enhanced%20Graphics%20Adapter%20%281984%2d08%2d02%29%2epdf

joncampbell123 commented 2 weeks ago

That should do it, let me know if something still thinks the EGA is in high res monitor mode for machine=ega200

MrMadguy64 commented 2 weeks ago

It looks like from IBM's reference, 08h means EGA in "emulation mode" while 09h means EGA in "hi res mode".

Note that the bits are inverted so ON=0 and OFF=1.

SW4-3-2-1 = OFF ON ON ON = 1 0 0 0 = 08h

image

http://hackipedia.org/browse.cgi/Computer/Platform/PC%2c%20IBM%20compatible/Video/EGA/IBM/IBM%20Enhanced%20Graphics%20Adapter%20%281984%2d08%2d02%29%2epdf

Thanks a lot.

Official EGA manual says, that 7 and 8 are essentially the same. So I'm not sure, what is better. May be 7 is more logical, as it means, that real CGA monitor is attached - not just CGA mode used on EGA display. But anyway. I'm not sure about other software, but my program uses simple "if it's neither mono, nor EGA Enhanced - then it's CGA" logic.

All 16 values of switches are actually used. Values < 6 are used to indicate, that EGA is secondary adapter. And values > 11 are used by VGAs to determine their default display combinations. At least Tseng ET3000 do it. I haven't checked other BIOSes.

Another thing, that doesn't affect anything, but isn't correct - is line 512 of int10.cpp:

reg_bh=(real_readw(BIOSMEM_SEG,BIOSMEM_CRTC_ADDRESS)==0x3B4);

This code comes from assumption, that default video mode is set, when this function is called. Same assumption is made by Linux X server. Real BIOS simply returns bit 1 of EGA info byte at 0x0487, that is determined via switch settings. It's more logical, as 0x0463 - is primary card's CRTC address. So, if EGA isn't primary, then reg_bh would be wrong. It doesn't matter, because DOSBox doesn't emulate secondary displays.

It also would be wrong, if user would change mode before calling this function. For example if user would set mode 0x07 or 0x0F.