projects
/
gbrg
/
.git
/ commitdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
| commitdiff |
tree
raw
|
patch
| inline |
side by side
(parent:
468d62d
)
map: get_tile now returns a static null tile if oob coordinates are requested
author
Lukas Krickl
<lukas@krickl.dev>
Thu, 27 Nov 2025 12:53:57 +0000
(13:53 +0100)
committer
Lukas Krickl
<lukas@krickl.dev>
Thu, 27 Nov 2025 12:53:57 +0000
(13:53 +0100)
src/map.s
patch
|
blob
|
history
src/tiles.s
patch
|
blob
|
history
diff --git
a/src/map.s
b/src/map.s
index ce2eb49cb141c137a88e7da75c434d43ebab210a..baaa29232cd882ad0fc8f62dc745b361cb48bbf4 100644
(file)
--- a/
src/map.s
+++ b/
src/map.s
@@
-189,6
+189,15
@@
map_draw_tile:
; returns:
; hl: tile
map_get_tile:
+ ; check if out of bounds
+ ld a, b
+ cp a, MAP_H
+ jp nc, @oob_tile
+
+ ld a, c
+ cp a, MAP_W
+ jp nc, @oob_tile
+
ld hl, tiles
ld de, MAP_W * t_size
@@
-215,6
+224,11
@@
map_get_tile:
; hl = tile now
ret
+
+@oob_tile:
+ ; fallback tile
+ ld hl, tile_null
+ ret
; prepares tile draw
; by writing the expected tiles
diff --git
a/src/tiles.s
b/src/tiles.s
index e383c9e79d3de620b2f5a90dd37e57db1a343bdf..230b9332af5f3bbd6dfed50e0a79f5643700bace 100644
(file)
--- a/
src/tiles.s
+++ b/
src/tiles.s
@@
-9,7
+9,10
@@
tile_id_table:
dw tile_grass
dw tile_wall
-
+
+ ; fallback tile
+tile_null:
+ tiledef 0, 0, 0
tile_grass:
tiledef TT_EMPTY, 0, GFX_GRASS