|
| 1 | +╒════════════════╕ |
| 2 | +│ FILE STRUCTURE │ |
| 3 | +╞════════╤═══════╧══════╤══════════════════════════════════════════════════════╕ |
| 4 | +│ OFFSET │ TYPE │ CONTENT │ |
| 5 | +╞════════╪══════════════╪══════════════════════════════════════════════════════╡ |
| 6 | +│ $0000 │ uint8_t │ Length of magic bytes (always 8) │ |
| 7 | +├────────┼──────────────┼──────────────────────────────────────────────────────┤ |
| 8 | +│ $0001 │ char[8] │ Magic bytes: "MONOTONE" │ |
| 9 | +├────────┼──────────────┼──────────────────────────────────────────────────────┤ |
| 10 | +│ $0009 │ uint8_t │ Length of song title (max 40) │ |
| 11 | +├────────┼──────────────┼──────────────────────────────────────────────────────┤ |
| 12 | +│ $000A │ char[40] │ Song title │ |
| 13 | +├────────┼──────────────┼──────────────────────────────────────────────────────┤ |
| 14 | +│ $0032 │ uint8_t │ Length of song comment (max 40) │ |
| 15 | +├────────┼──────────────┼──────────────────────────────────────────────────────┤ |
| 16 | +│ $0033 │ char[40] │ Song comment │ |
| 17 | +├────────┼──────────────┼──────────────────────────────────────────────────────┤ |
| 18 | +│ $005B │ uint8_t │ Song format version (currently always 1) │ |
| 19 | +├────────┼──────────────┼──────────────────────────────────────────────────────┤ |
| 20 | +│ $005C │ uint8_t │ Number of patterns │ |
| 21 | +├────────┼──────────────┼──────────────────────────────────────────────────────┤ |
| 22 | +│ $005D │ uint8_t │ Number of channels │ |
| 23 | +├────────┼──────────────┼──────────────────────────────────────────────────────┤ |
| 24 | +│ $005E │ uint8_t │ Size of each cell (note + effect) (always 2) │ |
| 25 | +├────────┼──────────────┼──────────────────────────────────────────────────────┤ |
| 26 | +│ $005F │ uint8_t[256] │ Order list (end of song / empty orders = $FF) │ |
| 27 | +├────────┼──────────────┼──────────────────────────────────────────────────────┤ |
| 28 | +│ $015F │ uint16_t[] │ Cells / pattern data (documented below) │ |
| 29 | +└────────┴──────────────┴──────────────────────────────────────────────────────┘ |
| 30 | + |
| 31 | +╒════════════════════════╕ |
| 32 | +│ PATTERN/CELL STRUCTURE │ |
| 33 | +├────────────────────────┴─────────────────────────────────────────────────────┐ |
| 34 | +│ The data structure at $015F is an array of all the patterns │ |
| 35 | +│ (the number of patterns is stored at $005C). │ |
| 36 | +│ │ |
| 37 | +│ Each pattern is an array of its rows (every pattern has 64 rows). │ |
| 38 | +│ │ |
| 39 | +│ Each row is an array of its cells (note + effect) │ |
| 40 | +│ (the number of cells per row is the number of channels, stored at $005D). │ |
| 41 | +│ │ |
| 42 | +│ Each cell is a 16-bit integer, structured as follows: │ |
| 43 | +│ │ |
| 44 | +│ HIGH BYTE LOW BYTE │ |
| 45 | +│ ──────── ──────── │ |
| 46 | +│ nnnnnnne eepppppp │ |
| 47 | +│ ││││││││ ││││││││ │ |
| 48 | +│ ││││││││ ││└┴┴┴┴┴─ parameter of effect (see below for more explanation) │ |
| 49 | +│ │││││││└────┴┴─────── effect type (0-7) (5,6,7 map to B,D,F respectively) │ |
| 50 | +│ └┴┴┴┴┴┴────────────── note (0-127) (0=empty, 1-126=A0-D11, 127=off) │ |
| 51 | +│ │ |
| 52 | +│ For single-parameter effects (1xx, 2xx, 3xx, Bxx, Dxx, and Fxx), │ |
| 53 | +│ all six parameter bits are used to encode xx, ranging from $00 to $3F. │ |
| 54 | +│ │ |
| 55 | +│ For double-parameter effects (0xy and 4xy), │ |
| 56 | +│ the upper three and lower three parameter bits are used to encode │ |
| 57 | +│ x and y respectively, each ranging from $0 to $7. │ |
| 58 | +│ │ |
| 59 | +│ Note that Intel's architecture is little-endian, meaning that each cell's │ |
| 60 | +│ low byte is written before its high byte. │ |
| 61 | +│ │ |
| 62 | +│ The size of the data structure stored at $015F is 128*C*P bytes, where │ |
| 63 | +│ C is the number of channels, and │ |
| 64 | +│ P is the number of patterns. │ |
| 65 | +│ │ |
| 66 | +│ (2 bytes per cell * C cells per row * 64 rows per pattern * P patterns) │ |
| 67 | +└──────────────────────────────────────────────────────────────────────────────┘ |
0 commit comments