Every DEGAS file starts with the same 34 bytes: a resolution word and a 16-word palette. A word is two bytes, and every word in the file is big-endian, as on the Atari ST’s 68000.
The three forms
| Form | Extensions | Layout | Size |
|---|---|---|---|
| DEGAS | .pi1, .pi2, .pi3 | resolution, palette, screen | 32,034 bytes |
| DEGAS Elite | .pi1, .pi2, .pi3 | resolution, palette, screen, colour cycling | 32,066 bytes |
| DEGAS Elite compressed | .pc1, .pc2, .pc3 | resolution (top bit set), palette, packed screen, colour cycling | under 32,066 bytes |
The two uncompressed forms share their extensions and differ only in the 32 bytes of colour cycling settings at the end, so the file size tells them apart. The compressed form is recognised by bit 15 of the resolution word.
Fields
| Offset | Size | Type | Name | Description |
|---|---|---|---|---|
| 0 | 2 | u16 | resolution | the screen mode, and in bit 15 whether the screen is compressed (below) |
| 2 | 32 | 16 × u16 | palette | colour registers 0 to 15 (below) |
| 34 | 32,000 | 16,000 × u16 | screen | uncompressed forms: the screen memory; see Screen data |
| 34 | varies | bytes | packed screen | compressed form: under 32,000 bytes; see Compression |
| end − 32 | 32 | 16 × u16 | colour cycling | DEGAS Elite and compressed forms only; see Colour cycling |
Resolution word
| Value | Mode | Picture | Bitplanes | Colours used |
|---|---|---|---|---|
0000 | low | 320 × 200 | 4 | 16 |
0001 | medium | 640 × 200 | 2 | 4: registers 0 to 3 |
0002 | high | 640 × 400 | 1 | 2: black and white |
8000 | low, compressed | 320 × 200 | 4 | 16 |
8001 | medium, compressed | 640 × 200 | 2 | 4 |
8002 | high, compressed | 640 × 400 | 1 | 2 |
The low bits give the mode and bit 15 means compressed. The other bits are reserved, so Baggett’s notes advise testing the bits a reader needs rather than comparing the whole word with these values. The digit in the extension matches the mode: 1 low, 2 medium, 3 high.
Palette
The palette is the ST’s 16 hardware colour registers in order, register 0 (the background) first. All 16 are stored even when the mode uses fewer. Each word holds three 3-bit intensities from 0 to 7:
| Bits | Meaning |
|---|---|
| 15–11 | unused; should be 0 |
| 10–8 | red, 0 to 7 |
| 7 | unused |
| 6–4 | green, 0 to 7 |
| 3 | unused |
| 2–0 | blue, 0 to 7 |
So the word reads 0000 0RRR 0GGG 0BBB in binary, or 0RGB in
hexadecimal with each digit 0 to 7: 0777 is white, 0700
bright red and 0000 black. The ST’s 9-bit colour gives 512 possible
colours. To show a level on a modern screen, scale it from 0–7 to 0–255, for example
level × 255 / 7.
Some programs, Art Studio among them, store other data in the unused upper bits, so a
reader should mask each word with 0777 before using it.
In high resolution the picture has one bitplane and is shown on the ST’s monochrome monitor in black and white. The 16 palette words are stored all the same.
Example
The start of a low-resolution DEGAS picture:
| Offset | Bytes | Field | Value |
|---|---|---|---|
| 0 | 00 00 | resolution | low, 320 × 200, uncompressed |
| 2 | 07 77 | register 0 | white background |
| 4 | 07 00 | register 1 | red |
| 6 | 00 70 | register 2 | green |
| … | registers 3 to 15 | ||
| 34 | 32,000 bytes | screen | interleaved bitplanes |
A file of exactly 32,034 bytes is plain DEGAS; one of 32,066 bytes is DEGAS Elite,
and its last 32 bytes are the colour cycling settings. The same picture compressed
would start 80 00.