; map flags
.se 1
-.de MAP_F_HOSTILE, 1
+.de MAP_F_DO_FULL_REDRAW, 1
; map header struct
.se 0
; 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"
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
; 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