From 2044cbf379717bac6dba4946e32b1e484823b088 Mon Sep 17 00:00:00 2001 From: Gwilym Kuiper Date: Sun, 23 Jan 2022 19:04:09 +0000 Subject: [PATCH] Generation makes more sense to be a u16 for better data storage --- agb/src/display/background.rs | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/agb/src/display/background.rs b/agb/src/display/background.rs index 60d61d2a..b35ed879 100644 --- a/agb/src/display/background.rs +++ b/agb/src/display/background.rs @@ -42,7 +42,7 @@ impl<'a> TileSet<'a> { #[derive(Clone, Copy, PartialEq, Eq)] pub struct TileSetReference { id: u16, - generation: u32, + generation: u16, } #[derive(Debug)] @@ -51,12 +51,12 @@ pub struct TileIndex(u16); enum ArenaStorageItem { EndOfFreeList, NextFree(usize), - Data(T, u32), + Data(T, u16), } pub struct VRamManager<'a> { tilesets: Vec>>, - generation: u32, + generation: u16, free_pointer: Option, tile_set_to_vram: HashMap<(u16, u16), u16>, @@ -81,7 +81,7 @@ impl<'a> VRamManager<'a> { pub fn add_tileset(&mut self, tileset: TileSet<'a>) -> TileSetReference { let generation = self.generation; - self.generation += 1; + self.generation = self.generation.wrapping_add(1); let tileset = ArenaStorageItem::Data(tileset, generation); @@ -332,7 +332,7 @@ impl Tiled0<'_> { } impl TileSetReference { - fn new(id: u16, generation: u32) -> Self { + fn new(id: u16, generation: u16) -> Self { Self { id, generation } } }