GRAB by Mihailo Despotovic, March 1996

A DOS utility that saved the EGA/VGA graphics screen to a file and loaded it back, working directly with the video card. In the 16-color modes, the screen lives in four bit planes, each holding one bit of every pixel's color; GRAB copies the four planes to the file, one after another, and back. Here the VGA card is simulated: paint on the screen, then type grab -s proba to save it, change the picture, and grab -l proba to bring it back. The program's messages are in Serbian, with the English beside them.

The four bit planes

What GRAB saves, one plane after the other: plane 0 holds the blue bit of every pixel's color, 1 the green, 2 the red and 3 the intensity, so a color's number is the sum of 1, 2, 4 and 8 for the planes that have its bit on.

Plane 0 (blue, 1)
Plane 1 (green, 2)
Plane 2 (red, 4)
Plane 3 (intensity, 8)

The DOS prompt

C:\>
The screen's text
In English

The disk

The files are the same as in 1996: the four planes and nothing else, 153,600 bytes in mode 12h. There's no header, so a file must be loaded in the mode it was saved in; loaded in another mode it shows garbage, as it did then, and a file that is too short leaves the last planes with what the program's buffer still held. One bug: after loading, the program “restored” the VGA's Map Mask register to 16 instead of 15. Only its four low bits choose the planes that writes reach, so 16 chooses none, and until a program or a mode change set it again, drawing on the screen changed nothing. Try painting after grab -l; tick Fixed and it restores 15, and changing the mode resets it. GRAB itself sets the register before it loads, so it always works. The port was checked against the original C++ on a simulated card: the same output, screen, file and registers in 78 runs.

The original C++ code