anim: added static animation step variable
authorLukas Krickl <lukas@krickl.dev>
Mon, 27 Jan 2025 12:31:16 +0000 (13:31 +0100)
committerLukas Krickl <lukas@krickl.dev>
Mon, 27 Jan 2025 12:31:16 +0000 (13:31 +0100)
src/animation.s
src/defs.s

index ff8359eab1032b67ca1bbcaea0447a141638020b..b573d7381c250f1f86855ca3ee42ff70d6cdc4e6 100644 (file)
@@ -28,15 +28,28 @@ anim_nop:
   ; inputs:
   ;   anim_p0/p1: ptr to y/x position
   ;   anim_p2: direction
-  ;   anim_p3: frames of movemnet 
+  ;   anim_step: frames of movemnet 
 anim_walk_simple:
   ; 1) check direction
   
   ; bc = anim type 
   inc bc
-  inc bc 
+  ; bc = anim step
+  push bc ; we need the step ptr again 
+  ld a, [bc] ; a = anim_step
+  ld d, a ; d = step counter
+  cp a, 0
+  dec bc ; bc = anim type
+  ; finish animation if step counter is 0
+  jp z, anim_finish 
+
+  ; go to p0
+  inc bc
+  inc bc
+  inc bc
   ; bc = p0
 
+
   ; load ptr to y/x 
   inc bc
   ld a, [bc]
@@ -48,7 +61,8 @@ anim_walk_simple:
 
   ; bc = p2
   ld a, [bc] 
-  
+  pop bc ; bc = anim_step ptr
+
   ; jump to direction 
   cp a, NORTH
   jr z, @north REL
index 9100bdbe6dc420cc54ab0ac003f4d310fefe3646..3321db468ed549c8b04c6d4541ce8fee3aed8072 100644 (file)
   ; anim entry struct 
 .se 0
 .de anim_type, 1
+.de anim_step, 1
 .de anim_flags, 1
 .de anim_p0, 1
 .de anim_p1, 1