From 3d7d835be5e9e69169df64d5d795f032c2e564f7 Mon Sep 17 00:00:00 2001 From: Lukas Krickl Date: Mon, 12 Jan 2026 08:37:00 +0100 Subject: [PATCH] map: Added basic map rendering --- assets | 2 +- src/defs.s | 4 ++++ src/map.s | 14 ++++++++++---- src/player.s | 2 +- src/tiles.s | 4 ++-- tiles/bank8800.inc | 30 +++++++++++++++--------------- tiles/bank9000.inc | 4 ++-- 7 files changed, 35 insertions(+), 25 deletions(-) diff --git a/assets b/assets index 1cd9eb1..fe8d447 160000 --- a/assets +++ b/assets @@ -1 +1 @@ -Subproject commit 1cd9eb176a55f76915cd3a702c5c0c4cbe0ac281 +Subproject commit fe8d4478a5657dba33c4bfc9f715a0e25f9fcc28 diff --git a/src/defs.s b/src/defs.s index b65046e..abfc2ef 100644 --- a/src/defs.s +++ b/src/defs.s @@ -16,6 +16,9 @@ #define STACK_BEGIN 0xDFFF + ; bank number when a tile is in ram (oob) +#define TILE_OOB_BANK 0x09 + ; seed for the rng ; 8 bit signed int #define RAND_MAGIC 0x1B @@ -118,6 +121,7 @@ .se 0 .de TT_NONE, 1 .de TT_WALL, 1 +.de TT_FLOOR, 1 .de TT_DOOR, 1 diff --git a/src/map.s b/src/map.s index 32a56f0..7395094 100644 --- a/src/map.s +++ b/src/map.s @@ -273,6 +273,11 @@ map_set_visible_row: pop bc pop de + ; if the tile is in rom skip it + ld a, h + cp a, TILE_OOB_BANK ; bank number + jr z, @skip REL + ; hl = tile ld a, [hl] ; TODO: do not set uncovered flag here @@ -280,6 +285,7 @@ map_set_visible_row: or a, TF0_VISIBLE | TF0_UNCOVERED ld [hl], a +@skip: ; next tile inc c ; x++ @@ -306,7 +312,7 @@ map_load_view_start_pos: ; returns: ; d: view range (radius*2) map_load_view_range: - ld a, d + ld a, [player_viewradius] add a, a ld d, a ; d = view radius * 2 ret @@ -403,9 +409,9 @@ map_full_draw_row: ; check if visible and a, TF0_VISIBLE ld a, [hl] ; a = tile - jr z, @is_visible REL - ; if not visible set 7th bit - and a, 0b10000000 + jr nz, @is_visible REL + ; if not visible set 6th bit + or a, 0b01000000 @is_visible: jr @done REL @not_uncovered: diff --git a/src/player.s b/src/player.s index 53b9686..8e707a5 100644 --- a/src/player.s +++ b/src/player.s @@ -47,7 +47,7 @@ player_init: call memset ; set default view - ld a, 5 + ld a, 10 ld [player_viewradius], a ret diff --git a/src/tiles.s b/src/tiles.s index 028a258..c395889 100644 --- a/src/tiles.s +++ b/src/tiles.s @@ -9,7 +9,7 @@ tile_wall: tiledef TT_WALL, TF0_WALL, 0, 0 tile_floor: - tiledef TT_NONE, 0, 0, 0 + tiledef TT_FLOOR, 0, 0, 0 tile_door: tiledef TT_DOOR, TF0_WALL, 0, 0 @@ -23,7 +23,7 @@ tile_table: ; map of tile type to gfx ; this is the base tile ; if the tile is not marked as visible it will never be drawn - ; if the tile is marked as visible, but not in view bit 7 will be set to get + ; if the tile is marked as visible, but not in view bit 6 will be set to get ; a different tile id ; the tile id is the top left corner of the tile tile_gfx_table: diff --git a/tiles/bank8800.inc b/tiles/bank8800.inc index 3824300..2f86dd4 100644 --- a/tiles/bank8800.inc +++ b/tiles/bank8800.inc @@ -289,13 +289,13 @@ .chr 00000000 .chr 00000000 ; tile 17 -.chr 00000000 -.chr 00000000 -.chr 00000000 -.chr 00000000 -.chr 00000000 -.chr 00000000 -.chr 00000000 +.chr 11000100 +.chr 30000330 +.chr 30000333 +.chr 03333300 +.chr 03333100 +.chr 10333100 +.chr 10100100 .chr 00000000 .chr 00300300 .chr 10033001 @@ -306,14 +306,14 @@ .chr 00300300 .chr 01000010 ; tile 18 -.chr 00000000 -.chr 00000000 -.chr 00000000 -.chr 00000000 -.chr 00000000 -.chr 00000000 -.chr 00000000 -.chr 00000000 +.chr 00300030 +.chr 00011100 +.chr 00010101 +.chr 01011101 +.chr 01233321 +.chr 01333331 +.chr 00132310 +.chr 00100010 .chr 00333300 .chr 03333030 .chr 00222030 diff --git a/tiles/bank9000.inc b/tiles/bank9000.inc index 408513b..1702d2f 100644 --- a/tiles/bank9000.inc +++ b/tiles/bank9000.inc @@ -603,8 +603,8 @@ .chr 11111111 .chr 11111111 ; tile 67 -.chr 00000000 -.chr 03333330 +.chr 11111111 +.chr 13333331 .chr 31111113 .chr 31111113 .chr 31311113 -- 2.30.2