diff options
author | Michiel Van Der Kolk <not.valid@email.address> | 2005-03-17 20:50:03 +0000 |
---|---|---|
committer | Michiel Van Der Kolk <not.valid@email.address> | 2005-03-17 20:50:03 +0000 |
commit | 27be5bc72855a0fbbdae230bc144624c9eb85f5e (patch) | |
tree | b553f1321df924c4b744ffcab48dce5f4f081f7d /apps/codecs/dumb/include/internal | |
parent | 7e7662bb716917ca431204f0113d400c1014f2e8 (diff) | |
download | rockbox-27be5bc72855a0fbbdae230bc144624c9eb85f5e.tar.gz rockbox-27be5bc72855a0fbbdae230bc144624c9eb85f5e.zip |
Initial check in dumb 0.9.2 - has a few usages of floating point that should
be rewritten to fixed point. seems to compile cleanly for iriver.
git-svn-id: svn://svn.rockbox.org/rockbox/trunk@6197 a1c6a512-1295-4272-9138-f99709370657
Diffstat (limited to 'apps/codecs/dumb/include/internal')
-rw-r--r-- | apps/codecs/dumb/include/internal/aldumb.h | 27 | ||||
-rw-r--r-- | apps/codecs/dumb/include/internal/dumb.h | 58 | ||||
-rw-r--r-- | apps/codecs/dumb/include/internal/it.h | 710 |
3 files changed, 795 insertions, 0 deletions
diff --git a/apps/codecs/dumb/include/internal/aldumb.h b/apps/codecs/dumb/include/internal/aldumb.h new file mode 100644 index 0000000000..a0c6d63c07 --- /dev/null +++ b/apps/codecs/dumb/include/internal/aldumb.h | |||
@@ -0,0 +1,27 @@ | |||
1 | /* _______ ____ __ ___ ___ | ||
2 | * \ _ \ \ / \ / \ \ / / ' ' ' | ||
3 | * | | \ \ | | || | \/ | . . | ||
4 | * | | | | | | || ||\ /| | | ||
5 | * | | | | | | || || \/ | | ' ' ' | ||
6 | * | | | | | | || || | | . . | ||
7 | * | |_/ / \ \__// || | | | ||
8 | * /_______/ynamic \____/niversal /__\ /____\usic /| . . ibliotheque | ||
9 | * / \ | ||
10 | * / . \ | ||
11 | * internal/aldumb.h - The internal header file / / \ \ | ||
12 | * for DUMB with Allegro. | < / \_ | ||
13 | * | \/ /\ / | ||
14 | * \_ / > / | ||
15 | * | \ / / | ||
16 | * | ' / | ||
17 | * \__/ | ||
18 | */ | ||
19 | |||
20 | #ifndef INTERNAL_ALDUMB_H | ||
21 | #define INTERNAL_ALDUMB_H | ||
22 | |||
23 | |||
24 | void _dat_unload_duh(void *duh); | ||
25 | |||
26 | |||
27 | #endif /* INTERNAL_DUMB_H */ | ||
diff --git a/apps/codecs/dumb/include/internal/dumb.h b/apps/codecs/dumb/include/internal/dumb.h new file mode 100644 index 0000000000..b4cd0ab1c4 --- /dev/null +++ b/apps/codecs/dumb/include/internal/dumb.h | |||
@@ -0,0 +1,58 @@ | |||
1 | /* _______ ____ __ ___ ___ | ||
2 | * \ _ \ \ / \ / \ \ / / ' ' ' | ||
3 | * | | \ \ | | || | \/ | . . | ||
4 | * | | | | | | || ||\ /| | | ||
5 | * | | | | | | || || \/ | | ' ' ' | ||
6 | * | | | | | | || || | | . . | ||
7 | * | |_/ / \ \__// || | | | ||
8 | * /_______/ynamic \____/niversal /__\ /____\usic /| . . ibliotheque | ||
9 | * / \ | ||
10 | * / . \ | ||
11 | * internal/dumb.h - DUMB's internal declarations. / / \ \ | ||
12 | * | < / \_ | ||
13 | * This header file provides access to the | \/ /\ / | ||
14 | * internal structure of DUMB, and is liable \_ / > / | ||
15 | * to change, mutate or cease to exist at any | \ / / | ||
16 | * moment. Include it at your own peril. | ' / | ||
17 | * \__/ | ||
18 | * ... | ||
19 | * | ||
20 | * I mean it, people. You don't need access to anything in this file. If you | ||
21 | * disagree, contact the authors. In the unlikely event that you make a good | ||
22 | * case, we'll add what you need to dumb.h. Thanking you kindly. | ||
23 | */ | ||
24 | |||
25 | #ifndef INTERNAL_DUMB_H | ||
26 | #define INTERNAL_DUMB_H | ||
27 | |||
28 | |||
29 | typedef struct DUH_SIGTYPE_DESC_LINK | ||
30 | { | ||
31 | struct DUH_SIGTYPE_DESC_LINK *next; | ||
32 | DUH_SIGTYPE_DESC *desc; | ||
33 | } | ||
34 | DUH_SIGTYPE_DESC_LINK; | ||
35 | |||
36 | |||
37 | typedef struct DUH_SIGNAL | ||
38 | { | ||
39 | sigdata_t *sigdata; | ||
40 | DUH_SIGTYPE_DESC *desc; | ||
41 | } | ||
42 | DUH_SIGNAL; | ||
43 | |||
44 | |||
45 | struct DUH | ||
46 | { | ||
47 | long length; | ||
48 | |||
49 | int n_signals; | ||
50 | DUH_SIGNAL **signal; | ||
51 | }; | ||
52 | |||
53 | |||
54 | DUH_SIGTYPE_DESC *_dumb_get_sigtype_desc(long type); | ||
55 | |||
56 | |||
57 | #endif /* INTERNAL_DUMB_H */ | ||
58 | |||
diff --git a/apps/codecs/dumb/include/internal/it.h b/apps/codecs/dumb/include/internal/it.h new file mode 100644 index 0000000000..7fffed6e6b --- /dev/null +++ b/apps/codecs/dumb/include/internal/it.h | |||
@@ -0,0 +1,710 @@ | |||
1 | /* _______ ____ __ ___ ___ | ||
2 | * \ _ \ \ / \ / \ \ / / ' ' ' | ||
3 | * | | \ \ | | || | \/ | . . | ||
4 | * | | | | | | || ||\ /| | | ||
5 | * | | | | | | || || \/ | | ' ' ' | ||
6 | * | | | | | | || || | | . . | ||
7 | * | |_/ / \ \__// || | | | ||
8 | * /_______/ynamic \____/niversal /__\ /____\usic /| . . ibliotheque | ||
9 | * / \ | ||
10 | * / . \ | ||
11 | * internal/it.h - Internal stuff for IT playback / / \ \ | ||
12 | * and MOD/XM/S3M conversion. | < / \_ | ||
13 | * | \/ /\ / | ||
14 | * \_ / > / | ||
15 | * | \ / / | ||
16 | * | ' / | ||
17 | * \__/ | ||
18 | */ | ||
19 | |||
20 | #ifndef INTERNAL_IT_H | ||
21 | #define INTERNAL_IT_H | ||
22 | |||
23 | |||
24 | |||
25 | #include <stddef.h> | ||
26 | |||
27 | |||
28 | |||
29 | /** TO DO: THINK ABOUT THE FOLLOWING: | ||
30 | |||
31 | sigdata->flags & IT_COMPATIBLE_GXX | ||
32 | |||
33 | Bit 5: On = Link Effect G's memory with Effect E/F. Also | ||
34 | Gxx with an instrument present will cause the | ||
35 | envelopes to be retriggered. If you change a | ||
36 | sample on a row with Gxx, it'll adjust the | ||
37 | frequency of the current note according to: | ||
38 | |||
39 | NewFrequency = OldFrequency * NewC5 / OldC5; | ||
40 | */ | ||
41 | |||
42 | |||
43 | |||
44 | /* These #defines are TEMPORARY. They are used to write alternative code to | ||
45 | * handle ambiguities in the format specification. The correct code in each | ||
46 | * case will be determined most likely by experimentation. | ||
47 | */ | ||
48 | #define STEREO_SAMPLES_COUNT_AS_TWO | ||
49 | #define INVALID_ORDERS_END_SONG | ||
50 | #define INVALID_NOTES_CAUSE_NOTE_CUT | ||
51 | #define SUSTAIN_LOOP_OVERRIDES_NORMAL_LOOP | ||
52 | #define VOLUME_OUT_OF_RANGE_SETS_MAXIMUM | ||
53 | |||
54 | |||
55 | |||
56 | #define SIGTYPE_IT DUMB_ID('I', 'T', ' ', ' ') | ||
57 | |||
58 | #define IT_SIGNATURE DUMB_ID('I', 'M', 'P', 'M') | ||
59 | #define IT_INSTRUMENT_SIGNATURE DUMB_ID('I', 'M', 'P', 'I') | ||
60 | #define IT_SAMPLE_SIGNATURE DUMB_ID('I', 'M', 'P', 'S') | ||
61 | |||
62 | |||
63 | |||
64 | /* 1 minute per 4 rows, each row 6 ticks; this is divided by the tempo to get | ||
65 | * the interval between ticks. | ||
66 | */ | ||
67 | #define TICK_TIME_DIVIDEND ((65536 * 60) / (4 * 6)) | ||
68 | |||
69 | |||
70 | |||
71 | /* I'm not going to try to explain this, because I didn't derive it very | ||
72 | * formally ;) | ||
73 | */ | ||
74 | /* #define AMIGA_DIVISOR ((float)(4.0 * 14317056.0)) */ | ||
75 | /* I believe the following one to be more accurate. */ | ||
76 | #define AMIGA_DIVISOR ((float)(8.0 * 7159090.5)) | ||
77 | |||
78 | |||
79 | |||
80 | typedef struct IT_MIDI IT_MIDI; | ||
81 | typedef struct IT_FILTER_STATE IT_FILTER_STATE; | ||
82 | typedef struct IT_ENVELOPE IT_ENVELOPE; | ||
83 | typedef struct IT_INSTRUMENT IT_INSTRUMENT; | ||
84 | typedef struct IT_SAMPLE IT_SAMPLE; | ||
85 | typedef struct IT_ENTRY IT_ENTRY; | ||
86 | typedef struct IT_PATTERN IT_PATTERN; | ||
87 | typedef struct IT_PLAYING_ENVELOPE IT_PLAYING_ENVELOPE; | ||
88 | typedef struct IT_PLAYING IT_PLAYING; | ||
89 | typedef struct IT_CHANNEL IT_CHANNEL; | ||
90 | typedef struct IT_CHECKPOINT IT_CHECKPOINT; | ||
91 | typedef struct IT_CALLBACKS IT_CALLBACKS; | ||
92 | |||
93 | |||
94 | |||
95 | struct IT_MIDI | ||
96 | { | ||
97 | unsigned char SFmacro[16][16]; // read these from 0x120 | ||
98 | unsigned char SFmacrolen[16]; | ||
99 | unsigned short SFmacroz[16]; /* Bitfield; bit 0 set = z in first position */ | ||
100 | unsigned char Zmacro[128][16]; // read these from 0x320 | ||
101 | unsigned char Zmacrolen[128]; | ||
102 | }; | ||
103 | |||
104 | |||
105 | |||
106 | struct IT_FILTER_STATE | ||
107 | { | ||
108 | float currsample, prevsample; | ||
109 | }; | ||
110 | |||
111 | |||
112 | |||
113 | #define IT_ENVELOPE_ON 1 | ||
114 | #define IT_ENVELOPE_LOOP_ON 2 | ||
115 | #define IT_ENVELOPE_SUSTAIN_LOOP 4 | ||
116 | #define IT_ENVELOPE_PITCH_IS_FILTER 128 | ||
117 | |||
118 | struct IT_ENVELOPE | ||
119 | { | ||
120 | unsigned char flags; | ||
121 | unsigned char n_nodes; | ||
122 | unsigned char loop_start; | ||
123 | unsigned char loop_end; | ||
124 | unsigned char sus_loop_start; | ||
125 | unsigned char sus_loop_end; | ||
126 | signed char node_y[25]; | ||
127 | unsigned short node_t[25]; | ||
128 | }; | ||
129 | |||
130 | |||
131 | |||
132 | #define NNA_NOTE_CUT 0 | ||
133 | #define NNA_NOTE_CONTINUE 1 | ||
134 | #define NNA_NOTE_OFF 2 | ||
135 | #define NNA_NOTE_FADE 3 | ||
136 | |||
137 | #define DCT_OFF 0 | ||
138 | #define DCT_NOTE 1 | ||
139 | #define DCT_SAMPLE 2 | ||
140 | #define DCT_INSTRUMENT 3 | ||
141 | |||
142 | #define DCA_NOTE_CUT 0 | ||
143 | #define DCA_NOTE_OFF 1 | ||
144 | #define DCA_NOTE_FADE 2 | ||
145 | |||
146 | struct IT_INSTRUMENT | ||
147 | { | ||
148 | int fadeout; | ||
149 | |||
150 | IT_ENVELOPE volume_envelope; | ||
151 | IT_ENVELOPE pan_envelope; | ||
152 | IT_ENVELOPE pitch_envelope; | ||
153 | |||
154 | unsigned char new_note_action; | ||
155 | unsigned char dup_check_type; | ||
156 | unsigned char dup_check_action; | ||
157 | unsigned char pp_separation; | ||
158 | unsigned char pp_centre; | ||
159 | unsigned char global_volume; | ||
160 | unsigned char default_pan; | ||
161 | unsigned char random_volume; | ||
162 | unsigned char random_pan; | ||
163 | |||
164 | unsigned char filter_cutoff; | ||
165 | unsigned char filter_resonance; | ||
166 | |||
167 | unsigned char map_note[120]; | ||
168 | unsigned short map_sample[120]; | ||
169 | }; | ||
170 | |||
171 | |||
172 | |||
173 | #define IT_SAMPLE_EXISTS 1 | ||
174 | #define IT_SAMPLE_16BIT 2 | ||
175 | #define IT_SAMPLE_STEREO 4 | ||
176 | #define IT_SAMPLE_LOOP 16 | ||
177 | #define IT_SAMPLE_SUS_LOOP 32 | ||
178 | #define IT_SAMPLE_PINGPONG_LOOP 64 | ||
179 | #define IT_SAMPLE_PINGPONG_SUS_LOOP 128 | ||
180 | |||
181 | #define IT_VIBRATO_SINE 0 | ||
182 | #define IT_VIBRATO_SAWTOOTH 1 /* Ramp down */ | ||
183 | #define IT_VIBRATO_SQUARE 2 | ||
184 | #define IT_VIBRATO_RANDOM 3 | ||
185 | |||
186 | struct IT_SAMPLE | ||
187 | { | ||
188 | unsigned char flags; | ||
189 | unsigned char global_volume; | ||
190 | unsigned char default_volume; | ||
191 | unsigned char default_pan; | ||
192 | |||
193 | long length; | ||
194 | long loop_start; | ||
195 | long loop_end; | ||
196 | long C5_speed; | ||
197 | long sus_loop_start; | ||
198 | long sus_loop_end; | ||
199 | |||
200 | unsigned char vibrato_speed; | ||
201 | unsigned char vibrato_depth; | ||
202 | unsigned char vibrato_rate; | ||
203 | unsigned char vibrato_waveform; | ||
204 | |||
205 | sample_t *left; | ||
206 | sample_t *right; | ||
207 | }; | ||
208 | |||
209 | |||
210 | |||
211 | #define IT_ENTRY_NOTE 1 | ||
212 | #define IT_ENTRY_INSTRUMENT 2 | ||
213 | #define IT_ENTRY_VOLPAN 4 | ||
214 | #define IT_ENTRY_EFFECT 8 | ||
215 | |||
216 | #define IT_SET_END_ROW(entry) ((entry)->channel = 255) | ||
217 | #define IT_IS_END_ROW(entry) ((entry)->channel >= DUMB_IT_N_CHANNELS) | ||
218 | |||
219 | #define IT_NOTE_OFF 255 | ||
220 | #define IT_NOTE_CUT 254 | ||
221 | |||
222 | #define IT_ENVELOPE_SHIFT 8 | ||
223 | |||
224 | #define IT_SURROUND 100 | ||
225 | #define IT_IS_SURROUND(pan) ((pan) > 64) | ||
226 | #define IT_IS_SURROUND_SHIFTED(pan) ((pan) > 64 << IT_ENVELOPE_SHIFT) | ||
227 | |||
228 | #define IT_SET_SPEED 1 | ||
229 | #define IT_JUMP_TO_ORDER 2 | ||
230 | #define IT_BREAK_TO_ROW 3 | ||
231 | #define IT_VOLUME_SLIDE 4 | ||
232 | #define IT_PORTAMENTO_DOWN 5 | ||
233 | #define IT_PORTAMENTO_UP 6 | ||
234 | #define IT_TONE_PORTAMENTO 7 | ||
235 | #define IT_VIBRATO 8 | ||
236 | #define IT_TREMOR 9 | ||
237 | #define IT_ARPEGGIO 10 | ||
238 | #define IT_VOLSLIDE_VIBRATO 11 | ||
239 | #define IT_VOLSLIDE_TONEPORTA 12 | ||
240 | #define IT_SET_CHANNEL_VOLUME 13 | ||
241 | #define IT_CHANNEL_VOLUME_SLIDE 14 | ||
242 | #define IT_SET_SAMPLE_OFFSET 15 | ||
243 | #define IT_PANNING_SLIDE 16 | ||
244 | #define IT_RETRIGGER_NOTE 17 | ||
245 | #define IT_TREMOLO 18 | ||
246 | #define IT_S 19 | ||
247 | #define IT_SET_SONG_TEMPO 20 | ||
248 | #define IT_FINE_VIBRATO 21 | ||
249 | #define IT_SET_GLOBAL_VOLUME 22 | ||
250 | #define IT_GLOBAL_VOLUME_SLIDE 23 | ||
251 | #define IT_SET_PANNING 24 | ||
252 | #define IT_PANBRELLO 25 | ||
253 | #define IT_MIDI_MACRO 26 //see MIDI.TXT | ||
254 | |||
255 | /* Some effects needed for XM compatibility */ | ||
256 | #define IT_XM_PORTAMENTO_DOWN 27 | ||
257 | #define IT_XM_PORTAMENTO_UP 28 | ||
258 | #define IT_XM_FINE_VOLSLIDE_DOWN 29 | ||
259 | #define IT_XM_FINE_VOLSLIDE_UP 30 | ||
260 | #define IT_XM_RETRIGGER_NOTE 31 | ||
261 | |||
262 | #define IT_N_EFFECTS 32 | ||
263 | |||
264 | /* These represent the top nibble of the command value. */ | ||
265 | #define IT_S_SET_FILTER 0 /* Greyed out in IT... */ | ||
266 | #define IT_S_SET_GLISSANDO_CONTROL 1 /* Greyed out in IT... */ | ||
267 | #define IT_S_FINETUNE 2 /* Greyed out in IT... */ | ||
268 | #define IT_S_SET_VIBRATO_WAVEFORM 3 | ||
269 | #define IT_S_SET_TREMOLO_WAVEFORM 4 | ||
270 | #define IT_S_SET_PANBRELLO_WAVEFORM 5 | ||
271 | #define IT_S_FINE_PATTERN_DELAY 6 | ||
272 | #define IT_S7 7 | ||
273 | #define IT_S_SET_PAN 8 | ||
274 | #define IT_S_SET_SURROUND_SOUND 9 | ||
275 | #define IT_S_SET_HIGH_OFFSET 10 | ||
276 | #define IT_S_PATTERN_LOOP 11 | ||
277 | #define IT_S_DELAYED_NOTE_CUT 12 | ||
278 | #define IT_S_NOTE_DELAY 13 | ||
279 | #define IT_S_PATTERN_DELAY 14 | ||
280 | #define IT_S_SET_MIDI_MACRO 15 | ||
281 | |||
282 | /* | ||
283 | S0x Set filter | ||
284 | S1x Set glissando control | ||
285 | S2x Set finetune | ||
286 | |||
287 | |||
288 | S3x Set vibrato waveform to type x | ||
289 | S4x Set tremelo waveform to type x | ||
290 | S5x Set panbrello waveform to type x | ||
291 | Waveforms for commands S3x, S4x and S5x: | ||
292 | 0: Sine wave | ||
293 | 1: Ramp down | ||
294 | 2: Square wave | ||
295 | 3: Random wave | ||
296 | S6x Pattern delay for x ticks | ||
297 | S70 Past note cut | ||
298 | S71 Past note off | ||
299 | S72 Past note fade | ||
300 | S73 Set NNA to note cut | ||
301 | S74 Set NNA to continue | ||
302 | S75 Set NNA to note off | ||
303 | S76 Set NNA to note fade | ||
304 | S77 Turn off volume envelope | ||
305 | S78 Turn on volume envelope | ||
306 | S79 Turn off panning envelope | ||
307 | S7A Turn on panning envelope | ||
308 | S7B Turn off pitch envelope | ||
309 | S7C Turn on pitch envelope | ||
310 | S8x Set panning position | ||
311 | S91 Set surround sound | ||
312 | SAy Set high value of sample offset yxx00h | ||
313 | SB0 Set loopback point | ||
314 | SBx Loop x times to loopback point | ||
315 | SCx Note cut after x ticks | ||
316 | SDx Note delay for x ticks | ||
317 | SEx Pattern delay for x rows | ||
318 | SFx Set parameterised MIDI Macro | ||
319 | */ | ||
320 | |||
321 | struct IT_ENTRY | ||
322 | { | ||
323 | unsigned char channel; /* End of row if channel >= DUMB_IT_N_CHANNELS */ | ||
324 | unsigned char mask; | ||
325 | unsigned char note; | ||
326 | unsigned char instrument; | ||
327 | unsigned char volpan; | ||
328 | unsigned char effect; | ||
329 | unsigned char effectvalue; | ||
330 | }; | ||
331 | |||
332 | |||
333 | |||
334 | struct IT_PATTERN | ||
335 | { | ||
336 | int n_rows; | ||
337 | int n_entries; | ||
338 | IT_ENTRY *entry; | ||
339 | }; | ||
340 | |||
341 | |||
342 | |||
343 | #define IT_STEREO 1 | ||
344 | #define IT_USE_INSTRUMENTS 4 | ||
345 | #define IT_LINEAR_SLIDES 8 /* If not set, use Amiga slides */ | ||
346 | #define IT_OLD_EFFECTS 16 | ||
347 | #define IT_COMPATIBLE_GXX 32 | ||
348 | |||
349 | /* Make sure IT_WAS_AN_XM and IT_WAS_A_MOD aren't set accidentally */ | ||
350 | #define IT_REAL_FLAGS 63 | ||
351 | |||
352 | #define IT_WAS_AN_XM 64 /* Set for both XMs and MODs */ | ||
353 | #define IT_WAS_A_MOD 128 | ||
354 | |||
355 | #define IT_ORDER_END 255 | ||
356 | #define IT_ORDER_SKIP 254 | ||
357 | |||
358 | struct DUMB_IT_SIGDATA | ||
359 | { | ||
360 | int n_orders; | ||
361 | int n_instruments; | ||
362 | int n_samples; | ||
363 | int n_patterns; | ||
364 | |||
365 | int flags; | ||
366 | |||
367 | int global_volume; | ||
368 | int mixing_volume; | ||
369 | int speed; | ||
370 | int tempo; | ||
371 | int pan_separation; | ||
372 | |||
373 | unsigned char channel_pan[DUMB_IT_N_CHANNELS]; | ||
374 | unsigned char channel_volume[DUMB_IT_N_CHANNELS]; | ||
375 | |||
376 | unsigned char *order; | ||
377 | unsigned char restart_position; /* for XM compatiblity */ | ||
378 | |||
379 | IT_INSTRUMENT *instrument; | ||
380 | IT_SAMPLE *sample; | ||
381 | IT_PATTERN *pattern; | ||
382 | |||
383 | IT_MIDI *midi; | ||
384 | |||
385 | IT_CHECKPOINT *checkpoint; | ||
386 | }; | ||
387 | |||
388 | |||
389 | |||
390 | struct IT_PLAYING_ENVELOPE | ||
391 | { | ||
392 | int next_node; | ||
393 | int tick; | ||
394 | }; | ||
395 | |||
396 | |||
397 | |||
398 | #define IT_PLAYING_BACKGROUND 1 | ||
399 | #define IT_PLAYING_SUSTAINOFF 2 | ||
400 | #define IT_PLAYING_FADING 4 | ||
401 | #define IT_PLAYING_DEAD 8 | ||
402 | |||
403 | struct IT_PLAYING | ||
404 | { | ||
405 | int flags; | ||
406 | |||
407 | IT_CHANNEL *channel; | ||
408 | IT_SAMPLE *sample; | ||
409 | IT_INSTRUMENT *instrument; | ||
410 | IT_INSTRUMENT *env_instrument; | ||
411 | |||
412 | unsigned short sampnum; | ||
413 | unsigned char instnum; | ||
414 | |||
415 | unsigned char channel_volume; | ||
416 | |||
417 | unsigned char volume; | ||
418 | unsigned short pan; | ||
419 | |||
420 | unsigned char note; | ||
421 | |||
422 | unsigned char filter_cutoff; | ||
423 | unsigned char filter_resonance; | ||
424 | |||
425 | unsigned short true_filter_cutoff; /* These incorporate the filter envelope, and will not */ | ||
426 | unsigned char true_filter_resonance; /* be changed if they would be set to 127<<8 and 0. */ | ||
427 | |||
428 | unsigned char vibrato_speed; | ||
429 | unsigned char vibrato_depth; | ||
430 | unsigned char vibrato_n; /* May be specified twice: volpan & effect. */ | ||
431 | unsigned char vibrato_time; | ||
432 | |||
433 | unsigned char tremolo_speed; | ||
434 | unsigned char tremolo_depth; | ||
435 | unsigned char tremolo_time; | ||
436 | |||
437 | unsigned char sample_vibrato_time; | ||
438 | int sample_vibrato_depth; /* Starts at rate?0:depth, increases by rate */ | ||
439 | |||
440 | int slide; | ||
441 | float delta; | ||
442 | |||
443 | IT_PLAYING_ENVELOPE volume_envelope; | ||
444 | IT_PLAYING_ENVELOPE pan_envelope; | ||
445 | IT_PLAYING_ENVELOPE pitch_envelope; | ||
446 | |||
447 | int fadeoutcount; | ||
448 | |||
449 | IT_FILTER_STATE filter_state[2]; /* Left and right */ | ||
450 | |||
451 | DUMB_RESAMPLER resampler[2]; | ||
452 | |||
453 | /* time_lost is used to emulate Impulse Tracker's sample looping | ||
454 | * characteristics. When time_lost is added to pos, the result represents | ||
455 | * the position in the theoretical version of the sample where all loops | ||
456 | * have been expanded. If this is stored, the resampling helpers will | ||
457 | * safely convert it for use with new loop boundaries. The situation is | ||
458 | * slightly more complicated if dir == -1 when the change takes place; we | ||
459 | * must reflect pos off the loop end point and set dir to 1 before | ||
460 | * proceeding. | ||
461 | */ | ||
462 | long time_lost; | ||
463 | }; | ||
464 | |||
465 | |||
466 | |||
467 | #define IT_CHANNEL_MUTED 1 | ||
468 | |||
469 | struct IT_CHANNEL | ||
470 | { | ||
471 | int flags; | ||
472 | |||
473 | unsigned char volume; | ||
474 | signed char volslide; | ||
475 | signed char xm_volslide; | ||
476 | |||
477 | /* xm_volslide is used for volume slides done in the volume column in an | ||
478 | * XM file, since it seems the volume column slide is applied first, | ||
479 | * followed by clamping, followed by the effects column slide. IT does | ||
480 | * not exhibit this behaviour, so xm_volslide is maintained at zero. | ||
481 | */ | ||
482 | |||
483 | unsigned char pan; | ||
484 | unsigned short truepan; | ||
485 | |||
486 | unsigned char channelvolume; | ||
487 | signed char channelvolslide; | ||
488 | |||
489 | unsigned char instrument; | ||
490 | unsigned char note; | ||
491 | |||
492 | unsigned char SFmacro; | ||
493 | |||
494 | unsigned char filter_cutoff; | ||
495 | unsigned char filter_resonance; | ||
496 | |||
497 | unsigned char note_cut_count; | ||
498 | unsigned char note_delay_count; | ||
499 | IT_ENTRY *note_delay_entry; | ||
500 | |||
501 | int arpeggio; | ||
502 | unsigned char retrig; | ||
503 | unsigned char xm_retrig; | ||
504 | int retrig_tick; | ||
505 | |||
506 | unsigned char tremor; | ||
507 | unsigned char tremor_time; /* Bit 6 set if note on; bit 7 set if tremor active. */ | ||
508 | |||
509 | int portamento; | ||
510 | int toneporta; | ||
511 | unsigned char destnote; | ||
512 | |||
513 | /** WARNING - for neatness, should one or both of these be in the IT_PLAYING struct? */ | ||
514 | unsigned short sample; | ||
515 | unsigned char truenote; | ||
516 | |||
517 | unsigned char midi_state; | ||
518 | |||
519 | signed char lastvolslide; | ||
520 | unsigned char lastDKL; | ||
521 | unsigned char lastEF; /* Doubles as last portamento up for XM files */ | ||
522 | unsigned char lastG; | ||
523 | unsigned char lastHspeed; | ||
524 | unsigned char lastHdepth; | ||
525 | unsigned char lastRspeed; | ||
526 | unsigned char lastRdepth; | ||
527 | unsigned char lastI; | ||
528 | unsigned char lastJ; /* Doubles as last portamento down for XM files */ | ||
529 | unsigned char lastN; | ||
530 | unsigned char lastO; | ||
531 | unsigned char high_offset; | ||
532 | unsigned char lastQ; | ||
533 | unsigned char lastS; | ||
534 | unsigned char pat_loop_row; | ||
535 | unsigned char pat_loop_count; | ||
536 | unsigned char lastW; | ||
537 | |||
538 | unsigned char xm_lastE1; | ||
539 | unsigned char xm_lastE2; | ||
540 | unsigned char xm_lastEA; | ||
541 | unsigned char xm_lastEB; | ||
542 | unsigned char xm_lastX1; | ||
543 | unsigned char xm_lastX2; | ||
544 | |||
545 | IT_PLAYING *playing; | ||
546 | }; | ||
547 | |||
548 | |||
549 | |||
550 | struct DUMB_IT_SIGRENDERER | ||
551 | { | ||
552 | DUMB_IT_SIGDATA *sigdata; | ||
553 | |||
554 | int n_channels; | ||
555 | |||
556 | unsigned char globalvolume; | ||
557 | signed char globalvolslide; | ||
558 | |||
559 | unsigned char tempo; | ||
560 | signed char temposlide; | ||
561 | |||
562 | IT_CHANNEL channel[DUMB_IT_N_CHANNELS]; | ||
563 | |||
564 | IT_PLAYING *playing[DUMB_IT_N_NNA_CHANNELS]; | ||
565 | |||
566 | int tick; | ||
567 | int speed; | ||
568 | int rowcount; | ||
569 | |||
570 | int order; /* Set to -1 if the song is terminated by a callback. */ | ||
571 | int row; | ||
572 | int processorder; | ||
573 | int processrow; | ||
574 | int breakrow; | ||
575 | int pat_loop_row; | ||
576 | |||
577 | int n_rows; | ||
578 | |||
579 | IT_ENTRY *entry_start; | ||
580 | IT_ENTRY *entry; | ||
581 | IT_ENTRY *entry_end; | ||
582 | |||
583 | long time_left; /* Time before the next tick is processed */ | ||
584 | int sub_time_left; | ||
585 | |||
586 | DUMB_CLICK_REMOVER **click_remover; | ||
587 | |||
588 | IT_CALLBACKS *callbacks; | ||
589 | }; | ||
590 | |||
591 | |||
592 | |||
593 | struct IT_CHECKPOINT | ||
594 | { | ||
595 | IT_CHECKPOINT *next; | ||
596 | long time; | ||
597 | DUMB_IT_SIGRENDERER *sigrenderer; | ||
598 | }; | ||
599 | |||
600 | |||
601 | |||
602 | struct IT_CALLBACKS | ||
603 | { | ||
604 | int (*loop)(void *data); | ||
605 | void *loop_data; | ||
606 | /* Return 1 to prevent looping; the music will terminate abruptly. If you | ||
607 | * want to make the music stop but allow samples to fade (beware, as they | ||
608 | * might not fade at all!), use dumb_it_sr_set_speed() and set the speed | ||
609 | * to 0. Note that xm_speed_zero() will not be called if you set the | ||
610 | * speed manually, and also that this will work for IT and S3M files even | ||
611 | * though the music can't stop in this way by itself. | ||
612 | */ | ||
613 | |||
614 | int (*xm_speed_zero)(void *data); | ||
615 | void *xm_speed_zero_data; | ||
616 | /* Return 1 to terminate the mod, without letting samples fade. */ | ||
617 | |||
618 | int (*midi)(void *data, int channel, unsigned char byte); | ||
619 | void *midi_data; | ||
620 | /* Return 1 to prevent DUMB from subsequently interpreting the MIDI bytes | ||
621 | * itself. In other words, return 1 if the Zxx macros in an IT file are | ||
622 | * controlling filters and shouldn't be. | ||
623 | */ | ||
624 | }; | ||
625 | |||
626 | |||
627 | |||
628 | void _dumb_it_end_sigrenderer(sigrenderer_t *sigrenderer); | ||
629 | void _dumb_it_unload_sigdata(sigdata_t *vsigdata); | ||
630 | |||
631 | extern DUH_SIGTYPE_DESC _dumb_sigtype_it; | ||
632 | |||
633 | |||
634 | |||
635 | long _dumb_it_build_checkpoints(DUMB_IT_SIGDATA *sigdata); | ||
636 | |||
637 | |||
638 | |||
639 | #define XM_APPREGIO 0 | ||
640 | #define XM_PORTAMENTO_UP 1 | ||
641 | #define XM_PORTAMENTO_DOWN 2 | ||
642 | #define XM_TONE_PORTAMENTO 3 | ||
643 | #define XM_VIBRATO 4 | ||
644 | #define XM_VOLSLIDE_TONEPORTA 5 | ||
645 | #define XM_VOLSLIDE_VIBRATO 6 | ||
646 | #define XM_TREMOLO 7 | ||
647 | #define XM_SET_PANNING 8 | ||
648 | #define XM_SAMPLE_OFFSET 9 | ||
649 | #define XM_VOLUME_SLIDE 10 /* A */ | ||
650 | #define XM_POSITION_JUMP 11 /* B */ | ||
651 | #define XM_SET_CHANNEL_VOLUME 12 /* C */ | ||
652 | #define XM_PATTERN_BREAK 13 /* D */ | ||
653 | #define XM_E 14 /* E */ | ||
654 | #define XM_SET_TEMPO_BPM 15 /* F */ | ||
655 | #define XM_SET_GLOBAL_VOLUME 16 /* G */ | ||
656 | #define XM_GLOBAL_VOLUME_SLIDE 17 /* H */ | ||
657 | #define XM_KEY_OFF 20 /* K (undocumented) */ | ||
658 | #define XM_SET_ENVELOPE_POSITION 21 /* L */ | ||
659 | #define XM_PANNING_SLIDE 25 /* P */ | ||
660 | #define XM_MULTI_RETRIG 27 /* R */ | ||
661 | #define XM_TREMOR 29 /* T */ | ||
662 | #define XM_X 33 /* X */ | ||
663 | #define XM_N_EFFECTS (10+26) | ||
664 | |||
665 | #define XM_E_SET_FILTER 0x0 | ||
666 | #define XM_E_FINE_PORTA_UP 0x1 | ||
667 | #define XM_E_FINE_PORTA_DOWN 0x2 | ||
668 | #define XM_E_SET_GLISSANDO_CONTROL 0x3 | ||
669 | #define XM_E_SET_VIBRATO_CONTROL 0x4 | ||
670 | #define XM_E_SET_FINETUNE 0x5 | ||
671 | #define XM_E_SET_LOOP 0x6 | ||
672 | #define XM_E_SET_TREMOLO_CONTROL 0x7 | ||
673 | #define XM_E_RETRIG_NOTE 0x9 | ||
674 | #define XM_E_FINE_VOLSLIDE_UP 0xA | ||
675 | #define XM_E_FINE_VOLSLIDE_DOWN 0xB | ||
676 | #define XM_E_NOTE_CUT 0xC | ||
677 | #define XM_E_NOTE_DELAY 0xD | ||
678 | #define XM_E_PATTERN_DELAY 0xE | ||
679 | |||
680 | #define XM_X_EXTRAFINE_PORTA_UP 1 | ||
681 | #define XM_X_EXTRAFINE_PORTA_DOWN 2 | ||
682 | |||
683 | /* To make my life a bit simpler during conversion, effect E:xy is converted | ||
684 | * to effect number EBASE+x:y. The same applies to effect X, and IT's S. That | ||
685 | * way, these effects can be manipulated like regular effects. | ||
686 | */ | ||
687 | #define EBASE (XM_N_EFFECTS) | ||
688 | #define XBASE (EBASE+16) | ||
689 | #define SBASE (IT_N_EFFECTS) | ||
690 | |||
691 | #define EFFECT_VALUE(x, y) (((x)<<4)|(y)) | ||
692 | #define HIGH(v) ((v)>>4) | ||
693 | #define LOW(v) ((v)&0x0F) | ||
694 | #define SET_HIGH(v, x) v = (((x)<<4)|((v)&0x0F)) | ||
695 | #define SET_LOW(v, y) v = (((v)&0xF0)|(y)) | ||
696 | #define BCD_TO_NORMAL(v) (HIGH(v)*10+LOW(v)) | ||
697 | |||
698 | |||
699 | |||
700 | #if 0 | ||
701 | unsigned char **_dumb_malloc2(int w, int h); | ||
702 | void _dumb_free2(unsigned char **line); | ||
703 | #endif | ||
704 | |||
705 | void _dumb_it_xm_convert_effect(int effect, int value, IT_ENTRY *entry); | ||
706 | int _dumb_it_fix_invalid_orders(DUMB_IT_SIGDATA *sigdata); | ||
707 | |||
708 | |||
709 | |||
710 | #endif /* INTERNAL_IT_H */ | ||