unit: Added move reset function
authorLukas Krickl <lukas@krickl.dev>
Sun, 18 May 2025 18:29:55 +0000 (20:29 +0200)
committerLukas Krickl <lukas@krickl.dev>
Sun, 18 May 2025 18:29:55 +0000 (20:29 +0200)
src/unit.s

index 302accb7a4a5f3ebf682bf3a329a75614609f621..90d949d5c582436f44541a4a8eceb16018db7efb 100644 (file)
@@ -427,8 +427,26 @@ unit_next:
   jp @again
 
   ; resets all moves
-  ; of all actors un p0 and p1_unts
+  ; of all actors in p0 and p1_unts
 unit_reset_all_moves:
+  ld b, UNITS_MAX * PLAYERS 
+  ld hl, p0_units
+@loop:
+    push hl 
+    ld de, act_moves+1
+    add hl, de ; hl = act_moves_max
+
+    ld a, [hl]
+    dec hl ; hl = current moves
+    ld [hl], a ; moves are now reset
+
+    pop hl
+    ld de, act_size
+    add hl, de ; move to next act
+
+    dec b
+  jr z, @loop REL
+
   ret