Add a 256 colour variant too

This commit is contained in:
Gwilym Inzani 2024-05-25 11:13:01 +01:00
parent bf4a6887a5
commit da9ad6d496

View file

@ -463,9 +463,16 @@ impl VRamManager {
}
/// Gets the index of the colour for a given background palette, or None if it doesn't exist
pub fn find_colour_index_16(&mut self, palette_index: usize, colour: u16) -> Option<usize> {
#[must_use]
pub fn find_colour_index_16(&self, palette_index: usize, colour: u16) -> Option<usize> {
assert!(palette_index < 16);
(0..16).find(|i| PALETTE_BACKGROUND.get(palette_index * 16 + i) == colour)
}
/// Gets the index of the colour in the entire background palette, or None if it doesn't exist
#[must_use]
pub fn find_colour_index_256(&self, colour: u16) -> Option<usize> {
(0..256).find(|&i| PALETTE_BACKGROUND.get(i) == colour)
}
}