diff --git a/agb/src/sound/mixer/mixer.s b/agb/src/sound/mixer/mixer.s index 8c2ebe3b..595885b7 100644 --- a/agb/src/sound/mixer/mixer.s +++ b/agb/src/sound/mixer/mixer.s @@ -16,30 +16,30 @@ agb_rs__mixer_add: push {r4-r10, lr} - ldr lr, [sp, #32] @ load the right channel modification amount into lr + ldr lr, [sp, #32] @ load the right channel modification amount into lr - mov r12, #0 @ current write offset into the resulting buffer - mov r8, #352 @ the offset for writing to the resulting buffer between left and right channels + mov r12, #0 @ current write offset into the resulting buffer + mov r8, #352 @ the offset for writing to the resulting buffer between left and right channels - mov r5, #0 @ current index we're reading from + mov r5, #0 @ current index we're reading from 1: - add r4, r0, r5, asr #8 @ calculate the address of the next read form the sound buffer - add r5, r5, r2 @ calculate the position to read the next step from - ldrsb r10, [r4] @ load the current value we want to read + add r4, r0, r5, asr #8 @ calculate the address of the next read form the sound buffer + add r5, r5, r2 @ calculate the position to read the next step from + ldrsb r10, [r4] @ load the current value we want to read - mov r6, r1 @ r6 = current buffer location + mov r6, r1 @ r6 = current buffer location - ldrh r9, [r6, r12]! @ load the current buffer value (r12 being the offset) but pre-increment r6 by r12 - mla r7, r10, r3, r9 @ r7 = r10 * r3 + r9 = current sound value * left amount + previous buffer value - strh r7, [r6], r8 @ *(r6 + r8) = r7, r8 = 352 = offset for the right hand side + ldrh r9, [r6, r12]! @ load the current buffer value (r12 being the offset) but pre-increment r6 by r12 + mla r7, r10, r3, r9 @ r7 = r10 * r3 + r9 = current sound value * left amount + previous buffer value + strh r7, [r6], r8 @ *(r6 + r8) = r7, r8 = 352 = offset for the right hand side - ldrh r7, [r6] @ same for the right hand side (slightly confused here, but this is what was generated) + ldrh r7, [r6] @ same for the right hand side (slightly confused here, but this is what was generated) mla r4, r10, lr, r7 strh r4, [r6] - add r12, r12, #2 @ increment the current write offset in the resulting buffer - cmp r12, #352 @ check if we're done + add r12, r12, #2 @ increment the current write offset in the resulting buffer + cmp r12, #352 @ check if we're done bne 1b pop {r4-r10, lr}