From: Lukas Krickl Date: Mon, 10 Nov 2025 12:47:07 +0000 (+0100) Subject: tiles: added get adjacent tile clearing X-Git-Url: https://git.krickl.dev/?a=commitdiff_plain;h=94425b2d873b2045fab8b7b18912e6948f9333c8;p=gbrg%2F.git tiles: added get adjacent tile clearing --- diff --git a/src/defs.s b/src/defs.s index d1009bb..4547f27 100644 --- a/src/defs.s +++ b/src/defs.s @@ -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 diff --git a/src/tiles.s b/src/tiles.s index 31ba935..a34b7a2 100644 --- a/src/tiles.s +++ b/src/tiles.s @@ -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 diff --git a/src/wram.s b/src/wram.s index 2a5c9c5..e2c662f 100644 --- a/src/wram.s +++ b/src/wram.s @@ -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