From 3b9909ad5b92799593fb050421347195959f416c Mon Sep 17 00:00:00 2001 From: Gwilym Kuiper Date: Tue, 3 May 2022 23:43:08 +0100 Subject: [PATCH] Add comment about how silly the implementation of gba_offset is --- agb/src/display/tiled/mod.rs | 2 ++ 1 file changed, 2 insertions(+) diff --git a/agb/src/display/tiled/mod.rs b/agb/src/display/tiled/mod.rs index 68ae2e9..1590779 100644 --- a/agb/src/display/tiled/mod.rs +++ b/agb/src/display/tiled/mod.rs @@ -53,6 +53,8 @@ impl RegularBackgroundSize { self.num_tiles() / (32 * 32) } + // This is hilariously complicated due to how the GBA stores the background screenblocks. + // See https://www.coranac.com/tonc/text/regbg.htm#sec-map for an explanation pub(crate) fn gba_offset(&self, pos: Vector2D) -> usize { let x_mod = pos.x & (self.width() as u16 - 1); let y_mod = pos.y & (self.height() as u16 - 1);