Also dma the palette in backgrounds

This commit is contained in:
Gwilym Kuiper 2022-03-13 19:53:07 +00:00
parent 989fcea1d0
commit ef8b2edc63
2 changed files with 10 additions and 2 deletions

View file

@ -266,8 +266,12 @@ impl<'a> VRamManager<'a> {
}
fn set_background_palette(&mut self, pal_index: u8, palette: &palette16::Palette16) {
for (colour_index, &colour) in palette.colours.iter().enumerate() {
PALETTE_BACKGROUND.set(pal_index as usize * 16 + colour_index, colour);
unsafe {
dma_copy16(
palette.colours.as_ptr(),
PALETTE_BACKGROUND.as_ptr().add(16 * pal_index as usize),
palette.colours.len(),
);
}
}

View file

@ -57,6 +57,10 @@ impl<T, const N: usize> MemoryMapped1DArray<T, N> {
pub fn set(&self, n: usize, val: T) {
unsafe { (&mut (*self.array)[n] as *mut T).write_volatile(val) }
}
pub fn as_ptr(&self) -> *mut T {
self.array.cast()
}
}
pub struct MemoryMapped2DArray<T, const X: usize, const Y: usize> {