Use .rept rather than defining a macro

This commit is contained in:
Gwilym Kuiper 2022-05-04 20:25:23 +01:00
parent 863abe1d42
commit a0b28176c6

View file

@ -28,7 +28,7 @@ modifications_fallback:
1: 1:
.macro mixer_add_loop .rept 4
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
@ -38,12 +38,7 @@ modifications_fallback:
mla r4, r6, r7, r4 @ r4 += r6 * r7 (calculating both the left and right samples together) mla r4, r6, r7, r4 @ r4 += r6 * r7 (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 .endr
mixer_add_loop
mixer_add_loop
mixer_add_loop
mixer_add_loop
subs r8, r8, #4 @ loop counter 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
@ -69,7 +64,8 @@ same_modification:
mov r5, #0 @ current index we're reading from mov r5, #0 @ current index we're reading from
ldr r8, agb_rs__buffer_size @ the number of steps left ldr r8, agb_rs__buffer_size @ the number of steps left
.macro mixer_add_loop_simple 1:
.rept 4
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
@ -81,13 +77,7 @@ same_modification:
add r4, r4, r6, lsl r3 @ r4 += r6 << r3 (calculating both the left and right samples together) add r4, r4, r6, lsl r3 @ r4 += r6 << r3 (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 .endr
1:
mixer_add_loop_simple
mixer_add_loop_simple
mixer_add_loop_simple
mixer_add_loop_simple
subs r8, r8, #4 @ loop counter 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
@ -107,7 +97,9 @@ agb_arm_func agb_rs__mixer_add_stereo
ldr r5, =0x00000FFF ldr r5, =0x00000FFF
.macro mixer_add_loop_simple_stereo ldr r8, agb_rs__buffer_size
1:
.rept 4
ldrsh r6, [r0], #2 @ load the current sound sample to r6 ldrsh r6, [r0], #2 @ load the current sound sample to r6
ldr r4, [r1] @ read the current value ldr r4, [r1] @ read the current value
@ -134,14 +126,7 @@ agb_arm_func agb_rs__mixer_add_stereo
add r4, r4, r6, lsl #4 @ r4 += r6 << 4 (calculating both the left and right samples together) add r4, r4, r6, lsl #4 @ r4 += r6 << 4 (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 .endr
ldr r8, agb_rs__buffer_size
1:
mixer_add_loop_simple_stereo
mixer_add_loop_simple_stereo
mixer_add_loop_simple_stereo
mixer_add_loop_simple_stereo
subs r8, r8, #4 @ loop counter 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