From 553c393df17ae41efb9651de93d8235cf3cccac2 Mon Sep 17 00:00:00 2001 From: Lukas Krickl Date: Sat, 5 Jul 2025 20:57:27 +0200 Subject: [PATCH] map: Fixed map load corrupting video memory Map loads now always disable interrupts and the lcd. In the future maybe we should only disable lcd if we are swapping out tilesets. During a map load it would probably be enough to wait for blank for each row of tiles loaded. --- src/main.s | 4 +++- src/map.s | 16 ++++++++++++++++ 2 files changed, 19 insertions(+), 1 deletion(-) diff --git a/src/main.s b/src/main.s index 946003e..1de7290 100644 --- a/src/main.s +++ b/src/main.s @@ -23,12 +23,14 @@ entry: call video_init call audio_init - call map_init call lcd_on call vblank_wait call enableinterrupts + + ; init initial map + call map_init ; main for gameply #ifndef TEST_BUILD diff --git a/src/map.s b/src/map.s index 76897f1..a098b96 100644 --- a/src/map.s +++ b/src/map.s @@ -6,7 +6,18 @@ map_init: ; loads a new map ; inputs: ; hl: map ptr + ; disables and enables interrupts + ; and lcd + ; TODO: do not touch lcd or interrupts if + ; they were not enabled! map_load: + ; disable interruts + ; wait for next blank + ; disable lcd + call disableinterrutpts + call next_vblank_wait + call lcd_off + push hl call map_draw_area_title pop hl @@ -33,6 +44,11 @@ map_load: call map_draw_all + ; restore lcd and interrupts + call lcd_on + call vblank_wait + call enableinterrupts + ret ; draws map title to UI (SCRN1) -- 2.30.2