Pass buffer size as an argument

This commit is contained in:
Gwilym Inzani 2023-06-18 16:02:14 +01:00
parent ba18a0bf4a
commit b2dcd8c854
2 changed files with 11 additions and 4 deletions

View file

@ -152,6 +152,7 @@ agb_arm_func agb_rs__mixer_collapse
@ Arguments:
@ r0 = target buffer (i8)
@ r1 = input buffer (i16) of fixnums with 4 bits of precision (read in sets of i16 in an i32)
@ r2 = loop counter
push {{r4-r11,lr}}
@ -164,8 +165,6 @@ SWAP_SIGN .req r11
ldr CONST_127, =127
ldr SWAP_SIGN, =0x80808080
ldr r2, =agb_rs__buffer_size @ loop counter
ldr r2, [r2]
mov r4, r2
@ The idea for this solution came from pimpmobile:

View file

@ -35,7 +35,11 @@ extern "C" {
volume: Num<i16, 4>,
);
fn agb_rs__mixer_collapse(sound_buffer: *mut i8, input_buffer: *const Num<i16, 4>);
fn agb_rs__mixer_collapse(
sound_buffer: *mut i8,
input_buffer: *const Num<i16, 4>,
num_samples: usize,
);
}
/// The main software mixer struct.
@ -458,7 +462,11 @@ impl MixerBuffer {
let write_buffer = free(|cs| self.state.borrow(cs).borrow_mut().active_advanced());
unsafe {
agb_rs__mixer_collapse(write_buffer, working_buffer.as_ptr());
agb_rs__mixer_collapse(
write_buffer,
working_buffer.as_ptr(),
self.frequency.buffer_size(),
);
}
}
}