2 * Generic routines for mixing audio samples
5 * This work is licensed under the terms of MAME license.
6 * See COPYING file in the top-level directory.
12 @ this assumes src is word aligned
13 .global mix_16h_to_32 @ int *dest, short *src, int count
23 add r3, r3, r4, asr #1
34 add r4, r4, r12,asr #17 @ we use half volume
36 add r3, r3, r12,asr #17
37 add r6, r6, lr, asr #17
39 add r5, r5, lr, asr #17
49 add r3, r3, r12,asr #17
50 add r4, r4, r5, asr #17
55 ldmeqfd sp!, {r4-r6,pc}
58 add r3, r3, r4, asr #1
66 .global mix_16h_to_32_s1 @ int *dest, short *src, int count
79 add r4, r4, r12,asr #17
81 add r3, r3, r12,asr #17 @ we use half volume
82 add r6, r6, lr, asr #17
84 add r5, r5, lr, asr #17
90 beq m16_32_s1_no_unal2
94 add r3, r3, r12,asr #17
95 add r4, r4, r5, asr #17
100 ldmeqfd sp!, {r4-r6,pc}
103 add r3, r3, r4, asr #1
106 ldmfd sp!, {r4-r6,lr}
111 .global mix_16h_to_32_s2 @ int *dest, short *src, int count
114 stmfd sp!, {r4-r6,lr}
124 add r4, r4, r12,asr #17
126 add r3, r3, r12,asr #17 @ we use half volume
127 add r6, r6, lr, asr #17
129 add r5, r5, lr, asr #17
135 beq m16_32_s2_no_unal2
139 add r3, r3, r12,asr #17
140 add r4, r4, r5, asr #17
145 ldmeqfd sp!, {r4-r6,pc}
148 add r3, r3, r4, asr #1
151 ldmfd sp!, {r4-r6,lr}
157 @ reg=int_sample, lr=1, r3=tmp, kills flags
159 add r3, lr, \reg, asr #15
160 bics r3, r3, #1 @ in non-overflow conditions r3 is 0 or 1
166 @ limit and shift up by 16
167 @ reg=int_sample, lr=1, r3=tmp, kills flags
169 @ movs r4, r3, asr #16
171 @ beq c32_16_no_overflow
176 add r3, lr, \reg, asr #15
177 bics r3, r3, #1 @ in non-overflow conditions r3 is 0 or 1
178 moveq \reg, \reg, lsl #16
179 movne \reg, #0x80000000
180 subpl \reg, \reg, #0x00010000
184 @ mix 32bit audio (with 16bits really used, upper bits indicate overflow) with normal 16 bit audio with left channel only
185 @ warning: this function assumes dest is word aligned
186 .global mix_32_to_16l_stereo @ short *dest, int *src, int count
188 mix_32_to_16l_stereo:
189 stmfd sp!, {r4-r8,lr}
202 add r4, r4, r8, asr #16
203 add r5, r5, r8, asr #16
204 add r6, r6, r12,asr #16
205 add r7, r7, r12,asr #16
211 orr r4, r5, r4, lsr #16
212 orr r5, r7, r6, lsr #16
217 @ check for remaining bytes to convert
219 beq m32_16l_st_no_unal2
226 orr r4, r5, r4, lsr #16
230 ldmfd sp!, {r4-r8,lr}
234 @ mix 32bit audio (with 16bits really used, upper bits indicate overflow) with normal 16 bit audio (for mono sound)
235 .global mix_32_to_16_mono @ short *dest, int *src, int count
238 stmfd sp!, {r4-r8,lr}
242 @ check if dest is word aligned
244 beq m32_16_mo_no_unalw
259 add r5, r5, r8, asr #16
261 add r4, r4, r8, asr #16
262 add r7, r7, r12,asr #16
264 add r6, r6, r12,asr #16
270 orr r4, r5, r4, lsr #16
271 orr r5, r7, r6, lsr #16
276 @ check for remaining bytes to convert
278 beq m32_16_mo_no_unal2
281 add r5, r5, r6, asr #16
283 add r4, r4, r6, asr #16
286 orr r4, r5, r4, lsr #16
291 ldmeqfd sp!, {r4-r8,pc}
298 ldmfd sp!, {r4-r8,lr}
306 .global mix_32_to_16l_level
313 @ same as mix_32_to_16l_stereo, but with additional shift
314 .global mix_32_to_16l_stereo_lvl @ short *dest, int *src, int count
316 mix_32_to_16l_stereo_lvl:
317 stmfd sp!, {r4-r9,lr}
319 ldr r9, =mix_32_to_16l_level
332 add r4, r4, r8, asr #16
333 add r5, r5, r8, asr #16
334 add r6, r6, r12,asr #16
335 add r7, r7, r12,asr #16
345 orr r4, r5, r4, lsr #16
346 orr r5, r7, r6, lsr #16
348 bpl m32_16l_st_l_loop
351 @ check for remaining bytes to convert
353 beq m32_16l_st_l_no_unal2
362 orr r4, r5, r4, lsr #16
365 m32_16l_st_l_no_unal2:
366 ldmfd sp!, {r4-r9,lr}
369 @ vim:filetype=armasm