; ptr to map routine
.de map_routine, 2
; ptr to actor table for this map
+ ; acto tables are terminated with a 0 type actor
.de map_acts, 2
+ ; ptr to tile props
+ ; tile props are modifiers that are applied to tiles after
+ ; the load takes place
+ ; the map_tp list is terminated by a 0 type
+.de map_tile_props, 2
; pointers to tile banks to be loaded
; maps to map property tile_bank0, tile_bank1, tile_bank2, tile_bank3
; note that tile_bank1 and tile_bank2 are 128 bytes each
.de map_tiles, MAP_W * MAP_H
.de map_size, 0
+ ; map tile props struct
+.se 0
+.de map_tp_type, 1
+.de map_tp_y, 1
+.de map_tp_x, 1
+.de map_tp_flags0, 1
+.de map_tp_flags1, 1
+.de map_tp_p0, 1
+.de map_tp_size, 0
+
; tile type enum
.se 0
.de TT_EMPTY, 1
-.de TT_WALL, 1
+.de TT_OPEN, 1
+.de TT_LOCKED, 1
; tile flags0
.se 1
; 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, l1_acts, tile_banks_default
+ mapdef MAP_F_DO_FULL_REDRAW, map_r_nop, l1_acts, l1_tile_props, tile_banks_default
#include "l1.inc"
; l1 actor table
actdef ACT_T_BAT, 0, 0, 2, 2, 1, ITEM_NONE, ITEM_NONE, ITEM_NONE, attr_bat
.db 0 ; terminate
+l1_tile_props:
+ maptpdef TT_LOCKED, 1, 0, 0, 0, 0
+ .db 0 ; terminate
tile_banks_default:
dw bank8000
; $1: flags
; $2: map routine
; $3: actors
- ; $4: tile bank table
+ ; $4: map tile props
+ ; $5: tile bank table
#macro mapdef
.db $1
dw $2
dw $3
dw $4
+ dw $5
+#endmacro
+
+ ; define a map tile prop entry
+ ; inputs:
+ ; $1: type
+ ; $2: y
+ ; $3: x
+ ; $4: flags0
+ ; $5: flags1
+ ; $6: p0
+#macro maptpdef
+ .db $1
+ .db $2
#endmacro
; define a tile
; $2: flags
; $3: p0
#macro tiledef
- .db $1, $2
+ .db $1, $2, 0
; t_actor
.db 0, 0
; t_prop
ld h, [hl]
ld l, a
call act_table_load
+
+ pop de
+
+ ; load tile props
+ ld hl, map_tile_props
+ add hl, de
+ ld a, [hl+]
+ ld h, [hl]
+ ld l, a
+ call map_load_tile_props
+ push de
; init the player
ld de, player
pop de
ret
+ ; applies tile props to a map
+ ; requires tiles to be loaded
+ ; applies tile props to all tiles until
+ ; type 0 is read
+ ; inputs:
+ ; hl: tile prop ptr
+map_load_tile_props:
+ ret
+
; loads a tile buffer
; tile buffers from maped only contain tile flags
; into the tile buffer