|Dͻ
|D |5The Happy Hacker |D
|Dͼ

^C^1A VIDEO TUTORIAL
^CPart 10:  First Look Inside the EGA
^Cby:  Joel Ellis Rea

   If you will recall, the CGA and MDA basically consist of a few main parts, 
each with a specific function.  These parts include:

   1.  Character Generator ROM.  Holds the shape of the letters for text mode.  
       Holds shapes for 256 9x14 letters (MDA), or 512 8x8 letters (CGA). 

   2.  Display Buffer RAM.  Where the display information goes.  Enough for one 
       80x25 character screen with 80x25 attributes for the MDA (4K); or 4 80x25 
       character/attribute screens, 8 40x25 character/attribute screens, or one 
       320x200x4-color or 640x200x2-color bit-mapped screen for the CGA (16K). 
   
   3.  On-board ports.  These are accessed by IN and OUT instructions.  The 
       MDA and CGA both have ports for Control and Status, as well as for CRTC 
       Index and Data (see below), while the CGA adds Color/Palette and Light 
       Pen ports. 
   
   4.  The Motorola 6845 Cathode Ray Tube Controller (CRTC).  This is accessed 
       via the CRTC Index and Data ports (see above), and controls the 
       fundamentals of the video display, such as sync, width, cursor, etc. 
   
   5.  Attribute Generator.  This is not directly accessible to the programmer.  
       It uses information contained in the attribute cells of the text screens, 
       and from other ports such as the Control and Color/Palette (CGA only) 
       ports.  It implements such display attributes as colors (CGA only), bold, 
       inverse, invisible, underscore (MDA only), palette (CGA only), etc. 
   
   The EGA is considerably more complex in nature, and thus has more main parts.  
These include: 

   1.  Character Generator ROM.  This ROM holds several character sets, 
       including one with 256 8x14 characters for the 350-line color and the 
       monochrome modes, and one with 256 8x8 characters (like the CGA) for the 
       200-line modes and for the 43-row 350-line text mode. 
   
   2.  Display Buffer RAM.  For the IBM EGA this is 64K, enough for 16 pages of
       80x25 text (only 8 pages of any mode can be accessed by the BIOS), 32
       pages of 40x25 text, 4 pages of any CGA-compatible graphics mode, 1 page
       of 640x200x16 colors mode, or 1 page of 640x350x4-colors mode.  To access
       640x350x16 colors mode, at least 128K is required.  This requires an
       upgrade for the IBM EGA.  For 2 pages of each mode, or for extra buffer
       RAM for user-defined character sets, etc., 256K is recommended.  This
       requires an additional upgrade for the IBM EGA.  All 3rd-party EGA clones
       that I know of come with 256K standard. 

   3.  External (On-Board) Ports.  These include Miscellaneous Output, Feature 
       Control, Miscellaneous Input, Input Status and two Light Pen ports.

   4.  The 82C431 Graphics Controller.  This provides many advanced graphics 
       capabilities, which can greatly increase the performance (perceived 
       speed) of graphics programs specifically written to use these 
       capabilities.  These include data latches, hardware logic (AND, OR, XOR, 
       etc.), a hardware barrel shifter register (for fast data shifts), fast 
       color fills, bit masking, color compares (with selectable "don't care" 
       bits), and many more.

   5.  The 82C432 Sequencer.  This controls several miscellaneous EGA 
       capabilities, such as having 2 character sets (512 characters) on the 
       screen at once, whether characters are 8 or 9 dots wide, whether the 
       current mode is text or bitmapped graphics, addressing modes, dot clock, 
       etc.

   6.  The 82C433 Attributes Controller.  This is similar, but far more powerful 
       than, either the MDA or CGA Attributes Controller.  It's capabilities 
       include 16 palette registers each capable of holding one of 64 colors, an 
       overscan (small border) register which can also hold one of 64 colors, 
       blink vs. background intensity (handled by Control port on CGA or MDA -- 
       bit 5, to be precise), data shifting, plus monochrome attributes such as 
       underscore (underscore position can be changed by CRT Controller -- see 
       below), normal and high intensity, several forms of blinking (invisible 
       to normal, invisible to high, normal to high, and reversed versions of 
       each), etc.

   7.  The 82C434 Cathode Ray Tube (CRT) Controller.  This is similar in 
       function to, but not fully compatible with, the Motorola 6845 CRTC used 
       in the CGA and MDA.  In addition to the functions of the 6845 CRTC, the 
       EGA CRT Controller implements such features as horizontal and vertical 
       blanking implemented separately from horizontal and vertical sync, Line 
       Compare for split-screen effects, Underline Location for the monochrome 
       underscore attribute (see above -- can turn underscore into strikeout, 
       for instance), and many others.

   8.  On-board Video BIOS ROM.  On power-up, this hooks into the location for 
       the INTerrupt 10h used by the standard Video BIOS, thus intercepting all 
       calls to that INTerrupt.  It implements many new modes made possible by 
       the advanced EGA hardware, plus add some new BIOS functions:  Function 
       10h for controlling the palette and blink/high intensity background and 
       overscan registers, Function 11h for downloading new character sets to 
       the Video Buffer RAM, Function 12h for returning general EGA information 
       such as DIP switch values (for determining what type of monitor is 
       connected), Feature Bits settings (for determining if an enhancement 
       board is plugged into the Feature Connector), amount of Video RAM 
       installed, and whether color or monochrome mode is in effect.  It can 
       also be used to select an alternate Print Screen routing.  Function 13h 
       is a convenience function which allows an entire string to be written in 
       "Teletype Mode", with or without cursor movement, with or without 
       embedded or specified attributes. 

   The next few installments will focus on each of the major parts in the order 
specified, and most will be accompanied by a demonstration program illustrating 
some of the special effects which can be done by manipulating that part of the 
EGA.  Of course, no EGA is needed to read the articles, but an EGA *WILL* be 
required to run the demonstrations.
