diff --git a/agb/examples/dynamic_tiles.rs b/agb/examples/dynamic_tiles.rs index aaa284b1..4871638b 100644 --- a/agb/examples/dynamic_tiles.rs +++ b/agb/examples/dynamic_tiles.rs @@ -3,7 +3,7 @@ use agb::display::{ palette16::Palette16, - tiled::{RegularBackgroundSize, TileFormat, TileSetting, TiledMap}, + tiled::{RegularBackgroundSize, TileFormat, TiledMap}, Priority, }; @@ -42,7 +42,7 @@ fn main(mut gba: agb::Gba) -> ! { &mut vram, (x as u16, y as u16).into(), &dynamic_tile.tile_set(), - TileSetting::from_raw(dynamic_tile.tile_index()), + dynamic_tile.tile_setting(), ); vram.remove_dynamic_tile(dynamic_tile); diff --git a/agb/examples/mixer_32768.rs b/agb/examples/mixer_32768.rs index b1ac9fc2..5ab57941 100644 --- a/agb/examples/mixer_32768.rs +++ b/agb/examples/mixer_32768.rs @@ -3,9 +3,7 @@ use agb::{ display::{ - tiled::{ - RegularBackgroundSize, RegularMap, TileFormat, TileSetting, TiledMap, VRamManager, - }, + tiled::{RegularBackgroundSize, RegularMap, TileFormat, TiledMap, VRamManager}, Font, Priority, }, include_font, include_wav, @@ -110,7 +108,7 @@ fn init_background(bg: &mut RegularMap, vram: &mut VRamManager) { vram, (x, y).into(), &background_tile.tile_set(), - TileSetting::from_raw(background_tile.tile_index()), + background_tile.tile_setting(), ); } } diff --git a/agb/examples/stereo_sound.rs b/agb/examples/stereo_sound.rs index c6ccc27b..23ed339c 100644 --- a/agb/examples/stereo_sound.rs +++ b/agb/examples/stereo_sound.rs @@ -3,9 +3,7 @@ use agb::{ display::{ - tiled::{ - RegularBackgroundSize, RegularMap, TileFormat, TileSetting, TiledMap, VRamManager, - }, + tiled::{RegularBackgroundSize, RegularMap, TileFormat, TiledMap, VRamManager}, Font, Priority, }, include_font, include_wav, @@ -98,7 +96,7 @@ fn init_background(bg: &mut RegularMap, vram: &mut VRamManager) { vram, (x, y).into(), &background_tile.tile_set(), - TileSetting::from_raw(background_tile.tile_index()), + background_tile.tile_setting(), ); } } diff --git a/agb/examples/text_render.rs b/agb/examples/text_render.rs index 4f0afa18..0d86a4b4 100644 --- a/agb/examples/text_render.rs +++ b/agb/examples/text_render.rs @@ -3,7 +3,7 @@ use agb::{ display::{ - tiled::{RegularBackgroundSize, TileFormat, TileSetting, TiledMap}, + tiled::{RegularBackgroundSize, TileFormat, TiledMap}, Font, Priority, }, include_font, @@ -37,7 +37,7 @@ fn main(mut gba: agb::Gba) -> ! { &mut vram, (x, y).into(), &background_tile.tile_set(), - TileSetting::from_raw(background_tile.tile_index()), + background_tile.tile_setting(), ); } } diff --git a/agb/src/display/font.rs b/agb/src/display/font.rs index e37a77a2..e70e66e0 100644 --- a/agb/src/display/font.rs +++ b/agb/src/display/font.rs @@ -3,7 +3,7 @@ use core::fmt::{Error, Write}; use crate::fixnum::Vector2D; use crate::hash_map::HashMap; -use super::tiled::{DynamicTile, RegularMap, TileSetting, VRamManager}; +use super::tiled::{DynamicTile, RegularMap, VRamManager}; /// The text renderer renders a variable width fixed size /// bitmap font using dynamic tiles as a rendering surface. @@ -230,7 +230,7 @@ impl<'a, 'b> TextRenderer<'b> { vram_manager, (self.tile_pos.x + *x as u16, self.tile_pos.y + *y as u16).into(), &tile.tile_set(), - TileSetting::from_raw(tile.tile_index()), + tile.tile_setting(), ); } } @@ -294,7 +294,7 @@ mod tests { &mut vram, (x, y).into(), &background_tile.tile_set(), - TileSetting::from_raw(background_tile.tile_index()), + background_tile.tile_setting(), ); } } diff --git a/agb/src/display/tiled/vram_manager.rs b/agb/src/display/tiled/vram_manager.rs index e14b259e..3d8c04aa 100644 --- a/agb/src/display/tiled/vram_manager.rs +++ b/agb/src/display/tiled/vram_manager.rs @@ -10,6 +10,8 @@ use crate::{ memory_mapped::MemoryMapped1DArray, }; +use super::TileSetting; + const TILE_RAM_START: usize = 0x0600_0000; const PALETTE_BACKGROUND: MemoryMapped1DArray = @@ -189,9 +191,11 @@ impl DynamicTile<'_> { } #[must_use] - pub fn tile_index(&self) -> u16 { + pub fn tile_setting(&self) -> TileSetting { let difference = self.tile_data.as_ptr() as usize - TILE_RAM_START; - (difference / TileFormat::FourBpp.tile_size()) as u16 + let tile_id = (difference / TileFormat::FourBpp.tile_size()) as u16; + + TileSetting::new(tile_id, false, false, 0) } }