1 /****************************************************************************
3 * ____ ___ ____ __ ______ ___ ____ ____/ / *
4 * / __ `__ \/ __ `/ |/ / __ `__ \/ __ \/ __ / *
5 * / / / / / / /_/ /> </ / / / / / /_/ / /_/ / *
6 * /_/ /_/ /_/\__,_/_/|_/_/ /_/ /_/\____/\__,_/ *
8 * Copyright (c) 2008, Mukunda Johnson (mukunda@maxmod.org) *
10 * Permission to use, copy, modify, and/or distribute this software for any *
11 * purpose with or without fee is hereby granted, provided that the above *
12 * copyright notice and this permission notice appear in all copies. *
14 * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES *
15 * WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF *
16 * MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR *
17 * ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES *
18 * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN *
19 * ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF *
20 * OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. *
21 ****************************************************************************/
28 typedef unsigned int mm_word; // 32 bits
29 typedef unsigned short mm_hword; // 16 bits
30 typedef unsigned char mm_byte; // 8 bits
32 typedef unsigned short mm_sfxhand; // sound effect handle
34 typedef unsigned char mm_bool; // boolean value
36 typedef void* mm_addr; // pointer
37 typedef void* mm_reg; // hardware register
48 MM_STREAM_8BIT_MONO = 0x0, // 000b
49 MM_STREAM_8BIT_STEREO = 0x1, // 001b
51 MM_STREAM_16BIT_MONO = 0x2, // 010b
52 MM_STREAM_16BIT_STEREO = 0x3, // 011b
54 // MM_STREAM_ADPCM_MONO = 0x4, // 100b
55 // MM_STREAM_ADPCM_STEREO = 0x5, // 101b
57 // adpcm streaming is not supported by the ds hardware
58 // (the loop point data gets recorded so ring buffers are not possible)
60 //-----------------------------------------------------------------------------
62 //-----------------------------------------------------------------------------
64 typedef mm_word (*mm_callback)( mm_word msg, mm_word param );
65 typedef mm_word (*mm_stream_func)( mm_word length, mm_addr dest, mm_stream_formats format );
78 MMRF_INVERSEPAN =0x80,
79 MMRF_NODRYLEFT =0x100,
80 MMRF_NODRYRIGHT =0x200,
82 MMRF_16BITLEFT =0x800,
83 MMRF_8BITRIGHT =0x1000,
84 MMRF_16BITRIGHT =0x2000,
87 //-----------------------------------------------------------------------------
89 //-----------------------------------------------------------------------------
96 //-----------------------------------------------------------------------------
98 //-----------------------------------------------------------------------------
101 typedef struct mmreverbcfg
109 //-----------------------------------------------------------------------------
111 //-----------------------------------------------------------------------------
117 //-----------------------------------------------------------------------------
119 //-----------------------------------------------------------------------------
131 //-----------------------------------------------------------------------------
133 //-----------------------------------------------------------------------------
137 MM_TIMER0, // hardware timer 0
138 MM_TIMER1, // hardware timer 1
139 MM_TIMER2, // hardware timer 2
140 MM_TIMER3 // hardware timer 3
142 //-----------------------------------------------------------------------------
144 //-----------------------------------------------------------------------------
146 typedef struct t_mmdssample
157 //-----------------------------------------------------------------------------
159 //-----------------------------------------------------------------------------
161 typedef struct t_mmsoundeffect
164 // sample ID (defined in soundbank header)
167 // external sample address, not valid on GBA system
168 mm_ds_sample* sample;
183 //-----------------------------------------------------------------------------
185 //-----------------------------------------------------------------------------
187 typedef struct t_mmgbasystem
189 mm_mixmode mixing_mode;
190 mm_word mod_channel_count;
191 mm_word mix_channel_count;
192 mm_addr module_channels;
193 mm_addr active_channels;
194 mm_addr mixing_channels;
195 mm_addr mixing_memory;
198 //-----------------------------------------------------------------------------
200 //-----------------------------------------------------------------------------
202 typedef struct t_mmdssystem
211 // pass pointer to memory buffer
212 // (mm_word mem_bank[MSL_BANKSIZE])
215 // fifo channel to use (usually 7)
216 mm_word fifo_channel;
218 //-----------------------------------------------------------------------------
220 //-----------------------------------------------------------------------------
222 typedef struct t_mmstream
224 // sampling rate. 1024->32768 (HZ)
225 mm_word sampling_rate;
227 // number of samples to buffer
228 mm_word buffer_length;
230 // pointer to filling routine
231 mm_stream_func callback;
233 // stream format (mm_stream_formats)
236 // hardware timer selection (mm_stream_timers)
239 // if set, user must call mmStreamUpdate manually
242 //-----------------------------------------------------------------------------
244 //-----------------------------------------------------------------------------
246 typedef struct t_mmlayer
249 // current tick count
252 // current row being played
255 // module sequence position
258 // number of rows in current pattern
261 // global volume multiplier
262 mm_byte global_volume;
264 // speed of module (ticks/row)
273 //-----------------------------------------------------------------------------
275 //-----------------------------------------------------------------------------
277 typedef struct tmm_voice
280 // data source information
281 mm_addr source; // address to sample data
282 mm_word length; // length of sample data OR loop length (expressed in WORDS)
283 mm_hword loop_start; // loop start position (expressed in WORDS)
292 mm_byte format; // 0: 8-bit
296 mm_byte repeat; // 0: manual
300 // volume + divider setting
301 mm_byte volume; // 0->127
302 mm_byte divider; // 0->3 = /1, /2, /4, /16
305 mm_byte panning; // 0->127
308 mm_byte index; // 0->15
313 //-----------------------------------------------------------------------------
315 //-----------------------------------------------------------------------------
318 MMVF_FREQ =2, // update frequency when this flag is set
319 MMVF_VOLUME =4, // update volume
320 MMVF_PANNING =8, // update panning
321 MMVF_SOURCE =16, // update source and start note
322 MMVF_STOP =32 // stop voice (cut sound)
325 //-----------------------------------------------------------------------------