Each pattern is found through the pattern offset table. An offset of 0 means an empty pattern of 64 rows. Patterns have 32 to 200 rows, and the notes are stored in a packed form.
Pattern header
| Offset | Size | Type | Name | Description |
|---|---|---|---|---|
| 0 | 2 | u16 | Length | Length of the packed data, not counting this 8-byte header. |
| 2 | 2 | u16 | Rows | Number of rows, 32 to 200. |
| 4 | 4 | – | unused | |
| 8 | Length | bytes | data | The packed rows. |
Packing
The data is read one row at a time until the row’s end marker. For each channel the player keeps a last mask, a last note, a last instrument, a last volume and a last command, all starting at 0.
- Read a channel marker byte. If it is 0, the row is finished.
- The channel is (marker − 1) & 63.
- If bit 7 of the marker is set, read a mask byte and remember it as that channel’s last mask. Otherwise reuse the channel’s last mask.
- Read the fields the mask calls for, in this order: note, instrument, volume, command and value.
| Mask bit | Value | Meaning when set |
|---|---|---|
| 0 | 01 | A note byte follows; remember it. |
| 1 | 02 | An instrument byte follows; remember it. |
| 2 | 04 | A volume/pan byte follows; remember it. |
| 3 | 08 | A command byte and a value byte follow; remember them. |
| 4 | 10 | Use the channel’s last note. |
| 5 | 20 | Use the channel’s last instrument. |
| 6 | 40 | Use the channel’s last volume/pan. |
| 7 | 80 | Use the channel’s last command and value. |
81 0F 3C 01 20 02 04 00
Note values
| Value | Meaning |
|---|---|
| 0 to 119 | C-0 to B-9. |
| 255 | Note off. |
| 254 | Note cut. |
| any other | Note fade. The player handles it; the editor cannot enter it. |
Instrument values are 1 to 99.
Volume column
Volumes are stored directly, and effects in the volume column use ranges of the same byte.
| Value | Shown as | Meaning |
|---|---|---|
| 0–64 | v00–v64 | Set the volume. |
| 65–74 | a0x | Fine volume slide up (same as D0F to D9F). |
| 75–84 | b0x | Fine volume slide down (DF0 to DF9). |
| 85–94 | c0x | Volume slide up (Dx0). |
| 95–104 | d0x | Volume slide down (D0x). |
| 105–114 | e0x | Pitch slide down. A value of x is a normal slide of 4x, using the memory of E and F. |
| 115–124 | f0x | Pitch slide up, on the same scale. |
| 128–192 | p00–p64 | Set panning, 0 to 64. |
| 193–202 | g0x | Portamento to note, using G’s memory. |
| 203–212 | h0x | Vibrato, using the memory of H and U. |
For portamento, the value 0 to 9 picks a slide from this table: 0, 1, 4, 8, 16, 32, 64, 96, 128, 255. A value of 0 means the G memory is used. Volume column volume slides and fine slides share their own memory, separate from Dxx.