Each pattern is found through the pattern parapointers and has 64 rows of up to 32 channels.
Packed pattern
| Offset | Size | Type | Name | Description |
|---|---|---|---|---|
| 0 | 2 | u16 | Length | Total packed length, including these two bytes. |
| 2 | Length − 2 | bytes | data | Rows, packed as below. |
Packing
Each row is a run of channel entries ended by a zero byte. An entry starts with a “what” byte:
| Bits | Meaning |
|---|---|
| All zero | End of the row. |
0–4 (&31) | The channel number, 0 to 31. |
5 (&32) | Note and instrument follow, one byte each. |
6 (&64) | Volume follows, one byte. |
7 (&128) | Command and info follow, one byte each. |
E0 50 01 30 01 06 00
How Scream Tracker 3.21 reads a row (St3.exe, the routine at 0x2d738): it takes the entries in the order they
stand, uses the channel setting of that pattern channel to find the output channel (Left 1 to 8, Right 1 to 8 or an
AdLib channel) and writes the entry’s parts into that output channel’s record. A pattern channel whose setting has bit 7
set (disabled, or 255) is skipped. A part an entry does not hold keeps what the record already had, so two pattern channels
mapped to one output channel share their note, instrument and effect fields, and the program handles the cell again for
each entry. The row reader never looks at the pattern’s length word beyond the first two bytes; libopenmpt does not
either, and reads on when a length is too short for 64 rows (found in s3m_hunt.lha).
Fields
| Field | Values |
|---|---|
| Note | High four bits the octave, low four bits the note (0 = C to 11 = B). 255 means no note, 254 means a key off. |
| Instrument | 1 to 99; 0 means none. St3.exe turns a number above 101 into 0 (0x2d8d3). |
| Volume | 0 to 64; 255 means use the instrument’s default. St3.exe turns a value above 63 into 63 (0x2d8dc), so 64 plays as 63. |
| Command | 1 to 26 for A to Z; 255 means none. See Effects. |
| Info | The command’s parameter. |
Scream Tracker keeps a 5-byte form of these fields in memory: 32 channels × 64 rows × 5 bytes, about 10 KB per pattern. That is internal and does not appear in the file.
Volume column
Scream Tracker’s volume column sets the volume only. OpenMPT adds panning in the same
column (pxx, 0 to 64), which is not original Scream Tracker behaviour.
Notes and periods
The period table used from C to B is 1712, 1616, 1524, 1440, 1356, 1280, 1208, 1140, 1076, 1016, 960, 907. A note’s period is:
period = 8363 × 16 × (table[note] >> octave) ÷ C2Spd
The frequency of a period is the clock divided by it. TECH.DOC gives 14,317,056 Hz; the
MultimediaWiki says that is wrong and the value is 14,317,456 (8363 × 1712). The play routine of Scream Tracker 3.21
itself, St3.exe, divides 0xDA7600 = 14,317,056 by the period (file offset 0x2ead2: the
instructions mov dx,0xDA and mov ax,0x7600 before the div), so TECH.DOC is what the
program does. The two clocks differ by 28 parts in a million, 0.05 of a semitone in a hundred.
The program works out the period as the table value times 16, shifted right by the octave, times 8363 and divided by C2Spd, all in integers, in that order (routine at 0x2ea2c, table at data offset 0xa2c); libopenmpt shifts after the multiplication, which differs only in the last bit for the highest octaves.