mirror of
https://github.com/italicsjenga/agb.git
synced 2025-01-27 09:36:39 +11:00
delete sprites during commit
This commit is contained in:
parent
845076d0b4
commit
859029a7a9
1 changed files with 26 additions and 9 deletions
|
@ -425,12 +425,13 @@ struct Loan<'a> {
|
||||||
impl Drop for Loan<'_> {
|
impl Drop for Loan<'_> {
|
||||||
fn drop(&mut self) {
|
fn drop(&mut self) {
|
||||||
let mut s = unsafe { get_object_controller(&self.phantom) };
|
let mut s = unsafe { get_object_controller(&self.phantom) };
|
||||||
s.free_object.push(self.index);
|
|
||||||
|
|
||||||
let o = s.shadow_oam[self.index as usize].take();
|
unsafe {
|
||||||
let o = unsafe { o.unwrap_unchecked() };
|
s.shadow_oam[self.index as usize]
|
||||||
o.previous_sprite.drop(&mut s.sprite_controller);
|
.as_mut()
|
||||||
o.sprite.drop(&mut s.sprite_controller);
|
.unwrap_unchecked()
|
||||||
|
.destroy = true
|
||||||
|
};
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -438,6 +439,7 @@ struct ObjectInner {
|
||||||
attrs: Attributes,
|
attrs: Attributes,
|
||||||
sprite: SpriteBorrow<'static>,
|
sprite: SpriteBorrow<'static>,
|
||||||
previous_sprite: SpriteBorrow<'static>,
|
previous_sprite: SpriteBorrow<'static>,
|
||||||
|
destroy: bool,
|
||||||
z: i32,
|
z: i32,
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -493,11 +495,25 @@ impl ObjectController {
|
||||||
|
|
||||||
for (i, &z) in s.z_order.iter().enumerate() {
|
for (i, &z) in s.z_order.iter().enumerate() {
|
||||||
if let Some(o) = &mut s.shadow_oam[z as usize] {
|
if let Some(o) = &mut s.shadow_oam[z as usize] {
|
||||||
o.attrs.commit(i);
|
if o.destroy {
|
||||||
|
s.free_object.push(z);
|
||||||
|
|
||||||
let mut a = o.sprite.clone(&mut s.sprite_controller);
|
unsafe {
|
||||||
core::mem::swap(&mut o.previous_sprite, &mut a);
|
(OBJECT_ATTRIBUTE_MEMORY as *mut u16)
|
||||||
a.drop(&mut s.sprite_controller);
|
.add((i as usize) * 4)
|
||||||
|
.write_volatile(HIDDEN_VALUE)
|
||||||
|
}
|
||||||
|
|
||||||
|
let a = unsafe { s.shadow_oam[z as usize].take().unwrap_unchecked() };
|
||||||
|
a.previous_sprite.drop(&mut s.sprite_controller);
|
||||||
|
a.sprite.drop(&mut s.sprite_controller);
|
||||||
|
} else {
|
||||||
|
o.attrs.commit(i);
|
||||||
|
|
||||||
|
let mut a = o.sprite.clone(&mut s.sprite_controller);
|
||||||
|
core::mem::swap(&mut o.previous_sprite, &mut a);
|
||||||
|
a.drop(&mut s.sprite_controller);
|
||||||
|
}
|
||||||
} else {
|
} else {
|
||||||
unsafe {
|
unsafe {
|
||||||
(OBJECT_ATTRIBUTE_MEMORY as *mut u16)
|
(OBJECT_ATTRIBUTE_MEMORY as *mut u16)
|
||||||
|
@ -551,6 +567,7 @@ impl ObjectController {
|
||||||
attrs,
|
attrs,
|
||||||
z: 0,
|
z: 0,
|
||||||
previous_sprite: new_sprite.clone(&mut s.sprite_controller),
|
previous_sprite: new_sprite.clone(&mut s.sprite_controller),
|
||||||
|
destroy: false,
|
||||||
sprite: new_sprite,
|
sprite: new_sprite,
|
||||||
});
|
});
|
||||||
|
|
||||||
|
|
Loading…
Add table
Reference in a new issue