From b9c24b87fb231b034225ef78dfadad4295cda754 Mon Sep 17 00:00:00 2001 From: Lukas Krickl Date: Sat, 4 Oct 2025 20:51:19 +0200 Subject: [PATCH] update: oam now only clears the unused objects each frame --- src/mem.s | 25 ++++++++++++++++++++++++- src/update.s | 5 +++-- 2 files changed, 27 insertions(+), 3 deletions(-) diff --git a/src/mem.s b/src/mem.s index ae06a61..07c063e 100644 --- a/src/mem.s +++ b/src/mem.s @@ -100,7 +100,30 @@ shadow_oam_clear: ld hl, shadow_oam ld d, 0 jp memset - + + ; clears the remaining shadow oam + ; entries +shadow_oam_clear_rest: + ld hl, shadow_oam + ld d, 0 + ld a, [current_oam_obj] + ld e, a + add hl, de ; hl = soam obj offset + xor a, a + + sra e + sra e ; / 4 for loop coutner + +@clear_loop: + ld [hl+], a + ld [hl+], a + ld [hl+], a + ld [hl+], a + dec e + jr nz, @clear_loop REL + + ret + ; dma shadow oam to oam ; registers: diff --git a/src/update.s b/src/update.s index 010c83a..9ae0149 100644 --- a/src/update.s +++ b/src/update.s @@ -5,8 +5,6 @@ update_game: ; tick rng every frame call rand - ; clear oam - call shadow_oam_clear call video_map_adjust_scroll @@ -16,6 +14,9 @@ update_game: call actor_update_all + ; clear oam + call shadow_oam_clear_rest + ret new_game: -- 2.30.2