; back
.db TF_EE
; left
-.db TF_NE
- ; right
.db TF_SE
+ ; right
+.db TF_NE
_dir_tf_east:
; forward
; back
.db TF_WE
; left
-.db TF_SE
- ; right
.db TF_NE
+ ; right
+.db TF_SE
; gets the direction vector
; for the current direction
; draws a static ceiling from the map buffer
map_full_draw_ceiling:
ld hl, render_buffer
- ld bc, RENDER_BUF_W * 4
- ld d, 0x12
+ ld bc, RENDER_BUF_W * 5
+ ld d, 0x11
; set ceiling tile for 4 rows
jp memset
; draws floor tiles
map_full_draw_floor:
- ld hl, render_buffer + RENDER_BUF_W * 4
- ld bc, RENDER_BUF_W * 10
+ ld hl, render_buffer + RENDER_BUF_W * 5
+ ld bc, RENDER_BUF_W * 9
ld d, 0x27
jp memset
ld e, a
#endmacro
- ; draws the far center wall
- ; either draws a wall or an open space
- ; depending on the door state
-map_full_draw_far_center:
+ ; loads the near tile ahead of player
+ ; returns:
+ ; hl: near tile
+#macro _map_full_draw_load_near_tile
+ ; near is just the current tile, no need for march load
+ ld a, [player+act_pos_y]
+ ld b, a
+ ld a, [player+act_pos_x]
+ ld c, a
+ call map_get_tile
+#endmacro
+
+ ; loads the far tile ahead of player
+ ; returns:
+ ; hl: far tile
+#macro _map_full_draw_load_far_tile
ld de, player
map_load_march_vec dir_vector_forward
ld a, 1
call map_get_tile_march
; hl = tile ahead
+#endmacro
+
+ ; draws the far center wall
+ ; either draws a wall or an open space
+ ; depending on the door state
+map_full_draw_far_center:
+ _map_full_draw_load_far_tile
ld de, t_flags0
add hl, de
jr z, @no_door REL
@door:
- ld hl, render_buffer + RENDER_BUF_W * 4 + 8
+ ld hl, render_buffer + RENDER_BUF_W * 5 + 8
ld de, far_center_door
ld bc, RENDER_BUF_W - 4
ld a, 3
jp tiles_block_copy
@no_door:
- ld hl, render_buffer + RENDER_BUF_W * 4 + 8
+ ld hl, render_buffer + RENDER_BUF_W * 5 + 8
ld de, far_center_wall
ld bc, RENDER_BUF_W - 4
ld a, 3
jp tiles_block_copy
- ; draws a near wall or doo
+ ; draws a near wall or door
map_full_draw_near_center:
- ; near is just the current tile, no need for march load
- ld a, [player+act_pos_y]
- ld b, a
- ld a, [player+act_pos_x]
- ld c, a
- call map_get_tile
+ _map_full_draw_load_near_tile
; hl = tile
ld de, t_flags0
add hl, de
ret
+ ; draws near left wall or door
+map_full_draw_near_left:
+ _map_full_draw_load_near_tile
+ ; hl = tile
+ ld de, t_flags0
+ add hl, de
+
+ ; get forward direction flag
+ ld b, [hl]
+ ld a, [dir_tf_left]
+ and a, b
+
+ jr z, @no_door REL
+@door:
+ ld hl, render_buffer + RENDER_BUF_W * 3
+ ld de, near_left_door
+ ld bc, RENDER_BUF_W - 4
+ ld a, 7
+ jp tiles_block_copy
+@no_door:
+ ld hl, render_buffer + RENDER_BUF_W * 3
+ ld de, near_left_wall
+ ld bc, RENDER_BUF_W - 4
+ ld a, 7
+ jp tiles_block_copy
+
+
+ ; draws near right wall or door
+map_full_draw_near_right:
+ _map_full_draw_load_near_tile
+ ; hl = tile
+ ld de, t_flags0
+ add hl, de
+
+ ; get forward direction flag
+ ld b, [hl]
+ ld a, [dir_tf_right]
+ and a, b
+
+ jr z, @no_door REL
+@door:
+ ld hl, render_buffer + RENDER_BUF_W * 3 + 16
+ ld de, near_right_door
+ ld bc, RENDER_BUF_W - 4
+ ld a, 7
+ jp tiles_block_copy
+@no_door:
+ ld hl, render_buffer + RENDER_BUF_W * 3 + 16
+ ld de, near_right_wall
+ ld bc, RENDER_BUF_W - 4
+ ld a, 7
+ jp tiles_block_copy
+
+
+ ; draws far left wall or door
+map_full_draw_far_left:
+ _map_full_draw_load_far_tile
+ ; hl = tile
+ ld de, t_flags0
+ add hl, de
+
+ ; get forward direction flag
+ ld b, [hl]
+ ld a, [dir_tf_left]
+ and a, b
+
+ jr z, @no_door REL
+@door:
+ ld hl, render_buffer + RENDER_BUF_W * 4 + 4
+ ld de, far_left_door
+ ld bc, RENDER_BUF_W - 4
+ ld a, 5
+ jp tiles_block_copy
+@no_door:
+ ld hl, render_buffer + RENDER_BUF_W * 4 + 4
+ ld de, far_left_wall
+ ld bc, RENDER_BUF_W - 4
+ ld a, 5
+ jp tiles_block_copy
+
+
+ ; draws far right wall or door
+map_full_draw_far_right:
+ _map_full_draw_load_far_tile
+ ; hl = tile
+ ld de, t_flags0
+ add hl, de
+
+ ; get forward direction flag
+ ld b, [hl]
+ ld a, [dir_tf_right]
+ and a, b
+
+ jr z, @no_door REL
+@door:
+ ld hl, render_buffer + RENDER_BUF_W * 4 + 12
+ ld de, far_right_door
+ ld bc, RENDER_BUF_W - 4
+ ld a, 5
+ jp tiles_block_copy
+@no_door:
+ ld hl, render_buffer + RENDER_BUF_W * 4 + 12
+ ld de, far_right_wall
+ ld bc, RENDER_BUF_W - 4
+ ld a, 5
+ jp tiles_block_copy
+
; draws a full map copy into the current map view buffer
; based on the current location the player is facing
; either draw a wall or a door ahead
call map_full_draw_far_center
+ call map_full_draw_far_left
+ call map_full_draw_far_right
; draw near wall or door
call map_full_draw_near_center
+ call map_full_draw_near_left
+ call map_full_draw_near_right
@done: