anim: Added setup for movement animation
authorLukas Krickl <lukas@krickl.dev>
Mon, 27 Jan 2025 09:25:36 +0000 (10:25 +0100)
committerLukas Krickl <lukas@krickl.dev>
Mon, 27 Jan 2025 09:25:36 +0000 (10:25 +0100)
src/animation.s
src/defs.s

index 9df3eb3e9da9343eacf59932e67131b8633195a1..ff8359eab1032b67ca1bbcaea0447a141638020b 100644 (file)
@@ -3,6 +3,15 @@
 ; updated
 
 
+  ; finish the current animation 
+  ; and transfer control to the next frame
+  ; input:
+  ;   bc: animation ptr
+anim_finish:
+  xor a, a ; set type to 0
+  ld [bc], a
+  ret
+
   ; animation update calls
   ; inputs for all:
   ;   bc: current animation ptr
@@ -19,8 +28,52 @@ anim_nop:
   ; inputs:
   ;   anim_p0/p1: ptr to y/x position
   ;   anim_p2: direction
-
+  ;   anim_p3: frames of movemnet 
 anim_walk_simple:
+  ; 1) check direction
+  
+  ; bc = anim type 
+  inc bc
+  inc bc 
+  ; bc = p0
+
+  ; load ptr to y/x 
+  inc bc
+  ld a, [bc]
+  ld h, a 
+  inc bc 
+  ld a, [bc]
+  ld l, a
+  ; hl = ptr to y/x
+
+  ; bc = p2
+  ld a, [bc] 
+  
+  ; jump to direction 
+  cp a, NORTH
+  jr z, @north REL
+
+  cp a, SOUTH
+  jr z, @south REL
+
+  cp a, EAST
+  jr z, @east REL
+
+  cp a, WEST
+  jr z, @west REL
+  
+  ; invalid direction PANIC
+  jp panic
+@west:
+  
+  ret
+@east:
+
+  ret
+@north:
+
+  ret
+@south:
   ret
 
 
index 73d0336380a26544c217ae550c6028b8dc3ecd68..9100bdbe6dc420cc54ab0ac003f4d310fefe3646 100644 (file)
 
   ; anim entry struct 
 .se 0
-.de anim_flags, 1
 .de anim_type, 1
+.de anim_flags, 1
 .de anim_p0, 1
 .de anim_p1, 1
 .de anim_p2, 1