mirror of
https://github.com/italicsjenga/agb.git
synced 2024-12-23 08:11:33 +11:00
hblack_transfer doesn't need to be unsafe
This commit is contained in:
parent
248f71dbfa
commit
e9ce8cd2ad
|
@ -70,14 +70,10 @@ impl Dma {
|
|||
/// drop the DmaTransferHandler return value until the next vblank interrupt to ensure that you
|
||||
/// a continuous effect.
|
||||
///
|
||||
/// # Safety
|
||||
///
|
||||
/// While DmaTransferHandle is not dropped, the slice at `values` must not move in memory.
|
||||
///
|
||||
/// # Examples
|
||||
///
|
||||
/// See the `dma_effect_*` examples in the repository to see some ways to use this.
|
||||
pub unsafe fn hblank_transfer<T>(
|
||||
pub fn hblank_transfer<T>(
|
||||
&self,
|
||||
location: &DmaControllable<T>,
|
||||
values: &[T],
|
||||
|
@ -93,10 +89,13 @@ impl Dma {
|
|||
|
||||
let n_transfers = (size_of::<T>() / 2) as u32;
|
||||
|
||||
self.source_addr.set(handle.data.as_ptr().add(1) as u32);
|
||||
self.source_addr.set(handle.data[1..].as_ptr() as u32);
|
||||
self.dest_addr.set(location.memory_location as u32);
|
||||
|
||||
// SAFETY: by construction it is safe to write to location.memory_location
|
||||
unsafe {
|
||||
location.memory_location.write_volatile(values[0]);
|
||||
}
|
||||
|
||||
self.ctrl_addr.set(
|
||||
(0b10 << 0x15) | // keep destination address fixed
|
||||
|
|
Loading…
Reference in a new issue