map loader: wip added full redraw flag
authorLukas Krickl <lukas@krickl.dev>
Sat, 13 Dec 2025 05:10:10 +0000 (06:10 +0100)
committerLukas Krickl <lukas@krickl.dev>
Sat, 13 Dec 2025 05:10:10 +0000 (06:10 +0100)
src/defs.s
src/levels.s
src/map.s
src/wram.s

index aa9f937655497b4dfd3d8879751c1ec60af313ee..32bced25838fce15135e6c45cc6a2820887a461c 100644 (file)
@@ -55,7 +55,7 @@
  
        ; map flags
 .se 1
-.de MAP_F_HOSTILE, 1
+.de MAP_F_DO_FULL_REDRAW, 1
 
   ; map header struct
 .se 0
index 9a6394c7824bc3735b642809a0e5f83096b86b66..a85707889fcaa62541481026f09f3de795d45bc4 100644 (file)
@@ -15,5 +15,5 @@
        ; where each tile has values and its current state. The map can be drawn from this.
 
 l1:
-       mapdef 0, map_r_nop, 0, 0, bank8000, bank8800, bank8C00, bank9000, tile_id_table
+       mapdef MAP_F_DO_FULL_REDRAW, map_r_nop, 0, 0, bank8000, bank8800, bank8C00, bank9000, tile_id_table
 #include "spawn.inc"
index d487c6aea957df4accee7f90123c8947022106b3..20dfd5749f3b49cee0f21645b51055e118297593 100644 (file)
--- a/src/map.s
+++ b/src/map.s
@@ -383,10 +383,38 @@ map_full_draw:
        map_full_draw_inc_b
 
        ret
+       
+       ; checks the current map
+       ; if the fully reload flag is set 
+       ; it will do a full redraw
+       ; otherwise this routine just returns
+       ; if a full redraw is requested this routine 
+       ; pops the previous caller's return from the stack
+       ; and jumps to a full load
+       ; inputs:
+       ;               de: new map ptr
+map_try_full_reload:
+       ld hl, map
+       ld a, [hl+]
+       ld h, [hl]
+       ld l, a ; hl = map
+
+       ld a, [hl] ; read flags
+       and a, MAP_F_DO_FULL_REDRAW
+       ret z 
+
+       BREAK
+       ret
 
        ; map transition routines
        ; gets the down exit and sets transition state
 map_get_exit_down_and_set_load:
+       ld hl, map_exit_down
+       ld a, [hl+]
+       ld d, [hl]
+       ld e, a ; de = new map
+       call map_try_full_reload
+
        ld hl, update_map_load_down
        call game_set_state
        ret
index 8f47d3cf184877f4916923470b4f7980dce48aac..e276a3e6c68bf9cec2543e9ffbd368bcee2e319b 100644 (file)
@@ -90,6 +90,20 @@ map: .adv 2
        ; where the map should be drawn
 map_vram_tl: .adv 2
 map_tmp_tile_id_table: .adv 2
+       ; exit table
+       ; an exit table always has 4 entries
+       ; exits usually transition using a scroll
+       ; unless the current map has the full reload flag 
+       ; set in which case the map fades out and full reloads
+       ; the scene
+       ; 0: eixt up
+       ; 1: exit down
+       ;       2: exit left
+       ;       3: exit right
+map_exit_up: .adv 2
+map_exit_down: .adv 2
+map_exit_left: .adv 2
+map_exit_right: .adv 2
        
        ; ptr to current tile to be updated
 tiles: .adv t_size * MAP_TILES