diff --git a/src/musyx/runtime/hw_dolphin.c b/src/musyx/runtime/hw_dolphin.c index 2f19071b..3e7701db 100644 --- a/src/musyx/runtime/hw_dolphin.c +++ b/src/musyx/runtime/hw_dolphin.c @@ -5,8 +5,8 @@ /* Is this actually what factor 5 did? They specify 0x2000 for the dram size, but the next TU winds * up incorrectly aligned */ -static u8 dram_image[0x2008] ATTRIBUTE_ALIGN(32); static DSPTaskInfo dsp_task ATTRIBUTE_ALIGN(8); +static u16 dram_image[4096 + 4] ATTRIBUTE_ALIGN(32); static volatile u32 oldState = 0; static volatile u16 hwIrqLevel = 0; @@ -36,7 +36,7 @@ void callUserCallback() { void salCallback() { salAIBufferIndex = (salAIBufferIndex + 1) % 4; - AIInitDMA((((u32)salAIBufferBase - 0x80000000) + (salAIBufferIndex * DMA_BUFFER_LEN)), + AIInitDMA(OSCachedToPhysical(salAIBufferBase) + (salAIBufferIndex * DMA_BUFFER_LEN), DMA_BUFFER_LEN); salLastTick = OSGetTick(); if (salDspIsDone) { @@ -55,19 +55,12 @@ void dspResumeCallback() { salDspIsDone = TRUE; if (salLogicIsWaiting) { salLogicIsWaiting = FALSE; - if (salLogicActive == FALSE) { - salLogicActive = TRUE; - OSEnableInterrupts(); - userCallback(); - OSDisableInterrupts(); - salLogicActive = FALSE; - } + callUserCallback(); } } u32 salInitAi(SND_SOME_CALLBACK callback, u32 unk, u32* outFreq) { - salAIBufferBase = salMalloc(DMA_BUFFER_LEN * 4); - if (salAIBufferBase != NULL) { + if ((salAIBufferBase = salMalloc(DMA_BUFFER_LEN * 4)) != NULL) { memset(salAIBufferBase, 0, DMA_BUFFER_LEN * 4); DCFlushRange(salAIBufferBase, DMA_BUFFER_LEN * 4); salAIBufferIndex = TRUE; @@ -76,9 +69,10 @@ u32 salInitAi(SND_SOME_CALLBACK callback, u32 unk, u32* outFreq) { salLogicActive = FALSE; userCallback = callback; AIRegisterDMACallback(salCallback); - AIInitDMA(OSCachedToPhysical((u32)salAIBufferBase) + (salAIBufferIndex * 0x280), 0x280); + AIInitDMA(OSCachedToPhysical(salAIBufferBase) + (salAIBufferIndex * 0x280), 0x280); synthInfo.numSamples = 0x20; *outFreq = 32000; + MUSY_DEBUG("MusyX AI interface initialized.\n"); return TRUE; } @@ -130,11 +124,12 @@ u32 salExitDsp() { return TRUE; } - void salStartDsp(u16* cmdList) { salDspIsDone = FALSE; PPCSync(); - MUSY_ASSERT(((u32)cmdList & 0x1F) == 0); + /* clang-format off */ + MUSY_ASSERT(((u32)cmdList&0x1F) == 0); + /* clang-format on */ DSPSendMailToDSP(dspCmdFirstSize | 0xbabe0000); while (DSPCheckMailToDSP()) diff --git a/src/musyx/runtime/synth_ac.c b/src/musyx/runtime/synth_ac.c index e6ab78cd..85f18dd9 100644 --- a/src/musyx/runtime/synth_ac.c +++ b/src/musyx/runtime/synth_ac.c @@ -2,7 +2,7 @@ extern SynthInfo synthInfo; -float toneup_tab[128] = { +static float toneup_tab[128] = { 1.0f, 1.0594635f, 1.1224623f, 1.1892071f, 1.2599211f, 1.3348398f, 1.4142141f, 1.4983072f, 1.5874014f, 1.6817932f, 1.7817984f, 1.8877487f, 2.000001f, 2.118927f, 2.2449245f, 2.378415f, 2.519843f, 2.6696806f, 2.8284283f, 2.9966154f, 3.1748037f, @@ -24,7 +24,7 @@ float toneup_tab[128] = { 1448.1554f, 1534.2672f, }; -float tonedown_tab[128] = { +static float tonedown_tab[128] = { 1.0f, 0.94387436f, 0.8908987f, 0.8408966f, 0.7937002f, 0.74915314f, 0.7071066f, 0.66741943f, 0.62996006f, 0.59460354f, 0.56123066f, 0.52973175f, 0.5f, 0.47193718f, 0.44544888f, 0.4204483f, 0.3968506f, 0.37457657f,