-Subproject commit 1cd9eb176a55f76915cd3a702c5c0c4cbe0ac281
+Subproject commit fe8d4478a5657dba33c4bfc9f715a0e25f9fcc28
#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
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
or a, TF0_VISIBLE | TF0_UNCOVERED
ld [hl], a
+@skip:
; next tile
inc c ; x++
; 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
; 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:
call memset
; set default view
- ld a, 5
+ ld a, 10
ld [player_viewradius], a
ret
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
; 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:
.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
.chr 11111111
.chr 11111111
; tile 67
-.chr 00000000
-.chr 03333330
+.chr 11111111
+.chr 13333331
.chr 31111113
.chr 31111113
.chr 31311113