VOGONS


First post, by gm_matthew

User metadata
Rank Newbie
Rank
Newbie

When running DOSBox with EGA emulation, many of the BIOS video modes have incorrect horizontal and/or vertical totals.

Modes 6 and E have what appears to be double the horizontal total of modes 4, 5 and D (120 compared to 60), but the stored values are 3 clocks higher than the actual horizontal totals due to the routine used to update each CRTC register. Modes 4, 5 and D have a horizontal total of 57 which is correctly stored as 60, but modes 6 and E have a total of 114, which should be stored as 117.

Mode 7 is the MDA-compatible mode, which should have a horizontal total of 98 (stored as 101) and a vertical total of 370 (currently in DOSBox it is 117x440; completely wrong).

Mode F is meant to be a 640x350 graphics mode for the monochrome 5151 monitor with the same horizontal and vertical totals (98x370) as mode 7, but in DOSBox it is currently 93x366, the same as mode 10h (which is intended for EGA monitors only).

Here are the corrected values for the EGA video modes (int10_modes.cpp, line 232):

{ 0x006  ,M_CGA2   ,640 ,200 ,80 ,25 ,8 ,8  ,1 ,0xB8000 ,0x4000 ,117 ,262 ,80 ,200 ,_EGA_LINE_DOUBLE},
{ 0x007 ,M_TEXT ,720 ,350 ,80 ,25 ,9 ,14 ,8 ,0xB0000 ,0x1000 ,101, 370 ,80 ,350 ,0 },

{ 0x00D ,M_EGA ,320 ,200 ,40 ,25 ,8 ,8 ,8 ,0xA0000 ,0x2000 ,60 ,262 ,40 ,200 ,_EGA_HALF_CLOCK | _EGA_LINE_DOUBLE },
{ 0x00E ,M_EGA ,640 ,200 ,80 ,25 ,8 ,8 ,4 ,0xA0000 ,0x4000 ,117 ,262 ,80 ,200 ,_EGA_LINE_DOUBLE },
{ 0x00F ,M_EGA ,640 ,350 ,80 ,25 ,8 ,14 ,2 ,0xA0000 ,0x8000 ,101 ,370 ,80 ,350 ,0 },/*was EGA_2*/

As an additional note, all of the 350-line modes except for mode F are supposed to use the 16 MHz clock, but only mode 7 actually does so; all the others use the 14 MHz clock and end up running at 52 Hz instead of the correct 60 Hz. The following code chooses the correct clock for the 350-line modes (line 715):

	if (((CurMode->type==M_TEXT) && (CurMode->cwidth==9)) ||
((!IS_VGA_ARCH) && (CurMode->vdispend == 350) && (mode != 0xf))){
// 28MHz clock for 9-pixel wide chars (16MHz for 350-line modes in EGA)
misc_output|=0x4;
}

Reply 1 of 2, by gm_matthew

User metadata
Rank Newbie
Rank
Newbie

Finally got around to creating a diff file with the changes, compatible with SVN r3923. Also posted on SourceForge.

Attachments

  • Filename
    ega_modes.diff
    File size
    2.3 KiB
    Downloads
    113 downloads
    File license
    Fair use/fair dealing exception

Reply 2 of 2, by TheGreatCodeholio

User metadata
Rank Oldbie
Rank
Oldbie

I incorporated the modified EGA modes into DOSBox-X. I just want to confirm: Mode 7 and mode F are supposed to produce a 50Hz refresh rate, all others a 60Hz refresh rate, correct?

DOSBox-X project: more emulation better accuracy.
DOSLIB and DOSLIB2: Learn how to tinker and hack hardware and software from DOS.