diff --git a/agb/src/display/tiled/mod.rs b/agb/src/display/tiled/mod.rs index 5a53cad6..3abc9cfa 100644 --- a/agb/src/display/tiled/mod.rs +++ b/agb/src/display/tiled/mod.rs @@ -52,19 +52,19 @@ impl RegularBackgroundSize { self.num_tiles() / (32 * 32) } - pub(crate) fn rem_euclid_width(&self, x: i32) -> u16 { + pub(crate) fn tile_pos_x(&self, x: i32) -> u16 { ((x as u32) & (self.width() - 1)) as u16 } - pub(crate) fn rem_euclid_height(&self, y: i32) -> u16 { + pub(crate) fn tile_pos_y(&self, y: i32) -> u16 { ((y as u32) & (self.height() - 1)) as u16 } - pub(crate) fn rem_euclid_width_px(&self, x: i32) -> u16 { + pub(crate) fn px_offset_x(&self, x: i32) -> u16 { ((x as u32) & (self.width() * 8 - 1)) as u16 } - pub(crate) fn rem_euclid_height_px(&self, y: i32) -> u16 { + pub(crate) fn px_offset_y(&self, y: i32) -> u16 { ((y as u32) & (self.height() * 8 - 1)) as u16 } } @@ -127,15 +127,12 @@ mod test { for size in sizes.iter() { let width = size.width() as i32; - assert_eq!(size.rem_euclid_width(8), 8); - assert_eq!(size.rem_euclid_width(3 + width), 3); - assert_eq!(size.rem_euclid_width(7 + width * 9), 7); + assert_eq!(size.tile_pos_x(8), 8); + assert_eq!(size.tile_pos_x(3 + width), 3); + assert_eq!(size.tile_pos_x(7 + width * 9), 7); - assert_eq!(size.rem_euclid_width(-8), (size.width() - 8) as u16); - assert_eq!( - size.rem_euclid_width(-17 - width * 8), - (size.width() - 17) as u16 - ); + assert_eq!(size.tile_pos_x(-8), (size.width() - 8) as u16); + assert_eq!(size.tile_pos_x(-17 - width * 8), (size.width() - 17) as u16); } } }