erysdren's WWW site

software, gameware, strangeware

RSS Feed

VGA CTEXT
2024-07-04

VGA text mode cells are stored in memory as 2 bytes. The low byte contains an ASCII code point, and the high byte contains text attributes.

The memory address for VGA's text screen is 0xB8000.

Example Code

Here is some C code to break a cell (a uint16_t) into its component parts:

// get ascii code point
uint8_t code = (uint8_t)(cell & 0xFF);

// get attributes
uint8_t attr = (uint8_t)(cell >> 8);

// break out attributes
uint8_t blink = (attr >> 7) & 0x01;
uint8_t bgcolor = (attr >> 4) & 0x07;
uint8_t fgcolor = attr & 0x0F;

EGA Palette

16-color EGA palette

Further Reading