From f1fb9d537547219498cbb6e774f6a6b77496c8fe Mon Sep 17 00:00:00 2001 From: Gwilym Kuiper Date: Tue, 11 Oct 2022 22:32:00 +0100 Subject: [PATCH 1/2] Remove pointless set_scroll_pos and scroll_pos from AffineBackground --- agb/src/display/tiled/map.rs | 41 ++++++++---------------------------- 1 file changed, 9 insertions(+), 32 deletions(-) diff --git a/agb/src/display/tiled/map.rs b/agb/src/display/tiled/map.rs index 38a8a483..b0ed0197 100644 --- a/agb/src/display/tiled/map.rs +++ b/agb/src/display/tiled/map.rs @@ -33,9 +33,6 @@ trait TiledMapPrivate: TiledMapTypes { fn update_bg_registers(&self); - fn scroll_pos(&self) -> Vector2D; - fn set_scroll_pos(&mut self, new_pos: Vector2D); - fn bg_control_register(&self) -> MemoryMapped { unsafe { MemoryMapped::new(0x0400_0008 + 2 * self.background_id()) } } @@ -52,10 +49,6 @@ pub trait TiledMap: TiledMapTypes { fn hide(&mut self); fn commit(&mut self, vram: &mut VRamManager); fn size(&self) -> Self::Size; - - #[must_use] - fn scroll_pos(&self) -> Vector2D; - fn set_scroll_pos(&mut self, pos: Vector2D); } impl TiledMap for T @@ -114,15 +107,6 @@ where fn size(&self) -> T::Size { self.map_size() } - - #[must_use] - fn scroll_pos(&self) -> Vector2D { - TiledMapPrivate::scroll_pos(self) - } - - fn set_scroll_pos(&mut self, pos: Vector2D) { - TiledMapPrivate::set_scroll_pos(self, pos); - } } pub struct RegularMap { @@ -170,12 +154,6 @@ impl TiledMapPrivate for RegularMap { self.x_register().set(self.scroll.x); self.y_register().set(self.scroll.y); } - fn scroll_pos(&self) -> Vector2D { - self.scroll - } - fn set_scroll_pos(&mut self, new_pos: Vector2D) { - self.scroll = new_pos; - } } impl RegularMap { @@ -230,6 +208,15 @@ impl RegularMap { *self.tiles_dirty() = true; } + #[must_use] + pub fn scroll_pos(&self) -> Vector2D { + self.scroll + } + + pub fn set_scroll_pos(&mut self, pos: Vector2D) { + self.scroll = pos; + } + fn x_register(&self) -> MemoryMapped { unsafe { MemoryMapped::new(0x0400_0010 + 4 * self.background_id as usize) } } @@ -245,8 +232,6 @@ pub struct AffineMap { priority: Priority, size: AffineBackgroundSize, - scroll: Vector2D, - transform: AffineMatrixBackground, tiles: Vec, @@ -282,12 +267,6 @@ impl TiledMapPrivate for AffineMap { fn update_bg_registers(&self) { self.bg_affine_matrix().set(self.transform); } - fn scroll_pos(&self) -> Vector2D { - self.scroll - } - fn set_scroll_pos(&mut self, new_pos: Vector2D) { - self.scroll = new_pos; - } } impl AffineMap { @@ -303,8 +282,6 @@ impl AffineMap { priority, size, - scroll: Default::default(), - transform: Default::default(), tiles: vec![Default::default(); size.num_tiles()], From 982cb42b38c1800ea00dc94a1fbc257dcb66f158 Mon Sep 17 00:00:00 2001 From: Gwilym Kuiper Date: Tue, 11 Oct 2022 22:36:14 +0100 Subject: [PATCH 2/2] Fix now unused import --- examples/the-hat-chooses-the-wizard/src/level_display.rs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/examples/the-hat-chooses-the-wizard/src/level_display.rs b/examples/the-hat-chooses-the-wizard/src/level_display.rs index 0defcc31..3e87f58b 100644 --- a/examples/the-hat-chooses-the-wizard/src/level_display.rs +++ b/examples/the-hat-chooses-the-wizard/src/level_display.rs @@ -1,5 +1,5 @@ use agb::display::{ - tiled::{RegularMap, TileSet, TileSetting, TiledMap, VRamManager}, + tiled::{RegularMap, TileSet, TileSetting, VRamManager}, HEIGHT, WIDTH, };