add similar treatment to sprite palettes as background palettes

This commit is contained in:
Corwin Kuiper 2021-06-05 16:14:41 +01:00
parent a3874e7140
commit a39363b6ae

View file

@ -274,11 +274,22 @@ impl Tiled0 {
} }
/// Copies raw palettes to the background palette without any checks. /// 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() { for (index, &entry) in colour.iter().enumerate() {
self.set_sprite_palette_entry(index.try_into().unwrap(), entry) 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. /// Copies raw palettes to the background palette without any checks.
pub fn set_background_palette_raw(&mut self, palette: &[u16]) { pub fn set_background_palette_raw(&mut self, palette: &[u16]) {