ATTRIB.TXT

        Character Attributes on Video Boards for the IBM PC

1. Introduction

This document describes the result of some testing of character attributes
on various video adaptor boards for the IBM PC.  These boards may vary in
their handling of the attribute byte, especially when emulating the IBM
Monochrome Display and Adaptor; thus text which is readable on one board
may not be visible on another, or its characteristics may be different.

Currently, only the IBM Monochrome Display and Printer Adaptor, the
Tecmar Graphics Master and the IBM Enhanced Graphics Adaptor are described.
Information on other boards is solicited.


2. Terminology

The following diagram shows the attribute byte layout (the byte which follows
each character byte in the regen memory of the video adaptor boards).  The
bit fields "B", "bg", and "fg" will be referred to in the following discussion.


        +---+---+---+---+---+---+---+---+
        | B |    bg     |      fg       |
        +---+---+---+---+---+---+---+---+
bit:      7   6   5   4   3   2   1   0
        (msb)                       (lsb)


Abbreviations for video boards:

        CGMA = IBM Color/Graphics Monitor Adaptor
        MDPA = IBM Monochrome Display and Printer Adaptor
        EGA  = IBM Enhanced Graphics Adaptor
        TGM  = Tecmar Graphics Master


3. Blink/Bright bit ("B")

First, port 3D8 bit 5 of the IBM Color/Graphics adaptor is supposed to control
the function of the "B" bit:

        port 3D8 bit 5 = 0  ==>  B bit = 0, dim background colors
                                 B bit = 1, bright background colors
        port 3D8 bit 5 = 1  ==>  B bit = 0, char not blinking
                                 B bit = 1, char blinking

On the IBM CGMA, this works as described.

On the MDPA, bit 5 of 3B8 disables blinking, essentially making bit "B"
of the attribute byte a "don't care".
(My IBM Tech Ref Manual indicates the the IBM Mono Adaptor has "CRT Control
Port 1" at 3B8 but does not detail the function of that port).

On the Tecmar Graphics Master (TGM) when configured to emulate the IBM CGMA,
this works as advertised.  In addition, when the TGM is configured to emulate
the IBM Monochrome/Printer Adaptor, bit 5 of port 3B8 has an analogous effect
(ie: makes bit "B" cause bright background).

On the EGA this bit seems to have no effect in either mode (ie: port 3D8 in
CGMA emulation, or port 3B8 in MDPA emulation).


4. Attributes in CGMA mode

Both the TGM and EGA seem to behave just as the CGMA does.


5. Attributes in MDPA mode

                IBM Monochrome Adaptor

   bg  background              fg  foreground
   0-6 black                    0  black IF bg = 0 or 7
    7  dim IF fg = 0            0  dim otherwise
    7  black IF fg not 0       1-7 dim
                                8  black IF bg = 0 or 7
                                8  bright otherwise
                               9-F bright

When fg is 1 or 9, the character is underlined, with the underline being the
same brightness as the character.  The underline is scan line 12 (of 0..13).
The underline blinks with the character (if enabled).

The "B" bit causes the char to blink if bit 5 of port 3B8 is 1, otherwise
has no effect.

                Tecmar Graphics Master

   bg  background              fg  forground
    0  black                    0  black
    1  dim                      1  dim
    2  black                    2  black
   3-7 dim                     3-7 dim
                                8  black
 *  0  black                    9  bright
 *  1  bright                   A  black
 *  2  black                   B-F bright
 * 3-7 bright

(* =  when port 3B8 bit 5 is 0, and attribute bit "B" is 1)

When fg is 1 or 9, the character is underlined, with the underline being
the same brightness as the char (1 = dim, 9 = bright).  The underline is
on the next to bottom scan line of the char (ie: line 12 of 0..13).  The
underline is steady, ie: does not blink when the character blinks.

                IBM Enhanced Graphics Adaptor

   bg  background               fg  foreground
    0  black                     0  black
   1-7 dim                      1-7 dim
                                 8  black
                                9-F bright

When fg is 1 or 9, the character is underlined, ONLY if bg is 0.  The
underline is the same brightness as the char, and is on the bottom scan
line if the char (ie: 13 of 0..13).  The underline blinks when the char
blinks.

Bit 5 of port 3B8 does not affect the blinking versus bright.


6. Summary of Monochrome Attribute Modes

The following modes are the only ones supported by the IBM MDPA:

        B  bg  fg           notes
        ?   0   0   (-/-)   black on black       (little use)
        ?   7   0   (-/D)   black on dim  (reverse video)
        ?   0   1   (D/-)   dim on black  underlined
        ?   0   7   (D/-)   dim on black 
        ?   0   9   (B/-)   bright on black  underlined
        ?   0   F   (B/-)   bright on black

        Note: the B bit controls blinking, unless disabled by 
        port 3B8 bit 5 = 0.


The IBM EGA can support all those and the following modes in addition:

        B  bg  fg           notes
        ?   7   F   (B/D)   bright on dim
        ?   7   7   (D/D)   dim on dim          (little use)

        Note: the B bit always controls blinking.


The Tecmar GM supports all of the above, and in addition:

        B  bg  fg           notes
        ?   7   9   (B/D)   bright on dim  underlined

        Note: the B bit controls blinking, if port 3B8 bit 5 = 1.
        If port 3B8 bit 5 = 0, the following modes are also supported:

        B  bg  fg   (?/?)   notes
        1   7   0   (-/B)   black on bright
        1   7   1   (D/B)   dim on bright  underlined
        1   7   7   (D/B)   dim on bright
        1   7   F   (B/B)   bright on bright    (little use)


7. More Information

More information about character attributes on other IBM compatible boards
and IBM compatible machines is needed.  The program "attrib.bas" will display
a matrix of 16 x 16 examples, one for each combination of foreground,
background, and "B" bit values.  The text displayed at each place is the
hexadecimal value of the corresponding attribute byte.  By using this program
others can test their machines/adaptors and report back about the results.
Try it both in "blink" and "bright" modes.  See the tables at the end of
this document and record your results there.  If you will send your results
to me I will incorporate them in future versions of this document.

        Zhahai Stewart          Compuserve address 74076,252 (EMAIL)
        HiSystems
        6521 Old Stage Rd.
        Boulder, CO 80302       (303) 449-8180


8. Reference Diagrams (see attrib.bas)

In the following, the foreground "color" is represented by the columns 0 to F
across the page, while the background "color" is represented by rows 0 to 7
down the page.  An additional "bottom half" is included for attributes with
the "B" bit set, if needed.

The entries are of the form:
   f/b, foreground intensity (over) background intensity
where the codes are:
   B = Bright
   D = Dim
   - = Black
Thus a dim character on a black background is D/-, while a black character
in a bright background would be -/B.  Characters with the same foreground
and background brightness are of course unreadable and must be inferred.



>>>>>>>>>>>>            IBM MDPA                        <<<<<<<<<<<<<

        ------------------------------ fg -----------------------------
B  bg    0   1   2   3   4   5   6   7    8   9   A   B   C   D   E   F
0   0    /  D/  D/  D/  D/  D/  D/  D/    /  B/  B/  B/  B/  B/  B/  B/ 
0   1   D/  D/  D/  D/  D/  D/  D/  D/   B/  B/  B/  B/  B/  B/  B/  B/ 
0   2   D/  D/  D/  D/  D/  D/  D/  D/   B/  B/  B/  B/  B/  B/  B/  B/ 
0   3   D/  D/  D/  D/  D/  D/  D/  D/   B/  B/  B/  B/  B/  B/  B/  B/ 
0   4   D/  D/  D/  D/  D/  D/  D/  D/   B/  B/  B/  B/  B/  B/  B/  B/ 
0   5   D/  D/  D/  D/  D/  D/  D/  D/   B/  B/  B/  B/  B/  B/  B/  B/ 
0   6   D/  D/  D/  D/  D/  D/  D/  D/   B/  B/  B/  B/  B/  B/  B/  B/ 
0   7    /D D/  D/  D/  D/  D/  D/  D/    /D B/  B/  B/  B/  B/  B/  B/ 

The bottom matrix with B = 1 looks the same except that the characters
blink IF port 3B8 bit 5 is 1.

Columns 1 and 9 are underlined.  The underline blinks when the char does.


>>>>>>>>>>>             Tecmar Graphics Master                  <<<<<<<<<<

        ------------------------------ fg -----------------------------
B  bg    0   1   2   3   4   5   6   7    8   9   A   B   C   D   E   F

0   0   -/- D/- -/- D/- D/- D/- D/- D/-  -/- B/- -/- B/- B/- B/- B/- B/-
0   1   -/D D/D -/D D/D D/D D/D D/D D/D  -/D B/D -/D B/D B/D B/D B/D B/D
0   2   -/- D/- -/- D/- D/- D/- D/- D/-  -/- B/- -/- B/- B/- B/- B/- B/-
0   3   -/D D/D -/D D/D D/D D/D D/D D/D  -/D B/D -/D B/D B/D B/D B/D B/D
0   4   -/D D/D -/D D/D D/D D/D D/D D/D  -/D B/D -/D B/D B/D B/D B/D B/D
0   5   -/D D/D -/D D/D D/D D/D D/D D/D  -/D B/D -/D B/D B/D B/D B/D B/D
0   6   -/D D/D -/D D/D D/D D/D D/D D/D  -/D B/D -/D B/D B/D B/D B/D B/D
0   7   -/D D/D -/D D/D D/D D/D D/D D/D  -/D B/D -/D B/D B/D B/D B/D B/D

If bit 5 of port 3B8 is 1, the bottom part of the matrix is the same as the
top expect the chars are blinking.  If it is 0, the dim backgrounds are
replaced by bright ones, thus:

1   0   -/- D/- -/- D/- D/- D/- D/- D/-  -/- B/- -/- B/- B/- B/- B/- B/-
1   1   -/B D/B -/B D/B D/B D/B D/B D/B  -/B B/B -/B B/B B/B B/B B/B B/B
1   2   -/- D/- -/- D/- D/- D/- D/- D/-  -/- B/- -/- B/- B/- B/- B/- B/-
1   3   -/B D/B -/B D/B D/B D/B D/B D/B  -/B B/B -/B B/B B/B B/B B/B B/B
1   4   -/B D/B -/B D/B D/B D/B D/B D/B  -/B B/B -/B B/B B/B B/B B/B B/B
1   5   -/B D/B -/B D/B D/B D/B D/B D/B  -/B B/B -/B B/B B/B B/B B/B B/B
1   6   -/B D/B -/B D/B D/B D/B D/B D/B  -/B B/B -/B B/B B/B B/B B/B B/B
1   7   -/B D/B -/B D/B D/B D/B D/B D/B  -/B B/B -/B B/B B/B B/B B/B B/B

Columns 1 and 9 are underlined.  The underline does NOT blink.


>>>>>>>>>               IBM ENHANCED GRAPHICS ADAPTOR           <<<<<<<<<<<

        ------------------------------ fg -----------------------------
B  bg    0   1   2   3   4   5   6   7    8   9   A   B   C   D   E   F

0   0   -/- D/- D/- D/- D/- D/- D/- D/-  -/- D/- D/- D/- D/- D/- D/- D/-
0   1   -/D D/D D/D D/D D/D D/D D/D D/D  -/D D/D D/D D/D D/D D/D D/D D/D
0   2   -/D D/D D/D D/D D/D D/D D/D D/D  -/D D/D D/D D/D D/D D/D D/D D/D
0   3   -/D D/D D/D D/D D/D D/D D/D D/D  -/D D/D D/D D/D D/D D/D D/D D/D
0   4   -/D D/D D/D D/D D/D D/D D/D D/D  -/D D/D D/D D/D D/D D/D D/D D/D
0   5   -/D D/D D/D D/D D/D D/D D/D D/D  -/D D/D D/D D/D D/D D/D D/D D/D
0   6   -/D D/D D/D D/D D/D D/D D/D D/D  -/D D/D D/D D/D D/D D/D D/D D/D
0   7   -/D D/D D/D D/D D/D D/D D/D D/D  -/D D/D D/D D/D D/D D/D D/D D/D

The bottom half of the matric is identical except that it blinks.  This
is unaffedted by port 3B8 bit 5.

The entries under columns 1 and 9 IN ROW 0 ONLY are underlined.  The
underline blinks when the character does.



9. History of this document

 1/10/85 Original draft (Tecmar & EGA) by Zhahai Stewart
 1/15/85 Updated to include IBM MDPA by Zhahai Stewart

�