DEGAS Elite’s compressed files, .pc1, .pc2 and
.pc3, have the same header and palette as the uncompressed ones, with bit 15
of the resolution word set. From offset 34 comes the packed screen, under 32,000 bytes,
and the file ends with the 32 bytes of
colour cycling settings.
Order of the data
The picture is packed one line at a time, top line first, and no run continues from one line into the next. Within a line the planes are not interleaved as they are in screen memory: all of plane 0’s bytes for the line come first, then all of plane 1’s, and so on up to the highest plane. This is the same order as the body of an IFF ILBM picture.
| Mode | One line, unpacked | Lines |
|---|---|---|
| low | plane 0, 1, 2, 3: 40 bytes each, 160 in all | 200 |
| medium | plane 0, 1: 80 bytes each, 160 in all | 200 |
| high | plane 0: 80 bytes | 400 |
Runs
The packing is PackBits, the run-length scheme of the Macintosh. Each run starts with a signed control byte n:
| Control byte n | Bytes | Meaning |
|---|---|---|
| 0 to 127 | 00 to 7F | copy the next n + 1 bytes as they are |
| −1 to −127 | FF to 81 | repeat the next byte −n + 1 times |
| −128 | 80 | unused: no operation |
The 40-byte rule
DEGAS Elite unpacks into a 40-byte buffer, which it empties only when exactly 40 bytes are in it. A run that would carry the buffer past 40 bytes makes Elite crash with a bus error when it loads the file. So a writer must end every run on or before each 40-byte boundary of the unpacked line: at every plane boundary in low resolution, and halfway through each plane in medium and high resolution. A run is therefore at most 40 bytes long, even though PackBits allows 128.
A reader does not need to enforce this; it can unpack each line to its full length. But a file that breaks the rule will not load in DEGAS Elite itself.
Back to screen memory
To get the interleaved layout described in Screen data, unpack a line and move each plane’s bytes back into place. Byte i of plane p in the unpacked line goes to this offset within the screen line:
| Mode | Offset within the line |
|---|---|
| low | 8 × floor(i / 2) + 2p + (i mod 2) |
| medium | 4 × floor(i / 2) + 2p + (i mod 2) |
| high | i: one plane, nothing to move |
The packed data has no length field. A reader finds its end by unpacking all the lines; the colour cycling settings are the last 32 bytes of the file.
Example
One low-resolution line in which every pixel is colour 0 unpacks to four planes of 40 zero bytes. Each plane packs to two bytes:
D9 00 ; −39: 00 repeated 40 times (plane 0)
D9 00 ; plane 1
D9 00 ; plane 2
D9 00 ; plane 3
A whole blank low-resolution picture is therefore 200 × 8 = 1,600 bytes of packed data, and the file is 34 + 1,600 + 32 = 1,666 bytes.