From c3b81a45850440294268e6d36347e6723b9dedd6 Mon Sep 17 00:00:00 2001 From: Corwin Kuiper Date: Sun, 30 May 2021 12:47:00 +0100 Subject: [PATCH] don't touch highest 16 bits --- agb/src/display/object.rs | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/agb/src/display/object.rs b/agb/src/display/object.rs index 5c717138..d7883191 100644 --- a/agb/src/display/object.rs +++ b/agb/src/display/object.rs @@ -52,7 +52,10 @@ pub struct ObjectAttribute { impl ObjectAttribute { unsafe fn commit(&self, index: usize) { OBJECT_MEMORY_STANDARD.set(index * 2, self.low); - OBJECT_MEMORY_STANDARD.set(index * 2 + 1, self.high); + // preserve top set of bits + let high_bits = OBJECT_MEMORY_STANDARD.get(index * 2 + 1); + let new_high_bits = (high_bits & !((1 << 16) - 1)) | self.high; + OBJECT_MEMORY_STANDARD.set(index * 2 + 1, new_high_bits); } pub fn set_hflip(&mut self, hflip: bool) {