mirror of
https://github.com/italicsjenga/agb.git
synced 2024-12-23 16:21:33 +11:00
Add gc step for tiles
This commit is contained in:
parent
7688316034
commit
178db91072
|
@ -116,6 +116,10 @@ impl TileReferenceCount {
|
|||
self.reference_count = 0;
|
||||
self.tile_in_tile_set = None;
|
||||
}
|
||||
|
||||
fn current_count(&self) -> u16 {
|
||||
self.reference_count
|
||||
}
|
||||
}
|
||||
|
||||
#[non_exhaustive]
|
||||
|
@ -279,6 +283,9 @@ impl VRamManager {
|
|||
pub(crate) fn gc(&mut self) {
|
||||
for tile_index in self.indices_to_gc.drain(..) {
|
||||
let index = tile_index.index() as usize;
|
||||
if self.reference_counts[index].current_count() > 0 {
|
||||
continue; // it has since been added back
|
||||
}
|
||||
|
||||
let tile_reference = Self::reference_from_index(tile_index);
|
||||
unsafe {
|
||||
|
|
|
@ -273,8 +273,8 @@ impl<'a, 'b> Map<'a, 'b> {
|
|||
self.background.set_pos(vram, self.position.floor());
|
||||
self.foreground.set_pos(vram, self.position.floor());
|
||||
|
||||
self.background.commit();
|
||||
self.foreground.commit();
|
||||
self.background.commit(vram);
|
||||
self.foreground.commit(vram);
|
||||
}
|
||||
|
||||
pub fn init_background(&mut self, vram: &mut VRamManager) -> PartialUpdateStatus {
|
||||
|
@ -793,7 +793,7 @@ fn main(mut agb: agb::Gba) -> ! {
|
|||
}
|
||||
}
|
||||
|
||||
world_display.commit();
|
||||
world_display.commit(&mut vram);
|
||||
world_display.show();
|
||||
|
||||
splash_screen::show_splash_screen(
|
||||
|
@ -835,7 +835,7 @@ fn main(mut agb: agb::Gba) -> ! {
|
|||
&mut vram,
|
||||
);
|
||||
|
||||
world_display.commit();
|
||||
world_display.commit(&mut vram);
|
||||
world_display.show();
|
||||
|
||||
music_box.before_frame(&mut mixer);
|
||||
|
|
|
@ -76,7 +76,7 @@ pub fn show_splash_screen(
|
|||
}
|
||||
}
|
||||
|
||||
map.commit();
|
||||
map.commit(vram);
|
||||
vram.set_background_palettes(palette);
|
||||
map.show();
|
||||
|
||||
|
|
|
@ -85,9 +85,9 @@ impl<'a> Level<'a> {
|
|||
foreground.init(vram, start_pos, &mut between_updates);
|
||||
clouds.init(vram, start_pos / 4, &mut between_updates);
|
||||
|
||||
backdrop.commit();
|
||||
foreground.commit();
|
||||
clouds.commit();
|
||||
backdrop.commit(vram);
|
||||
foreground.commit(vram);
|
||||
clouds.commit(vram);
|
||||
|
||||
backdrop.show();
|
||||
foreground.show();
|
||||
|
@ -2081,9 +2081,9 @@ impl<'a> Game<'a> {
|
|||
.commit_with_fudge(this_frame_offset, (0, 0).into());
|
||||
}
|
||||
|
||||
self.level.background.commit();
|
||||
self.level.foreground.commit();
|
||||
self.level.clouds.commit();
|
||||
self.level.background.commit(vram);
|
||||
self.level.foreground.commit(vram);
|
||||
self.level.clouds.commit(vram);
|
||||
|
||||
for i in remove {
|
||||
self.particles.remove(i);
|
||||
|
|
Loading…
Reference in a new issue