; returns:
; a: flags
; b: tile index
+ ; hl: ptr to tile index
map_get_tile:
; current map
ld hl, map
ld b, a
ld a, [hl] ; tile flags
+ dec hl
+
ret
; loads map tiles
; a: row offset
map_draw_shadow2:
ld hl, map
- ld de, MAP_W
+ ld de, MAP_W * c_size
; calculate what row to draw
@offset_loop:
; redraw_shadow and redraw steps for 4 rows of tiles
; inputs:
; hl: bg target ptr
+ ; a: row offset (a*2*32 + hl)
map_request_redraw2:
+ ; adjust screen target position by row offset
+ ld de, 32
+ add a, a
+@row_offset_calc:
+ cp a, 0
+ jr z, @row_offset_done REL
+ add hl, de
+ dec a
+ jr @row_offset_calc REL
+@row_offset_done:
+
; write bg target
ld a, h
ld [redraw_bg], a
ld [player_rt_special_flags], a
pop af ; get back a for next check
pop de
+
+ ; hl should still be tile ptr here
; check if player is on a door tile
; if so, remove door and queue a map redraw
and a, CF_DOOR
+ push de
call nz, unit_player_remove_door
+ pop de
; check for exit flags
push de
; standing on
; inputs:
; de: actor
+ ; hl: ptr to tile player is on
unit_player_remove_door:
- ; TODO: remove door tile, door flag
+ ; remove door tile, door flag
; and redraw map
+ ld a, 0x48 ; roof tile
+ ; clear map
+ ld [hl+], a
+ ld a, CF_COVERED
+ ld [hl], a
+
+ ld hl, act_pos_y
+ add hl, de
+ ld a, [hl] ; load y offset
+ push af ; save y for after
+ call map_draw_shadow2
+ pop af
+
+ ld hl, SCRN0
+ ; a = y position
+ call map_request_redraw2
+
ret
; checks the current tile
.db CF_COLLISION, CF_COLLISION
.db 0x00 ; floor
; doors
- .db CF_DOOR, CF_DOOR, CF_DOOR, CF_DOOR
+ .db CF_DOOR | CF_COVERED, CF_DOOR | CF_COVERED, CF_DOOR | CF_COVERED, CF_DOOR | CF_COVERED
; roof
.db CF_COVERED