From: Lukas Krickl Date: Sat, 13 Dec 2025 06:49:55 +0000 (+0100) Subject: map: Added full reload code X-Git-Url: https://git.krickl.dev/?a=commitdiff_plain;h=aff4143d7b78e0516ab5a5e9328c71061c813391;p=gbrg%2F.git map: Added full reload code --- diff --git a/src/defs.s b/src/defs.s index 32bced2..895f1bb 100644 --- a/src/defs.s +++ b/src/defs.s @@ -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 diff --git a/src/levels.s b/src/levels.s index a857078..efa692a 100644 --- a/src/levels.s +++ b/src/levels.s @@ -15,5 +15,11 @@ ; 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 diff --git a/src/map.s b/src/map.s index 20dfd57..a636569 100644 --- 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