From 5cdcfcc0b3eb9a94a04eadeba1262a8475a7c06a Mon Sep 17 00:00:00 2001 From: Corwin Kuiper Date: Sun, 30 May 2021 17:00:01 +0100 Subject: [PATCH] add set bits function --- agb/src/display/object.rs | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/agb/src/display/object.rs b/agb/src/display/object.rs index a7f1ccab..49f217e0 100644 --- a/agb/src/display/object.rs +++ b/agb/src/display/object.rs @@ -46,6 +46,11 @@ impl ObjectStandard { } } +fn set_bits(current: u16, value: u16, length: u16, shift: u16) -> u16 { + let mask: u16 = (1 << length) - 1; + (current & !(mask << shift)) | ((value & mask) << shift) +} + pub struct ObjectAttribute { a0: u16, a1: u16,