Unwind loop 4 times

This commit is contained in:
Gwilym Kuiper 2021-08-15 22:36:32 +01:00
parent 0c48975fa0
commit 1be6dfbf36

View file

@ -19,6 +19,7 @@ agb_arm_func agb_rs__mixer_add
mov r8, #SOUND_BUFFER_SIZE @ the number of steps left mov r8, #SOUND_BUFFER_SIZE @ the number of steps left
1: 1:
.macro mixer_add_loop
add r4, r0, r5, asr #8 @ calculate the address of the next read from the sound buffer 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 ldrsb r6, [r4] @ load the current sound sample to r6
add r5, r5, r2 @ calculate the position to read the next sample from 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) 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 str r4, [r1], #4 @ store the new value, and increment the pointer
.endm
subs r8, r8, #1 @ loop counter mixer_add_loop
mixer_add_loop
mixer_add_loop
mixer_add_loop
subs r8, r8, #4 @ loop counter
bne 1b @ jump back if we're done with the loop bne 1b @ jump back if we're done with the loop
pop {r4-r10} pop {r4-r10}