Chip Tracker 1.x module format ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ Author: Dmitrij Mikhajlovich 'Alone Coder/AlCo' Bystrov Extension: .CHI A module has four parts -- the header, the order list (contains positions), patterns, and samples. Each part is sector-aligned (a sector is 256 bytes). The integers stored are little-endian. The header is 1 sector long. +offset (length) description ---------------------------- +0 (8) signature "CHIPv1.0" +8 (32) track name (ASCII only) +40 (1) tempo Attention! ALWAYS measure tempo in 50ths of second, even though the editor up to v1.3 and the player v0.01 both have an error that makes them a bit slower than that! +41 (1) song length - 1 (that's the last position used) 0..255 +42 (1) loop position (0..255) +43 (16*4) sample descriptions (in order from 0 through F): ++0 (2) loop position (equals to length if not looped) ++1 (2) length Contains zeroes for the unused samples. +107 (21) reserved (zeroes). +128 (16*8) sample names (in the same order). 8 bytes per name. Contains spaces for the unused samples. The order list is 1 sector in size and contains the pattern numbers in order of playback. The pattern numbers are stored as 0 through 30, i.e. 1 less than the editor shows. The unused positions contain 0. The number of stored patterns equals to the max pattern number used in the order list. Each pattern is 512 bytes long, which is interpreted as two parallel blocks 256 bytes each. Each pattern has 64 lines. A line is 4 bytes long in the first 256-byte block plus 4 bytes in the second block. The A, B, C, D channels are stored in that exact order. Note that A and D must be played panned right, but B and C panned left. For each note of each channel: in the first block: in the second block: %nnnnnnCC %ssssPPPP nnnnnn: note (0=empty, 1=C-1, ... 60=B-5, 63=pause); ssss: its sample (must be present!); CC: command code and PPPP: command parameter. These are as follows: 00=sample offset. Play the sample starting from byte PPPP*512, but the note bitfield must contain a note; 01=slide down(-) by PPPP microthunks each 1/50 of a second; 10=slide up(+) на PPPP microthunks each 1/50 of a second; A microthunk: an arbitrary unit of frequency (not period!); Slides only count within the current line. 11=in A channel: tempo in PPPP (1..15); in D channel: end of pattern (the current line is the last); in B and C channel: invalid. The samples are stored 8-bit unsigned, and each sample is aligned by sector. The unused part of the sector contains the same data as the start of this sample's loop position. If the sample isn't looped, the alignment bytes contain 80h. All samples are stored in the module apart from those empty. There can be at most BBh=187 sectors containing samples. Attention (again)! Because another error causes Chip Tracker Compiler v0.01 to load incomplete modules if they have empty samples, the player source is made available in which all necessary fixes are done for this (and for the tempo). -- Translated and typos fixed by Kae (TG@kaens)