/**************************************************************************** * __ * * ____ ___ ____ __ ______ ___ ____ ____/ / * * / __ `__ \/ __ `/ |/ / __ `__ \/ __ \/ __ / * * / / / / / / /_/ /> mixlen? blt .mpf_mix_adv @ no, mix and process tick b .mpf_mix @ yes, mix the rest of samples .mpf_mix_adv: mov r1, #MPL_SAMPCOUNT @ reset sample counter mov r7, #0 @ strh r7, [r0,r1] @ sub r4, r5 @ subtract from #samples to mix PROF_START mov r0, r5 ldr r7,=mmMixerMix @ mix samples bl _call_via_r7 PROF_END 0 ldr r7,=mppProcessTick bl _call_via_r7 b .mpf_mix_advr @ process more samples .mpf_mix: @ add samples remaining to SAMPCOUNT @ and mix more samples mov r1, #MPL_SAMPCOUNT add r6, r4 strh r6, [r0, r1] mov r0, r4 PROF_START ldr r1,=mmMixerMix bl _call_via_r1 PROF_END 0 pop {r4-r7} ret1 @ return to user .mpf_no_mainlayer: @ main layer isn't active, @ mix full amount mov r0, r4 PROF_START ldr r1,=mmMixerMix bl _call_via_r1 PROF_END 0 pop {r4-r7} ret1 .pool //----------------------------------------------------------------------------- #endif //----------------------------------------------------------------------------- /****************************************************************************** * * NDS * ******************************************************************************/ //----------------------------------------------------------------------------- #ifdef SYS_NDS //----------------------------------------------------------------------------- .TEXT .THUMB .ALIGN 2 /****************************************************************************** * mmSuspendIRQ_t * * Function to disable interrupts via the status register ******************************************************************************/ .global mmSuspendIRQ_t .thumb_func mmSuspendIRQ_t: ldr r0,=1f bx r0 .arm .align 2 1: mrs r0, cpsr and r1, r0, #0x80 orr r0, #0x80 msr cpsr, r0 str r1, previous_irq_state bx lr .thumb /****************************************************************************** * mmRestoreIRQ_t * * Function to enable interrupts via the status register ******************************************************************************/ .global mmRestoreIRQ_t .thumb_func mmRestoreIRQ_t: ldr r0,=1f bx r0 .arm .align 2 1: mrs r0, cpsr ldr r1, previous_irq_state bic r0, #0x80 orr r0, r1 msr cpsr, r0 bx lr .thumb previous_irq_state: .space 4 .thumb_func /****************************************************************************** * mmIsInitialized() * * Returns true if the system is ready for playback ******************************************************************************/ .global mmIsInitialized .thumb_func mmIsInitialized: ldr r0,=mmInitialized ldrb r0, [r0] bx lr /****************************************************************************** * mmInit7() * * Initialize system ******************************************************************************/ .global mmInit7 .thumb_func mmInit7: push {lr} mov r0, #0x08 ldr r1,=mmFrame bl irqSet mov r0, #0x08 bl irqEnable ldr r0,=0x400 // set volumes bl mmSetModuleVolume // ldr r0,=0x400 // bl mmSetJingleVolume // ldr r0,=0x400 // bl mmSetEffectsVolume // ldr r0,=mmInitialized // set initialized flag mov r1, #42 // strb r1, [r0] // ldr r0,=0xFFFF // select all hardware channels bl mmUnlockChannels // ldr r0,=mm_achannels // setup channel addresses ldr r1,=mm_rds_achannels // str r1, [r0] // ldr r1,=mm_rds_pchannels // str r1, [r0,#4] // mov r1, #32 // 32 channels str r1, [r0,#8] // str r1, [r0,#12] // ldr r0,=0x400 bl mmSetModuleTempo ldr r0,=0x400 bl mmSetModulePitch bl mmResetEffects bl mmMixerInit // setup mixer ldr r0,=mmEventForwarder // forward events bl mmSetEventHandler ldr r0,=mmInitialized // set initialized flag mov r1, #42 // strb r1, [r0] // .exit_r3: pop {r3} bx r3 /****************************************************************************** * mmInstall( channel ) * * Install ARM7 system ******************************************************************************/ .global mmInstall .thumb_func mmInstall: push {lr} ldr r1,=mmInitialized // not initialized until we get soundbank data mov r2, #0 // strb r2, [r1] // bl mmSetupComms // setup communication b .exit_r3 /****************************************************************************** * mmEventForwarder( msg, param ) * * Forward event to arm9 ******************************************************************************/ .thumb_func mmEventForwarder: push {lr} lsl r1, #8 orr r0, r1 mov r1, #1 lsl r1, #20 orr r0, r1 bl mmARM9msg pop {pc} /****************************************************************************** * mmGetSoundBank( n_songs, bank ) * * Load sound bank address ******************************************************************************/ .global mmGetSoundBank .thumb_func mmGetSoundBank: ldr r2,=mmModuleCount // save data stmia r2!, {r0,r1} // lsl r0, #2 // also sample bank address add r1, r0 // stmia r2!, {r1} // //------------------------------------------------ // initialize system //------------------------------------------------ b mmInit7 /****************************************************************************** * mmFrame() * * Routine function ******************************************************************************/ .global mmFrame .thumb_func mmFrame: push {lr} ldr r0,=mmInitialized // catch not-initialized ldrb r0, [r0] // cmp r0, #42 // bne 1f // bl mmMixerPre // <-- critical timing ldr r0,=0x4000208 // enable irq mov r1, #1 // strh r1, [r0] // bl mmUpdateEffects // update sound effects bl mmPulse // update module playback bl mmMixerMix // update audio bl mmSendUpdateToARM9 1: bl mmProcessComms // process communications ret1 .pool //----------------------------------------------------------------------------- #endif //----------------------------------------------------------------------------- //----------------------------------------------------------------------------- .end //-----------------------------------------------------------------------------