mirror of
https://github.com/italicsjenga/agb.git
synced 2024-12-23 08:11:33 +11:00
Add implementation for if this is the first
This commit is contained in:
parent
938b052997
commit
306be59cde
|
@ -91,7 +91,8 @@ same_modification:
|
|||
|
||||
agb_arm_end agb_rs__mixer_add
|
||||
|
||||
agb_arm_func agb_rs__mixer_add_stereo
|
||||
.macro stereo_add_fn 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)
|
||||
|
@ -127,16 +128,24 @@ agb_arm_func agb_rs__mixer_add_stereo
|
|||
lsl r6, r6, #24 @ r6 = | R | 0 | 0 | 0 | drop everything except the right sample
|
||||
orr r6, r7, r6, asr #8 @ r6 = | 1 | R | 1 | L | now we have it perfectly set up
|
||||
|
||||
.ifc \is_first,true
|
||||
mul \sample_reg, r6, r2
|
||||
.else
|
||||
mla \sample_reg, r6, r2, \sample_reg @ r4 += r6 * r2 (calculating both the left and right samples together)
|
||||
.endif
|
||||
.endm
|
||||
|
||||
1:
|
||||
.ifc \is_first,true
|
||||
.else
|
||||
ldmia r1, {{r9-r12}} @ read the current values
|
||||
.endif
|
||||
|
||||
add_stereo_sample r9
|
||||
add_stereo_sample r10
|
||||
add_stereo_sample r11
|
||||
add_stereo_sample r12
|
||||
.purgem add_stereo_sample
|
||||
|
||||
stmia r1!, {{r9-r12}} @ store the new value, and increment the pointer
|
||||
|
||||
|
@ -146,7 +155,11 @@ agb_arm_func agb_rs__mixer_add_stereo
|
|||
pop {{r4-r11}}
|
||||
bx lr
|
||||
|
||||
agb_arm_end agb_rs__mixer_add_stereo
|
||||
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
|
||||
|
||||
agb_arm_func agb_rs__mixer_collapse
|
||||
@ Arguments:
|
||||
|
|
|
@ -35,6 +35,12 @@ extern "C" {
|
|||
volume: Num<i16, 4>,
|
||||
);
|
||||
|
||||
fn agb_rs__mixer_add_stereo_first(
|
||||
sound_data: *const u8,
|
||||
sound_buffer: *mut Num<i16, 4>,
|
||||
volume: Num<i16, 4>,
|
||||
);
|
||||
|
||||
fn agb_rs__mixer_collapse(
|
||||
sound_buffer: *mut i8,
|
||||
input_buffer: *const Num<i16, 4>,
|
||||
|
@ -406,7 +412,7 @@ impl MixerBuffer {
|
|||
working_buffer: &mut [Num<i16, 4>],
|
||||
channels: impl Iterator<Item = &'a mut SoundChannel>,
|
||||
) {
|
||||
working_buffer.fill(0.into());
|
||||
// working_buffer.fill(0.into());
|
||||
|
||||
for channel in channels {
|
||||
if channel.is_done {
|
||||
|
|
Loading…
Reference in a new issue