From f1b6b1035bdf6f1e90cb367d892df1aa518c5b19 Mon Sep 17 00:00:00 2001 From: Gwilym Kuiper Date: Sat, 31 Jul 2021 22:01:20 +0100 Subject: [PATCH] Reduce mixer_collapse by 1 instruction --- agb/src/sound/mixer/mixer.s | 10 ++++------ 1 file changed, 4 insertions(+), 6 deletions(-) diff --git a/agb/src/sound/mixer/mixer.s b/agb/src/sound/mixer/mixer.s index 60d10eab..8879376f 100644 --- a/agb/src/sound/mixer/mixer.s +++ b/agb/src/sound/mixer/mixer.s @@ -74,7 +74,7 @@ agb_rs__mixer_collapse: @ r0 = target buffer (i8) @ r1 = input buffer (i16) of fixnums with 4 bits of precision - mov r2, #0 + mov r2, #352 1: @ r12 = *r1; r1++ @@ -88,11 +88,9 @@ agb_rs__mixer_collapse: cmp r12, #2048 @ compare r12 against 2048 movge r3, #127 @ r3 = 127 if r12 >= 2048 - strb r3, [r0, -r2] @ r2 counts down, so need a negative offset + strb r3, [r0], #1 @ *r0 = r3; r0++ - sub r2, r2, #1 @ r2 -= 1 - cmn r2, #352 @ compare r2 against -352 - - bne 1b @ loop if not equal + subs r2, r2, #1 @ r2 -= 1 + bne 1b @ loop if not 0 bx lr