From 836143e1f47c5bcaaff83b57d5f065cbf219360d Mon Sep 17 00:00:00 2001 From: Corwin Date: Sat, 12 Feb 2022 14:44:18 +0000 Subject: [PATCH] copy the sprite and palette data --- agb/src/display/object.rs | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/agb/src/display/object.rs b/agb/src/display/object.rs index 848f12ea..9890fcac 100644 --- a/agb/src/display/object.rs +++ b/agb/src/display/object.rs @@ -193,6 +193,11 @@ impl SpriteController { } }; + unsafe { + dest.as_ptr() + .copy_from(sprite.data.as_ptr(), sprite.data.len()) + } + let storage = Storage::from_sprite_ptr(dest); inner.sprite.insert(id, storage); @@ -214,6 +219,13 @@ impl SpriteControllerInner { Some(storage.location) } else { let dest = unsafe { PALETTE_ALLOCATOR.alloc(Palette16::layout())? }; + + unsafe { + dest.as_ptr() + .cast::() + .copy_from(palette.colours.as_ptr(), palette.colours.len()) + } + let storage = Storage::from_palette_ptr(dest); self.palette.insert(id, storage);