mirror of
https://github.com/italicsjenga/agb.git
synced 2024-12-23 08:11:33 +11:00
Remove unused methods
This commit is contained in:
parent
c2e7a3b9b4
commit
03b5f2fafd
|
@ -1,139 +1,3 @@
|
|||
.macro mixer_add fn_name:req is_first:req
|
||||
agb_arm_func \fn_name
|
||||
@ Arguments
|
||||
@ r0 - pointer to the data to be copied (u8 array)
|
||||
@ r1 - pointer to the sound buffer (i16 array which will alternate left and right channels, 32-bit aligned)
|
||||
@ r2 - playback speed (usize fixnum with 8 bits)
|
||||
@ r3 - amount to modify the left channel by (u16 fixnum with 4 bits)
|
||||
@ stack position 1 - amount to modify the right channel by (u16 fixnum with 4 bits)
|
||||
@ stack position 2 - the buffer_size (usize)
|
||||
@
|
||||
@ The sound buffer must be buffer_size * 2 in size
|
||||
push {{r4-r8}}
|
||||
|
||||
ldr r7, [sp, #20] @ load the right channel modification amount into r7
|
||||
ldr r8, [sp, #24] @ load the buffer size into r8
|
||||
|
||||
movs r8, r8 @ check that the buffer size isn't 0
|
||||
bne 1f
|
||||
|
||||
pop {{r4-r8}}
|
||||
bx lr
|
||||
1:
|
||||
|
||||
cmp r7, r3 @ check if left and right channel need the same modifications
|
||||
beq 3f @ same modification
|
||||
|
||||
4: @ modification fallback
|
||||
orr r7, r7, r3, lsl #16 @ r7 now is the left channel followed by the right channel modifications.
|
||||
|
||||
mov r5, #0 @ current index we're reading from
|
||||
|
||||
.macro add_one_sample
|
||||
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
|
||||
add r5, r5, r2 @ calculate the position to read the next sample from
|
||||
|
||||
.ifc \is_first,true
|
||||
mul r4, r6, r7 @ r4 = r6 * r7 (calculating both the left and right samples together)
|
||||
.else
|
||||
ldr r4, [r1] @ read the current value
|
||||
mla r4, r6, r7, r4 @ r4 += r6 * r7 (calculating both the left and right samples together)
|
||||
.endif
|
||||
|
||||
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
|
||||
.endr
|
||||
.purgem add_one_sample
|
||||
subs r8, r8, #4 @ loop counter
|
||||
bne 1b @ jump back if we're done with the loop
|
||||
|
||||
2:
|
||||
pop {{r4-r8}}
|
||||
bx lr
|
||||
|
||||
3: @ same modification
|
||||
@ check to see if this is a perfect power of 2
|
||||
@ r5 is a scratch register, r7 = r3 = amount to modify
|
||||
sub r5, r7, #1
|
||||
ands r5, r5, r7
|
||||
|
||||
bne 4b @ not 0 means we need to do the full modification, jump to modification fallback
|
||||
|
||||
@ count leading zeros of r7 into r3
|
||||
mov r3, #0
|
||||
1:
|
||||
add r3, r3, #1
|
||||
lsrs r7, r7, #1
|
||||
bne 1b
|
||||
|
||||
sub r3, r3, #1
|
||||
|
||||
mov r5, #0 @ current index we're reading from
|
||||
|
||||
.macro add_one_sample_same_modification
|
||||
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
|
||||
add r5, r5, r2 @ calculate the position to read the next sample from
|
||||
|
||||
lsl r6, r6, #16
|
||||
orr r6, r6, lsr #16
|
||||
|
||||
.ifc \is_first,true
|
||||
mov r4, r6, lsl r3 @ r4 = r6 << r3
|
||||
.else
|
||||
ldr r4, [r1] @ read the current value
|
||||
add r4, r4, r6, lsl r3 @ r4 += r6 << r3 (calculating both the left and right samples together)
|
||||
.endif
|
||||
|
||||
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
|
||||
.endr
|
||||
.purgem add_one_sample_same_modification
|
||||
|
||||
subs r8, r8, #4 @ loop counter
|
||||
bne 1b @ jump back if we're done with the loop
|
||||
|
||||
2:
|
||||
pop {{r4-r8}}
|
||||
bx lr
|
||||
|
||||
agb_arm_end \fn_name
|
||||
.endm
|
||||
|
||||
mixer_add agb_rs__mixer_add false
|
||||
mixer_add agb_rs__mixer_add_first true
|
||||
|
||||
.macro stereo_add_fn fn_name:req is_first:req
|
||||
agb_arm_func \fn_name
|
||||
@ Arguments
|
||||
|
@ -202,7 +66,9 @@ agb_arm_end \fn_name
|
|||
.endm
|
||||
|
||||
stereo_add_fn agb_rs__mixer_add_stereo false
|
||||
stereo_add_fn agb_rs__mixer_add_stereo_first true
|
||||
|
||||
@ TODO(GI): Might bring this back later
|
||||
@ stereo_add_fn agb_rs__mixer_add_stereo_first true
|
||||
|
||||
agb_arm_func agb_rs__mixer_collapse
|
||||
@ Arguments:
|
||||
|
|
|
@ -1,6 +1,5 @@
|
|||
use core::cell::RefCell;
|
||||
use core::marker::PhantomData;
|
||||
use core::ops::ControlFlow;
|
||||
use core::pin::Pin;
|
||||
|
||||
use alloc::boxed::Box;
|
||||
|
@ -22,24 +21,6 @@ use crate::{
|
|||
|
||||
// Defined in mixer.s
|
||||
extern "C" {
|
||||
fn agb_rs__mixer_add(
|
||||
sound_data: *const u8,
|
||||
sound_buffer: *mut Num<i16, 4>,
|
||||
playback_speed: Num<u32, 8>,
|
||||
left_amount: Num<i16, 4>,
|
||||
right_amount: Num<i16, 4>,
|
||||
buffer_size: usize,
|
||||
);
|
||||
|
||||
fn agb_rs__mixer_add_first(
|
||||
sound_data: *const u8,
|
||||
sound_buffer: *mut Num<i16, 4>,
|
||||
playback_speed: Num<u32, 8>,
|
||||
left_amount: Num<i16, 4>,
|
||||
right_amount: Num<i16, 4>,
|
||||
buffer_size: usize,
|
||||
);
|
||||
|
||||
fn agb_rs__mixer_add_stereo(
|
||||
sound_data: *const u8,
|
||||
sound_buffer: *mut Num<i16, 4>,
|
||||
|
@ -47,13 +28,6 @@ extern "C" {
|
|||
buffer_size: usize,
|
||||
);
|
||||
|
||||
fn agb_rs__mixer_add_stereo_first(
|
||||
sound_data: *const u8,
|
||||
sound_buffer: *mut Num<i16, 4>,
|
||||
volume: Num<i16, 4>,
|
||||
buffer_size: usize,
|
||||
);
|
||||
|
||||
fn agb_rs__mixer_collapse(
|
||||
sound_buffer: *mut i8,
|
||||
input_buffer: *const Num<i16, 4>,
|
||||
|
|
Loading…
Reference in a new issue