mirror of
https://github.com/italicsjenga/agb.git
synced 2024-12-24 08:41:34 +11:00
Somehow reduce clamp_s8 by 1 instruction
This commit is contained in:
parent
0229b95d7c
commit
3fea9aada0
|
@ -155,19 +155,24 @@ agb_arm_func agb_rs__mixer_collapse
|
||||||
@ Arguments:
|
@ Arguments:
|
||||||
@ r0 = target buffer (i8)
|
@ r0 = target buffer (i8)
|
||||||
@ r1 = input buffer (i16) of fixnums with 4 bits of precision (read in sets of i16 in an i32)
|
@ r1 = input buffer (i16) of fixnums with 4 bits of precision (read in sets of i16 in an i32)
|
||||||
push {r4, r5, r6}
|
push {r4, r5, r6, r7, r8, r9, r10}
|
||||||
|
|
||||||
|
CONST_0 .req r7
|
||||||
|
CONST_FF .req r8
|
||||||
|
CONST_127 .req r9
|
||||||
|
TEMP .req r10
|
||||||
|
|
||||||
|
ldr CONST_0, =0
|
||||||
|
ldr CONST_FF, =0xff
|
||||||
|
ldr CONST_127, =127
|
||||||
|
|
||||||
ldr r2, agb_rs__buffer_size @ loop counter
|
ldr r2, agb_rs__buffer_size @ loop counter
|
||||||
mov r4, r2
|
mov r4, r2
|
||||||
|
|
||||||
.macro clamp_s8 reg:req
|
.macro clamp_s8 reg:req
|
||||||
cmn \reg, #128
|
add \reg, \reg, #127
|
||||||
mvnlt \reg, #128
|
subs r10, r7, \reg, asr #8
|
||||||
|
andne \reg, r8, r10, lsr #24
|
||||||
cmp \reg, #127
|
|
||||||
movgt \reg, #127
|
|
||||||
|
|
||||||
and \reg, \reg, #255
|
|
||||||
.endm
|
.endm
|
||||||
|
|
||||||
.macro load_sample left_reg:req right_reg:req
|
.macro load_sample left_reg:req right_reg:req
|
||||||
|
@ -197,12 +202,16 @@ agb_arm_func agb_rs__mixer_collapse
|
||||||
orr r3, r3, r5, lsl #24
|
orr r3, r3, r5, lsl #24
|
||||||
orr r12, r12, r6, lsl #24
|
orr r12, r12, r6, lsl #24
|
||||||
|
|
||||||
|
ldr r5, =0x80808080
|
||||||
|
eor r3, r3, r5
|
||||||
|
eor r12, r12, r5
|
||||||
|
|
||||||
str r3, [r0, r4] @ *(r0 + (r4 = SOUND_BUFFER_SIZE)) = r3
|
str r3, [r0, r4] @ *(r0 + (r4 = SOUND_BUFFER_SIZE)) = r3
|
||||||
str r12, [r0], #4 @ *r0 = r12; r0 += 4
|
str r12, [r0], #4 @ *r0 = r12; r0 += 4
|
||||||
|
|
||||||
subs r2, r2, #4 @ r2 -= 4
|
subs r2, r2, #4 @ r2 -= 4
|
||||||
bne 1b @ loop if not 0
|
bne 1b @ loop if not 0
|
||||||
|
|
||||||
pop {r4, r5, r6}
|
pop {r4, r5, r6, r7, r8, r9, r10}
|
||||||
bx lr
|
bx lr
|
||||||
agb_arm_end agb_rs__mixer_collapse
|
agb_arm_end agb_rs__mixer_collapse
|
||||||
|
|
Loading…
Reference in a new issue