map: Added basic map rendering
authorLukas Krickl <lukas@krickl.dev>
Mon, 12 Jan 2026 07:37:00 +0000 (08:37 +0100)
committerLukas Krickl <lukas@krickl.dev>
Mon, 12 Jan 2026 07:37:00 +0000 (08:37 +0100)
assets
src/defs.s
src/map.s
src/player.s
src/tiles.s
tiles/bank8800.inc
tiles/bank9000.inc

diff --git a/assets b/assets
index 1cd9eb176a55f76915cd3a702c5c0c4cbe0ac281..fe8d4478a5657dba33c4bfc9f715a0e25f9fcc28 160000 (submodule)
--- a/assets
+++ b/assets
@@ -1 +1 @@
-Subproject commit 1cd9eb176a55f76915cd3a702c5c0c4cbe0ac281
+Subproject commit fe8d4478a5657dba33c4bfc9f715a0e25f9fcc28
index b65046e7452163d2e8a45526f6762e1c63df70a7..abfc2ef7d7f4a64f4b5556322b691648c46f1ef0 100644 (file)
@@ -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
 .se 0
 .de TT_NONE, 1
 .de TT_WALL, 1
+.de TT_FLOOR, 1
 .de TT_DOOR, 1
 
 
index 32a56f0a212e48caf30e73bbf0c0e9d90829e932..739509449dac92d0a0538f718dd89122a9b08827 100644 (file)
--- 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:
index 53b9686d2fa4468bbfbf2c299c8dbbfa554043bb..8e707a5277ee29a12d5996b3c6afec8c91e50a64 100644 (file)
@@ -47,7 +47,7 @@ player_init:
        call memset
 
        ; set default view
-       ld a, 5
+       ld a, 10
        ld [player_viewradius], a
        
        ret
index 028a2581e9f070fe8e28ebe6df828d7c4dedbd50..c395889c2ddd76da8270d242022a147e1c790d18 100644 (file)
@@ -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:
index 38243002adefbc9787133acc08cb8e9b5866d99c..2f86dd4392b1ce32115b3f9d866bbb31507d6376 100644 (file)
 .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
 .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
index 408513b376eccf5cec74c649f432e80f97e03af4..1702d2f5fba5ed3589fea5a59b97e780d1bc55bd 100644 (file)
 .chr 11111111
 .chr 11111111
 ; tile 67
-.chr 00000000
-.chr 03333330
+.chr 11111111
+.chr 13333331
 .chr 31111113
 .chr 31111113
 .chr 31311113