VGA Images
VGA offers a family of screen modes rather than one. The famous one is mode 13h, a 320×200 screen where each pixel is a single byte selecting one of 256 colours from a programmable palette. Higher modes trade that simple layout for planar memory to reach more pixels, and the undocumented Mode-X arrangements unlock the full 256KB for smooth scrolling and page flipping.
Overview
A VGA card carries 256KB of video memory and drives the screen through one of several modes. The choice of mode fixes the resolution, the number of colours on screen at once, and how those pixels are laid out in memory. Two memory models matter for art: the linear chunky model of mode 13h, where one byte is one pixel, and the planar model of every other VGA mode, where the four bit-planes are addressed as one and a pixel's bits are spread across them.
| Property | Value |
|---|---|
| Video memory | 256KB |
| Palette size | 256 entries |
| Palette depth | 18-bit (6 bits per channel) |
| Colours on screen | 256 (mode 13h and Mode-X), 16 in planar 640×480 |
| Framebuffer segment | A000:0000 (graphics), B800:0000 (text) |
Mode 13h
Mode 13h is 320×200 pixels with 256 colours, and its appeal is the layout. The screen is a linear chunky framebuffer at segment A000:0000, one byte per pixel, laid out left to right then top to bottom with no interleaving. The byte at offset y * 320 + x is the colour index of the pixel at column x, row y. The whole screen is 320 × 200 = 64000 bytes, which fits inside a single 64KB segment, so a program can plot a pixel with one store and address the screen as a flat array.
The byte value is not a colour itself but an index into the 256-entry palette. The default palette holds a spread of colours, but a program is free to reprogram every entry, so mode 13h shows any 256 colours chosen from the palette's full range.
| Property | Value |
|---|---|
| Resolution | 320 × 200 pixels |
| Memory model | Linear chunky, one byte per pixel |
| Pixel address | A000:0000 + y × 320 + x |
| Screen size | 64000 bytes |
| Colours | 256, each a palette index |
The palette and DAC
The colour a pixel index maps to is set in the DAC, a table of 256 entries. Each entry is an 18-bit RGB triple: 6 bits of red, 6 bits of green and 6 bits of blue, so each channel runs 0 to 63 and the card can show any of 262,144 colours, 256 of them at a time.
The DAC is programmed through two I/O ports. Write the entry number to the index port at 3C8h, then write three bytes to the data port at 3C9h in the order red, green, blue. After the third write the DAC auto-advances to the next entry, so a whole palette loads as one index write followed by 768 data writes.
| Port | Role |
|---|---|
| 3C8h | DAC write index: the palette entry to start at. |
| 3C9h | DAC data: red, then green, then blue, 6 bits each, auto-advancing. |
| 3C7h | DAC read index: the entry to start reading from. |
Because the palette is separate from the pixels, an image can be recoloured, faded or cycled without touching the framebuffer, simply by rewriting DAC entries. Palette cycling and fade-to-black effects come straight from this.
Mode-X and planar modes
Mode 13h is easy but wastes memory: 64000 bytes of a 256KB card leaves the rest unused, and there is no room for a second page. Mode-X is a family of undocumented tweaks that switch the card into unchained planar mode at 256 colours, most often 320×240. In this mode the four bit-planes are addressed in parallel: successive pixels across a row land in plane 0, 1, 2, 3, 0, 1 and so on, so each plane holds every fourth pixel.
Spreading pixels across four planes quarters the memory each screen needs, which frees the card for several full pages. Programs use those spare pages for page flipping (drawing the next frame off-screen, then pointing the display at it for flicker-free updates) and for smooth hardware scrolling. The cost is that plotting a single pixel means selecting the right plane first through the Sequencer's map-mask register, so Mode-X trades simple pixel access for more memory and speed on aligned copies.
The planar 640×480 16-colour mode (mode 12h) works the same way but uses the four planes as bit-planes of a 4-bit colour index: a pixel's colour is one bit from each of the four planes at the same address. This reaches the highest standard VGA resolution, at the price of only 16 colours and slower per-pixel writes.
Modes table
The common VGA graphics modes and how their pixels sit in the 256KB of video memory.
| Mode | Resolution | Colours | Memory model |
|---|---|---|---|
| 13h | 320 × 200 | 256 | Linear chunky, 1 byte per pixel at A000:0000 |
| Mode-X | 320 × 240 | 256 | Unchained planar, 4 planes, page flipping |
| 12h | 640 × 480 | 16 | Planar, 4 bit-planes forming a 4-bit index |
| 10h | 640 × 350 | 16 | Planar, 4 bit-planes |
| 0Dh | 320 × 200 | 16 | Planar, 4 bit-planes |