maps: rendering now works as before
authorLukas Krickl <lukas@krickl.dev>
Thu, 1 Jan 2026 16:05:59 +0000 (17:05 +0100)
committerLukas Krickl <lukas@krickl.dev>
Thu, 1 Jan 2026 16:05:59 +0000 (17:05 +0100)
actors can still be seen and attacked through walls.

makefile
maps/far_left_wall.inc [new file with mode: 0644]
maps/far_right_wall.inc [new file with mode: 0644]
maps/near_left_wall.inc [new file with mode: 0644]
maps/near_right_wall.inc [new file with mode: 0644]
src/map.s
src/tiles.s

index 37e45fbd55ad4fd6ac2dee7d3266ca35c9460d34..8956187e2a19a62f3518fef45007943d5aee5f6b 100644 (file)
--- a/makefile
+++ b/makefile
@@ -35,3 +35,9 @@ maps:
        ./tools/tmx2map.py assets/maps/near_center_wall_left.tmx 1 > maps/near_center_wall_left.inc 
        ./tools/tmx2map.py assets/maps/near_center_wall_middle.tmx 1 > maps/near_center_wall_middle.inc 
        ./tools/tmx2map.py assets/maps/near_center_wall_right.tmx 1 > maps/near_center_wall_right.inc 
+       
+       ./tools/tmx2map.py assets/maps/near_left_wall.tmx 1 > maps/near_left_wall.inc 
+       ./tools/tmx2map.py assets/maps/near_right_wall.tmx 1 > maps/near_right_wall.inc 
+
+       ./tools/tmx2map.py assets/maps/far_left_wall.tmx 1 > maps/far_left_wall.inc 
+       ./tools/tmx2map.py assets/maps/far_right_wall.tmx 1 > maps/far_right_wall.inc 
diff --git a/maps/far_left_wall.inc b/maps/far_left_wall.inc
new file mode 100644 (file)
index 0000000..047e48a
--- /dev/null
@@ -0,0 +1,4 @@
+; this map was generated by tmx2map.py
+
+.db 0x0, 0x1, 0x2, 0x3, 0x10, 0x12, 0x12, 0x13, 0x10, 0x12, 0x12, 0x12, 0x10, 0x12, 0x12, 0x23, 0x30, 0x31, 0x32, 0x33
+
diff --git a/maps/far_right_wall.inc b/maps/far_right_wall.inc
new file mode 100644 (file)
index 0000000..34d17d4
--- /dev/null
@@ -0,0 +1,4 @@
+; this map was generated by tmx2map.py
+
+.db 0x4, 0x5, 0x6, 0x7, 0x14, 0x12, 0x12, 0x20, 0x12, 0x12, 0x12, 0x20, 0x24, 0x12, 0x12, 0x20, 0x34, 0x35, 0x36, 0x37
+
diff --git a/maps/near_left_wall.inc b/maps/near_left_wall.inc
new file mode 100644 (file)
index 0000000..aeb8543
--- /dev/null
@@ -0,0 +1,5 @@
+; this map was generated by tmx2map.py
+
+.db 0x0, 0x1, 0x2, 0x3, 0x10, 0x12, 0x12, 0x13, 0x10, 0x12, 0x12, 0x12, 0x10, 0x12, 0x12, 0x12, 0x10, 0x12, 0x12, 0x12
+.db 0x10, 0x12, 0x12, 0x23, 0x30, 0x31, 0x32, 0x33
+
diff --git a/maps/near_right_wall.inc b/maps/near_right_wall.inc
new file mode 100644 (file)
index 0000000..a58b7be
--- /dev/null
@@ -0,0 +1,5 @@
+; this map was generated by tmx2map.py
+
+.db 0x4, 0x5, 0x6, 0x7, 0x14, 0x12, 0x12, 0x20, 0x12, 0x12, 0x12, 0x20, 0x12, 0x12, 0x12, 0x20, 0x12, 0x12, 0x12, 0x20
+.db 0x24, 0x12, 0x12, 0x20, 0x34, 0x35, 0x36, 0x37
+
index 3c81ec19ba19b6b0b4f9c21399115b2ab73f2d66..a474d3514adee874ceefa5176eea32da5759ef23 100644 (file)
--- a/src/map.s
+++ b/src/map.s
@@ -328,9 +328,9 @@ _dir_tf_west:
        ; back
 .db TF_EE
        ; left
-.db TF_NE
-       ; right
 .db TF_SE
+       ; right
+.db TF_NE
 
 _dir_tf_east:
        ; forward
@@ -338,9 +338,9 @@ _dir_tf_east:
        ; back
 .db TF_WE
        ; left
-.db TF_SE
-       ; right
 .db TF_NE
+       ; right
+.db TF_SE
 
        ; gets the direction vector
        ; for the current direction
@@ -407,15 +407,15 @@ map_get_dir_vectors:
        ; 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
        
@@ -465,15 +465,34 @@ map_get_tile_march:
        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
 
@@ -484,27 +503,22 @@ map_full_draw_far_center:
 
        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
@@ -538,6 +552,113 @@ map_full_draw_near_center:
 
        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
@@ -561,9 +682,13 @@ map_full_draw:
        
        ; 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:
index d4abb58e80d0dda493f70d7c907e7d49eddf64ff..2a18d2c91edd1594aed43c1c6da420ed1dec4e19 100644 (file)
@@ -47,6 +47,22 @@ near_center_wall_middle:
 near_center_wall_right:
 #include "near_center_wall_right.inc"
 
+       ; 4x7 tiles
+near_left_wall:
+#include "near_left_wall.inc"
+
+       ; 4x7 tiles
+near_right_wall:
+#include "near_right_wall.inc"
+       
+       ; 4x5 tiles
+far_left_wall:
+#include "far_left_wall.inc"
+
+       ; 4x5 tiles
+far_right_wall:
+#include "far_right_wall.inc"
+
        ; copies a row of tiles
        ; from a linear buffer into a new block
        ; blocks must be 4 tiles wide