l1: changed map layout
authorLukas Krickl <lukas@krickl.dev>
Fri, 19 Dec 2025 11:27:29 +0000 (12:27 +0100)
committerLukas Krickl <lukas@krickl.dev>
Fri, 19 Dec 2025 11:27:29 +0000 (12:27 +0100)
map render: Added some constants for door states instead of using magic numbers.

maps/l1.inc
src/defs.s
src/levels.s
src/map.s
tiles/bank8000.inc
tiles/bank9000.inc

index a41a5b06f2f6c67d09a950093aa026a29cbe680e..48cd84facbf2bb92cc5e9e5e121b4ae16cf5aadb 100644 (file)
@@ -1,17 +1,17 @@
 ; this map was generated by tmx2map.py
 
-.db 0x9, 0xd, 0xc, 0xc, 0xd, 0xd, 0xd, 0xd, 0xd, 0xd, 0xd, 0xd, 0xd, 0xd, 0xd, 0xd, 0xd, 0xd, 0xd, 0x5
-.db 0x3, 0xf, 0xd, 0xd, 0xf, 0xf, 0xf, 0xf, 0xf, 0xf, 0xf, 0xf, 0xf, 0xf, 0xf, 0xf, 0xf, 0xf, 0xf, 0x7
-.db 0x3, 0xf, 0xf, 0xf, 0xf, 0xf, 0xf, 0xf, 0xf, 0xf, 0xf, 0xf, 0xf, 0xf, 0xf, 0xf, 0xf, 0xf, 0xf, 0x7
-.db 0xa, 0xf, 0xf, 0xf, 0xf, 0xf, 0xf, 0xf, 0xf, 0xf, 0xf, 0xf, 0xf, 0xf, 0xf, 0xf, 0xf, 0xf, 0xf, 0x7
-.db 0x9, 0xf, 0xf, 0xf, 0xf, 0xf, 0xf, 0xf, 0xf, 0xf, 0xf, 0xf, 0xf, 0xf, 0xf, 0xf, 0xf, 0xf, 0xf, 0x7
-.db 0x3, 0xf, 0xf, 0xf, 0xf, 0xf, 0xf, 0xf, 0xf, 0xf, 0xf, 0xf, 0xf, 0xf, 0xf, 0xf, 0xf, 0xf, 0xf, 0x7
-.db 0x3, 0xf, 0xf, 0xf, 0xf, 0xf, 0xf, 0xf, 0xf, 0xf, 0xf, 0xf, 0xf, 0xf, 0xf, 0xf, 0xf, 0xf, 0xf, 0x7
-.db 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x0, 0x0
+.db 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0
 
index 8de6270f345225bdfa1716e96d48aeb089c5a8f1..135dbdb6f62774472a2f65081db0b5f8e4c2c623 100644 (file)
        ; to slow step through the map 
        ; update routines
 .de DEBUG_F_ENABLE, 1
+
+       ; map drawing enums
+.se 0
+.de MAP_NO_DOOR, 1
+.de MAP_NEAR_DOOR, 1
+.de MAP_FAR_DOOR, 1
+.de MAP_FURTHEST_DOOR, 1
index a4aae475d55b68f9a5438b30bb1b28e22649b401..4618e1bb7201acba22c73a8210d87c83f912b940 100644 (file)
@@ -14,7 +14,7 @@ l1:
        
        ; l1 actor table
 l1_acts:
-       actdef ACT_T_BAT, 0, 10, 10, 0, 0
+       actdef ACT_T_BAT, 0, 4, 6, 0, 0
        actdef ACT_T_BAT, 0, 0, 2, 0, 0
        .db 0 ; terminate
        
index fc567378f14f60c3d2ad5fe9d7e9bf8daae340ce..811811e57509c25f62f1978e3c1cbb39dab9219c 100644 (file)
--- a/src/map.s
+++ b/src/map.s
@@ -280,30 +280,30 @@ map_get_tile:
        ;                $2: left direction
        ;                $3: right direction
        ; returns:
-       ;               d/e: left/right door state
+       ;               d/e: left/right door state (MAP_NO_DOOR or MAP_NEAR_DOOR)
        ;     a: forward door state
 #macro map_full_draw_door_state
 .beginscope
-       ld d, 0
-       ld e, 0
+       ld d, MAP_NO_DOOR
+       ld e, MAP_NO_DOOR
 
        inc hl ; flags
        ld a, [hl]
        and a, $2
        jp z, @no_left
-               ld d, 
+               ld d, MAP_NEAR_DOOR
 @no_left:
 
        ld a, [hl]
        and a, $3
        jp z, @no_right
-               ld e, 1
+               ld e, MAP_NEAR_DOOR
 @no_right:
 
        ld a, [hl]
        and a, $1
        jp z, @no_forward
-               ld a, 1
+               ld a, MAP_NEAR_DOOR
 @no_forward:
 
        dec hl ; back to tile
@@ -317,6 +317,8 @@ map_get_tile:
        ;               $1: offset from tmp_map_forward (e.g. +2 to write to far left/right door)
        ;               $2: forward value to set
        ;               $3: instruction to run if forward is 1 (e.g. ret, nop)
+       ;       returns:
+       ;               writes MAP_NO_DOOR, MAP_NEAR_DOOR, MAP_FAR_DOOR, MAP_FURTHEST_DOOR to tmp map door table        
 #macro map_full_draw_write_door_state
 .beginscope
        push af
@@ -418,7 +420,7 @@ map_full_draw_count_forward_attributes:
 @north:
        ; write near tile
        map_full_draw_door_state TF_NE, TF_WE, TF_EE
-       map_full_draw_write_door_state 1, 1, ret
+       map_full_draw_write_door_state 1, MAP_NEAR_DOOR, ret
 
        dec b ; move one tile back
        _map_write_nearby_tile 2
@@ -428,18 +430,18 @@ map_full_draw_count_forward_attributes:
 
        ; write far tile
        map_full_draw_door_state TF_NE, TF_WE, TF_EE
-       map_full_draw_write_door_state 3, 2, ret
+       map_full_draw_write_door_state 3, MAP_FAR_DOOR, ret
 
        dec b ; move one tile back
        _map_write_nearby_tile 4
 
        ; write furthest tile
        map_full_draw_door_state TF_NE, TF_WE, TF_EE
-       map_full_draw_write_door_state 5, 3, ret
+       map_full_draw_write_door_state 5, MAP_FURTHEST_DOOR, ret
        ret
 @south:
        map_full_draw_door_state TF_SE, TF_WE, TF_EE
-       map_full_draw_write_door_state 1, 1, ret
+       map_full_draw_write_door_state 1, MAP_NEAR_DOOR, ret
        
        inc b ; move one tile forward
        _map_write_nearby_tile 2
@@ -448,18 +450,18 @@ map_full_draw_count_forward_attributes:
        pop bc
 
        map_full_draw_door_state TF_SE, TF_WE, TF_EE
-       map_full_draw_write_door_state 3, 2, ret
+       map_full_draw_write_door_state 3, MAP_FAR_DOOR, ret
 
        inc b ; move one tile forward
        _map_write_nearby_tile 4
        call map_get_tile
 
        map_full_draw_door_state TF_SE, TF_WE, TF_EE
-       map_full_draw_write_door_state 5, 3, ret
+       map_full_draw_write_door_state 5, MAP_FURTHEST_DOOR, ret
        ret
 @east:
        map_full_draw_door_state TF_EE, TF_NE, TF_SE
-       map_full_draw_write_door_state 1, 1, ret
+       map_full_draw_write_door_state 1, MAP_NEAR_DOOR, ret
 
        inc c ; move one tile east
        _map_write_nearby_tile 2
@@ -468,18 +470,18 @@ map_full_draw_count_forward_attributes:
        pop bc
 
        map_full_draw_door_state TF_EE, TF_NE, TF_SE
-       map_full_draw_write_door_state 3, 3, ret
+       map_full_draw_write_door_state 3, MAP_FAR_DOOR, ret
 
        inc c ; move one tile east
        _map_write_nearby_tile 4
        call map_get_tile
 
        map_full_draw_door_state TF_EE, TF_NE, TF_SE
-       map_full_draw_write_door_state 5, 3, ret
+       map_full_draw_write_door_state 5, MAP_FURTHEST_DOOR, ret
        ret
 @west:
        map_full_draw_door_state TF_WE, TF_SE, TF_NE
-       map_full_draw_write_door_state 1, 1, ret
+       map_full_draw_write_door_state 1, MAP_NEAR_DOOR, ret
 
        dec c ; move one tile west
        _map_write_nearby_tile 2
@@ -488,20 +490,20 @@ map_full_draw_count_forward_attributes:
        pop bc
 
        map_full_draw_door_state TF_WE, TF_SE, TF_NE
-       map_full_draw_write_door_state 3, 2, ret
+       map_full_draw_write_door_state 3, MAP_FAR_DOOR, ret
 
        dec c ; move one tile west
        _map_write_nearby_tile 4
        call map_get_tile
        
        map_full_draw_door_state TF_WE, TF_SE, TF_NE
-       map_full_draw_write_door_state 5, 3, ret
+       map_full_draw_write_door_state 5, MAP_FURTHEST_DOOR, ret
        ret
        
        ; draws near doors
 _map_full_draw_near_doors:
        ld a, [tmp_map_near_left_door]
-       cp a, 1
+       cp a, MAP_NEAR_DOOR
        jr nz, @no_near_left REL
                ld hl, render_buffer + RENDER_BUF_W * 3
                ld de, near_left_door
@@ -511,7 +513,7 @@ _map_full_draw_near_doors:
 @no_near_left:
 
        ld a, [tmp_map_near_right_door]
-       cp a, 1
+       cp a, MAP_NEAR_DOOR
        jr nz, @no_near_right REL
                ld hl, render_buffer + RENDER_BUF_W * 3 + 16
                ld de, near_right_door
@@ -537,7 +539,7 @@ map_full_draw:
        call map_full_draw_count_forward_attributes
 
        ld a, [tmp_map_forward]
-       cp a, 0
+       cp a, MAP_NO_DOOR
        jp z, @short_wall
 
 @far_wall:
@@ -549,7 +551,7 @@ map_full_draw:
 
        ; clear far back door if _forward is > 1
        ld a, [tmp_map_forward]
-       cp a, 2
+       cp a, MAP_FAR_DOOR
        jr c, @no_far_forward_door REL
                ld hl, render_buffer + RENDER_BUF_W * 5 + 8
                ld de, far_center_door
@@ -559,7 +561,7 @@ map_full_draw:
 @no_far_forward_door:
 
        ld a, [tmp_map_far_left_door]
-       cp a, 1
+       cp a, MAP_NEAR_DOOR
        jr nz, @no_far_left_door REL
                ld hl, render_buffer + RENDER_BUF_W * 4 + 4
                ld de, far_left_door
@@ -569,7 +571,7 @@ map_full_draw:
 @no_far_left_door:
 
        ld a, [tmp_map_far_right_door]
-       cp a, 1
+       cp a, MAP_NEAR_DOOR
        jr nz, @no_far_right_door REL
                ld hl, render_buffer + RENDER_BUF_W * 4 + 12
                ld de, far_right_door
index b711d6f90262454c845b2ee9de938ae07f04e62d..62c6464b7487d77e5d24bf06ac192f148f810f23 100644 (file)
 .chr 00000000
 ; tile 96
 .chr 00000000
-.chr 03333330
-.chr 03333330
-.chr 03333330
-.chr 03333330
-.chr 03333330
-.chr 03333330
+.chr 00000000
+.chr 00000000
+.chr 00000000
+.chr 00000000
+.chr 00000000
+.chr 00000000
 .chr 00000000
 ; tile 97
 .chr 00000000
index b711d6f90262454c845b2ee9de938ae07f04e62d..62c6464b7487d77e5d24bf06ac192f148f810f23 100644 (file)
 .chr 00000000
 ; tile 96
 .chr 00000000
-.chr 03333330
-.chr 03333330
-.chr 03333330
-.chr 03333330
-.chr 03333330
-.chr 03333330
+.chr 00000000
+.chr 00000000
+.chr 00000000
+.chr 00000000
+.chr 00000000
+.chr 00000000
 .chr 00000000
 ; tile 97
 .chr 00000000