From da9ad6d496ca1589cf87066b422f757ab3bc0779 Mon Sep 17 00:00:00 2001 From: Gwilym Inzani Date: Sat, 25 May 2024 11:13:01 +0100 Subject: [PATCH] Add a 256 colour variant too --- agb/src/display/tiled/vram_manager.rs | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/agb/src/display/tiled/vram_manager.rs b/agb/src/display/tiled/vram_manager.rs index 2a482a69..4339d56b 100644 --- a/agb/src/display/tiled/vram_manager.rs +++ b/agb/src/display/tiled/vram_manager.rs @@ -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 { + #[must_use] + pub fn find_colour_index_16(&self, palette_index: usize, colour: u16) -> Option { 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 { + (0..256).find(|&i| PALETTE_BACKGROUND.get(i) == colour) + } }