diff --git a/examples/chicken.rs b/examples/chicken.rs index cb735ef2..a0fd6d0b 100644 --- a/examples/chicken.rs +++ b/examples/chicken.rs @@ -52,7 +52,7 @@ fn main(_argc: isize, _argv: *const *const u8) -> isize { object.enable(); unsafe { object.clear_objects() }; let mut chicken = Character { - object: object.get_object(0), + object: unsafe { object.get_object(0) }, position: Vector2D { x: 20 << 8, y: 20 << 8, diff --git a/src/display/object.rs b/src/display/object.rs index c831a48d..3f5f5ca7 100644 --- a/src/display/object.rs +++ b/src/display/object.rs @@ -102,7 +102,7 @@ impl ObjectControl { } /// # Safety - /// Temporary + /// Temporary, do not call if you currently hold an object pub unsafe fn clear_objects(&mut self) { let mut o = ObjectAttributeStandard::new(); o.set_mode(Mode::Hidden); @@ -124,7 +124,9 @@ impl ObjectControl { DISPLAY_CONTROL.set(disp); } - pub fn get_object(&self, id: usize) -> ObjectStandard { + /// # Safety + /// Temporary function, you must not get multiple objects with the same id + pub unsafe fn get_object(&self, id: usize) -> ObjectStandard { assert!(id < 128, "object id must be less than 128"); ObjectStandard { attributes: ObjectAttributeStandard::new(),