Check if the tiles passed are of the correct format

This commit is contained in:
Gwilym Inzani 2023-02-24 08:47:45 +00:00
parent c6bac34294
commit 689bfc642f
3 changed files with 12 additions and 1 deletions

View file

@ -8,7 +8,6 @@ use agb::{
},
include_font,
};
use modular_bitfield::private::checks::FourMod8;
use core::fmt::Write;

View file

@ -195,6 +195,14 @@ impl RegularMap {
tileset: &TileSet<'_>,
tile_setting: TileSetting,
) {
if tileset.format() != self.colours() {
panic!(
"Cannot set a {:?} colour tile on a {:?} colour background",
tileset.format(),
self.colours()
);
}
let pos = self.map_size().gba_offset(pos);
let old_tile = self.tiles_mut()[pos];

View file

@ -57,6 +57,10 @@ impl<'a> TileSet<'a> {
fn reference(&self) -> NonNull<[u8]> {
self.tiles.into()
}
pub(crate) fn format(&self) -> TileFormat {
self.format
}
}
#[derive(Debug, Clone, Copy)]