mirror of
https://github.com/italicsjenga/agb.git
synced 2024-12-24 00:31:34 +11:00
Make rem_euclid_* return a u16
This commit is contained in:
parent
817e1e305e
commit
ae65af4ca2
|
@ -63,8 +63,8 @@ impl<'a> InfiniteScrolledMap<'a> {
|
|||
|
||||
let offset = self.current_pos - (x_start * 8, y_start * 8).into();
|
||||
let offset_scroll = (
|
||||
self.map.size().rem_euclid_width(offset.x) as u16,
|
||||
self.map.size().rem_euclid_height(offset.y) as u16,
|
||||
self.map.size().rem_euclid_width(offset.x),
|
||||
self.map.size().rem_euclid_height(offset.y),
|
||||
)
|
||||
.into();
|
||||
|
||||
|
@ -179,8 +179,8 @@ impl<'a> InfiniteScrolledMap<'a> {
|
|||
self.map.set_tile(
|
||||
vram,
|
||||
(
|
||||
size.rem_euclid_width(tile_x - self.offset.x) as u16,
|
||||
size.rem_euclid_height(tile_y - self.offset.y) as u16,
|
||||
size.rem_euclid_width(tile_x - self.offset.x),
|
||||
size.rem_euclid_height(tile_y - self.offset.y),
|
||||
)
|
||||
.into(),
|
||||
tileset,
|
||||
|
@ -190,8 +190,8 @@ impl<'a> InfiniteScrolledMap<'a> {
|
|||
|
||||
let current_scroll = self.map.scroll_pos();
|
||||
let new_scroll = (
|
||||
size.rem_euclid_width_px(current_scroll.x as i32 + difference.x) as u16,
|
||||
size.rem_euclid_height_px(current_scroll.y as i32 + difference.y) as u16,
|
||||
size.rem_euclid_width_px(current_scroll.x as i32 + difference.x),
|
||||
size.rem_euclid_height_px(current_scroll.y as i32 + difference.y),
|
||||
)
|
||||
.into();
|
||||
|
||||
|
|
|
@ -48,20 +48,20 @@ impl RegularBackgroundSize {
|
|||
(self.width() * self.height()) as usize
|
||||
}
|
||||
|
||||
pub(crate) fn rem_euclid_width(&self, x: i32) -> u32 {
|
||||
(x as u32) & (self.width() - 1)
|
||||
pub(crate) fn rem_euclid_width(&self, x: i32) -> u16 {
|
||||
((x as u32) & (self.width() - 1)) as u16
|
||||
}
|
||||
|
||||
pub(crate) fn rem_euclid_height(&self, y: i32) -> u32 {
|
||||
(y as u32) & (self.height() - 1)
|
||||
pub(crate) fn rem_euclid_height(&self, y: i32) -> u16 {
|
||||
((y as u32) & (self.height() - 1)) as u16
|
||||
}
|
||||
|
||||
pub(crate) fn rem_euclid_width_px(&self, x: i32) -> u32 {
|
||||
(x as u32) & (self.width() * 8 - 1)
|
||||
pub(crate) fn rem_euclid_width_px(&self, x: i32) -> u16 {
|
||||
((x as u32) & (self.width() * 8 - 1)) as u16
|
||||
}
|
||||
|
||||
pub(crate) fn rem_euclid_height_px(&self, y: i32) -> u32 {
|
||||
(y as u32) & (self.height() * 8 - 1)
|
||||
pub(crate) fn rem_euclid_height_px(&self, y: i32) -> u16 {
|
||||
((y as u32) & (self.height() * 8 - 1)) as u16
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -127,8 +127,11 @@ mod test {
|
|||
assert_eq!(size.rem_euclid_width(3 + width), 3);
|
||||
assert_eq!(size.rem_euclid_width(7 + width * 9), 7);
|
||||
|
||||
assert_eq!(size.rem_euclid_width(-8), size.width() - 8);
|
||||
assert_eq!(size.rem_euclid_width(-17 - width * 8), size.width() - 17);
|
||||
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
|
||||
);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue