tiles: added get adjacent tile clearing
authorLukas Krickl <lukas@krickl.dev>
Mon, 10 Nov 2025 12:47:07 +0000 (13:47 +0100)
committerLukas Krickl <lukas@krickl.dev>
Mon, 10 Nov 2025 12:47:07 +0000 (13:47 +0100)
src/defs.s
src/tiles.s
src/wram.s

index d1009bb17a903b5ffe4530d776c0843e183bdaf9..4547f27fac0657875b1494227948013e4286056b 100644 (file)
@@ -5,6 +5,8 @@
 
 #define UI_STATUS_LINE shadow_ui+1
 
+#define TILES_ADJACENT_MAX 8
+
 .def int OAMDMAFN = 0xFF80 
 #define WRAM 0xC000
 #define WRAMLEN 0xFFF
index 31ba935aa1e3606a2849de60ded2d11a3410cadb..a34b7a2b0343124d43a8c5afca1ea5b495b2cb2c 100644 (file)
@@ -83,6 +83,10 @@ tile_update_draw:
        ; inputs:
        ;               de: tile
 tile_update:
+       push de
+       call tile_get_adjacent
+       pop de
+
        ld a, [de] ; load tile type 
        add a, a ; * 2 offset into table
 
@@ -128,6 +132,7 @@ tile_str_table:
        ;       returns:
        ;               bc: actor
 tile_get_actor:
+       ld bc, NULL
        ; TODO:
        ret
        
@@ -138,6 +143,23 @@ tile_get_actor:
        ; also counts the amount of seen types 
        ; in tiles_adjacen_types
 tile_get_adjacent:
+       ; clear adjacent tiles
+       ; stored by previous frame
+       ld hl, tiles_adjacent
+       ld bc, 2 * TILES_ADJACENT_MAX
+       ld de, 0
+       call memset
+
+       ; bc = y/x
+       ld a, [update_tile_y]
+       ld b, a
+       ld a, [update_tile_x]
+       ld c, a
+
+       ld hl, tiles_adjacent
+
+       ; now get all tiles adjacent
+
        ret
 
        ; updates empty tile
index 2a5c9c515d5ad36a4e6ccf25c879e3bf57ad3e34..e2c662ffe66fa5e042d75a2d85a7a5a201507446 100644 (file)
@@ -84,10 +84,7 @@ tiles_end: .adv 0
        ; list of pointers
        ; to all adjacent tiles
        ; set to NULL if no tile is adjacent
-tiles_adjacent: .adv 2 * 8
-       ; a list of adjacent types
-       ; one byte for each TI_* type
-tiles_adjacent_types: .adv TI_SIZE
+tiles_adjacent: .adv 2 * TILES_ADJACENT_MAX
 
 ui_draw_routine: .adv 2