diff --git a/asm/musyx/creverb.s b/asm/musyx/runtime/CheapReverb/creverb.s similarity index 100% rename from asm/musyx/creverb.s rename to asm/musyx/runtime/CheapReverb/creverb.s diff --git a/asm/musyx/creverb_fx.s b/asm/musyx/runtime/CheapReverb/creverb_fx.s similarity index 100% rename from asm/musyx/creverb_fx.s rename to asm/musyx/runtime/CheapReverb/creverb_fx.s diff --git a/asm/musyx/chorus_fx.s b/asm/musyx/runtime/Chorus/chorus_fx.s similarity index 100% rename from asm/musyx/chorus_fx.s rename to asm/musyx/runtime/Chorus/chorus_fx.s diff --git a/asm/musyx/delay_fx.s b/asm/musyx/runtime/Delay/delay_fx.s similarity index 100% rename from asm/musyx/delay_fx.s rename to asm/musyx/runtime/Delay/delay_fx.s diff --git a/asm/musyx/reverb.s b/asm/musyx/runtime/StdReverb/reverb.s similarity index 100% rename from asm/musyx/reverb.s rename to asm/musyx/runtime/StdReverb/reverb.s diff --git a/asm/musyx/reverb_fx.s b/asm/musyx/runtime/StdReverb/reverb_fx.s similarity index 100% rename from asm/musyx/reverb_fx.s rename to asm/musyx/runtime/StdReverb/reverb_fx.s diff --git a/asm/musyx/dsp_import.s b/asm/musyx/runtime/dsp_import.s similarity index 100% rename from asm/musyx/dsp_import.s rename to asm/musyx/runtime/dsp_import.s diff --git a/asm/musyx/hardware.s b/asm/musyx/runtime/hardware.s similarity index 100% rename from asm/musyx/hardware.s rename to asm/musyx/runtime/hardware.s diff --git a/asm/musyx/hw_aramdma.s b/asm/musyx/runtime/hw_aramdma.s similarity index 100% rename from asm/musyx/hw_aramdma.s rename to asm/musyx/runtime/hw_aramdma.s diff --git a/asm/musyx/hw_dolphin.s b/asm/musyx/runtime/hw_dolphin.s similarity index 100% rename from asm/musyx/hw_dolphin.s rename to asm/musyx/runtime/hw_dolphin.s diff --git a/asm/musyx/hw_dspctrl.s b/asm/musyx/runtime/hw_dspctrl.s similarity index 100% rename from asm/musyx/hw_dspctrl.s rename to asm/musyx/runtime/hw_dspctrl.s diff --git a/asm/musyx/hw_memory.s b/asm/musyx/runtime/hw_memory.s similarity index 100% rename from asm/musyx/hw_memory.s rename to asm/musyx/runtime/hw_memory.s diff --git a/asm/musyx/hw_volconv.s b/asm/musyx/runtime/hw_volconv.s similarity index 100% rename from asm/musyx/hw_volconv.s rename to asm/musyx/runtime/hw_volconv.s diff --git a/asm/musyx/s_data.s b/asm/musyx/runtime/s_data.s similarity index 100% rename from asm/musyx/s_data.s rename to asm/musyx/runtime/s_data.s diff --git a/asm/musyx/seq.s b/asm/musyx/runtime/seq.s similarity index 100% rename from asm/musyx/seq.s rename to asm/musyx/runtime/seq.s diff --git a/asm/musyx/seq_api.s b/asm/musyx/runtime/seq_api.s similarity index 100% rename from asm/musyx/seq_api.s rename to asm/musyx/runtime/seq_api.s diff --git a/asm/musyx/snd3d.s b/asm/musyx/runtime/snd3d.s similarity index 100% rename from asm/musyx/snd3d.s rename to asm/musyx/runtime/snd3d.s diff --git a/asm/musyx/snd_init.s b/asm/musyx/runtime/snd_init.s similarity index 100% rename from asm/musyx/snd_init.s rename to asm/musyx/runtime/snd_init.s diff --git a/asm/musyx/snd_math.s b/asm/musyx/runtime/snd_math.s similarity index 100% rename from asm/musyx/snd_math.s rename to asm/musyx/runtime/snd_math.s diff --git a/asm/musyx/snd_midictrl.s b/asm/musyx/runtime/snd_midictrl.s similarity index 100% rename from asm/musyx/snd_midictrl.s rename to asm/musyx/runtime/snd_midictrl.s diff --git a/asm/musyx/snd_service.s b/asm/musyx/runtime/snd_service.s similarity index 100% rename from asm/musyx/snd_service.s rename to asm/musyx/runtime/snd_service.s diff --git a/asm/musyx/snd_synthapi.s b/asm/musyx/runtime/snd_synthapi.s similarity index 100% rename from asm/musyx/snd_synthapi.s rename to asm/musyx/runtime/snd_synthapi.s diff --git a/asm/musyx/stream.s b/asm/musyx/runtime/stream.s similarity index 100% rename from asm/musyx/stream.s rename to asm/musyx/runtime/stream.s diff --git a/asm/musyx/synth.s b/asm/musyx/runtime/synth.s similarity index 100% rename from asm/musyx/synth.s rename to asm/musyx/runtime/synth.s diff --git a/asm/musyx/synth_ac.s b/asm/musyx/runtime/synth_ac.s similarity index 100% rename from asm/musyx/synth_ac.s rename to asm/musyx/runtime/synth_ac.s diff --git a/asm/musyx/synth_adsr.s b/asm/musyx/runtime/synth_adsr.s similarity index 100% rename from asm/musyx/synth_adsr.s rename to asm/musyx/runtime/synth_adsr.s diff --git a/asm/musyx/synth_dbtab.s b/asm/musyx/runtime/synth_dbtab.s similarity index 100% rename from asm/musyx/synth_dbtab.s rename to asm/musyx/runtime/synth_dbtab.s diff --git a/asm/musyx/synth_vsamples.s b/asm/musyx/runtime/synth_vsamples.s similarity index 100% rename from asm/musyx/synth_vsamples.s rename to asm/musyx/runtime/synth_vsamples.s diff --git a/asm/musyx/synthdata.s b/asm/musyx/runtime/synthdata.s similarity index 100% rename from asm/musyx/synthdata.s rename to asm/musyx/runtime/synthdata.s diff --git a/asm/musyx/synthmacros.s b/asm/musyx/runtime/synthmacros.s similarity index 100% rename from asm/musyx/synthmacros.s rename to asm/musyx/runtime/synthmacros.s diff --git a/asm/musyx/synthvoice.s b/asm/musyx/runtime/synthvoice.s similarity index 100% rename from asm/musyx/synthvoice.s rename to asm/musyx/runtime/synthvoice.s diff --git a/configure.py b/configure.py index 2121276c..b3b3ef51 100755 --- a/configure.py +++ b/configure.py @@ -919,41 +919,43 @@ LIBS = [ }, { "lib": "musyx", + #"mw_version": "1.2.5", + #"cflags": "-nodefaults -fp hard -O0 -maxerrors 1 -enum int -str reuse -nosyspath -i include -i libc -use_lmw_stmw on -inline off", "mw_version": "1.3.2", "cflags": "$cflags_musyx", "host": False, "objects": [ - "musyx/seq", - "musyx/synth", - ["musyx/seq_api", True], - ["musyx/snd_synthapi", True, {"add_to_all": False}], - ["musyx/stream", False], - "musyx/synthdata", - "musyx/synthmacros", - "musyx/synthvoice", - ["musyx/synth_ac", True], - "musyx/synth_adsr", - ["musyx/synth_vsamples", False], - ["musyx/synth_dbtab", True], - "musyx/s_data", - ["musyx/hw_dspctrl", False], - ["musyx/hw_volconv", False], - ["musyx/snd3d", False], - ["musyx/snd_init", True], - ["musyx/snd_math", True], - ["musyx/snd_midictrl", False], - ["musyx/snd_service", True], - ["musyx/hardware", True], - "musyx/hw_aramdma", - ["musyx/dsp_import", True], - ["musyx/hw_dolphin", True], - ["musyx/hw_memory", True], - ["musyx/creverb_fx", True], - "musyx/creverb", - ["musyx/reverb_fx", True], - ["musyx/reverb", False], - ["musyx/delay_fx", True], - ["musyx/chorus_fx", True], + "musyx/runtime/seq", + "musyx/runtime/synth", + ["musyx/runtime/seq_api", True], + ["musyx/runtime/snd_synthapi", True, {"add_to_all": False}], + ["musyx/runtime/stream", False], + "musyx/runtime/synthdata", + "musyx/runtime/synthmacros", + "musyx/runtime/synthvoice", + ["musyx/runtime/synth_ac", True], + "musyx/runtime/synth_adsr", + ["musyx/runtime/synth_vsamples", False], + ["musyx/runtime/synth_dbtab", True], + "musyx/runtime/s_data", + ["musyx/runtime/hw_dspctrl", False], + ["musyx/runtime/hw_volconv", False], + ["musyx/runtime/snd3d", False], + ["musyx/runtime/snd_init", True], + ["musyx/runtime/snd_math", True], + ["musyx/runtime/snd_midictrl", False], + ["musyx/runtime/snd_service", True], + ["musyx/runtime/hardware", True], + "musyx/runtime/hw_aramdma", + ["musyx/runtime/dsp_import", True], + ["musyx/runtime/hw_dolphin", True], + ["musyx/runtime/hw_memory", True], + ["musyx/runtime/CheapReverb/creverb_fx", True], + "musyx/runtime/CheapReverb/creverb", + ["musyx/runtime/StdReverb/reverb_fx", True], + ["musyx/runtime/StdReverb/reverb", False], + ["musyx/runtime/Delay/delay_fx", True], + ["musyx/runtime/Chorus/chorus_fx", True], ], }, { diff --git a/include/musyx/assert.h b/include/musyx/assert.h index b6664204..0796ef94 100644 --- a/include/musyx/assert.h +++ b/include/musyx/assert.h @@ -5,12 +5,12 @@ extern void OSPanic(const char* file, int line, const char* msg, ...); #ifndef ASSERT #ifdef _DEBUG -#define ASSERT(cond) \ - do { \ - if (!cond) { \ - OSPanic(__FILE__, __LINE__, "Failed assertion " #cond); \ - } \ - } while(0) +#define ASSERT(cond) \ + do { \ + if (!cond) { \ + OSPanic(__FILE__, __LINE__, "Failed assertion " #cond); \ + } \ + } while (0) #else #define ASSERT(cond) #endif @@ -18,15 +18,23 @@ extern void OSPanic(const char* file, int line, const char* msg, ...); #ifndef ASSERT_MSG #ifdef _DEBUG -#define ASSERT_MSG(cond, msg) \ - do { \ - if (!cond) { \ - OSPanic(__FILE__, __LINE__, msg); \ - } \ - } while(0) +#define ASSERT_MSG(cond, msg) \ + do { \ + if (!cond) { \ + OSPanic(__FILE__, __LINE__, msg); \ + } \ + } while (0) #else #define ASSERT_MSG(cond, msg) #endif #endif +#ifndef MUSY_DEBUG +#if _DEBUG +#define MUSY_DEBUG OSReport +#else +#define MUSY_DEBUG +#endif +#endif + #endif // _MUSYX_ASSERT diff --git a/include/musyx/musyx_priv.h b/include/musyx/musyx_priv.h index ff683894..23a41c53 100644 --- a/include/musyx/musyx_priv.h +++ b/include/musyx/musyx_priv.h @@ -607,7 +607,7 @@ void sndConvertTicks(u32* out, u32 seconds); u32 sndConvert2Ms(u32 time); void hwActivateStudio(unsigned char studio, unsigned long isMaster, SND_STUDIO_TYPE type); void hwDeactivateStudio(u8); -u32 hwIsActive(s32); +u32 hwIsActive(u32); extern SND_HOOKS salHooks; extern u8 sndActive; diff --git a/src/musyx/creverb_fx.c b/src/musyx/runtime/CheapReverb/creverb_fx.c similarity index 100% rename from src/musyx/creverb_fx.c rename to src/musyx/runtime/CheapReverb/creverb_fx.c diff --git a/src/musyx/chorus_fx.c b/src/musyx/runtime/Chorus/chorus_fx.c similarity index 100% rename from src/musyx/chorus_fx.c rename to src/musyx/runtime/Chorus/chorus_fx.c diff --git a/src/musyx/delay_fx.c b/src/musyx/runtime/Delay/delay_fx.c similarity index 100% rename from src/musyx/delay_fx.c rename to src/musyx/runtime/Delay/delay_fx.c diff --git a/src/musyx/reverb_fx.c b/src/musyx/runtime/StdReverb/reverb_fx.c similarity index 100% rename from src/musyx/reverb_fx.c rename to src/musyx/runtime/StdReverb/reverb_fx.c diff --git a/src/musyx/dsp_import.c b/src/musyx/runtime/dsp_import.c similarity index 100% rename from src/musyx/dsp_import.c rename to src/musyx/runtime/dsp_import.c diff --git a/src/musyx/hardware.c b/src/musyx/runtime/hardware.c similarity index 94% rename from src/musyx/hardware.c rename to src/musyx/runtime/hardware.c index c19ba604..cfc78fdd 100644 --- a/src/musyx/hardware.c +++ b/src/musyx/runtime/hardware.c @@ -1,5 +1,8 @@ +#include "musyx/assert.h" #include "musyx/musyx_priv.h" +extern void OSReport(const char*, ...); + extern void DCStoreRange(void* addr, u32 nBytes); static volatile const u16 itdOffTab[128] = { @@ -65,29 +68,30 @@ void snd_handle_irq() { hwIRQLeaveCritical(); } -s32 hwInit(u32 * frq, u16 numVoices, u16 numStudios, u32 flags) { +s32 hwInit(u32* frq, u16 numVoices, u16 numStudios, u32 flags) { + MUSY_DEBUG("Entering hwInit()\n\n"); hwInitIrq(); salFrame = 0; salAuxFrame = 0; salMessageCallback = NULL; - if (salInitAi(snd_handle_irq, flags, frq) == 0) { - // OSReport("Could not initialize AI.\n"); - } else { - // OSReport("salInitAi() is done.\n\n"); - if (salInitDspCtrl(numVoices, numStudios, (flags & 1) != 0) == 0) { - // OSReport("Could not initialize DSP control logic.\n"); - } else { - // OSReport("salInitDspCtrl() is done.\n\n"); + if (salInitAi(snd_handle_irq, flags, frq) != 0) { + MUSY_DEBUG("salInitAi() is done.\n\n"); + if (salInitDspCtrl(numVoices, numStudios, (flags & 1) != 0) != 0) { + MUSY_DEBUG("salInitDspCtrl() is done.\n\n"); if (salInitDsp(flags)) { - // OSReport("salInitDsp() is done.\n\n"); + MUSY_DEBUG("salInitDsp() is done.\n\n"); hwEnableIrq(); - // OSReport("Starting AI DMA...\n\n"); + MUSY_DEBUG("Starting AI DMA...\n\n"); salStartAi(); - // OSReport("hwInit() done.\n\n"); + MUSY_DEBUG("hwInit() done.\n\n"); return 0; } - // OSReport("Could not initialize DSP.\n"); + MUSY_DEBUG("Could not initialize DSP.\n"); + } else { + MUSY_DEBUG("Could not initialize DSP control logic.\n"); } + } else { + MUSY_DEBUG("Could not initialize AI.\n"); } return -1; } @@ -105,7 +109,7 @@ void hwSetTimeOffset(u8 offset) { salTimeOffset = offset; } u8 hwGetTimeOffset() { return salTimeOffset; } -u32 hwIsActive(s32 idx) { return dspVoice[idx].state != 0; } +u32 hwIsActive(u32 v) { return dspVoice[v].state != 0; } void hwSetMesgCallback(SND_MESSAGE_CALLBACK callback) { salMessageCallback = callback; } @@ -292,9 +296,12 @@ void hwSetITDMode(u32 v, u8 mode) { dspVoice[v].flags &= ~0x80000000; } + +#define hwGetITDMode(dsp_vptr) (dsp_vptr->flags & 0x80000000) + void hwSetVolume(unsigned long v, unsigned char table, float vol, unsigned long pan, unsigned long span, float auxa, float auxb) { - struct SAL_VOLINFO vi; // r1+0x24 + SAL_VOLINFO vi; // r1+0x24 unsigned short il; // r30 unsigned short ir; // r29 unsigned short is; // r28 @@ -353,8 +360,8 @@ void hwSetVolume(unsigned long v, unsigned char table, float vol, unsigned long dsp_vptr->lastUpdate.volB = 0; } - if (dsp_vptr->flags & 0x80000000) { - SetupITD(dsp_vptr, pan >> 16); + if (hwGetITDMode(dsp_vptr)) { + SetupITD(dsp_vptr, (pan >> 16) & 0xFF); } } @@ -538,7 +545,7 @@ void hwDisableHRTF() { dspHRTFOn = FALSE; } u32 hwGetVirtualSampleID(u32 v) { if (dspVoice[v].state == 0) { - return ~0; + return 0xFFFFFFFF; } return dspVoice[v].virtualSampleID; diff --git a/src/musyx/hw_dolphin.c b/src/musyx/runtime/hw_dolphin.c similarity index 100% rename from src/musyx/hw_dolphin.c rename to src/musyx/runtime/hw_dolphin.c diff --git a/src/musyx/hw_dspctrl.c b/src/musyx/runtime/hw_dspctrl.c similarity index 100% rename from src/musyx/hw_dspctrl.c rename to src/musyx/runtime/hw_dspctrl.c diff --git a/src/musyx/hw_memory.c b/src/musyx/runtime/hw_memory.c similarity index 100% rename from src/musyx/hw_memory.c rename to src/musyx/runtime/hw_memory.c diff --git a/src/musyx/hw_volconv.c b/src/musyx/runtime/hw_volconv.c similarity index 100% rename from src/musyx/hw_volconv.c rename to src/musyx/runtime/hw_volconv.c diff --git a/src/musyx/reverb.c b/src/musyx/runtime/reverb.c similarity index 100% rename from src/musyx/reverb.c rename to src/musyx/runtime/reverb.c diff --git a/src/musyx/seq_api.c b/src/musyx/runtime/seq_api.c similarity index 100% rename from src/musyx/seq_api.c rename to src/musyx/runtime/seq_api.c diff --git a/src/musyx/snd3d.c b/src/musyx/runtime/snd3d.c similarity index 100% rename from src/musyx/snd3d.c rename to src/musyx/runtime/snd3d.c diff --git a/src/musyx/snd_init.c b/src/musyx/runtime/snd_init.c similarity index 100% rename from src/musyx/snd_init.c rename to src/musyx/runtime/snd_init.c diff --git a/src/musyx/snd_math.c b/src/musyx/runtime/snd_math.c similarity index 100% rename from src/musyx/snd_math.c rename to src/musyx/runtime/snd_math.c diff --git a/src/musyx/snd_midictrl.c b/src/musyx/runtime/snd_midictrl.c similarity index 100% rename from src/musyx/snd_midictrl.c rename to src/musyx/runtime/snd_midictrl.c diff --git a/src/musyx/snd_service.c b/src/musyx/runtime/snd_service.c similarity index 100% rename from src/musyx/snd_service.c rename to src/musyx/runtime/snd_service.c diff --git a/src/musyx/snd_synthapi.c b/src/musyx/runtime/snd_synthapi.c similarity index 100% rename from src/musyx/snd_synthapi.c rename to src/musyx/runtime/snd_synthapi.c diff --git a/src/musyx/stream.c b/src/musyx/runtime/stream.c similarity index 100% rename from src/musyx/stream.c rename to src/musyx/runtime/stream.c diff --git a/src/musyx/synth_ac.c b/src/musyx/runtime/synth_ac.c similarity index 100% rename from src/musyx/synth_ac.c rename to src/musyx/runtime/synth_ac.c diff --git a/src/musyx/synth_dbtab.c b/src/musyx/runtime/synth_dbtab.c similarity index 100% rename from src/musyx/synth_dbtab.c rename to src/musyx/runtime/synth_dbtab.c diff --git a/src/musyx/synth_vsamples.c b/src/musyx/runtime/synth_vsamples.c similarity index 100% rename from src/musyx/synth_vsamples.c rename to src/musyx/runtime/synth_vsamples.c