From a39363b6aec242089e23128a2fc24dfadf2844a1 Mon Sep 17 00:00:00 2001 From: Corwin Kuiper Date: Sat, 5 Jun 2021 16:14:41 +0100 Subject: [PATCH] add similar treatment to sprite palettes as background palettes --- agb/src/display/tiled0.rs | 13 ++++++++++++- 1 file changed, 12 insertions(+), 1 deletion(-) diff --git a/agb/src/display/tiled0.rs b/agb/src/display/tiled0.rs index 46247be5..3cb637fe 100644 --- a/agb/src/display/tiled0.rs +++ b/agb/src/display/tiled0.rs @@ -274,11 +274,22 @@ impl Tiled0 { } /// Copies raw palettes to the background palette without any checks. - pub fn set_sprite_palette(&mut self, colour: &[u16]) { + pub fn set_sprite_palette_raw(&mut self, colour: &[u16]) { for (index, &entry) in colour.iter().enumerate() { self.set_sprite_palette_entry(index.try_into().unwrap(), entry) } } + fn set_sprite_palette(&mut self, pal_index: u8, palette: &palette16::Palette16) { + for (colour_index, &colour) in palette.colours.iter().enumerate() { + PALETTE_SPRITE.set(pal_index as usize * 16 + colour_index, colour); + } + } + + pub fn set_sprite_palettes(&mut self, palettes: &[palette16::Palette16]) { + for (palette_index, entry) in palettes.iter().enumerate() { + self.set_sprite_palette(palette_index as u8, entry) + } + } /// Copies raw palettes to the background palette without any checks. pub fn set_background_palette_raw(&mut self, palette: &[u16]) {