CGAEX / MDAEX                                       15 June 2003, John Elliott
==============================================================================

  CGAEX and MDAEX are programs that can be used to examine various common 
features of a CGA or MDA display card (or of a chipset emulating one). This 
can be used either to work out the capabilities of the display card in a 
computer under test, or to check the performance of a PC emulator.

  The programs can be run under a modern chipset such as VGA, but not all 
features will work.

MDAEX
=====

  MDAEX displays two test screens. The top half shows the entire character
set, while the bottom half shows all 256 combinations of attributes that the
MDA can display. The background is filled with character 177 (half grey).

  Press RETURN to go to the second test screen. This shows all characters,
using attributes 0x07, 0x70 and 0x78.

CGAEX
=====

  CGAEX, when started, displays a menu listing the CGA modes that can be
tested. If you run it on a VGA, the menu will be in VGA mode, but the tests
will still only use CGA modes.
  Whichever mode is selected, the screen will clear and a test screen will be
displayed in that mode. At this point, you can press:

- ESCAPE, to return to the menu. Pressing ESCAPE at the menu will close CGAEX.
- 0-7, to flip bits in the CGA mode control register (port 0x3D8). Be
  careful with bits marked "also requires reprogramming the 6845"; these may
  generate strange output frequencies or blow up your monitor.
     0: 40/80 columns (also requires reprogramming the 6845).
     1: Graphics/text mode (also requires reprogramming the 6845).
     2: Black/white.
     3: Disable/enable video.
     4: Switch between 640x200 and 320x200 graphics.
     5: Enable/disable blinking.
     6: Not used on standard CGA.
     7: Not used on standard CGA.

- a-h, to flip bits in the CGA colour select register (port 0x3D9). These
     vary depending on mode, but as a rough outline:
     a-d: Border colour (text modes)
          Background colour (320x200 modes)
          Foreground colour (640x200 mode)
     e: High intensity (320x200 modes)
     f: Alternate palette (320x200 modes)

   The keys 0-7 and a-h will not work on VGA or similar chipsets.

The modes are:

* Modes 0-3: Text modes. 
  In these modes the test screen consists of a display of all 256 text
 attributes.

* Modes 4-6: Graphics modes.
  In these modes the test screen consists of a grainy testcard image. On a
  PC1512, the mode 6 image is in 16 colours.

* 160x100 mode:
  An even cruder testcard is displayed.

CGAEX results
=============

Adaptor: PC1512 internal chipset
Monitor: PC1512 PC-CM

Mode 0: Colour, 25x40
Mode 1: Colour, 25x40
              0: Changes between legible 25x40 and 25x80 modes, with no CRTC
                reprogramming required.
              1: Changes to graphic mode. The layout of video RAM changes,
                so that each byte written during graphic mode is repeated 4
                times when text mode is selected  - eg, "colour" becomes
                "cc**oo**ll**oo**uu**rr".
              2: No effect
              3: Disables/enables video correctly.
              4: If bit 1 is set, switches to/from 640x200 mode.
              5: Toggles blink as expected.
              a-d: Change border colour
Mode 2: Colour, 25x80
Mode 3: Colour, 25x80
              All effects the same as for Modes 0/1, except that the screen
              starts off being 25x80.
Mode 4: Colour, 320x200
              Starts off with magenta/cyan/white palette.
              0: No effect
              1: Changes to text mode - reverse effect of what happens in
                modes 0-3.
              2: If palette is red/green/yellow, changes to red/cyan/white.
                Otherwise no effect.
              3: Disables/enables video correctly.
              4: Switches to/from 640x200 mode.
              5: No effect.
              a-d: Change background colour
              e: Change foreground intensity
              f: Swap palette between magenta/cyan/white and whatever is
                suggested by bit 2 of port 3D8h.
Mode 5: Colour, 320x200
              Exactly like Mode 4, but starts with the red/cyan/white palette.

Mode 6: Colour, 640x200
              CGAEX unlocks the CGA so this mode has 16 colours.
              0: No effect
              1: Changes to text mode - reverse effect of what happens in
                modes 0-3.
              2: No effect
              3: Disables/enables video correctly.
              4: Switches to/from 320x200 mode.
              5: No effect.
              a-d: Enable/disable B/G/R/I planes.

160x100 mode: Colour, 160x100
              This mode is selected correctly.
              0: Changes to a 40-column version of the mode - not legible.
              1: Changes to graphics mode - same effect as in mode 0.
              2: No effect
              3: Disables/enables video correctly.
              4: If bit 1 is set, switches to/from 640x200 mode.
              5: Toggles blink as expected.

______________________________________________________________________________

Adaptor: PC1512 internal chipset
Monitor: PC1512 PC-MM

All results identical; the monitor displays 16 greyscales instead of colours.

______________________________________________________________________________

Adaptor: PPC512 internal display adaptor (CGA mode)
Monitor: PPC512 LCD panel

Mode 0: Blue/green, 25x40
Mode 1: Blue/green, 25x40
        Colours are converted to MDA-esque attributes using a technique which
        this margin is not wide enough to describe.

Mode 0: Blue/green, 25x80
Mode 1: Blue/green, 25x80

Mode 4: Blue/green, 640x200
Mode 5: Blue/green, 640x200
Mode 6: Blue/green, 640x200
        These three modes all display exactly the same way, in glorious
        monochrome. The CGA colour register does nothing.

160x100 mode: Blue/green, 640x200
        This mode is selected correctly. Colours are simulated with shaded
        patterns.

______________________________________________________________________________



MDAEX results
=============

Adaptor: Original IBM MDA
Monitor: Sinclair S12MM

* Character cells are 9 pixels wide, 14 high.
* Characters 192-223 have a 9th pixel column copied from the 8th column.
 Other characters do not.
* The grey background therefore shows vertical black stripes.
* Apart from 8 attributes listed below, all the character attributes follow
 this scheme:
   Character is underlined if and only if bit 1 is set.
   Foreground is bright if bit 3 is set, dim otherwise.
   Foreground blinks if and only if bit 7 is set.

 The eight exceptions are (hex numbers):
 0x00; 0x08; 0x80; 0x88: These display as solid black.
 0x70: Displays as black foreground, normal background
 0xF0: Blinking version of 0x70.
 0x78: Displays as haloed foreground, normal background
 0xF8: Blinking version of 0x78.

  The effect I have described as "haloed" is very hard to see, let alone 
describe; on the S12MM, you have to turn the brightness and contrast down very 
low. Then white pixels to the left of black pixels show up brighter than
their surroundings. For example, in reverse video the MDA I looks something
like this:

xxxxxxxx      and the "haloed" effect        xxxxxxxx
xx    xx      brightens the pixels marked    x!    xx
xxx  xxx      with exclamation marks:        xx!  xxx
xxx  xxx                                     xx!  xxx
xxx  xxx                                     xx!  xxx
xxx  xxx                                     xx!  xxx
xxx  xxx                                     xx!  xxx
xxx  xxx                                     xx!  xxx
xxx  xxx                                     xx!  xxx
xx    xx                                     x!    xx
xxxxxxxx                                     xxxxxxxx

______________________________________________________________________________

Adaptor: Amstrad PPC512 Internal Display Adaptor
Monitor: Sinclair S12MM

The Sinclair PC200 and Amstrad PC20 use a very similar internal display
adaptor and behave the same way with MDAEX.

* Character cells are 8 pixels wide, 14 high.
* The grey background therefore does not show vertical black stripes.
* Apart from 8 attributes listed below, all the character attributes follow
 this scheme:
   Character is underlined if and only if bit 1 is set.
   Foreground is bright if bit 3 is set, dim otherwise.
   Foreground blinks if and only if bit 7 is set.

 The eight exceptions are (hex numbers):
 0x00; 0x40; 0x80; 0xC0: These display as solid black.
 0x70; 0x78: Display as black foreground, normal background
 0xF0; 0xF8: Blinking version of 0x70.

  The "haloed" effect is not present. 

______________________________________________________________________________

Adaptor: Amstrad PPC512 Internal Display Adaptor
Monitor: Built-in LCD

* Character cells are 8 pixels wide, 8 high.
* The background is green rather than black; the foreground is dark blue.
* The grey background does not show vertical stripes.
* There is no underlining.
* Apart from 8 attributes listed below, all the character attributes follow
 this scheme:
   Character is thin if bit 3 is set, normal otherwise.
   Foreground blinks if and only if bit 7 is set.

  "Thin" characters are displayed by taking the logical AND of the character
 pattern, and the same pattern rotated 1 position to the right.

 The eight exceptions in the attribute scheme are (hex numbers):
 0x00; 0x40; 0x80; 0xC0: These display as green on green - nothing is visible.
 0x70: Inverted (green on black).
 0x78: Thin and inverted (the thinning happens before the inversion.
 0xF0: Blinking version of 0x70.
 0xF8: Blinking version of 0x78.

Adaptor: Intel VGA chipset in mono text mode 7
Monitor: IBM E74

  This has been included to describe how a VGA chipset emulates MDA.

* Character cells are 9 pixels wide, 14 high.
* Characters 192-223 have a 9th pixel column copied from the 8th column.
 Other characters do not.
* The grey background therefore shows vertical black stripes.
* Underlines are supported.

  The attribute scheme is:

     0x00 and 0x08 display as solid black.
     0x01-0x07 display grey on black.
     0x09-0x0F display white on black.
     0x10, 0x18, 0x20, 0x28, 0x30, 0x38, 0x40, 0x48, 0x50, 0x58, 0x60, 0x68,
        0x70 and 0x78 display black on grey.
     0x19-0x1F, 0x29-0x2F, 0x39-0x3F, 0x49-0x4F, 0x59-0x5F, 0x69-0x6F and
        0x79-0x7F display white on grey.
     Other attributes display as solid grey.
     Underlines only show against a black background.

     Blinking attributes 0x80-0x8F alternate between the non-blinking version
     and solid black. 0x90-0xFF alternate between the non-blinking version and
     solid grey.

______________________________________________________________________________

Adaptor: Linux DOSEMU VGA, in mono text mode 7
Monitor: xdos window

* Character cells are 8 pixels wide, 14 high.
* The grey background therefore does not show vertical black stripes.
* Underlines are supported.
* There is no blinking.

  The attribute scheme is:

     0x00 displays as solid black.
     0x01-0x08 display grey on black.
     0x09-0x0F display white on black.
     0x10, 0x20, 0x30, 0x40, 0x50, 0x60, 0x70, 0x890 display black on
        grey.
     0x11-0x18, 0x21-0x28, 0x31-0x38, 0x41-0x48, 0x51-0x58, 0x61-0x68,
        0x71-0x78, 0x81-0x88 display as solid grey.
     0x19-0x1F, 0x29-0x2F, 0x39-0x3F, 0x49-0x4F, 0x59-0x5F, 0x69-0x6F,
        0x79-0x7F, 0x89-0x8F display as white on grey.
     0x90, 0xA0, 0xB0, 0xC0, 0xD0, 0xE0, 0xF0 display black on white.
     0x91-0x98, 0xA1-0xA8, 0xB1-0xB8, 0xC1-0xC8, 0xD1-0xD8, 0xE1-0xE8,
        0xF1-0xF8 display as grey on white.
     0x99-0x9F, 0xA9-0xAF, 0xB9-0xBF, 0xC9-0xCF, 0xD9-0xDF, 0xE9-0xEF,
        0xF9-0xFF display as solid white.
     Underlines only show for attributes 0x01, 0x09, 0x81, 0x89.

______________________________________________________________________________

Adaptor: MESS CVS v0.70 (15 June 2003) emulated MDA
Monitor: MESS X11 window

* Character cells are 9 pixels wide, 14 high.
* The grey background correctly shows vertical stripes.
* There is no underlining.
* The attributes behave more like a VGA emulation of an MDA than a real MDA:

     0x00 and 0x08 display as solid black.
     0x07 displays dark green on black.
     0x0F displays bright green on black.
     0x10, 0x20, 0x30, 0x40, 0x50, 0x60, 0x70-0x76 display black on dark
        green.
     0x18, 0x28, 0x38, 0x48, 0x58, 0x68, 0x78-0x7E display black on bright
        green.
     Other attributes with bit 3 set display as solid bright green.
     Other attributes with bit 3 reset display as solid dark green.

     Blinking attributes 0x80-0x8F alternate between the non-blinking version
     and solid black. 0x90-0xFF alternate between the non-blinking version and
     solid dark green (even where the normal version is bright green).

