Merge pull request #326 from gwilymk/remove-pointless-set-scroll-in-affine-background

Remove pointless set scroll in affine background
This commit is contained in:
Gwilym Kuiper 2022-10-11 22:46:43 +01:00 committed by GitHub
commit 59de262532
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
2 changed files with 10 additions and 33 deletions

View file

@ -33,9 +33,6 @@ trait TiledMapPrivate: TiledMapTypes {
fn update_bg_registers(&self); fn update_bg_registers(&self);
fn scroll_pos(&self) -> Vector2D<i16>;
fn set_scroll_pos(&mut self, new_pos: Vector2D<i16>);
fn bg_control_register(&self) -> MemoryMapped<u16> { fn bg_control_register(&self) -> MemoryMapped<u16> {
unsafe { MemoryMapped::new(0x0400_0008 + 2 * self.background_id()) } unsafe { MemoryMapped::new(0x0400_0008 + 2 * self.background_id()) }
} }
@ -52,10 +49,6 @@ pub trait TiledMap: TiledMapTypes {
fn hide(&mut self); fn hide(&mut self);
fn commit(&mut self, vram: &mut VRamManager); fn commit(&mut self, vram: &mut VRamManager);
fn size(&self) -> Self::Size; fn size(&self) -> Self::Size;
#[must_use]
fn scroll_pos(&self) -> Vector2D<i16>;
fn set_scroll_pos(&mut self, pos: Vector2D<i16>);
} }
impl<T> TiledMap for T impl<T> TiledMap for T
@ -114,15 +107,6 @@ where
fn size(&self) -> T::Size { fn size(&self) -> T::Size {
self.map_size() self.map_size()
} }
#[must_use]
fn scroll_pos(&self) -> Vector2D<i16> {
TiledMapPrivate::scroll_pos(self)
}
fn set_scroll_pos(&mut self, pos: Vector2D<i16>) {
TiledMapPrivate::set_scroll_pos(self, pos);
}
} }
pub struct RegularMap { pub struct RegularMap {
@ -170,12 +154,6 @@ impl TiledMapPrivate for RegularMap {
self.x_register().set(self.scroll.x); self.x_register().set(self.scroll.x);
self.y_register().set(self.scroll.y); self.y_register().set(self.scroll.y);
} }
fn scroll_pos(&self) -> Vector2D<i16> {
self.scroll
}
fn set_scroll_pos(&mut self, new_pos: Vector2D<i16>) {
self.scroll = new_pos;
}
} }
impl RegularMap { impl RegularMap {
@ -230,6 +208,15 @@ impl RegularMap {
*self.tiles_dirty() = true; *self.tiles_dirty() = true;
} }
#[must_use]
pub fn scroll_pos(&self) -> Vector2D<i16> {
self.scroll
}
pub fn set_scroll_pos(&mut self, pos: Vector2D<i16>) {
self.scroll = pos;
}
fn x_register(&self) -> MemoryMapped<i16> { fn x_register(&self) -> MemoryMapped<i16> {
unsafe { MemoryMapped::new(0x0400_0010 + 4 * self.background_id as usize) } unsafe { MemoryMapped::new(0x0400_0010 + 4 * self.background_id as usize) }
} }
@ -245,8 +232,6 @@ pub struct AffineMap {
priority: Priority, priority: Priority,
size: AffineBackgroundSize, size: AffineBackgroundSize,
scroll: Vector2D<i16>,
transform: AffineMatrixBackground, transform: AffineMatrixBackground,
tiles: Vec<u8>, tiles: Vec<u8>,
@ -282,12 +267,6 @@ impl TiledMapPrivate for AffineMap {
fn update_bg_registers(&self) { fn update_bg_registers(&self) {
self.bg_affine_matrix().set(self.transform); self.bg_affine_matrix().set(self.transform);
} }
fn scroll_pos(&self) -> Vector2D<i16> {
self.scroll
}
fn set_scroll_pos(&mut self, new_pos: Vector2D<i16>) {
self.scroll = new_pos;
}
} }
impl AffineMap { impl AffineMap {
@ -303,8 +282,6 @@ impl AffineMap {
priority, priority,
size, size,
scroll: Default::default(),
transform: Default::default(), transform: Default::default(),
tiles: vec![Default::default(); size.num_tiles()], tiles: vec![Default::default(); size.num_tiles()],

View file

@ -1,5 +1,5 @@
use agb::display::{ use agb::display::{
tiled::{RegularMap, TileSet, TileSetting, TiledMap, VRamManager}, tiled::{RegularMap, TileSet, TileSetting, VRamManager},
HEIGHT, WIDTH, HEIGHT, WIDTH,
}; };