diff --git a/agb/src/sound/mixer/mixer.s b/agb/src/sound/mixer/mixer.s index 69399f33..3b16eeb5 100644 --- a/agb/src/sound/mixer/mixer.s +++ b/agb/src/sound/mixer/mixer.s @@ -23,15 +23,21 @@ agb_rs__mixer_add: mov r5, #0 @ current index we're reading from + @ kept between iterations: + @ r12 - current write offset into the output buffer (r1) + @ r8 - the constant 352 + @ r5 - the current index from the input buffer we're reading from (r0) + + @ all other registers are temporary 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 r5, r5, r2 @ calculate the position to read the next step from 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 + ldrh r4, [r6, r12]! @ load the current buffer value (r12 being the offset) but pre-increment r6 by r12 + mla r7, r10, r3, r4 @ r7 = r10 * r3 + r9 = current sound value * left amount + previous buffer value strh r7, [r6], r8 @ *r6 = r7, r6 += r8 where r8 = 352 = offset for the right hand side ldrh r7, [r6] @ same for the right hand side, r6 now points to the right hand side location