ANSIPLUS manages two sets of colors: the current set displayed by the VGA/EGA controller, and a default set maintained within the ANSIPLUS driver. The Esc [!c ANSIPLUS control sequence defines either of these color schemes.
The standard IBM VGA/EGA color palette has limitations that ANSIPLUS removes. The first limitation is that there are normally only 8 low intensity background colors in text modes, because blinking is enabled in the normal VGA/EGA configuration. Unless told otherwise, ANSIPLUS keeps VGA/EGA hardware blinking disabled, so that all 16 background colors can be used. For those applications that need both blinking and more than 8 background colors, ANSIPLUS provides control sequences that let any of the 16 colors on the screen blink at independent rates, in either text or graphics modes.
The second limitation removed is the color choices themselves. The standard IBM VGA/EGA palette is generated mechanically, with little apparent consideration for the subjective appearance of the colors individually or in combination. The IBM 64-color palette simply consists of all possible combinations of 0, 33, 67 and 100 percent intensities for the red, green and blue CRT cathodes. The 8 low intensity colors (black, red, brown, green, cyan, blue, magenta and light gray) are mixed with white to form 8 high intensity colors, giving a washed out appearance to many of the high intensity colors.
For the ANSIPLUS palette, individual attention has been given to both the 16 colors selected from the EGA palette and to the VGA DAC color intensities of all 256 VGA colors, with the goal being to select colors that are more vivid and provide generally better contrast and appearance when combined. For those with other color preferences, ANSIPLUS provides color control functions and utility programs that assist developing personal or application color schemes. The 16 default ANSIPLUS and OEM/IBM colors (actually, the closest web-friendly approximations of them) are compared in the following table:
The Esc [!c control sequence includes options for setting the current and default colors, the 64 VGA/EGA palette registers (PALs), and the 256 VGA DAC registers, for selecting the PAL registers to use for colors, and for color blinking. Because of all these options, six variations of the Esc [!c control sequence can be used, depending on the number of parameters supplied. Some of these require red, green and blue color intensities (RGB values), which all range from 0 (darkest) to 255 (brightest). The six variations of Esc [!c are:
Zero parameters resets all colors, PALs and DACs to default values:
Esc [!c Restore the default color scheme
One parameter restores a single color or PAL to either its default value or to the OEM value. The interpretation of the parameter varies for different ranges according to the table following. For example:
Esc [!5c Reset color 5 to default palette and DAC selection Esc [!38c Set color 6 to OEM EGA palette/DAC selection Esc [!65c Reset PAL 1 to default DAC values (65=64+1) Esc [!130c Reset PAL 2 to OEM EGA DAC color (130=128+2)
Interpretation of Color Reset Selectors
Selector Meaning 0 to 15 Default color 0 to 15 (16 colors) 16 Default screen border color 32 to 47 OEM color 0 to 15 (16 colors) 48 OEM screen border color 64 to 127 Default VGA/EGA PAL number 0 to 63 (64 EGA colors) 128 to 191 OEM VGA/EGA PAL number 0 to 63 (64 EGA colors)
Two parameters select the PAL code to use for a color. The first parameter selects the color (0-16 for current, 32-48 for default), and the second parameter selects the PAL register (0-63). For example:
Esc [!4;8c Set color 4 to select PAL 8 until the next mode set Esc [!36;8c Set color 4 to select PAL 8 as default (36=32+4)
Three parameters define blink color and duration. The first parameter selects a color (0-16), the second selects the EGA PAL (0-63) to use as the blink color, and the third parameter is the time in milliseconds for a complete blink cycle (100-28000). For example:
Esc [!1;0;400c Set color 1 to blink black (PAL 0) on a 400 ms cycle
Four parameters define the RGB values for a color, PAL or DAC. The first parameter selects the color (see table below), and the next three define the RGB values:
Esc [!4;0;0;128c Set color 4 values to 0 red, 0 green, 128 blue using a PAL or DAC of ANSIPLUSís choice until the next mode set Esc [!36;0;0;128c Set color 4 PAL and DAC now and as default (36=32+4) Esc [!65;128;0;0c Set PAL/DAC 1 to 128 red, 0 green/blue (65=64+1) Esc [!129;128;0;0c Set PAL/DAC 1 as default (129=128+1) Esc [!257;128;0;0c Set DAC 1 until next mode set (257=256+1) Esc [!513;128;0;0c Set DAC 1 now and as default (513=512+1)
Five parameters define both the PAL and RGB values for a color. The first parameter is the color selector (see table following), the second selects the palette register to use (0-63), and the final three define the RGB color values:
Esc [!4;8;0;0;128c Set color 4 to 0 red, 0 green and 128 blue using PAL number 8 until next mode set Esc [!36;8;0;0;128c Set color 4 to use PAL 8 and the RGB values as default (36=32+4)
Interpretation of Color Definition Selectors
Selector Meaning 0 to 15 Current color 0 to 15 (16 colors) 16 Current screen border color 32 to 47 Default color 0 to 15 (16 colors) 48 Default screen border color 64 to 127 Current VGA/EGA PAL number 0 to 63 (64 EGA colors) 128 to 191 Default VGA/EGA PAL number 0 to 63 (64 EGA colors) 256 to 511 Current VGA DAC color 0 to 255 (256 VGA colors) 512 to 767 Default VGA DAC color 0 to 255 (256 VGA colors)
The MS-DOS ANSI.sys driver is aware of 8 foreground and 8 background colors. It also provides control over intensity, underline, blinking and reverse video. All the original ANSI.sys graphics renditions are supported by ANSIPLUS (see the table at the end of this section).
However, to use 16 foreground colors with the ANSI.sys driver, programs have to break color codes apart and set both intensity and color. For 16 background colors, the same thing has to be done using "blink." A further complication is that the only way to reset either blink or intensity is to reset the foreground to gray and background to black with Esc [0m.
ANSIPLUS eliminates these complications by allowing several additional control codes for colors. In text modes, foreground and background colors are chosen directly from a 16 color palette. When using a VGA or EGA display in a sixteen color graphics mode, ANSIPLUS allows mixing any two colors to form a composite background color, for a total of 136 mixed and unmixed background color combinations, so foreground colors are chosen from 16 possibilities, and background colors from either 16 or 256 possibilities. In 256-color graphics modes, the foreground and background colors are selected from a 256 color palette. A summary of the ANSIPLUS extended color codes is shown in the adjacent table. The 16 ANSIPLUS foreground and background color codes are related to their names in a table above.
In addition to the color code extensions, three parameter values have slightly changed meanings in ANSIPLUS from the ANSI.sys driver, and several parameters have been added for special applications. First, the changed meanings:
The Esc [0m color reset escape sequence has been changed because ANSIPLUS maintains both a current foreground and background color combination and a default foreground and background which can be any colors at all. In the ANSI.sys driver, when colors are reset by Esc [0m, the result is always a gray foreground and black background. In ANSIPLUS, the Esc [0m sequence will restore the default colors, whatever they currently are. (When ANSIPLUS is first installed, the default colors are gray over black, so until the default is changed, ANSIPLUS resets the colors to be the same as ANSI.sys.)
The Esc [7m reverse video sequence swaps the foreground and background colors. In the ANSI.sys driver, this escape sequence sets the foreground to black and the background to gray. In ANSIPLUS, the current foreground and background, whatever they may be, are exchanged, making it very simple to display any reversed color combination on the screen without knowing what the colors to be reversed are. Reverse video is canceled the next time that foreground or background colors are set with Esc [m. Repeated Esc [7m requests also do not alternate between normal and reversed colors.
The Esc [8m invisible video sequence does not change the background color. In the ANSI.sys driver, this escape sequence sets the foreground to black and the background to black. In ANSIPLUS, the current foreground is set to whatever the current background is, making text invisible on a potentially colored background.
The following parameter values have been added for special applications:
Esc [2m resets the foreground intensity in text modes without otherwise changing the color. In 16-color graphics modes, this escape sequence enables the black shadow text enhancement.
Esc [3m enables the italics (or slant) text enhancement in 16-color graphics modes. It is ignored in text modes.
Esc [6m enables blinking (or background intensity) in text modes, and enables the black outline text enhancement in 16-color graphics modes.
Esc [10m causes the current foreground and background to be installed as the default foreground and background colors.
Esc [48m enables and Esc [49m disables setting the background color to "transparent." In text modes, a transparent background simply leaves the color attribute unchanged when writing a character. In graphics modes, a transparent background leaves the entire background of a character cell unchanged -- any character will be written in the foreground color over whatever was formerly there. The transparent background mode can be useful when running programs that set up a background with BIOS calls and assume it doesnít change, when labeling graphics without disturbing them, or when multi-character overstrike is required in graphics modes.
Esc [50m enables and Esc [51m disables a "shadow" output mode that assists writing text boxes on the screen that cast shadows over adjacent character cells. In text modes, when a blank space is output in shadow output mode, the background color is darkened, and the character currently in the character cell is also darkened. In graphics modes, when a blank space is output, a black 50% fill character is written in transparent mode in the character cell, darkening whatever was there.
© Copyright 2000-2007, Kristofer Sweger. All rights reserved.