map: maps are now 20x14
authorLukas Krickl <lukas@krickl.dev>
Sat, 6 Dec 2025 13:12:07 +0000 (14:12 +0100)
committerLukas Krickl <lukas@krickl.dev>
Sat, 6 Dec 2025 13:12:07 +0000 (14:12 +0100)
src/actor.s
src/defs.s
src/levels.s
src/map.s
src/tiles.s
src/wram.s

index 263d78e65791a6d87abefd6b753804c6d406a9d3..24b35adae7b31ae988927151d772f52a8749b956 100644 (file)
@@ -119,8 +119,8 @@ act_test_tile_collision:
        ld a, c
        add a, $3
        ld c, a
-       div16 b
-       div16 c
+       div8 b
+       div8 c
 
        call map_get_tile
        ld de, t_flags
index 5bcb6b672606cbd3dbc48ba6e0e72dd7598573a3..aa9f937655497b4dfd3d8879751c1ec60af313ee 100644 (file)
@@ -27,8 +27,8 @@
 #define UI_TILE_HEIGHT 4
        
        ; player position offset to get center of tile
-#define MAP_W 10
-#define MAP_H 8
+#define MAP_W 20
+#define MAP_H 14
 #define MAP_TILES (MAP_W * MAP_H)
 
   ; actor type enum
index 8d83e55bc1eb98f1384896373ac1d5e9cebdf288..8a1666d030017d6da6e9573a09b4f094af93ede1 100644 (file)
@@ -1,8 +1,10 @@
        
-       ; tile grass
-.def int TGS = TT_EMPTY
-.def int TWL = TT_WALL
-
+       ; default tile id table
+       ; 00: empty
+       ; 01: wall up left
+       ;       02: wall up right
+       ;       03: wall down left
+       ;       04: wall down right
 
        ; level definitions
        ; levels always have a header
 
 l1:
        mapdef 0, map_r_nop, 0, 0, bank8000, bank8800, bank8C00, bank9000, tile_id_table
-       .db TWL, TGS, TGS, TGS, TGS, TGS, TGS, TGS, TGS, TGS
-       .db TGS, TGS, TGS, TGS, TGS, TGS, TGS, TGS, TGS, TGS
-       .db TGS, TGS, TGS, TGS, TGS, TGS, TGS, TGS, TGS, TGS
-       .db TGS, TGS, TGS, TWL, TWL, TWL, TGS, TGS, TGS, TGS
-       .db TGS, TGS, TGS, TGS, TGS, TGS, TGS, TGS, TGS, TGS
-       .db TGS, TGS, TGS, TGS, TGS, TGS, TGS, TGS, TGS, TGS
-       .db TGS, TGS, TGS, TGS, TGS, TGS, TGS, TGS, TGS, TWL
-       .db TGS, TGS, TGS, TGS, TGS, TGS, TGS, TGS, TGS, TWL
+       .db 01, 02, 00, 00, 00, 00, 00, 00, 00, 00, 00, 00, 00, 00, 00, 00, 00, 00, 00, 00 
+       .db 03, 04, 00, 00, 00, 00, 00, 00, 00, 00, 00, 00, 00, 00, 00, 00, 00, 00, 00, 00 
+       .db 00, 00, 00, 00, 00, 00, 00, 00, 00, 00, 00, 00, 00, 00, 00, 00, 00, 00, 00, 00 
+       .db 00, 00, 00, 00, 00, 00, 00, 00, 00, 00, 00, 00, 00, 00, 00, 00, 00, 00, 00, 00 
+       .db 00, 00, 00, 00, 00, 00, 00, 00, 00, 00, 00, 00, 00, 00, 00, 00, 00, 00, 00, 00 
+       .db 00, 00, 00, 00, 00, 00, 00, 00, 00, 00, 00, 00, 00, 00, 00, 00, 00, 00, 00, 00 
+       .db 00, 00, 00, 00, 00, 00, 00, 01, 02, 01, 02, 00, 00, 00, 00, 00, 00, 00, 00, 00 
+       .db 00, 00, 00, 00, 00, 00, 00, 03, 04, 03, 04, 00, 00, 00, 00, 00, 00, 00, 00, 00 
+       .db 00, 00, 00, 00, 00, 00, 00, 00, 00, 00, 00, 00, 00, 00, 00, 00, 00, 00, 00, 00 
+       .db 00, 00, 00, 00, 00, 00, 00, 00, 00, 00, 00, 00, 00, 00, 00, 00, 00, 00, 00, 00 
+       .db 00, 00, 00, 00, 00, 00, 00, 00, 00, 00, 00, 00, 00, 00, 00, 00, 00, 00, 00, 00 
+       .db 00, 00, 00, 00, 00, 00, 00, 00, 00, 00, 00, 00, 00, 00, 00, 00, 00, 00, 00, 00 
+       .db 00, 00, 00, 00, 00, 00, 00, 00, 00, 00, 00, 00, 00, 00, 00, 00, 00, 00, 00, 00
+       .db 00, 00, 00, 00, 00, 00, 00, 00, 00, 00, 00, 00, 00, 00, 00, 00, 00, 00, 01, 02
index 4667a0ac11d1e3d94a0e6975d109bbb4d014b805..b4d47d9cd4bddb8c323125dd3cac26844da4d787 100644 (file)
--- a/src/map.s
+++ b/src/map.s
@@ -175,24 +175,7 @@ map_draw_tile:
 
        ld de, update_tile_to_draw
        
-       ; draw 4 tiles
-       ld a, [de]
-       inc de
-       ld [hl+], a
-       
-       ld a, [de]
-       inc de
-       ld [hl], a
-
-       ; next row
-       ; next row 
-       ld bc, ((MAP_W * 2) + 12) - 1
-       add hl, bc
-
-       ld a, [de]
-       inc de
-       ld [hl+], a
-
+       ; draw 1 tile
        ld a, [de]
        inc de
        ld [hl], a
@@ -251,7 +234,7 @@ map_get_tile:
        ; inputs:
        ;               b/c: y/x position
        ;       returns:
-       ;               update_tile_to_draw: 4 bytes of new tile data
+       ;               update_tile_to_draw: 1 bytes of new tile data
        ;               upte_tile_vram: ptr to vram
 map_draw_tile_prep:
        ; find tile to draw
@@ -276,7 +259,7 @@ map_draw_tile_prep:
        ld h, a
        ld a, [map_vram_tl+1]
        ld l, a
-       ld de, ((MAP_W * 2) + 12) * 2 ; * 4 because tiles are 8x8 
+       ld de, ((MAP_W) + 12) ; one row
        
        ; skip y loop if b is 0
        ld a, b
@@ -291,7 +274,6 @@ map_draw_tile_prep:
 
        ld d, 0
        ld a, c
-       add a, a ; * 2 because tiles are 8x8
        ld e, a
        add hl, de ; hl = SCRN location
 
@@ -308,17 +290,7 @@ map_draw_tile_prep:
        ; a = start tile
        pop af 
 
-       ; draw 2x2 tile
-       ld [hl+], a
-       inc a
-       ld [hl+], a
-
-       
-       ; move down one tile row as well
-       add a, 15
-
-       ld [hl+], a
-       inc a
+       ; draw 1 tile
        ld [hl], a
 
        ret
@@ -333,7 +305,7 @@ map_draw_tile_prep:
        inc c
 #endmacro
 
-       ; draws 16 tiles
+       ; draws a row of tiles
        ; inputs:
        ;               b: y position
 map_draw_row:  
@@ -348,6 +320,18 @@ map_draw_row:
        map_draw_row_inc_c
        map_draw_row_inc_c
 
+       map_draw_row_inc_c
+       map_draw_row_inc_c
+       map_draw_row_inc_c
+       map_draw_row_inc_c
+
+       map_draw_row_inc_c
+       map_draw_row_inc_c
+       map_draw_row_inc_c
+       map_draw_row_inc_c
+
+       map_draw_row_inc_c
+       map_draw_row_inc_c
        map_draw_row_inc_c
        map_draw_row_inc_c
 
@@ -373,6 +357,14 @@ map_full_draw:
        map_full_draw_inc_b
        map_full_draw_inc_b
 
+       map_full_draw_inc_b
+       map_full_draw_inc_b
+       map_full_draw_inc_b
+       map_full_draw_inc_b
+
+       map_full_draw_inc_b
+       map_full_draw_inc_b
+
        ret
        
        ; nop map rotuine
index 1288244ca57b12996d8e623b1834a23f3f843e6b..9467609bacde19eb40b8e89bacba7827716bf2ef 100644 (file)
@@ -8,7 +8,10 @@
        ; to tile presets (tile index)
 tile_id_table:
        dw tile_grass
-       dw tile_wall
+       dw tile_wall_tl
+       dw tile_wall_tr
+       dw tile_wall_bl
+       dw tile_wall_br
        
        ; fallback tile 
 tile_null:
@@ -17,5 +20,17 @@ tile_null:
 tile_grass:
        tiledef TT_EMPTY, 0, 0, GFX_GRASS
 
-tile_wall:
+
+tile_wall_tr:
+       tiledef TT_WALL, TF_WALL, 0, GFX_WALL+1
+
+tile_wall_tl:
        tiledef TT_WALL, TF_WALL, 0, GFX_WALL
+
+tile_wall_bl:
+       tiledef TT_WALL, TF_WALL, 0, GFX_WALL+16
+
+tile_wall_br:
+       tiledef TT_WALL, TF_WALL, 0, GFX_WALL+17
+
+
index aa5b2210eecc9a783c229e8c71ea3f98f999816e..11b0b4cc7f90188421bc4334a6809aac73ceac09 100644 (file)
@@ -108,10 +108,10 @@ col_direction: .adv 2
 col_prev_pos: .adv 2
        
        
-       ; space for 4 tile ids
+       ; space for 1 tile id
        ; that represent the current tile
        ; this gets drawn during the next blank
-update_tile_to_draw: .adv 4
+update_tile_to_draw: .adv 1
        ; ptr to vram for the next update tile
 update_tile_vram: .adv 2