diff --git a/agb/src/dma.rs b/agb/src/dma.rs index b1a3aac9..48e870db 100644 --- a/agb/src/dma.rs +++ b/agb/src/dma.rs @@ -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( + pub fn hblank_transfer( &self, location: &DmaControllable, values: &[T], @@ -93,10 +89,13 @@ impl Dma { let n_transfers = (size_of::() / 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); - location.memory_location.write_volatile(values[0]); + // 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