VGA-compatible text mode
||This article needs additional citations for verification. (March 2010)|
The implementation of computer monitor text mode on VGA-compatible hardware is quite complex. Its use on PC-compatible computers was widespread in 1980s–1990s (particularly under DOS systems), but persists today for some applications even on modern desktop computers. Main features of VGA text mode are colored (arbitrary 16 color palette) characters and their background, blinking, various shapes of the cursor (block/underline/hidden static/blinking), loadable fonts (with various glyph sizes). Linux console usually (but not necessarily) uses hardware VGA-compatible text modes, and Win32 console environment has an ability to switch its application to text mode for some text window sizes.
Distinctive features of VGA text as it commonly used:
Light gray background (normally not white).
|CGA–EGA-style 16 color palette for foreground.
 Data arrangement
 Text buffer
Each screen character is actually represented by two bytes aligned as a 16-bit word accessible by CPU at a single operation. The lower, or character byte is the actual code point for the current character set, and the higher, or attribute byte is a bit field used to select various video attributes such as color, blinking, character set, and so forth. This byte-pair scheme is among the features that VGA inherited from EGA and CGA and ultimately from MDA.
|Blink[n 1]||Background color||Foreground color[n. 2]||Code point|
Numeration of bits given in a way usually used in technical documentation.
- ^ Depending on mode setup, attribute bit 7 may be either the blink bit or the fourth background color bit (which allows to use all 16 colors).
- ^ Attribute bit 3 also chooses between fonts A and B (see below), therefore if these font are not the same, this bit is simultaneously an additional code point bit.
Colors are assigned in the same way as in 4-bit indexed color graphic modes, see detailed description of VGA palette. VGA modes have no need in reverse and bright attributes because foreground/background colors can be set explicitly. The VGA hardware has an ability to enable underline on some foreground/background combinations, normally disabled in color modes, therefore an underline feature in a color text mode normally is unavailable. Underline is used, though, in monochrome (MDA-like) text modes, those text buffer has the same arrangement as above.
Screen fonts used in EGA and VGA are monospace raster fonts containing 256 glyphs with 8 dots glyph width and a some glyph height fixed for each font, less or equal to 32. Each row of a glyph is coded in a 8 bit byte, with high bits at the left and low at the right. Along with several hardware-dependent fonts stored in the adapter’s ROM, the text mode offers 8 loadable font storages. Two active font pointers (font A and font B) choose each one of available fonts, they usually (but not necessarily) point to the same font. When font A ≠ font B, the attribute bit 3 (see above) acts both as a foreground color bit and as the ninth (28) code point bit. To make a 512 character set mode (instead of the common 256), available colors should be halved from 16 to 8.
There are modes with 9-dots character box width (e.g. the default 80×25 mode), where an extra column of a character matrix appears, not accessible directly. It may be left empty (all 0s), but may be enabled a special processing of characters with code points 0xB0–0xDF, which are usually box drawing. In this so named Line Graphics Enable mode, that extra column become a duplicate of the rightmost addressable column (encoded by a least significant bit in each row) for 0xB0–0xDF characters, and left empty for the rest of characters. For this reason, placing letter-like characters to code points 0xB0–0xDF should be avoided.
A shape of the cursor is restricted to rectangle which width occupies all character box and filled by the foreground color of current character box. Its height and position may be arbitrary within a character box; notably, the cursor may be hidden (invisible). There is also a bit which controls cursor blink activity.
A mouse cursor in TUI (when implemented) is not usually the same thing as a hardware cursor, but a moving rectangle with altered background or a special glyph.
Some text-based interfaces, such as that of Impulse Tracker, went to even greater lengths to provide a smoother and more graphic-looking mouse cursor. This was done by constantly re-generating character glyphs in realtime according to the cursor's on-screen position and the underlying characters.
 Access methods
There are generally two way to access a VGA text for an application: through a text terminal emulation (usually by OS) or directly via memory mapped I/O. The latter method also allows reading of text buffer, for which reason it is preferred for advanced TUI programs.
From the point of view of 16-bit x86 application or system software (including BIOS), the text buffer is just a region of RAM. Its range is 0xB8000–0xBFFFF (a half of segment B800h). The text buffer data can be read and written, bitwise operations may be applied to them. A part of text buffer memory above the scope of the current mode is accessible, but is not shown.
The same physical addresses are used in CPU’s protected mode: applications may either have this part of memory mapped to their address space or access it via the operating system. When an application (on a modern multitasking OS) does not have control over the console, it accesses a part of mainboard RAM instead of actual text buffer.
For computers of 1980s, very fast access to text buffer was extremely useful for a fast UI; even on relatively modern hardware an overhead of text mode emulation via hardware APA modes may be noticeable.
 Modes and timings
 Video signal
From the monitor’s side, there is no difference in input signal in a text mode and an APA mode of the same size. A text mode signal may have the same timings than VESA standard modes. Same registers are used on adapter’s side to set up these parameters in a text mode as in APA modes. Text mode output signal is essentially the same as in graphic modes, but its source is text buffer and character generator, not framebuffer as in APA.
|This section requires expansion. (March 2010)|
 PC common text modes
|This section does not cite any references or sources. (March 2010)|
Depending on the graphics adapter used, a variety of text modes are available on IBM PC compatible computers. They are listed on the table below:
|Text res.||Char. size||Graphics res.||Colors||Adapters|
|80×25||9×14||720×350||B&W Text||MDA, Hercules|
|40×25||8×8||320×200||16 colors||CGA, EGA|
|80×25||8×8||640×200||16 colors||CGA, EGA|
|80×60||16 colors||VESA-compatible Super VGA|
|132×25||16 colors||VESA-compatible Super VGA|
|132×43||16 colors||VESA-compatible Super VGA|
|132×50||16 colors||VESA-compatible Super VGA|
|132×60||16 colors||VESA-compatible Super VGA|
VGA and compatible cards support MDA, CGA and EGA modes. All colored modes have the same design of text attributes. MDA modes have some specific features (see above) – a text could be emphasized with bright, underline, reverse and blinking attributes.
By far the most common text mode used in DOS environments, and initial Windows consoles, is the default 80 columns by 25 rows, or 80×25, with 16 colors. This mode was available on practically all IBM and compatible personal computers.
Two other VGA text modes, 80×43 and 80×50, exist but were very rarely used. The 40 column text modes were never very popular, and were used only for demonstration purposes or with very old hardware.
Character sizes and graphical resolutions for the extended VESA-compatible Super VGA text modes are manufacturer's dependent. Some cards (e.g. S3) supported custom very large text modes, like 100×37 or even 160×120. Like as in graphic modes, graphic adapters of 2000s commonly are capable to set up an arbitrarily-sized text mode (in reasonable limits) instead of choosing its parameters from some list. But poor software support deters widespread use of such custom modes.
On Linux and DOS systems with so named SVGA cards, a program called SVGATextMode is used to set up better looking text modes than EGA and VGA standard ones. This is particularly useful for large (≥ 17") monitors, where normal VGA 400 lines text mode appear as extremely low resolution. SVGATextMode allows setting of the pixel clock and higher refresh rate, larger font size, cursor size, etc., and allows a better use of the potential of a video card and monitor. In non-Windows systems, the use of SVGATextMode (or alternative options such as the Linux framebuffer) to obtain a sharp text is critical for LCD monitors of 1280×1024 (or higher resolution) because none of so named standard text modes fits to this matrix size. SVGATextMode also allows a fine tuning of video signal timings.
Despite the name of this program, only a few of its supported modes conform to SVGA (i.e. VESA) standards.
 General restrictions
Such VGA text modes have some hardware-imposed limitations. Because some of them appear now too restrictive, the hardware text mode on VGA compatible video adapters has only a limited use.
|Parameter||Original VGA||Modern video adapters||Remarks|
|8 or 9 dots||≤ 9 dots||Not all hardware support glyphs narrower than 8 dots;
Even width=9 looks ugly on high resolutions, particularly for people with hyperopia, and is insufficient for East Asian scripts. Height=32 is more than sufficient.
|≤ 32 dots|
|Number of character cells||At least
(reached at 80×50)
|≤ 16,384 = 214
(memory addressing limitations)
|A modern adapter, if supports non-standard modes, may produce a reasonably dense text screen even on a large monitor.|
|Width in character cells
(characters per line)
|Height in character cells
(number of lines)
(reached at 80×50)
|Code page size
(number of different glyphs displayed simultaneously)
|≤ 512 = 29
(if font A ≠ font B)
|Even 512 is insufficient for comprehensive Unicode support.|
|≤ 256 = 28
(if font A = font B)
|Number of colors||foreground: 16*
background: 8 or 16**
|16 of arbitrarily chosen colors, not fixed.|
* 8 colors may be used by font A and other 8 colors by font B; so, if font A ≠ font B (512 characters mode), then the palette should be halved and a text may effectively use only 8 colors.
** Normally, first 8 colors of the same palette. If blink is disabled, then all 16 colors are available for background.
- FreeVGA Project: VGA Text Mode Operation
- FreeVGA Project: Manipulating the Text-mode Cursor