From 083fd43ea301c061d751bcf0e0614de5e457476a Mon Sep 17 00:00:00 2001 From: Corwin Date: Sat, 3 Jun 2023 16:54:44 +0100 Subject: [PATCH 1/4] just dealloc in gc --- agb/src/display/tiled/vram_manager.rs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/agb/src/display/tiled/vram_manager.rs b/agb/src/display/tiled/vram_manager.rs index e2ae2d1d..c9220f73 100644 --- a/agb/src/display/tiled/vram_manager.rs +++ b/agb/src/display/tiled/vram_manager.rs @@ -342,7 +342,7 @@ impl VRamManager { let tile_reference = Self::reference_from_index(tile_index); unsafe { - TILE_ALLOCATOR.dealloc_no_normalise( + TILE_ALLOCATOR.dealloc( tile_reference.0.cast().as_ptr(), layout_of(tile_index.format()), ); From cbb0b7d2a0e96370cbedd8a07119fac7c91111b5 Mon Sep 17 00:00:00 2001 From: Corwin Date: Sun, 4 Jun 2023 00:15:16 +0100 Subject: [PATCH 2/4] resolve stutter --- examples/hyperspace-roll/src/customise.rs | 2 +- examples/hyperspace-roll/src/level_generation.rs | 4 +++- 2 files changed, 4 insertions(+), 2 deletions(-) diff --git a/examples/hyperspace-roll/src/customise.rs b/examples/hyperspace-roll/src/customise.rs index 4c6a5aec..78c2d9b2 100644 --- a/examples/hyperspace-roll/src/customise.rs +++ b/examples/hyperspace-roll/src/customise.rs @@ -175,7 +175,7 @@ pub(crate) fn customise_screen( agb.sfx.frame(); - let mut upgrades = crate::level_generation::generate_upgrades(level); + let mut upgrades = crate::level_generation::generate_upgrades(level, &mut || agb.sfx.frame()); let mut _upgrade_objects = create_upgrade_objects(&agb.obj, &upgrades); let mut input = agb::input::ButtonController::new(); diff --git a/examples/hyperspace-roll/src/level_generation.rs b/examples/hyperspace-roll/src/level_generation.rs index 04c45b5f..5c190495 100644 --- a/examples/hyperspace-roll/src/level_generation.rs +++ b/examples/hyperspace-roll/src/level_generation.rs @@ -37,7 +37,7 @@ fn generate_cooldown(current_level: u32) -> u32 { rng::gen().rem_euclid((5 * 60 - current_level as i32 * 10).max(1)) as u32 + 2 * 60 } -pub fn generate_upgrades(level: u32) -> Vec { +pub fn generate_upgrades(level: u32, call: &mut dyn FnMut()) -> Vec { let mut upgrade_values = HashMap::new(); upgrade_values.insert(Face::Shoot, 5); @@ -73,6 +73,8 @@ pub fn generate_upgrades(level: u32) -> Vec { let mut attempts = 0; while upgrades.len() != 3 { + call(); + attempts += 1; let next = potential_upgrades[rng::gen() as usize % potential_upgrades.len()]; let number_of_malfunctions = upgrades From 95a880409446e3f163753fe30e17e20741fbe092 Mon Sep 17 00:00:00 2001 From: Corwin Date: Sun, 4 Jun 2023 00:17:50 +0100 Subject: [PATCH 3/4] reset the number of attempts --- examples/hyperspace-roll/src/level_generation.rs | 1 + 1 file changed, 1 insertion(+) diff --git a/examples/hyperspace-roll/src/level_generation.rs b/examples/hyperspace-roll/src/level_generation.rs index 5c190495..646f30cc 100644 --- a/examples/hyperspace-roll/src/level_generation.rs +++ b/examples/hyperspace-roll/src/level_generation.rs @@ -91,6 +91,7 @@ pub fn generate_upgrades(level: u32, call: &mut dyn FnMut()) -> Vec { } if attempts > 100 { + attempts = 0; upgrades.clear(); } } From 6b84833c4ffc017675c66837a3b3da5183905e93 Mon Sep 17 00:00:00 2001 From: Corwin Date: Sun, 4 Jun 2023 00:50:30 +0100 Subject: [PATCH 4/4] remove dealloc_no_normalise --- agb/src/agb_alloc/block_allocator.rs | 6 ------ 1 file changed, 6 deletions(-) diff --git a/agb/src/agb_alloc/block_allocator.rs b/agb/src/agb_alloc/block_allocator.rs index c65e4c96..f9d1da00 100644 --- a/agb/src/agb_alloc/block_allocator.rs +++ b/agb/src/agb_alloc/block_allocator.rs @@ -85,12 +85,6 @@ impl BlockAllocator { self.with_inner(|inner| inner.dealloc(ptr, layout)); } - pub unsafe fn dealloc_no_normalise(&self, ptr: *mut u8, layout: Layout) { - self.with_inner(|inner| { - inner.dealloc_no_normalise(ptr, layout); - }); - } - pub unsafe fn grow( &self, ptr: *mut u8,