diff --git a/agb/src/sound/mixer/mixer.s b/agb/src/sound/mixer/mixer.s index af28f05a..b37052e3 100644 --- a/agb/src/sound/mixer/mixer.s +++ b/agb/src/sound/mixer/mixer.s @@ -19,6 +19,7 @@ agb_arm_func agb_rs__mixer_add mov r8, #SOUND_BUFFER_SIZE @ the number of steps left 1: +.macro mixer_add_loop add r4, r0, r5, asr #8 @ calculate the address of the next read from the sound buffer ldrsb r6, [r4] @ load the current sound sample to r6 add r5, r5, r2 @ calculate the position to read the next sample from @@ -28,8 +29,14 @@ agb_arm_func agb_rs__mixer_add mla r4, r6, r9, r4 @ r4 += r6 * r9 (calculating both the left and right samples together) str r4, [r1], #4 @ store the new value, and increment the pointer +.endm + + mixer_add_loop + mixer_add_loop + mixer_add_loop + mixer_add_loop - subs r8, r8, #1 @ loop counter + subs r8, r8, #4 @ loop counter bne 1b @ jump back if we're done with the loop pop {r4-r10}