map: Added far wall rendering
authorLukas Krickl <lukas@krickl.dev>
Fri, 2 Jan 2026 06:21:16 +0000 (07:21 +0100)
committerLukas Krickl <lukas@krickl.dev>
Fri, 2 Jan 2026 06:21:16 +0000 (07:21 +0100)
src/map.s

index 397ea3815c7d866141733183ba854dc3b7340ca3..4fcb633e1bd5867d23dc1dd5a24a5cd0861f1609 100644 (file)
--- a/src/map.s
+++ b/src/map.s
@@ -288,9 +288,9 @@ _dir_vectors_north:
        ; back
        .db 1, 0
        ; left
-       .db 0, 1
-       ; right
        .db 0, -1
+       ; right
+       .db 0, 1
 
 _dir_vectors_south:
        ; forward
@@ -298,9 +298,9 @@ _dir_vectors_south:
        ; back
        .db -1, 0
        ; left
-       .db 0, -1
-       ; right
        .db 0, 1
+       ; right
+       .db 0, -1
 
 _dir_tf_south:
        ; forward
@@ -682,7 +682,9 @@ map_full_draw_far_left:
        ld de, far_left_door
        ld bc, RENDER_BUF_W - 4
        ld a, 5
-       jp tiles_block_copy
+       call tiles_block_copy
+
+       jp map_full_draw_far_left_wall
 @no_door:
        ld hl, render_buffer + RENDER_BUF_W * 4 + 4
        ld de, far_left_wall
@@ -691,6 +693,41 @@ map_full_draw_far_left:
        jp tiles_block_copy
 
 
+       ; draws a far left wall if 
+       ; the far left tile has a forward wall
+       ; otherwise does nothing
+map_full_draw_far_left_wall:
+       ; get left tile
+       ld de, player
+       map_load_march_vec dir_vector_left
+       ; load the march vec, but or it with the forward vec
+       ld a, [dir_vector_forward]
+       or a, d
+       ld d, a
+       ld a, [dir_vector_forward+1]
+       or a, e
+       ld e, a ; d/e = forward + left vector
+
+       ld a, 1 
+       call map_get_tile_march
+       ; hl = tile to the left
+       ld de, t_flags0
+       add hl, de
+       
+       ld b, [hl]
+       ld a, [dir_tf_forward]
+       and a, b
+       ret nz ; bail if door
+
+       ld hl, render_buffer + RENDER_BUF_W * 4 + 4
+       ld de, far_center_left_wall
+       ld bc, RENDER_BUF_W-4
+       ld a, 4
+       call tiles_block_copy
+
+       ret
+
+
        ; draws far right wall or door
 map_full_draw_far_right:
        _map_full_draw_load_far_tile
@@ -709,7 +746,9 @@ map_full_draw_far_right:
        ld de, far_right_door
        ld bc, RENDER_BUF_W - 4
        ld a, 5
-       jp tiles_block_copy
+       call tiles_block_copy
+       
+       jp map_full_draw_far_right_wall
 @no_door:
        ld hl, render_buffer + RENDER_BUF_W * 4 + 12
        ld de, far_right_wall
@@ -717,6 +756,41 @@ map_full_draw_far_right:
        ld a, 5
        jp tiles_block_copy
 
+
+       ; draws a far right wall if 
+       ; the far right tile has a forward wall
+       ; otherwise does nothing
+map_full_draw_far_right_wall:
+       ; get right tile
+       ld de, player
+       map_load_march_vec dir_vector_right
+       ; load the march vec, but or it with the forward vec
+       ld a, [dir_vector_forward]
+       or a, d
+       ld d, a
+       ld a, [dir_vector_forward+1]
+       or a, e
+       ld e, a ; d/e = forward + left vector
+
+       ld a, 1 
+       call map_get_tile_march
+       ; hl = tile to the left
+       ld de, t_flags0
+       add hl, de
+       
+       ld b, [hl]
+       ld a, [dir_tf_forward]
+       and a, b
+       ret nz ; bail if door
+
+       ld hl, render_buffer + RENDER_BUF_W * 4 + 12
+       ld de, far_center_right_wall
+       ld bc, RENDER_BUF_W-4
+       ld a, 4
+       call tiles_block_copy
+
+       ret
+
        
        ; draws a full map copy into the current map view buffer
        ; based on the current location the player is facing