mirror of
https://github.com/italicsjenga/agb.git
synced 2024-12-24 00:31:34 +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.reference_count = 0;
|
||||||
self.tile_in_tile_set = None;
|
self.tile_in_tile_set = None;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
fn current_count(&self) -> u16 {
|
||||||
|
self.reference_count
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
#[non_exhaustive]
|
#[non_exhaustive]
|
||||||
|
@ -279,6 +283,9 @@ impl VRamManager {
|
||||||
pub(crate) fn gc(&mut self) {
|
pub(crate) fn gc(&mut self) {
|
||||||
for tile_index in self.indices_to_gc.drain(..) {
|
for tile_index in self.indices_to_gc.drain(..) {
|
||||||
let index = tile_index.index() as usize;
|
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);
|
let tile_reference = Self::reference_from_index(tile_index);
|
||||||
unsafe {
|
unsafe {
|
||||||
|
|
|
@ -273,8 +273,8 @@ impl<'a, 'b> Map<'a, 'b> {
|
||||||
self.background.set_pos(vram, self.position.floor());
|
self.background.set_pos(vram, self.position.floor());
|
||||||
self.foreground.set_pos(vram, self.position.floor());
|
self.foreground.set_pos(vram, self.position.floor());
|
||||||
|
|
||||||
self.background.commit();
|
self.background.commit(vram);
|
||||||
self.foreground.commit();
|
self.foreground.commit(vram);
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn init_background(&mut self, vram: &mut VRamManager) -> PartialUpdateStatus {
|
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();
|
world_display.show();
|
||||||
|
|
||||||
splash_screen::show_splash_screen(
|
splash_screen::show_splash_screen(
|
||||||
|
@ -835,7 +835,7 @@ fn main(mut agb: agb::Gba) -> ! {
|
||||||
&mut vram,
|
&mut vram,
|
||||||
);
|
);
|
||||||
|
|
||||||
world_display.commit();
|
world_display.commit(&mut vram);
|
||||||
world_display.show();
|
world_display.show();
|
||||||
|
|
||||||
music_box.before_frame(&mut mixer);
|
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);
|
vram.set_background_palettes(palette);
|
||||||
map.show();
|
map.show();
|
||||||
|
|
||||||
|
|
|
@ -85,9 +85,9 @@ impl<'a> Level<'a> {
|
||||||
foreground.init(vram, start_pos, &mut between_updates);
|
foreground.init(vram, start_pos, &mut between_updates);
|
||||||
clouds.init(vram, start_pos / 4, &mut between_updates);
|
clouds.init(vram, start_pos / 4, &mut between_updates);
|
||||||
|
|
||||||
backdrop.commit();
|
backdrop.commit(vram);
|
||||||
foreground.commit();
|
foreground.commit(vram);
|
||||||
clouds.commit();
|
clouds.commit(vram);
|
||||||
|
|
||||||
backdrop.show();
|
backdrop.show();
|
||||||
foreground.show();
|
foreground.show();
|
||||||
|
@ -2081,9 +2081,9 @@ impl<'a> Game<'a> {
|
||||||
.commit_with_fudge(this_frame_offset, (0, 0).into());
|
.commit_with_fudge(this_frame_offset, (0, 0).into());
|
||||||
}
|
}
|
||||||
|
|
||||||
self.level.background.commit();
|
self.level.background.commit(vram);
|
||||||
self.level.foreground.commit();
|
self.level.foreground.commit(vram);
|
||||||
self.level.clouds.commit();
|
self.level.clouds.commit(vram);
|
||||||
|
|
||||||
for i in remove {
|
for i in remove {
|
||||||
self.particles.remove(i);
|
self.particles.remove(i);
|
||||||
|
|
Loading…
Reference in a new issue