From a61069fb60363293915ebc37fd65ca6263d2ec51 Mon Sep 17 00:00:00 2001 From: Gwilym Inzani Date: Fri, 14 Jul 2023 23:46:42 +0100 Subject: [PATCH] Handle non multiple of 4 buffer sizes for mono --- agb/src/sound/mixer/mixer.s | 26 ++++++++++++++++++++++++++ 1 file changed, 26 insertions(+) diff --git a/agb/src/sound/mixer/mixer.s b/agb/src/sound/mixer/mixer.s index f9477b91..8cc44ea0 100644 --- a/agb/src/sound/mixer/mixer.s +++ b/agb/src/sound/mixer/mixer.s @@ -43,6 +43,18 @@ agb_arm_func \fn_name str r4, [r1], #4 @ store the new value, and increment the pointer .endm + +@ handle the non-multiple of 4 buffer size case + and r3, r8, #3 +1: + subs r3, r3, #1 + bmi 1f + + add_one_sample + subs r8, r8, #1 + beq 2f + b 1b + 1: .rept 4 add_one_sample @@ -51,6 +63,7 @@ agb_arm_func \fn_name subs r8, r8, #4 @ loop counter bne 1b @ jump back if we're done with the loop +2: pop {{r4-r8}} bx lr @@ -90,6 +103,18 @@ agb_arm_func \fn_name str r4, [r1], #4 @ store the new value, and increment the pointer .endm + +@ handle the non-multiple of 4 buffer size case + and r7, r8, #3 +1: + subs r7, r7, #1 + bmi 1f + + add_one_sample_same_modification + subs r8, r8, #1 + beq 2f + b 1b + 1: .rept 4 add_one_sample_same_modification @@ -99,6 +124,7 @@ agb_arm_func \fn_name subs r8, r8, #4 @ loop counter bne 1b @ jump back if we're done with the loop +2: pop {{r4-r8}} bx lr