From 1be6dfbf360df4f8cc8288b49243ccce7ecc4d30 Mon Sep 17 00:00:00 2001 From: Gwilym Kuiper Date: Sun, 15 Aug 2021 22:36:32 +0100 Subject: [PATCH] Unwind loop 4 times --- agb/src/sound/mixer/mixer.s | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) 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}