From 301e2c115a4edda33109ab98f980e886728361e6 Mon Sep 17 00:00:00 2001 From: Corwin Kuiper Date: Sat, 30 Oct 2021 20:33:54 +0100 Subject: [PATCH] fix tile ids --- agb/src/display/object.rs | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/agb/src/display/object.rs b/agb/src/display/object.rs index f8d21d50..83a72051 100644 --- a/agb/src/display/object.rs +++ b/agb/src/display/object.rs @@ -119,6 +119,10 @@ impl ObjectStandard<'_> { self.attributes.set_mode(Mode::Hidden) } + pub fn set_palette(&mut self, palette: u16) { + self.attributes.set_palette(palette); + } + /// Sets the x and y position of the object, performing casts as nessesary /// to fit within the bits allocated for this purpose. pub fn set_position(&mut self, position: Vector2D) { @@ -231,6 +235,10 @@ impl ObjectAttribute { self.a1 = set_bits(self.a1, a1, 2, 0xE); } + fn set_palette(&mut self, palette: u16) { + self.a2 = set_bits(self.a2, palette, 4, 0xC); + } + fn set_x(&mut self, x: u16) { self.a1 = set_bits(self.a1, x, 9, 0); } @@ -240,7 +248,7 @@ impl ObjectAttribute { } fn set_tile_id(&mut self, id: u16) { - self.a2 = set_bits(self.a2, id, 9, 0); + self.a2 = set_bits(self.a2, id, 10, 0); } fn set_mode(&mut self, mode: Mode) {