From 41ea39bad8812adb680a1d3616dbaef583242b38 Mon Sep 17 00:00:00 2001 From: Lukas Krickl Date: Sat, 6 Dec 2025 14:12:07 +0100 Subject: [PATCH] map: maps are now 20x14 --- src/actor.s | 4 ++-- src/defs.s | 4 ++-- src/levels.s | 32 ++++++++++++++++++----------- src/map.s | 58 ++++++++++++++++++++++------------------------------ src/tiles.s | 19 +++++++++++++++-- src/wram.s | 4 ++-- 6 files changed, 68 insertions(+), 53 deletions(-) diff --git a/src/actor.s b/src/actor.s index 263d78e..24b35ad 100644 --- a/src/actor.s +++ b/src/actor.s @@ -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 diff --git a/src/defs.s b/src/defs.s index 5bcb6b6..aa9f937 100644 --- a/src/defs.s +++ b/src/defs.s @@ -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 diff --git a/src/levels.s b/src/levels.s index 8d83e55..8a1666d 100644 --- a/src/levels.s +++ b/src/levels.s @@ -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 @@ -14,11 +16,17 @@ 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 diff --git a/src/map.s b/src/map.s index 4667a0a..b4d47d9 100644 --- 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 diff --git a/src/tiles.s b/src/tiles.s index 1288244..9467609 100644 --- a/src/tiles.s +++ b/src/tiles.s @@ -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 + + diff --git a/src/wram.s b/src/wram.s index aa5b221..11b0b4c 100644 --- a/src/wram.s +++ b/src/wram.s @@ -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 -- 2.30.2