PC Sprites
The PC has no sprite hardware. Everything that moves is a software sprite: a small bitmap the program copies into the screen buffer by hand, then erases and redraws each frame. VGA's mode 13h makes this easy, because its linear 256-colour buffer lets a sprite be a plain run of bytes.
Overview
No PC adapter has hardware sprites, so a sprite is just pixel data the CPU writes into video memory at the right place. The program works out the target address, copies the sprite in, and restores the background when the sprite moves. All the cost is in the CPU and the memory bus, so sprite size and count trade against frame rate. The layout of the target mode decides how hard the copy is: the linear mode 13h is the friendliest, so it is the usual home for software sprites.
Blitting in mode 13h
In mode 13h each pixel is one byte and the screen is a flat 320×200 block at A000:0000. A sprite is stored the same way: rows of bytes, one colour index per pixel, laid out left to right, top to bottom. Drawing it, blitting, means copying each sprite row into the screen at offset y * 320 + x, advancing the destination by 320 for each row and the source by the sprite's width.
| Field | Layout |
|---|---|
| Pixel | 1 byte, a colour index 0–255 |
| Row | width bytes, left to right |
| Sprite | width × height bytes, top row first |
| Screen step | 320 bytes per row down |
Because the pixel is a whole byte, no shifting or bit masking is needed to place a sprite at any x, unlike bit-packed machines. A solid rectangular blit is a plain memory copy row by row, which the x86 string instructions do quickly.
Masks and transparency
A plain copy draws a solid box, including the sprite's background. To draw only the shape, one colour index is reserved as transparent, usually index 0. The blit then tests each source byte: if it is the transparent index, skip it and leave the screen pixel alone; otherwise write it. This per-pixel test is simple because each pixel is one byte, so there is no mask bitmap to carry as there is on bit-packed screens.
Where speed matters, a separate mask can still be used: a second array marking which pixels are solid, letting the copy run in longer unbroken spans. Either way the effect is the same, the sprite's own pixels overwrite the background and its transparent pixels let it show through.
XOR sprites
An XOR sprite is drawn by combining each pixel with the screen using exclusive-or instead of overwriting: screen = screen XOR sprite. Its useful property is that drawing the same sprite twice at the same place restores the original background exactly, so a program can erase a sprite by re-drawing it, with no need to save the pixels underneath.
The cost is that the sprite's colours mix with whatever is behind them, so an XOR sprite looks like a shifting stencil rather than a solid object. It suits cursors, wireframe overlays and quick markers more than character art, where masked drawing gives the clean look.
Page flipping in Mode-X
Drawing straight to the visible screen can show tearing and flicker as the sprite is built up while the display is being read. Page flipping fixes this by drawing to an off-screen page, then telling the adapter to display that page instead. Mode 13h's chunky layout leaves too little spare memory for a second full page, but Mode-X unlocks VGA's full 256 KB, enough for several pages.
The program keeps two pages, draws the next frame into the hidden one, and flips by pointing the display start address at it, so the viewer only ever sees finished frames. The extra memory also holds ready-made background tiles off-screen, which the adapter can copy on-chip faster than the CPU, a technique that made Mode-X popular for smooth-scrolling games.