map: Added full reload code
authorLukas Krickl <lukas@krickl.dev>
Sat, 13 Dec 2025 06:49:55 +0000 (07:49 +0100)
committerLukas Krickl <lukas@krickl.dev>
Sat, 13 Dec 2025 06:49:55 +0000 (07:49 +0100)
src/defs.s
src/levels.s
src/map.s

index 32bced25838fce15135e6c45cc6a2820887a461c..895f1bbd107bc6fbb824e6304573a51de3a9588f 100644 (file)
@@ -65,6 +65,7 @@
        ; ptr to actor table for this map
 .de map_acts, 2
        ; ptr to exit table 
+       ; in the following order: up, down, left, right
 .de map_exits, 2
   ; pointers to tile banks to be loaded 
   ; maps to map property tile_bank0, tile_bank1, tile_bank2, tile_bank3
index a85707889fcaa62541481026f09f3de795d45bc4..efa692ac85c0047658ee1de207b7c6c8ed8756d8 100644 (file)
        ; where each tile has values and its current state. The map can be drawn from this.
 
 l1:
-       mapdef MAP_F_DO_FULL_REDRAW, map_r_nop, 0, 0, bank8000, bank8800, bank8C00, bank9000, tile_id_table
+       mapdef MAP_F_DO_FULL_REDRAW, map_r_nop, 0, l1_exits, bank8000, bank8800, bank8C00, bank9000, tile_id_table
 #include "spawn.inc"
+
+l1_exits:
+       dw l1
+       dw l1
+       dw l1
+       dw l1
index 20dfd5749f3b49cee0f21645b51055e118297593..a636569063b0d3d6d7ae8517f243d48e71b4ec61 100644 (file)
--- a/src/map.s
+++ b/src/map.s
@@ -60,11 +60,53 @@ map_settings_load:
        push de
        call map_tiles_load
        pop de
+       
+       ; exit table
+       ld hl, map_exits
+       add hl, de
+       ld a, [hl+]
+       ld h, [hl]
+       ld l, a
+
+       ; load exits in the following order:
+       ; up, down, left, right
+       ld bc, map_exit_up
+
+       ; up
+       ld a, [hl+]
+       ld [bc], a
+       inc bc
+       ld a, [hl+]
+       ld [bc], a
+       inc bc
+
+       ; down
+       ld a, [hl+]
+       ld [bc], a
+       inc bc
+       ld a, [hl+]
+       ld [bc], a
+       inc bc
+
+       ; left
+       ld a, [hl+]
+       ld [bc], a
+       inc bc
+       ld a, [hl+]
+       ld [bc], a
+       inc bc
+
+       ; right
+       ld a, [hl+]
+       ld [bc], a
+       inc bc
+       ld a, [hl]
+       ld [bc], a
+
+
 
        ; TODO: 
        ; load actors
-       ; encounter table
-       ; exit table
        ret
        
        ; loads a tileset
@@ -403,8 +445,8 @@ map_try_full_reload:
        and a, MAP_F_DO_FULL_REDRAW
        ret z 
 
-       BREAK
-       ret
+       pop hl ; remove previous caller from call stack 
+       jp map_load     
 
        ; map transition routines
        ; gets the down exit and sets transition state
@@ -413,6 +455,9 @@ map_get_exit_down_and_set_load:
        ld a, [hl+]
        ld d, [hl]
        ld e, a ; de = new map
+
+       ; this call does not return
+       ; if a full load is needed
        call map_try_full_reload
 
        ld hl, update_map_load_down