From 288fa0c85e9f72c1636c85077c37befb4137909d Mon Sep 17 00:00:00 2001 From: Gwilym Kuiper Date: Tue, 3 May 2022 21:28:32 +0100 Subject: [PATCH] Add an enum for tracking background size of regular tiles --- agb/src/display/tiled/mod.rs | 36 ++++++++++++++++++++++++++++++++++++ 1 file changed, 36 insertions(+) diff --git a/agb/src/display/tiled/mod.rs b/agb/src/display/tiled/mod.rs index a0ec32d8..9e56513a 100644 --- a/agb/src/display/tiled/mod.rs +++ b/agb/src/display/tiled/mod.rs @@ -8,6 +8,42 @@ pub use map::{MapLoan, RegularMap}; pub use tiled0::Tiled0; pub use vram_manager::{DynamicTile, TileFormat, TileIndex, TileSet, VRamManager}; +pub enum RegularBackgroundSize { + Background32x32, + Background64x32, + Background32x64, + Background64x64, +} + +impl RegularBackgroundSize { + pub fn width(&self) -> u32 { + match self { + RegularBackgroundSize::Background32x32 => 32, + RegularBackgroundSize::Background64x32 => 64, + RegularBackgroundSize::Background32x64 => 32, + RegularBackgroundSize::Background64x64 => 64, + } + } + + pub fn height(&self) -> u32 { + match self { + RegularBackgroundSize::Background32x32 => 32, + RegularBackgroundSize::Background64x32 => 32, + RegularBackgroundSize::Background32x64 => 64, + RegularBackgroundSize::Background64x64 => 64, + } + } + + pub(crate) fn size_flag(&self) -> u16 { + match self { + RegularBackgroundSize::Background32x32 => 0, + RegularBackgroundSize::Background64x32 => 1, + RegularBackgroundSize::Background32x64 => 2, + RegularBackgroundSize::Background64x64 => 3, + } + } +} + #[derive(Clone, Copy, Debug, Default, PartialEq, Eq)] #[repr(transparent)] struct Tile(u16);