Each pixel of an ILBM is a number made of one bit from each bitplane. Usually that
number picks a colour from the CMAP chunk. The
CAMG chunk, the Amiga display mode, can say that the
number means something else: half of another colour in
Extra Half-Brite, or a change to the previous pixel in
hold-and-modify. A deep picture, with 24 or 32
planes, stores each colour directly.
CMAP, the colour map
A list of ColorRegister entries, one for each colour number from 0:
| Offset | Size | Type | Name | Description |
|---|---|---|---|---|
| 0 | 1 | UBYTE | red | Red, 0 to 255. |
| 1 | 1 | UBYTE | green | Green, 0 to 255. |
| 2 | 1 | UBYTE | blue | Blue, 0 to 255. |
- The number of colours is
ckSize ÷ 3. It is normally 2nPlanes, but fewer is allowed, and a reader ignores any entries beyond what the planes can reach. When the size is odd a pad byte follows. - Without a
CMAPa reader uses colours of its own. The explorer shows greys. Some write-ups say that an 8-plane picture without a colour map is a greyscale picture. - A file with
nPlanes0 and noBODYholds only a colour map: a palette file.
Scaling old 4-bit values
The original Amiga had 4 bits for each of red, green and blue, and old writers
stored the 4-bit value in the high half of the byte, so 15 became
0xF0. The document now asks writers to repeat the 4 bits, so that 15
is 0xFF, and asks readers to spot the old way: if the low four bits of
every value in the map are zero, the map “was stored shifted rather than scaled”,
and should be scaled.
The explorer does this. When every low half is zero it spreads each value as
v | (v >> 4), so 0xF0 becomes 0xFF and
0x80 becomes 0x88, and shows both the stored and the shown
values.
00000028 43 4D 41 50 00 00 03 00 00 00 00 10 10 10 20 20
00000038 20 35 35 35 45 45 45 55 …
CMAP, 256 colours: colour 0 is black, colour 1 #101010, then #202020, #353535, #454545CAMG, the Amiga display mode
The CAMG chunk holds one ULONG: the Amiga viewport mode the picture was
made for. Its low 16 bits are mode flags, from the Amiga’s
graphics/view.h:
| Bit | Name | Meaning |
|---|---|---|
0x8000 | HIRES | High resolution, 640 pixels wide. |
0x4000 | SPRITES | Sprites are used. |
0x2000 | VP_HIDE | The viewport is hidden. |
0x1000 | EXTENDED_MODE | The value is a whole AmigaOS 2.0 ModeID (see below). |
0x0800 | HAM | Hold-and-modify. |
0x0400 | DUALPF | Dual playfield. |
0x0100 | GENLOCK_AUDIO | Genlock audio. |
0x0080 | EXTRA_HALFBRITE | Extra Half-Brite. |
0x0040 | PFBA | Playfield B in front of A. |
0x0020 | SUPERHIRES | Super-high resolution (AmigaOS 2.0, ECS). |
0x0008 | DOUBLESCAN | Double-scanned. |
0x0004 | LACE | Interlaced, twice the lines. |
0x0002 | GENLOCK_VIDEO | Genlock video. |
ModeIDs
From AmigaOS 2.0, by Commodore’s rules in the October 1988 revision of the
document, writers store a whole 32-bit ModeID: a monitor in the upper 16 bits, with
EXTENDED_MODE set, and the mode in the lower 16. The monitor is the
value under the mask 0xFFFF1000:
| Value | Monitor |
|---|---|
0x00011000 | NTSC |
0x00021000 | PAL |
0x00031000 | VGA (Productivity) |
0x00061000 | Euro72 |
0x000A1000 | DblPAL |
The explorer also names A2024, Proto, Euro36, Super72 and DblNTSC, from the
values that follow the same pattern (0x00041000 and so on); those were
not checked against Commodore’s headers. A common value is
0x00019004: the NTSC monitor with HIRES,
LACE and EXTENDED_MODE, a 640 × 400 screen.
Old values and bad values
- Writers for AmigaOS 1.3 store a 16-bit value with the upper word zero. They
clear the bits that do not describe the picture:
EXTENDED_MODE,SPRITES,VP_HIDE,GENLOCK_AUDIOandGENLOCK_VIDEO(together0x7102), so the value is masked with0x8EFD. - Readers should mask those bits off only when the upper word is zero.
- Some programs that save brushes put junk in the upper word without setting
EXTENDED_MODE. The document’s code throws such a value away and picksHIRESif the width is 640 or more andLACEif the height is 400 or more; when it keeps an old value, it keeps onlyHIRES,LACE,HAMandEXTRA_HALFBRITE.
The explorer shows the names of the bits that are set, and the monitor when the
upper word is a known ModeID. When the upper word is not zero and
EXTENDED_MODE is clear, it says the upper word is not a ModeID. It
reads HAM and Extra Half-Brite from the low word.
43 41 4D 47 00 00 00 04 50 02 10 00
CAMG written by ASDG’s Art Department Professional: EXTENDED_MODE with the upper word 0x5002, which the explorer does not name; probably a graphics card’s monitor, but that is not confirmedExtra Half-Brite
An Extra Half-Brite picture has 6 planes and the CAMG bit
0x80. The lower five planes pick one of 32 colours from the colour map.
When the top plane, plane 5, is set, the colour is shown at half brightness: colours
32 to 63 are colours 0 to 31 with red, green and blue each shifted right by one bit.
A reader can expand the map to 64 entries that way and then treat the picture as
ordinary 64-colour pixels.
Deluxe Paint added Extra Half-Brite in Deluxe Paint III (1989). The explorer adds the 32 derived colours to the palette it shows, marked as halves of the first 32.
Hold-and-modify
A HAM picture has the CAMG bit 0x800. Each pixel either
picks a colour from the map or keeps two of the previous pixel’s components and
changes the third. This shows far more colours than the planes could pick, with some
fringing at sharp edges.
HAM6
6 planes; 5 are also possible, the sixth then taken as 0. The lower four bits of each pixel are data, and bits 5 and 4, from planes 5 and 4, say what to do with it:
| Bits 5, 4 | Meaning |
|---|---|
00 | The data is a colour number, 0 to 15, from the colour map. |
01 | Keep the previous pixel’s red and green; blue is the data. |
10 | Keep green and blue; red is the data. |
11 | Keep red and blue; green is the data. |
A 4-bit value v becomes v × 17 in 8 bits. The ILBM document
lists the planes in the order 4, 5, and so writes 01 and
10 the other way round; the table follows the hardware, as does
Wikipedia’s article on HAM. “If the first pixel of a scan line is a modification
pixel, it modifies the RGB value of the border color (register 0).”
HAM8
The AGA chips of the Amiga 1200 and 4000 added HAM8: 8 planes (7 are possible), six data bits, and the control bits in the top two planes, 7 and 6. There are 64 base colours. A change replaces the upper six bits of the component and keeps its lower two bits “as set by the most recent set operation”.
Some AGA documentation puts HAM8’s control bits in the two lowest planes. A note on HAM8 at Lysator says that is wrong and that “bpl 7 and bpl 8 are the control bitplanes”, counting from 1; FFmpeg and Netpbm read the top two, and so does the explorer.
Without a CAMG
The ILBM document says a 6-plane picture without a CAMG is “probably
HAM”. The explorer guesses HAM6 for 6 planes and up to 16 colours with no
CAMG, and Extra Half-Brite for 6 planes and exactly 32 colours, and
says that it guessed.
HAM came to Deluxe Paint in Deluxe Paint IV (1991). Deluxe Paint V shows its 24-bit pictures in HAM8.
Deep pictures
A deep picture has no colour map. Each pixel’s colour is stored directly, one bit of it in each plane:
| Planes | Order, plane 0 first |
|---|---|
| 24 | R0 to R7, G0 to G7, B0 to B7: plane 0 is the lowest bit of red, plane 23 the highest bit of blue. |
| 32 | The same, then A0 to A7, the alpha (opacity). |
- A mask plane can follow the 24 planes, with masking 1. Some 24-bit brushes, such as those that came with LightWave 3D, have one.
- NewTek’s 21-bit pictures use another order, R7 G7 B7 R6 G6 B6 … R0 G0 B0. The explorer does not read them.
- The explorer paints 24- and 32-plane pictures. It also paints other multiples of 3 above 8 planes in the red, green, blue order, scaled up; that is an assumption.
Transparency
| Masking | What is transparent |
|---|---|
| 1 | Every pixel whose bit in the mask plane is 0. |
| 2 | Every pixel of colour transparentColor. |
| 3 (lasso) | Pixels of colour transparentColor that join the edge of the picture through other pixels of that colour. |
The explorer applies all three in its preview. It does not apply a transparent colour to HAM and deep pictures, whose pixels are not colour numbers, but it does apply their mask plane.