From: Lukas Krickl Date: Wed, 2 Apr 2025 10:42:50 +0000 (+0200) Subject: cells: stubs for cell updating and management X-Git-Url: https://git.krickl.dev/?a=commitdiff_plain;h=10836b298c7424a8af11cb2e4589d5daabedad79;p=gbrg%2F.git cells: stubs for cell updating and management --- diff --git a/src/cells.s b/src/cells.s index 31f0c6d..450903f 100644 --- a/src/cells.s +++ b/src/cells.s @@ -1,8 +1,34 @@ + ; updates all cells + ; eihter until the end of the + ; end of the cell list is reached + ; or CELLS_MAX_FRAME is reached + ; only head cells count towards the cell update limit + ; increments cell_idx every iteration + ; resets cell_idx to 0 when end of cells is reached +cells_update: + ret + + ; updates a cell + ; does not call c_st_routine if c_head_offset != 0 + ; inputs: + ; de: cell ptr + ; returns: + ; de: next cell ptr +cell_update: + ret + ; default road update state -cell_road_head: +cell_road_update: ldnull bc ret + ; sets up a road cell + ; updates the tiles + ; by pushing tile updates +cell_road_init: + ld bc, cell_road_update + ret + cell_template_road: - c_def C_ROAD, cell_road_head, 0, 0 + c_def C_ROAD, cell_road_init, 0, 0 diff --git a/src/defs.s b/src/defs.s index 05706ff..e128a1d 100644 --- a/src/defs.s +++ b/src/defs.s @@ -40,10 +40,21 @@ .se 0 ; cell type/cell gfx .de c_type, 1 + + ; if c_st_rotuine + ; is unsued (true for all non-head cells) + ; this space can be used by the head cell + ; to store data +.de c_st_data, 0 ; this is the same as st routine, ; but tiles do not have a timer or ; a next flag + ; only head cells have an update routine + ; if a c_st_rotuine returns a non-zero value in bc + ; the rotuine pointed to will be used during the next + ; cell update .de c_st_routine, 2 + .de c_flags, 1 ; offset to head tile for thsi tile ; if offset is 0000 this is the head tile diff --git a/src/simulation.s b/src/simulation.s index e64f959..3e5fb92 100644 --- a/src/simulation.s +++ b/src/simulation.s @@ -1,2 +1,9 @@ + ; updates all cells + ; eihter until the end of the + ; end of the cell list is reached + ; or CELLS_MAX_FRAME is reached + ; only head cells count towards the cell update limit + ; increments cell_idx every iteration + ; resets cell_idx to 0 when end of cells is reached sim_update: ret diff --git a/src/wram.s b/src/wram.s index 9619372..1742b51 100644 --- a/src/wram.s +++ b/src/wram.s @@ -57,6 +57,10 @@ r_stone: .adv 2 r_food: .adv 2 r_population: .adv 2 + ; current cell index + ; for cell update loop +cell_idx: .adv 2 + state_cells: .adv c_size * MAP_SIZE state_cells_end: