summaryrefslogtreecommitdiff
path: root/packages/libndsfpc/src/maxmod
diff options
context:
space:
mode:
Diffstat (limited to 'packages/libndsfpc/src/maxmod')
-rw-r--r--packages/libndsfpc/src/maxmod/inc/maxmod.inc80
-rw-r--r--packages/libndsfpc/src/maxmod/inc/maxmod7.inc91
-rw-r--r--packages/libndsfpc/src/maxmod/inc/maxmod9.inc137
-rw-r--r--packages/libndsfpc/src/maxmod/inc/mm_mas.inc167
-rw-r--r--packages/libndsfpc/src/maxmod/inc/mm_msl.inc38
-rw-r--r--packages/libndsfpc/src/maxmod/inc/mm_types.inc234
-rw-r--r--packages/libndsfpc/src/maxmod/maxmod7.pp33
-rw-r--r--packages/libndsfpc/src/maxmod/maxmod9.pp33
8 files changed, 813 insertions, 0 deletions
diff --git a/packages/libndsfpc/src/maxmod/inc/maxmod.inc b/packages/libndsfpc/src/maxmod/inc/maxmod.inc
new file mode 100644
index 0000000000..bded1a0140
--- /dev/null
+++ b/packages/libndsfpc/src/maxmod/inc/maxmod.inc
@@ -0,0 +1,80 @@
+(****************************************************************************
+ * __ *
+ * ____ ___ ____ __ ______ ___ ____ ____/ / *
+ * / __ `__ \/ __ `/ |/ / __ `__ \/ __ \/ __ / *
+ * / / / / / / /_/ /> </ / / / / / /_/ / /_/ / *
+ * /_/ /_/ /_/\__,_/_/|_/_/ /_/ /_/\____/\__,_/ *
+ * *
+ * ARM7 Definitions *
+ * *
+ * Copyright (c) 2008, Mukunda Johnson (mukunda@maxmod.org) *
+ * *
+ * Permission to use, copy, modify, and/or distribute this software for any *
+ * purpose with or without fee is hereby granted, provided that the above *
+ * copyright notice and this permission notice appear in all copies. *
+ * *
+ * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES *
+ * WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF *
+ * MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR *
+ * ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES *
+ * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN *
+ * ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF *
+ * OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. *
+ ****************************************************************************)
+
+{$ifdef NDS_INTERFACE}
+const
+ // precalculated mix buffer lengths (in bytes)
+ MM_MIXLEN_8KHZ = 544; // (8121 hz)
+ MM_MIXLEN_10KHZ = 704; // (10512 hz)
+ MM_MIXLEN_13KHZ = 896; // (13379 hz)
+ MM_MIXLEN_16KHZ = 1056; // (15768 hz)
+ MM_MIXLEN_18KHZ = 1216; // (18157 hz)
+ MM_MIXLEN_21KHZ = 1408; // (21024 hz)
+ MM_MIXLEN_27KHZ = 1792; // (26758 hz)
+ MM_MIXLEN_31KHZ = 2112; // (31536 hz)
+
+ // measurements of channel types (bytes)
+ MM_SIZEOF_MODCH = 40;
+ MM_SIZEOF_ACTCH = 28;
+ MM_SIZEOF_MIXCH = 24;
+
+procedure mmInitDefault(soundbank: mm_addr; number_of_channels: mm_word); cdecl; external;
+procedure mmInit(var setup: mm_gba_system); cdecl; external;
+procedure mmVBlank(); cdecl; external;
+procedure mmSetVBlankHandler(func: pointer); cdecl; external;
+procedure mmSetEventHandler(handler: mm_callback); cdecl; external;
+procedure mmFrame(); cdecl; external; //__attribute((long_call)) ???
+procedure mmStart(id: mm_word; mode: mm_pmode); cdecl; external;
+procedure mmPause(); cdecl; external;
+procedure mmResume(); cdecl; external;
+procedure mmStop(); cdecl; external;
+procedure mmPosition(position: mm_word); cdecl; external;
+function mmActive(): cint; cdecl; external;
+procedure mmJingle(module_ID: mm_word); cdecl; external;
+function mmActiveSub(): cint; cdecl; external;
+procedure mmSetModuleVolume(volume: mm_word); cdecl; external;
+procedure mmSetJingleVolume(volume: mm_word); cdecl; external;
+procedure mmSetModuleTempo(tempo: mm_word); cdecl; external;
+procedure mmSetModulePitch(pitch: mm_word); cdecl; external;
+procedure mmPlayModule(address, mode, layer: mm_word); cdecl; external;
+function mmEffect(sample_ID: mm_word): mm_sfxhand; cdecl; external;
+function mmEffectEx(sound: pmm_sound_effect): mm_sfxhand; cdecl; external;
+procedure mmEffectVolume(handle: mm_sfxhand; volume: mm_word); cdecl; external;
+procedure mmEffectPanning(handle: mm_sfxhand; panning: mm_byte); cdecl; external;
+procedure mmEffectRate(handle: mm_sfxhand; rate: mm_word); cdecl; external;
+procedure mmEffectScaleRate(handle: mm_sfxhand; factor: mm_word); cdecl; external;
+procedure mmEffectCancel(handle: mm_sfxhand); cdecl; external;
+procedure mmEffectRelease(handle: mm_sfxhand); cdecl; external;
+procedure mmSetEffectsVolume(volume: mm_word); cdecl; external;
+procedure mmEffectCancelAll(); cdecl; external;
+
+const
+ MMCB_SONGMESSAGE = $2A;
+ MMCB_SONGFINISHED = $2B;
+
+var
+ mp_mix_seg: mm_byte; cvar; external; // current mixing segment
+ mp_writepos: mm_word; cvar; external; // mixer's write position
+
+{$endif NDS_INTERFACE}
diff --git a/packages/libndsfpc/src/maxmod/inc/maxmod7.inc b/packages/libndsfpc/src/maxmod/inc/maxmod7.inc
new file mode 100644
index 0000000000..4445b4b079
--- /dev/null
+++ b/packages/libndsfpc/src/maxmod/inc/maxmod7.inc
@@ -0,0 +1,91 @@
+(****************************************************************************
+ * __ *
+ * ____ ___ ____ __ ______ ___ ____ ____/ / *
+ * / __ `__ \/ __ `/ |/ / __ `__ \/ __ \/ __ / *
+ * / / / / / / /_/ /> </ / / / / / /_/ / /_/ / *
+ * /_/ /_/ /_/\__,_/_/|_/_/ /_/ /_/\____/\__,_/ *
+ * *
+ * ARM7 Definitions *
+ * *
+ * Copyright (c) 2008, Mukunda Johnson (mukunda@maxmod.org) *
+ * *
+ * Permission to use, copy, modify, and/or distribute this software for any *
+ * purpose with or without fee is hereby granted, provided that the above *
+ * copyright notice and this permission notice appear in all copies. *
+ * *
+ * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES *
+ * WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF *
+ * MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR *
+ * ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES *
+ * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN *
+ * ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF *
+ * OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. *
+ ****************************************************************************)
+
+{$ifdef ARM9}
+ {$error maxmod7 is for ARM7!}
+{$endif ARM9}
+
+
+{$ifdef NDS_INTERFACE}
+
+procedure mmInstall(fifo_channel: cint); cdecl; external;
+procedure mmLockChannels(bitmask: mm_word); cdecl; external;
+procedure mmUnlockChannels(bitmask: mm_word); cdecl; external;
+function mmIsInitialized(): mm_bool; cdecl; external;
+procedure mmSelectMode(mode: mm_mode_enum); cdecl; external;
+procedure mmFrame(); cdecl; external;
+procedure mmStart(module_ID: mm_word; mode: mm_pmode); cdecl; external;
+procedure mmPause(); cdecl; external;
+procedure mmResume(); cdecl; external;
+procedure mmStop(); cdecl; external;
+procedure mmPosition(position: mm_word); cdecl; external;
+function mmActive(): mm_bool; cdecl; external;
+procedure mmJingle(module_ID: mm_word); cdecl; external;
+function mmActiveSub(): mm_bool; cdecl; external;
+procedure mmSetModuleVolume(volume: mm_word); cdecl; external;
+procedure mmSetJingleVolume(volume: mm_word); cdecl; external;
+procedure mmPlayModule(address, mode, layer: mm_word); cdecl; external;
+
+function mmEffect(sample_ID: mm_word): mm_sfxhand; cdecl; external;
+function mmEffectEx(sound: pmm_sound_effect): mm_sfxhand; cdecl; external;
+procedure mmEffectVolume(handle: mm_sfxhand; volume: mm_word); cdecl; external;
+procedure mmEffectPanning(handle: mm_sfxhand; panning: mm_byte); cdecl; external;
+procedure mmEffectRate(handle: mm_sfxhand; rate: mm_word); cdecl; external;
+procedure mmEffectScaleRate(handle: mm_sfxhand; factor: mm_word); cdecl; external;
+procedure mmEffectCancel(handle: mm_sfxhand); cdecl; external;
+procedure mmEffectRelease(handle: mm_sfxhand); cdecl; external;
+procedure mmSetEffectsVolume(volume: mm_word); cdecl; external;
+procedure mmEffectCancelAll(); cdecl; external;
+
+procedure mmStreamOpen(stream: pmm_stream; memory: mm_addr); cdecl; external;
+procedure mmStreamUpdate(); cdecl; external;
+procedure mmCloseStream(); cdecl; external;
+
+procedure mmReverbEnable(); cdecl; external;
+procedure mmReverbConfigure(config: pmm_reverb_cfg); cdecl; external;
+procedure mmReverbStart(channels: mm_reverbch); cdecl; external;
+procedure mmReverbStop(channels: mm_reverbch); cdecl; external;
+function mmReverbBufferSize(bit_depth, sampling_rate, delay: mm_word): mm_word; inline;
+procedure mmReverbDisable(); cdecl; external;
+
+const
+ MMCB_SONGMESSAGE = $2A;
+ MMCB_SONGFINISHED = $2B;
+
+var
+ mmLayerMain: mm_modlayer; cvar; external;
+ mmLayerSub: mm_modlayer; cvar; external;
+{$endif NDS_INTERFACE}
+
+
+
+{$ifdef NDS_IMPLEMENTATION}
+function mmReverbBufferSize(bit_depth, sampling_rate, delay: mm_word): mm_word; inline;
+begin
+ if bit_depth = 16 then
+ result := ((((sampling_rate * delay * 2) div 1000) + 3) and (not 3)) div 4
+ else
+ result := ((((sampling_rate * delay) div 1000) + 3) and (not 3)) div 4;
+end;
+{$endif NDS_IMPLEMENTATION}
diff --git a/packages/libndsfpc/src/maxmod/inc/maxmod9.inc b/packages/libndsfpc/src/maxmod/inc/maxmod9.inc
new file mode 100644
index 0000000000..21958109fc
--- /dev/null
+++ b/packages/libndsfpc/src/maxmod/inc/maxmod9.inc
@@ -0,0 +1,137 @@
+(****************************************************************************
+ * __ *
+ * ____ ___ ____ __ ______ ___ ____ ____/ / *
+ * / __ `__ \/ __ `/ |/ / __ `__ \/ __ \/ __ / *
+ * / / / / / / /_/ /> </ / / / / / /_/ / /_/ / *
+ * /_/ /_/ /_/\__,_/_/|_/_/ /_/ /_/\____/\__,_/ *
+ * *
+ * ARM9 Definitions *
+ * *
+ * Copyright (c) 2008, Mukunda Johnson (mukunda@maxmod.org) *
+ * *
+ * Permission to use, copy, modify, and/or distribute this software for any *
+ * purpose with or without fee is hereby granted, provided that the above *
+ * copyright notice and this permission notice appear in all copies. *
+ * *
+ * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES *
+ * WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF *
+ * MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR *
+ * ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES *
+ * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN *
+ * ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF *
+ * OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. *
+ ****************************************************************************)
+
+{$ifdef ARM7}
+ {$error maxmod9 is for ARM9!}
+{$endif}
+
+
+{$ifdef NDS_INTERFACE}
+procedure mmInitDefault(soundbank_file: pcchar); cdecl; external;
+
+procedure mmInitDefaultMem(soundbank: mm_addr); cdecl; external;
+
+procedure mmInit(system: pmm_ds_system); cdecl; external;
+
+procedure mmSelectMode(mode: mm_mode_enum); cdecl; external;
+
+procedure mmLoad(module_ID: mm_word); cdecl; external;
+
+procedure mmUnload(module_ID: mm_word); cdecl; external;
+
+procedure mmLoadEffect(sample_ID: mm_word); cdecl; external;
+
+procedure mmUnloadEffect(sample_ID: mm_word); cdecl; external;
+
+procedure mmLockChannels(bitmask: mm_word); cdecl; external;
+
+procedure mmUnlockChannels(bitmask: mm_word); cdecl; external;
+
+procedure mmSetEventHandler(handler: mm_callback); cdecl; external;
+
+procedure mmSoundBankInMemory(address: mm_addr); cdecl; external;
+procedure mmSoundBankInFiles(filename: pcchar); cdecl; external;
+procedure mmSetCustomSoundBankHandler(p_loader: mm_callback); cdecl; external;
+
+
+procedure mmStart(module_ID: mm_word; mode: mm_pmode); cdecl; external;
+
+procedure mmPause(); cdecl; external;
+
+procedure mmResume(); cdecl; external;
+
+procedure mmStop(); cdecl; external;
+
+procedure mmPosition(position: mm_word); cdecl; external;
+
+procedure mmJingle(module_ID: mm_word); cdecl; external;
+
+procedure mmSetModuleVolume(volume: mm_word); cdecl; external;
+procedure mmSetJingleVolume(volume: mm_word); cdecl; external;
+
+procedure mmSetModuleTempo(tempo: mm_word); cdecl; external;
+
+procedure mmSetModulePitch(pitch: mm_word); cdecl; external;
+
+function mmActive(): mm_bool; cdecl; external;
+
+function mmEffect(sample_ID: mm_word): mm_sfxhand; cdecl; external;
+
+function mmEffectEx(sound: pmm_sound_effect): mm_sfxhand; cdecl; external;
+
+procedure mmEffectVolume(handle: mm_sfxhand; volume: mm_word); cdecl; external;
+
+procedure mmEffectPanning(handle: mm_sfxhand; panning: mm_byte); cdecl; external;
+
+procedure mmEffectRate(handle: mm_sfxhand; rate: mm_word); cdecl; external;
+
+procedure mmEffectScaleRate(handle: mm_sfxhand; factor: mm_word); cdecl; external;
+
+procedure mmEffectCancel(handle: mm_sfxhand); cdecl; external;
+
+procedure mmEffectRelease(handle: mm_sfxhand); cdecl; external;
+
+function mmEffectExt(sound: pmm_sound_effect; sample: pmm_ds_sample): mm_sfxhand; cdecl; external;
+
+procedure mmSetEffectsVolume(volume: mm_word); cdecl; external;
+
+procedure mmEffectCancelAll(); cdecl; external;
+
+procedure mmStreamOpen(stream: pmm_stream); cdecl; external;
+
+procedure mmStreamUpdate(); cdecl; external;
+
+procedure mmStreamClose(); cdecl; external;
+
+procedure mmReverbEnable(); cdecl; external;
+
+procedure mmReverbConfigure(config: pmm_reverb_cfg); cdecl; external;
+
+procedure mmReverbStart(channels: mm_reverbch); cdecl; external;
+
+procedure mmReverbStop(channels: mm_reverbch); cdecl; external;
+
+function mmReverbBufferSize(bit_depth, sampling_rate, delay: mm_word): mm_word; inline;
+
+procedure mmReverbDisable(); cdecl; external;
+
+const
+ MMCB_SONGREQUEST = $1A;
+ MMCB_SAMPREQUEST = $1B;
+ MMCB_DELETESONG = $1C;
+ MMCB_DELETESAMPLE = $1D;
+
+ MMCB_SONGMESSAGE = $2A;
+ MMCB_SONGFINISHED = $2B;
+{$endif NDS_INTERFACE}
+
+{$ifdef NDS_IMPLEMENTATION}
+function mmReverbBufferSize(bit_depth, sampling_rate, delay: mm_word): mm_word; inline;
+begin
+ if bit_depth = 16 then
+ result := ((((sampling_rate * delay * 2) div 1000) + 3) and (not 3)) div 4
+ else
+ result := ((((sampling_rate * delay) div 1000) + 3) and (not 3)) div 4;
+end;
+{$endif NDS_IMPLEMENTATION}
diff --git a/packages/libndsfpc/src/maxmod/inc/mm_mas.inc b/packages/libndsfpc/src/maxmod/inc/mm_mas.inc
new file mode 100644
index 0000000000..440fd1b28b
--- /dev/null
+++ b/packages/libndsfpc/src/maxmod/inc/mm_mas.inc
@@ -0,0 +1,167 @@
+(****************************************************************************
+ * __ *
+ * ____ ___ ____ __ ______ ___ ____ ____/ / *
+ * / __ `__ \/ __ `/ |/ / __ `__ \/ __ \/ __ / *
+ * / / / / / / /_/ /> </ / / / / / /_/ / /_/ / *
+ * /_/ /_/ /_/\__,_/_/|_/_/ /_/ /_/\____/\__,_/ *
+ * *
+ * Copyright (c) 2008, Mukunda Johnson (mukunda@maxmod.org) *
+ * *
+ * Permission to use, copy, modify, and/or distribute this software for any *
+ * purpose with or without fee is hereby granted, provided that the above *
+ * copyright notice and this permission notice appear in all copies. *
+ * *
+ * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES *
+ * WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF *
+ * MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR *
+ * ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES *
+ * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN *
+ * ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF *
+ * OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. *
+ ****************************************************************************)
+
+
+{$ifdef NDS_INTERFACE}
+
+{$define _____badbear_____}
+
+type
+ tmm_mas_prefix = record
+ size : mm_word;
+ _type : mm_byte;
+ version : mm_byte;
+ reserved : array [0..1] of mm_byte;
+ end;
+ mm_mas_prefix = tmm_mas_prefix;
+ pmm_mas_prefix = ^tmm_mas_prefix;
+
+ tmm_mas_head = record
+ order_count : mm_byte;
+ instr_count : mm_byte;
+ sampl_count : mm_byte;
+ pattn_count : mm_byte;
+ flags : mm_byte;
+ global_volume : mm_byte;
+ initial_speed : mm_byte;
+ initial_tempo : mm_byte;
+ repeat_position : mm_byte;
+ reserved : array [0..2] of mm_byte;
+ channel_volume : array [0..31] of mm_byte;
+ channel_panning : array [0..31] of mm_byte;
+ sequence : array [0..199] of mm_byte;
+
+ {$ifdef _____badbear_____}
+ tables : array [0..0] of mm_addr;
+ {$endif}
+ // ::instrument table
+ // ::sample info table
+ // ::pattern table
+ end;
+ mm_mas_head = tmm_mas_head;
+ pmm_mas_head = ^tmm_mas_head;
+
+ tmm_mas_instrument = record
+ global_volume: mm_byte;
+ fadeout: mm_byte;
+ random_volume: mm_byte;
+ nna: mm_byte;
+ dct: mm_byte;
+ dca: mm_byte;
+ env_flags: mm_byte;
+ panning: mm_byte;
+ note_map: array [0..119] of mm_hword;
+ {$ifdef _____badbear_____}
+ envelopes: array [0..0] of mm_byte;
+ {$endif}
+ // ::envelopes
+ end;
+ mm_mas_instrument = tmm_mas_instrument;
+ pmm_mas_instrument = ^tmm_mas_instrument;
+
+ tmm_mas_envelope = record
+ size: mm_byte;
+ loop_start: mm_byte;
+ loop_end: mm_byte;
+ sus_start: mm_byte;
+ sus_end: mm_byte;
+ node_count: mm_byte;
+ is_filter: mm_byte; // (maybe supported someday :)
+ wasted: mm_byte;
+ {$ifdef _____badbear_____}
+ env_nodes: array [0..0] of mm_byte;
+ {$endif}
+ // ::envelope nodes
+ end;
+ mm_mas_envelope = tmm_mas_envelope;
+ pmm_mas_envelope = ^tmm_mas_envelope;
+
+ tmm_mas_sample_info = record
+ global_volume: mm_byte;
+ default_volume: mm_byte;
+ frequency: mm_hword;
+ av_type: mm_byte; // (auto vibrato)
+ av_depth: mm_byte;
+ av_speed: mm_byte;
+ panning: mm_byte;
+ av_rate: mm_hword;
+ msl_id: mm_hword;
+ {$ifdef _____badbear_____}
+ data: array [0..0] of mm_byte;
+ {$endif}
+ // ::sample may follow
+ end;
+ mm_mas_sample_info = tmm_mas_sample_info;
+ pmm_mas_sample_info = ^tmm_mas_sample_info;
+
+ tmm_mas_pattern = record
+ row_count: mm_byte;
+ {$ifdef _____badbear_____}
+ pattern_data: array [0..0] of mm_byte;
+ {$endif}
+ // ::pattern data
+ end;
+ mm_mas_pattern = tmm_mas_pattern;
+ pmm_mas_pattern = ^tmm_mas_pattern;
+
+ tmm_mas_gba_sample = record
+ length: mm_word;
+ loop_length: mm_word;
+ reserved: mm_hword;
+ default_frequency: mm_hword;
+ {$ifdef _____badbear_____}
+ data: array [0..0] of mm_byte;
+ {$endif}
+ // ::8-bit sample data
+ end;
+ mm_mas_gba_sample = tmm_mas_gba_sample;
+ pmm_mas_gba_sample = ^tmm_mas_gba_sample;
+
+ tmm_mas_ds_sample = record
+ loop_start: mm_word;
+ format: mm_byte;
+ repeat_mode: mm_byte;
+ default_frequency: mm_hword;
+ {$ifdef _____badbear_____}
+ data: array [0..0] of mm_byte;
+ {$endif}
+ // ::sample data
+ case integer of
+ 0: (loop_length: mm_word;);
+ 1: (length: mm_word;);
+ end;
+ mm_mas_ds_sample = tmm_mas_ds_sample;
+ pmm_mas_ds_sample = ^tmm_mas_ds_sample;
+
+const
+ MM_SFORMAT_8BIT = 0;
+ MM_SFORMAT_16BIT = 1;
+ MM_SFORMAT_ADPCM = 2;
+
+ MM_SREPEAT_FORWARD = 1;
+ MM_SREPEAT_OFF = 2;
+
+
+
+
+{$endif NDS_INTERFACE}
+
diff --git a/packages/libndsfpc/src/maxmod/inc/mm_msl.inc b/packages/libndsfpc/src/maxmod/inc/mm_msl.inc
new file mode 100644
index 0000000000..8362ac75f3
--- /dev/null
+++ b/packages/libndsfpc/src/maxmod/inc/mm_msl.inc
@@ -0,0 +1,38 @@
+(****************************************************************************
+ * __ *
+ * ____ ___ ____ __ ______ ___ ____ ____/ / *
+ * / __ `__ \/ __ `/ |/ / __ `__ \/ __ \/ __ / *
+ * / / / / / / /_/ /> </ / / / / / /_/ / /_/ / *
+ * /_/ /_/ /_/\__,_/_/|_/_/ /_/ /_/\____/\__,_/ *
+ * *
+ * Copyright (c) 2008, Mukunda Johnson (mukunda@maxmod.org) *
+ * *
+ * Permission to use, copy, modify, and/or distribute this software for any *
+ * purpose with or without fee is hereby granted, provided that the above *
+ * copyright notice and this permission notice appear in all copies. *
+ * *
+ * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES *
+ * WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF *
+ * MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR *
+ * ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES *
+ * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN *
+ * ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF *
+ * OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. *
+ ****************************************************************************)
+
+
+{$ifdef NDS_INTERFACE}
+type
+ tmslhead = record
+ sampleCount : mm_hword;
+ moduleCount : mm_hword;
+ reserved : array [0..1] of mm_word;
+ sampleTable : array [0..MSL_NSAMPS-1] of mm_addr;
+ moduleTable : array [0..MSL_NSONGS-1] of mm_addr;
+ end;
+ msl_head = tmslhead;
+ pmsl_head = ^tmslhead;
+
+
+{$endif NDS_INTERFACE}
+
diff --git a/packages/libndsfpc/src/maxmod/inc/mm_types.inc b/packages/libndsfpc/src/maxmod/inc/mm_types.inc
new file mode 100644
index 0000000000..120133b1be
--- /dev/null
+++ b/packages/libndsfpc/src/maxmod/inc/mm_types.inc
@@ -0,0 +1,234 @@
+(****************************************************************************
+ * __ *
+ * ____ ___ ____ __ ______ ___ ____ ____/ / *
+ * / __ `__ \/ __ `/ |/ / __ `__ \/ __ \/ __ / *
+ * / / / / / / /_/ /> </ / / / / / /_/ / /_/ / *
+ * /_/ /_/ /_/\__,_/_/|_/_/ /_/ /_/\____/\__,_/ *
+ * *
+ * Copyright (c) 2008, Mukunda Johnson (mukunda@maxmod.org) *
+ * *
+ * Permission to use, copy, modify, and/or distribute this software for any *
+ * purpose with or without fee is hereby granted, provided that the above *
+ * copyright notice and this permission notice appear in all copies. *
+ * *
+ * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES *
+ * WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF *
+ * MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR *
+ * ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES *
+ * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN *
+ * ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF *
+ * OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. *
+ ****************************************************************************)
+
+
+{$ifdef NDS_INTERFACE}
+type
+ mm_word = cuint;
+ pmm_word = ^mm_word;
+
+ mm_hword = cushort;
+ pmm_hword = ^mm_hword;
+
+ mm_byte = cuchar;
+ pmm_byte = ^mm_byte;
+
+ mm_sfxhand = cushort;
+ pmm_sfxhand = ^mm_sfxhand;
+
+ mm_bool = cuchar;
+
+ mm_addr = pointer;
+ mm_reg = pointer;
+
+type
+ mm_mode_enum = integer;
+const
+ MM_MODE_A: mm_mode_enum = 0;
+ MM_MODE_B: mm_mode_enum = 1;
+ MM_MODE_C: mm_mode_enum = 2;
+
+type
+ mm_stream_formats = integer;
+const
+ MM_STREAM_8BIT_MONO : mm_stream_formats = $0;
+ MM_STREAM_8BIT_STEREO : mm_stream_formats = $1;
+ MM_STREAM_16BIT_MONO : mm_stream_formats = $2;
+ MM_STREAM_16BIT_STEREO: mm_stream_formats = $3;
+
+
+type
+ mm_callback = function (msg, param: mm_word): mm_word;
+ mm_stream_func = function (length: mm_word; dest: mm_addr; format: mm_stream_formats): mm_word;
+
+
+type
+ mm_reverbflags = integer;
+const
+ MMRF_MEMORY : mm_reverbflags = $01;
+ MMRF_DELAY : mm_reverbflags = $02;
+ MMRF_RATE : mm_reverbflags = $04;
+ MMRF_FEEDBACK : mm_reverbflags = $08;
+ MMRF_PANNING : mm_reverbflags = $10;
+ MMRF_LEFT : mm_reverbflags = $20;
+ MMRF_RIGHT : mm_reverbflags = $40;
+ MMRF_BOTH : mm_reverbflags = $60;
+
+ MMRF_INVERSEPAN : mm_reverbflags = $80;
+ MMRF_NODRYLEFT : mm_reverbflags = $100;
+ MMRF_NODRYRIGHT : mm_reverbflags = $200;
+ MMRF_8BITLEFT : mm_reverbflags = $400;
+ MMRF_16BITLEFT : mm_reverbflags = $800;
+ MMRF_8BITRIGHT : mm_reverbflags = $1000;
+ MMRF_16BITRIGHT : mm_reverbflags = $2000;
+ MMRF_DRYLEFT : mm_reverbflags = $4000;
+ MMRF_DRYRIGHT : mm_reverbflags = $8000;
+
+type
+ mm_reverbch = integer;
+const
+ MMRC_LEFT : mm_reverbch = 1;
+ MMRC_RIGHT : mm_reverbch = 2;
+ MMRC_BOTH : mm_reverbch = 3;
+
+type
+ mmreverbcfg = record
+ flags : mm_word;
+ memory : mm_addr;
+ delay : mm_hword;
+ rate : mm_hword;
+ feedback : mm_hword;
+ panning : mm_byte;
+ end;
+ mm_reverb_cfg = mmreverbcfg;
+ pmm_reverb_cfg = ^mm_reverb_cfg;
+
+type
+ mm_pmode = integer;
+const
+ MM_PLAY_LOOP: mm_pmode = 0;
+ MM_PLAY_ONCE: mm_pmode = 1;
+
+type
+ mm_mixmode = integer;
+const
+ MM_MIX_8KHZ : mm_mixmode = 0;
+ MM_MIX_10KHZ: mm_mixmode = 1;
+ MM_MIX_13KHZ: mm_mixmode = 2;
+ MM_MIX_16KHZ: mm_mixmode = 3;
+ MM_MIX_18KHZ: mm_mixmode = 4;
+ MM_MIX_21KHZ: mm_mixmode = 5;
+ MM_MIX_27KHZ: mm_mixmode = 6;
+ MM_MIX_31KHZ: mm_mixmode = 7;
+
+type
+ mm_stream_timer = integer;
+const
+ MM_TIMER0: mm_stream_timer = 0;
+ MM_TIMER1: mm_stream_timer = 1;
+ MM_TIMER2: mm_stream_timer = 2;
+ MM_TIMER3: mm_stream_timer = 3;
+
+type
+ t_mmdssample = record
+ loop_start : mm_word;
+ case integer of
+ 0: (loop_length : mm_word);
+ 1: (length : mm_word;
+ format : mm_byte;
+ repeat_mode : mm_byte;
+ base_rate : mm_hword;
+ data : mm_addr;
+ );
+ end;
+ mm_ds_sample = t_mmdssample;
+ pmm_ds_sample = ^t_mmdssample;
+
+ t_mmsoundeffect = record
+ case integer of
+ 0: (id : mm_word);
+ 1: (sample : pmm_ds_sample;
+ rate : mm_hword;
+ handle : mm_sfxhand;
+ volume : mm_byte;
+ panning : mm_byte;
+ );
+ end;
+ mm_sound_effect = t_mmsoundeffect;
+ pmm_sound_effect = ^t_mmsoundeffect;
+
+ t_mmgbasystem = record
+ mixing_mode : mm_mixmode;
+ mod_channel_count : mm_word;
+ mix_channel_count : mm_word;
+ module_channels : mm_addr;
+ active_channels : mm_addr;
+ mixing_channels : mm_addr;
+ mixing_memory : mm_addr;
+ wave_memory : mm_addr;
+ soundbank : mm_addr;
+ end;
+ mm_gba_system = t_mmgbasystem;
+ pmm_gba_system = ^t_mmgbasystem;
+
+ t_mmdssystem = record
+ mod_count : mm_word;
+ samp_count : mm_word;
+ mem_bank : pmm_word;
+ fifo_channel : mm_word;
+ end;
+ mm_ds_system = t_mmdssystem;
+ pmm_ds_system = ^t_mmdssystem;
+
+ t_mmstream = record
+ sampling_rate : mm_word;
+ buffer_length : mm_word;
+ callback : mm_stream_func;
+ format : mm_word;
+ timer : mm_word;
+ manual : mm_bool;
+ end;
+ mm_stream = t_mmstream;
+ pmm_stream = ^t_mmstream;
+
+
+ t_mmlayer = record
+ tick : mm_byte;
+ row : mm_byte;
+ position : mm_byte;
+ nrows : mm_byte;
+ global_volume : mm_byte;
+ speed : mm_byte;
+ active : mm_byte;
+ bpm : mm_byte;
+ end;
+ mm_modlayer = t_mmlayer;
+ pmm_modlayer = ^t_mmlayer;
+
+
+
+ tmm_voice = record
+ source : mm_addr;
+ length : mm_word;
+ loop_start : mm_hword;
+ timer : mm_hword;
+ flags : mm_byte;
+ format : mm_byte;
+ rept : mm_byte;
+ volume : mm_byte;
+ divider : mm_byte;
+ panning : mm_byte;
+ index : mm_byte;
+ reserved : array [0..0] of mm_byte;
+ end;
+ mm_voice = tmm_voice;
+ pmm_voice = ^tmm_voice;
+
+const
+ MMVF_FREQ = 2;
+ MMVF_VOLUME = 4;
+ MMVF_PANNING = 8;
+ MMVF_SOURCE = 16;
+ MMVF_STOP = 32;
+
+{$endif NDS_INTERFACE}
+
diff --git a/packages/libndsfpc/src/maxmod/maxmod7.pp b/packages/libndsfpc/src/maxmod/maxmod7.pp
new file mode 100644
index 0000000000..8b4baee886
--- /dev/null
+++ b/packages/libndsfpc/src/maxmod/maxmod7.pp
@@ -0,0 +1,33 @@
+unit maxmod7;
+{$mode objfpc}
+{$apptype arm7}
+{$define arm7}
+
+{$J+}
+{$INLINE ON}
+{$MACRO ON}
+{$PACKRECORDS C}
+
+interface
+
+uses
+ ctypes, nds7;
+
+{$linklib nds7}
+{$linklib mm7}
+
+{$linklib c}
+{$linklib gcc}
+{$linklib sysbase}
+
+{$define NDS_INTERFACE}
+{$include inc/mm_types.inc}
+{$include inc/maxmod7.inc}
+{$undef NDS_INTERFACE}
+
+implementation
+{$define NDS_IMPLEMENTATION}
+{$include inc/maxmod7.inc}
+{$undef NDS_IMPLEMENTATION}
+
+end.
diff --git a/packages/libndsfpc/src/maxmod/maxmod9.pp b/packages/libndsfpc/src/maxmod/maxmod9.pp
new file mode 100644
index 0000000000..c7b581f5c2
--- /dev/null
+++ b/packages/libndsfpc/src/maxmod/maxmod9.pp
@@ -0,0 +1,33 @@
+unit maxmod9;
+{$mode objfpc}
+{$apptype arm9}
+{$define arm9}
+
+{$J+}
+{$INLINE ON}
+{$MACRO ON}
+{$PACKRECORDS C}
+
+interface
+
+uses
+ ctypes, nds9;
+
+{$linklib nds9}
+{$linklib mm9}
+
+{$linklib c}
+{$linklib gcc}
+{$linklib sysbase}
+
+{$define NDS_INTERFACE}
+{$include inc/mm_types.inc}
+{$include inc/maxmod9.inc}
+{$undef NDS_INTERFACE}
+
+implementation
+{$define NDS_IMPLEMENTATION}
+{$include inc/maxmod9.inc}
+{$undef NDS_IMPLEMENTATION}
+
+end.