Use dma in objects

This commit is contained in:
Gwilym Kuiper 2022-03-13 19:36:14 +00:00
parent 3710d9ad1c
commit 056a38703d

View file

@ -16,6 +16,7 @@ use super::palette16::Palette16;
use super::{Priority, DISPLAY_CONTROL}; use super::{Priority, DISPLAY_CONTROL};
use crate::agb_alloc::block_allocator::BlockAllocator; use crate::agb_alloc::block_allocator::BlockAllocator;
use crate::agb_alloc::bump_allocator::StartEnd; use crate::agb_alloc::bump_allocator::StartEnd;
use crate::dma;
use crate::fixnum::Vector2D; use crate::fixnum::Vector2D;
use attributes::*; use attributes::*;
@ -577,8 +578,11 @@ impl SpriteController {
}; };
unsafe { unsafe {
dest.as_ptr() dma::dma_copy(
.copy_from_nonoverlapping(sprite.data.as_ptr(), sprite.data.len()) sprite.data.as_ptr().cast(),
dest.as_ptr().cast(),
sprite.data.len() / 2,
);
} }
let storage = Storage::from_sprite_ptr(dest); let storage = Storage::from_sprite_ptr(dest);
@ -610,9 +614,11 @@ impl SpriteControllerInner {
let dest = unsafe { PALETTE_ALLOCATOR.alloc(Palette16::layout())? }; let dest = unsafe { PALETTE_ALLOCATOR.alloc(Palette16::layout())? };
unsafe { unsafe {
dest.as_ptr() dma::dma_copy(
.cast::<u16>() palette.colours.as_ptr().cast(),
.copy_from_nonoverlapping(palette.colours.as_ptr(), palette.colours.len()) dest.as_ptr().cast(),
palette.colours.len(),
);
} }
let storage = Storage::from_palette_ptr(dest); let storage = Storage::from_palette_ptr(dest);