mirror of
https://github.com/italicsjenga/agb.git
synced 2025-01-22 23:26:33 +11:00
Also dma the palette in backgrounds
This commit is contained in:
parent
989fcea1d0
commit
ef8b2edc63
2 changed files with 10 additions and 2 deletions
|
@ -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(),
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -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> {
|
||||
|
|
Loading…
Add table
Reference in a new issue