00001 /**************************************************************************** 00002 * __ * 00003 * ____ ___ ____ __ ______ ___ ____ ____/ / * 00004 * / __ `__ \/ __ `/ |/ / __ `__ \/ __ \/ __ / * 00005 * / / / / / / /_/ /> </ / / / / / /_/ / /_/ / * 00006 * /_/ /_/ /_/\__,_/_/|_/_/ /_/ /_/\____/\__,_/ * 00007 * * 00008 * Copyright (c) 2008, Mukunda Johnson (mukunda@maxmod.org) * 00009 * * 00010 * Permission to use, copy, modify, and/or distribute this software for any * 00011 * purpose with or without fee is hereby granted, provided that the above * 00012 * copyright notice and this permission notice appear in all copies. * 00013 * * 00014 * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES * 00015 * WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF * 00016 * MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR * 00017 * ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES * 00018 * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN * 00019 * ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF * 00020 * OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. * 00021 ****************************************************************************/ 00022 00023 // TYPE DEFINITIONS 00024 00025 #ifndef MM_TYPES_H 00026 #define MM_TYPES_H 00027 00028 typedef unsigned int mm_word; // 32 bits 00029 typedef unsigned short mm_hword; // 16 bits 00030 typedef unsigned char mm_byte; // 8 bits 00031 00032 typedef unsigned short mm_sfxhand; // sound effect handle 00033 00034 typedef unsigned char mm_bool; // boolean value 00035 00036 typedef void* mm_addr; // pointer 00037 typedef void* mm_reg; // hardware register 00038 00039 typedef enum 00040 { 00041 MM_MODE_A, 00042 MM_MODE_B, 00043 MM_MODE_C 00044 } mm_mode_enum; 00045 00046 typedef enum 00047 { 00048 MM_STREAM_8BIT_MONO = 0x0, // 000b 00049 MM_STREAM_8BIT_STEREO = 0x1, // 001b 00050 00051 MM_STREAM_16BIT_MONO = 0x2, // 010b 00052 MM_STREAM_16BIT_STEREO = 0x3, // 011b 00053 00054 // MM_STREAM_ADPCM_MONO = 0x4, // 100b 00055 // MM_STREAM_ADPCM_STEREO = 0x5, // 101b 00056 00057 // adpcm streaming is not supported by the ds hardware 00058 // (the loop point data gets recorded so ring buffers are not possible) 00059 00060 //----------------------------------------------------------------------------- 00061 } mm_stream_formats; 00062 //----------------------------------------------------------------------------- 00063 00064 typedef mm_word (*mm_callback)( mm_word msg, mm_word param ); 00065 typedef mm_word (*mm_stream_func)( mm_word length, mm_addr dest, mm_stream_formats format ); 00066 00067 typedef enum 00068 { 00069 MMRF_MEMORY =0x01, 00070 MMRF_DELAY =0x02, 00071 MMRF_RATE =0x04, 00072 MMRF_FEEDBACK =0x08, 00073 MMRF_PANNING =0x10, 00074 MMRF_LEFT =0x20, 00075 MMRF_RIGHT =0x40, 00076 MMRF_BOTH =0x60, 00077 00078 MMRF_INVERSEPAN =0x80, 00079 MMRF_NODRYLEFT =0x100, 00080 MMRF_NODRYRIGHT =0x200, 00081 MMRF_8BITLEFT =0x400, 00082 MMRF_16BITLEFT =0x800, 00083 MMRF_8BITRIGHT =0x1000, 00084 MMRF_16BITRIGHT =0x2000, 00085 MMRF_DRYLEFT =0x4000, 00086 MMRF_DRYRIGHT =0x8000 00087 //----------------------------------------------------------------------------- 00088 } mm_reverbflags; 00089 //----------------------------------------------------------------------------- 00090 00091 typedef enum 00092 { 00093 MMRC_LEFT = 1, 00094 MMRC_RIGHT = 2, 00095 MMRC_BOTH = 3 00096 //----------------------------------------------------------------------------- 00097 } mm_reverbch; 00098 //----------------------------------------------------------------------------- 00099 00100 00101 typedef struct mmreverbcfg 00102 { 00103 mm_word flags; 00104 mm_addr memory; 00105 mm_hword delay; 00106 mm_hword rate; 00107 mm_hword feedback; 00108 mm_byte panning; 00109 //----------------------------------------------------------------------------- 00110 } mm_reverb_cfg; 00111 //----------------------------------------------------------------------------- 00112 00113 typedef enum 00114 { 00115 MM_PLAY_LOOP, 00116 MM_PLAY_ONCE 00117 //----------------------------------------------------------------------------- 00118 } mm_pmode; 00119 //----------------------------------------------------------------------------- 00120 00121 typedef enum 00122 { 00123 MM_MIX_8KHZ, 00124 MM_MIX_10KHZ, 00125 MM_MIX_13KHZ, 00126 MM_MIX_16KHZ, 00127 MM_MIX_18KHZ, 00128 MM_MIX_21KHZ, 00129 MM_MIX_27KHZ, 00130 MM_MIX_31KHZ 00131 //----------------------------------------------------------------------------- 00132 } mm_mixmode; 00133 //----------------------------------------------------------------------------- 00134 00135 typedef enum 00136 { 00137 MM_TIMER0, // hardware timer 0 00138 MM_TIMER1, // hardware timer 1 00139 MM_TIMER2, // hardware timer 2 00140 MM_TIMER3 // hardware timer 3 00141 00142 //----------------------------------------------------------------------------- 00143 } mm_stream_timer; 00144 //----------------------------------------------------------------------------- 00145 00146 typedef struct t_mmdssample 00147 { 00148 mm_word loop_start; 00149 union { 00150 mm_word loop_length; 00151 mm_word length; 00152 }; 00153 mm_byte format; 00154 mm_byte repeat_mode; 00155 mm_hword base_rate; 00156 mm_addr data; 00157 //----------------------------------------------------------------------------- 00158 } mm_ds_sample; 00159 //----------------------------------------------------------------------------- 00160 00161 typedef struct t_mmsoundeffect 00162 { 00163 union { 00164 // sample ID (defined in soundbank header) 00165 mm_word id; 00166 00167 // external sample address, not valid on GBA system 00168 mm_ds_sample* sample; 00169 }; 00170 00171 // playback rate 00172 mm_hword rate; 00173 00174 // sound handle 00175 mm_sfxhand handle; 00176 00177 // volume, 0..255 00178 mm_byte volume; 00179 00180 // panning, 0..255 00181 mm_byte panning; 00182 00183 //----------------------------------------------------------------------------- 00184 } mm_sound_effect; 00185 //----------------------------------------------------------------------------- 00186 00187 typedef struct t_mmgbasystem 00188 { 00189 mm_mixmode mixing_mode; 00190 mm_word mod_channel_count; 00191 mm_word mix_channel_count; 00192 mm_addr module_channels; 00193 mm_addr active_channels; 00194 mm_addr mixing_channels; 00195 mm_addr mixing_memory; 00196 mm_addr wave_memory; 00197 mm_addr soundbank; 00198 //----------------------------------------------------------------------------- 00199 } mm_gba_system; 00200 //----------------------------------------------------------------------------- 00201 00202 typedef struct t_mmdssystem 00203 { 00204 00205 // give MSL_NSONGS 00206 mm_word mod_count; 00207 00208 // pass MSL_NSAMPS 00209 mm_word samp_count; 00210 00211 // pass pointer to memory buffer 00212 // (mm_word mem_bank[MSL_BANKSIZE]) 00213 mm_word* mem_bank; 00214 00215 // fifo channel to use (usually 7) 00216 mm_word fifo_channel; 00217 00218 //----------------------------------------------------------------------------- 00219 } mm_ds_system; 00220 //----------------------------------------------------------------------------- 00221 00222 typedef struct t_mmstream 00223 { 00224 // sampling rate. 1024->32768 (HZ) 00225 mm_word sampling_rate; 00226 00227 // number of samples to buffer 00228 mm_word buffer_length; 00229 00230 // pointer to filling routine 00231 mm_stream_func callback; 00232 00233 // stream format (mm_stream_formats) 00234 mm_word format; 00235 00236 // hardware timer selection (mm_stream_timers) 00237 mm_word timer; 00238 00239 // if set, user must call mmStreamUpdate manually 00240 mm_bool manual; 00241 00242 //----------------------------------------------------------------------------- 00243 } mm_stream; 00244 //----------------------------------------------------------------------------- 00245 00246 typedef struct t_mmlayer 00247 { 00248 00249 // current tick count 00250 mm_byte tick; 00251 00252 // current row being played 00253 mm_byte row; 00254 00255 // module sequence position 00256 mm_byte position; 00257 00258 // number of rows in current pattern 00259 mm_byte nrows; 00260 00261 // global volume multiplier 00262 mm_byte global_volume; 00263 00264 // speed of module (ticks/row) 00265 mm_byte speed; 00266 00267 // module is active 00268 mm_byte active; 00269 00270 // tempo of module 00271 mm_byte bpm; 00272 00273 //----------------------------------------------------------------------------- 00274 } mm_modlayer; 00275 //----------------------------------------------------------------------------- 00276 00277 typedef struct tmm_voice 00278 { 00279 00280 // data source information 00281 mm_addr source; // address to sample data 00282 mm_word length; // length of sample data OR loop length (expressed in WORDS) 00283 mm_hword loop_start; // loop start position (expressed in WORDS) 00284 00285 // frequency divider 00286 mm_hword timer; 00287 00288 // update flags 00289 mm_byte flags; 00290 00291 // source format 00292 mm_byte format; // 0: 8-bit 00293 // 1: 16-bit 00294 // 2: adpcm 00295 // repeat mode 00296 mm_byte repeat; // 0: manual 00297 // 1: forward loop 00298 // 2: one shot 00299 00300 // volume + divider setting 00301 mm_byte volume; // 0->127 00302 mm_byte divider; // 0->3 = /1, /2, /4, /16 00303 00304 // panning setting 00305 mm_byte panning; // 0->127 00306 00307 // index of voice 00308 mm_byte index; // 0->15 00309 00310 // pad to 20 bytes 00311 mm_byte reserved[1]; 00312 00313 //----------------------------------------------------------------------------- 00314 } mm_voice; 00315 //----------------------------------------------------------------------------- 00316 00317 enum { 00318 MMVF_FREQ =2, // update frequency when this flag is set 00319 MMVF_VOLUME =4, // update volume 00320 MMVF_PANNING =8, // update panning 00321 MMVF_SOURCE =16, // update source and start note 00322 MMVF_STOP =32 // stop voice (cut sound) 00323 }; 00324 00325 //----------------------------------------------------------------------------- 00326 00327 #endif