@@ -29,8 +29,8 @@ Features
2929
3030- 16-bit frequency dividers (accurate pitch within <0.15% margin)
3131- sample rate: 13.5 KHz
32- - per- step tempo , 6-bit tempo resolution
33- - BPM (~2.5 BMP granularity).
32+ - variable step length , 6-bit resolution
33+ - variable global tempo (~2.5bpm granularity)
3434
3535
3636Limitations
@@ -57,11 +57,11 @@ The following limitations apply:
5757- Any changes to instruments/samples are ignored.
5858- FX commands are ignored, except for Fxx (change tempo, xx < 0x20)
5959- The range of instruments is limited:
60- - instruments 1 and 2: C0 ..G#8
61- - instrument 3: C0..A5
62- - instruments 4, 5 and 6: C0 ..G#4
63- - instrument 7: C0..G#2
64- - instrument 8: C0..A1
60+ - instruments 1 and 2: C-0 ..G#8
61+ - instrument 3: C-0..A-6
62+ - instruments 4, 5 and 6: C-0 ..G#5
63+ - instrument 7: C-0..A-1
64+ - instrument 8: C-0..A-1
6565
6666Pattern length is also limited. The actual limit depends on the converted data
6767size. In the worst case, you will run out of bytes after 51 rows, but normally
@@ -83,23 +83,24 @@ main directory.
8383MUSIC DATA FORMAT
8484================================================================================
8585
86- Music data for TIAtune consists of a sequence, followed by one or more patterns.
86+ Music data for TIAtune consists of a sequence, followed by one or more patterns,
87+ and additionally a lookup table for used note dividers.
8788The music data must be provided in a file named "music.asm", which is included
8889by the main file.
8990
9091
9192Sequence
9293========
9394
94- The sequence contains a list of ids of pointers to patterns, in the order in
95- which they are to be played. The sequence list must be terminated with a 0-byte.
96- The sequence may at most contain 255 entries.
95+ The sequence contains a list of 8-bit IDs of pointers to patterns, in the order
96+ in which they are to be played. The sequence list must be terminated with a
97+ 0-byte. The sequence may at most contain 255 entries.
9798
98- The pattern pointer are split into a hi-byte and a lo-byte part, labelled
99- "pattern_lookup_hi" and "pattern_lookup_lo", respectively. The pattern pointer
100- must be ordered like the pattern definitions . The lo-list must be terminated
101- with the lo-pointer to the byte after the last pattern. For the hi-pointer, two
102- pointers are encoded into one byte (see example below).
99+ The pattern lookup table is split into a hi-byte and a lo-byte part, labelled
100+ "pattern_lookup_hi" and "pattern_lookup_lo", respectively. Pattern pointers
101+ must be ordered by their respective IDs . The lo-list must be terminated with the
102+ lo-pointer to the byte after the last pattern. For the hi-pointer, two pointers
103+ are encoded into one byte (see example below).
103104
104105The most simple sequence would thus be:
105106
@@ -129,10 +130,10 @@ byte bits function
129130 0..5 tempo (step length)
1301312 0..2 waveform channel 1 (0..4)
131132 3..6 volume channel 1
132- 3 0..7 note channel 1
133+ 3 0..7 note index channel 1
1331344 0..2 waveform channel 2 (0..4)
134135 3..6 volume channel 2
135- 5 0..7 note channel 2
136+ 5 0..7 note index channel 2
136137
137138If bit 0 of byte 1 is set, byte 2 and 3 are omitted. Likewise, if bit 1 of byte
1381391 is set, byte 4 and 5 are omitted. On the first step of the first pattern in
@@ -142,16 +143,41 @@ AUDCx equivalents of the waveform parameter, and their note ranges are as
142143follows:
143144
144145wave AUDCx range
145- 0 4,5,C,D C0 ..G#8
146- 1 8 C0 ..G#8
147- 2 1 C0..A5
148- 3 6,A C0 ..G#4
149- 4 7,9 C0 ..G#4
150- 5 3 C0..G#2
151- 6 2 C0..A1
146+ 0 4,5,C,D C-0 ..G#8
147+ 1 8 C-0 ..G#8
148+ 2 1 C-0..A-6
149+ 3 6,A C-0 ..G#5
150+ 4 7,9 C-0 ..G#5
151+ 5 3 C-0..A-1
152+ 6 2 C-0..A-1
152153
153154Each pattern may contain up to 255 data bytes. Thus, each pattern may contain at
154155least 51 steps. In most cases however, it is advisable to use shorter patterns,
155156to optimize overall data usage.
156157
158+ Note Divider Lookup
159+ ===================
160+
161+ The note divider lookup table must be provided separately for PAL and NTSC
162+ timings, using files named "note_table_pal.h" and "note_table_ntsc.h",
163+ respectively. The lookup table must include values for each unique note +
164+ wave period combination. The table must be sorted by note index, as used in the
165+ pattern section.
166+
167+ To derive the divider value NDIV from a note frequency NOTE_FREQ and a wave
168+ period WP:
169+
170+ NDIV = 0x10000 - NOTE_FREQ * 256 * 256 / (BASE_FREQ / (88 + 14 / 256)) * WP
171+
172+ where BASE_FREQ is 1193181.67 for NTSC, and 1182298.0 for PAL, and WP may be
173+ assumed as:
174+
175+ wave period
176+ 0 2
177+ 1 any, converter uses 4
178+ 2 15 (converter uses 7.5)
179+ 3,4 31 (converter uses 15.5)
180+ 5,6 465 (converter uses 232.5)
181+
182+
157183For more information, check the provided example music.asm file.
0 commit comments