From d0808cb7f2e11cf39f24691230a7a7d8f8f84630 Mon Sep 17 00:00:00 2001 From: Corwin Kuiper Date: Sat, 30 Oct 2021 18:38:57 +0100 Subject: [PATCH] added helpful functions --- agb/src/display/object.rs | 8 +++++++- agb/src/display/palette16.rs | 1 + 2 files changed, 8 insertions(+), 1 deletion(-) diff --git a/agb/src/display/object.rs b/agb/src/display/object.rs index e7ce3707..f8d21d50 100644 --- a/agb/src/display/object.rs +++ b/agb/src/display/object.rs @@ -12,7 +12,7 @@ const OBJECT_ATTRIBUTE_MEMORY: MemoryMapped1DArray = unsafe { MemoryMapped1DArray::new(0x0700_0000) }; const PALETTE_SPRITE: MemoryMapped1DArray = unsafe { MemoryMapped1DArray::new(0x0500_0200) }; -const TILE_SPRITE: MemoryMapped1DArray = +const TILE_SPRITE: MemoryMapped1DArray = unsafe { MemoryMapped1DArray::new(0x06010000) }; /// Handles distributing objects and matricies along with operations that effect all objects. @@ -331,6 +331,12 @@ impl ObjectControl { } } + pub fn set_sprite_tilemap_at_idx(&self, idx: usize, tiles: &[u32]) { + for (index, &tile) in tiles.iter().enumerate() { + self.set_sprite_tilemap_entry(index + idx, tile) + } + } + /// Enable objects on the GBA. pub fn enable(&mut self) { let disp = DISPLAY_CONTROL.get(); diff --git a/agb/src/display/palette16.rs b/agb/src/display/palette16.rs index ea653a48..0ad1ca17 100644 --- a/agb/src/display/palette16.rs +++ b/agb/src/display/palette16.rs @@ -1,3 +1,4 @@ +#[derive(Clone)] pub struct Palette16 { pub(crate) colours: [u16; 16], }