background id exposed

This commit is contained in:
Corwin 2022-08-04 21:41:48 +01:00
parent 15cfc5196b
commit 10423d0752
3 changed files with 15 additions and 2 deletions

View file

@ -1,6 +1,6 @@
use alloc::boxed::Box; use alloc::boxed::Box;
use super::{MapLoan, RegularMap, TileSet, TileSetting, VRamManager}; use super::{BackgroundID, MapLoan, RegularMap, TileSet, TileSetting, VRamManager};
use crate::{ use crate::{
display, display,
@ -414,6 +414,11 @@ impl<'a> InfiniteScrolledMap<'a> {
pub fn clear(&mut self, vram: &mut VRamManager) { pub fn clear(&mut self, vram: &mut VRamManager) {
self.map.clear(vram); self.map.clear(vram);
} }
#[must_use]
pub const fn background(&self) -> BackgroundID {
self.map.background()
}
} }
fn div_floor(x: i32, y: i32) -> i32 { fn div_floor(x: i32, y: i32) -> i32 {

View file

@ -7,7 +7,7 @@ use crate::dma::dma_copy16;
use crate::fixnum::Vector2D; use crate::fixnum::Vector2D;
use crate::memory_mapped::MemoryMapped; use crate::memory_mapped::MemoryMapped;
use super::{RegularBackgroundSize, Tile, TileSet, TileSetting, VRamManager}; use super::{BackgroundID, RegularBackgroundSize, Tile, TileSet, TileSetting, VRamManager};
use alloc::{vec, vec::Vec}; use alloc::{vec, vec::Vec};
@ -201,6 +201,11 @@ impl<'a, T> MapLoan<'a, T> {
screenblock_list, screenblock_list,
} }
} }
#[must_use]
pub const fn background(&self) -> BackgroundID {
BackgroundID(self.background_id)
}
} }
impl<'a, T> Drop for MapLoan<'a, T> { impl<'a, T> Drop for MapLoan<'a, T> {

View file

@ -17,6 +17,9 @@ pub enum RegularBackgroundSize {
Background64x64, Background64x64,
} }
#[derive(Debug, Clone, Copy, PartialEq, Eq)]
pub struct BackgroundID(pub(crate) u8);
impl RegularBackgroundSize { impl RegularBackgroundSize {
#[must_use] #[must_use]
pub fn width(&self) -> u32 { pub fn width(&self) -> u32 {