In an uncompressed DEGAS file the 32,000 bytes from offset 34 are an exact copy of the Atari ST’s screen memory: 16,000 big-endian words. Every mode uses the same 32,000 bytes; what differs is how many bitplanes share them.
Interleaved bitplanes
The ST stores its screen in planes, one bit of each pixel’s colour number per plane, and interleaves the planes word by word. The screen is cut into groups of 16 pixels along each line. For each group there is one word per plane, plane 0 first, and the groups follow each other left to right, then line after line, top line first, with no gaps.
Within a word the most significant bit, bit 15, is the leftmost of the 16 pixels and bit 0 the rightmost. A pixel’s colour number is its bit from plane 0, plus 2 times its bit from plane 1, plus 4 times plane 2, plus 8 times plane 3, and it selects that palette register.
| Mode | Planes | Bytes per 16-pixel group | Groups per line | Bytes per line | Lines |
|---|---|---|---|---|---|
| low | 4 | 8: planes 0, 1, 2, 3 | 20 | 160 | 200 |
| medium | 2 | 4: planes 0, 1 | 40 | 160 | 200 |
| high | 1 | 2: plane 0 | 40 | 80 | 400 |
Finding a pixel
For the pixel at column x and line y, counting from 0 at the top left, the word holding its bit in plane p is at this file offset, and the bit within the word is 15 − (x mod 16):
| Mode | File offset of the word |
|---|---|
| low | 34 + 160y + 8 × floor(x / 16) + 2p |
| medium | 34 + 160y + 4 × floor(x / 16) + 2p |
| high | 34 + 80y + 2 × floor(x / 16) |
Example
The first 8 bytes of a low-resolution picture describe the first 16 pixels of the top line:
| Offset | Bytes | Plane | Bits |
|---|---|---|---|
| 34 | C0 00 | 0 | 1100 0000 0000 0000 |
| 36 | 80 00 | 1 | 1000 0000 0000 0000 |
| 38 | 00 00 | 2 | 0000 0000 0000 0000 |
| 40 | FF FF | 3 | 1111 1111 1111 1111 |
Pixel 0 has bits 1, 1, 0, 1 in planes 0 to 3: 1 + 2 + 8 = colour 11. Pixel 1 has 1, 0, 0, 1: colour 9. Pixels 2 to 15 have only the plane 3 bit: colour 8. The next group, pixels 16 to 31, starts at offset 42.