From: Lukas Krickl Date: Wed, 5 Nov 2025 04:34:51 +0000 (+0100) Subject: tiles: wip added tile update logic X-Git-Url: https://git.krickl.dev/?a=commitdiff_plain;h=4faffc24005b9b5f91ac207e11dfcb1cbb74ca5d;p=gbrg%2F.git tiles: wip added tile update logic --- diff --git a/src/map.s b/src/map.s index f04823e..d77bc24 100644 --- a/src/map.s +++ b/src/map.s @@ -33,6 +33,9 @@ map_load: call player_init call ui_init + ld de, tiles + call tile_next_set + ret ; loads a tileset diff --git a/src/tiles.s b/src/tiles.s index b87ac05..3a2436c 100644 --- a/src/tiles.s +++ b/src/tiles.s @@ -4,14 +4,51 @@ #define GFX_PHIVE 0x62 #define GFX_EHIVE 0x4A #define GFX_FOOD 0x03 + + + ; inits the next tile + ; inputs: + ; de: next tile +tile_next_set: + ld a, d + ld [next_update_tile], a + ld a, e + ld [next_update_tile+1], a + ret + + ; updates the next tile + ; in the queue + ; inputs: + ; next_update_tile + ; sets next_update_tile to next tile + ; wraps to first tile if end is reached +tile_next_update: + ld a, [next_update_tile] + ld d, a + ld a, [next_update_tile+1] + ld e, a + push de + call tile_update + pop de + + ; next tile + ld hl, t_size + add hl, de + push hl + pop de + ; TODO: wrap back to start + call tile_next_set + + ret + ; updates a tile with its ; routine ; inputs: ; de: tile tile_update: ret - + ; table of update routines ; for each tile tile_update_table: diff --git a/src/update.s b/src/update.s index a5cf3d1..7e399f7 100644 --- a/src/update.s +++ b/src/update.s @@ -15,6 +15,8 @@ update_game: call enemy_update + call tile_next_update + call ui_update