cells: stubs for cell updating and management
authorLukas Krickl <lukas@krickl.dev>
Wed, 2 Apr 2025 10:42:50 +0000 (12:42 +0200)
committerLukas Krickl <lukas@krickl.dev>
Wed, 2 Apr 2025 10:42:50 +0000 (12:42 +0200)
src/cells.s
src/defs.s
src/simulation.s
src/wram.s

index 31f0c6d700a80ffbb2f19f6432eaac93f447682b..450903f8815dd6aa53603651747f49ddd926950e 100644 (file)
@@ -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
index 05706ffbfd287aad606eea0a95c33ba41265b693..e128a1d1955dfc46ab947605f17a9570326a68f0 100644 (file)
 .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 
index e64f9595da1d059a7a1d30e09b461091a5e9dccd..3e5fb92e49bc482a8485dd180b366a0dac7c795d 100644 (file)
@@ -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
index 96193722831aa58089b1a0deccf0521dcfa14e16..1742b51c9c295ad63e51531fd933bd3aa5964f7b 100644 (file)
@@ -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: