cells: Added additional input to cells
authorLukas Krickl <lukas@krickl.dev>
Sun, 20 Apr 2025 06:16:44 +0000 (08:16 +0200)
committerLukas Krickl <lukas@krickl.dev>
Sun, 20 Apr 2025 06:16:44 +0000 (08:16 +0200)
cells now also get passed the screen ptr to their tile in bc

src/cells.s
src/defs.s
src/simulation.s
src/update.s
src/wram.s

index fe20de10d80914302f8ca4a19c0aafbfbe7411e7..84f8ca228a8e9af29b232a2bdf088b0d0826a777 100644 (file)
@@ -3,6 +3,7 @@
   ; does not call c_st_routine if c_head_offset != 0
   ; inputs:
   ;   de: cell ptr
+  ;   bc: screen ptr 
 cell_update:
   inc de ; de = flags
   ld a, [de] ; a = head offset
index c2b94d4f3b49ca5cd302c298811f745836092740..fe813c4b69f46c3a0c0fb4efd0e45887d6584bc6 100644 (file)
   ; if a c_st_rotuine returns a non-zero value in bc
   ; the rotuine pointed to will be used during the next 
   ; cell update
+  ; additionally bc will point to the current screen 
+  ; pointer for the cell
+  ; inputs:
+  ;   de: cell ptr 
+  ;   bc: screen ptr
 .de c_st_routine, 2 
-
 .de c_size, 0
 
   ; cell type enum
index eb0d4702face9c541d9a3a2bce0ad416575f8cbd..c3a98a907d674e006a07ece86b3f891da3f767c0 100644 (file)
@@ -11,11 +11,19 @@ sim_update:
   ; cells in a single go
   ; later we want a limit 
   ld de, state_cells
+  ld bc, SCRN0 
 @loop:
 
     ; advance to next cell
     .rep i, c_size, 1, inc de
-   
+    inc bc
+
+    push de
+    push bc
+    call cell_update
+    pop bc
+    pop de
+    
     ; check if we need to exit
     ld a, state_cells_end LO
     cp a, e
index 076d2d697865568b0bee6a42b7e345ca166d6a64..2e6c2d5c7d2f0a0f84c948b6adb2411c375dedae 100644 (file)
@@ -9,7 +9,6 @@ update_game:
   ld de, actor_player 
   call st_update
 
-  ; call player_update
   ; call sim_update 
 
   ldnull bc
index 4376b059e89b3ce4bf69f579c6bacc8ed9a20324..e8fbee17a2b3862c8eed92341e54dd4f7e097999 100644 (file)
@@ -68,6 +68,10 @@ r_population: .adv 2
   ; for cell update loop
   ; big endian
 cell_ptr: .adv 2
+  
+  ; cell screen ptr 
+  ; points to tile that this cell owns
+cell_screen_ptr: .adv 2
 
 state_cells: .adv c_size * MAP_SIZE
 state_cells_end: