animation: added basic setup for new animation system
authorLukas Krickl <lukas@krickl.dev>
Sun, 26 Jan 2025 17:53:00 +0000 (18:53 +0100)
committerLukas Krickl <lukas@krickl.dev>
Sun, 26 Jan 2025 17:53:00 +0000 (18:53 +0100)
src/animation.s
src/defs.s
src/wram.s

index 704ba67c850bd2d339dbf28f8dc2390c524b88b5..7f42acae5b7fde89f7a688f03059a4438ec75aba 100644 (file)
@@ -2,13 +2,39 @@
 ; each frame the latest animation is 
 ; updated
 
+
+  ; animation update calls
+  ; inputs for all:
+  ;   bc: current animation ptr
 animation_table:
   dw anim_nop
-
+  dw anim_walk_up
+  dw anim_walk_down
+  dw anim_walk_left
+  dw anim_walk_right
+  
+  ; empty animation used as default value 
 anim_nop:
   ret
 
 
+  ; anim walk_<direction>
+  ; inputs:
+  ;   anim_p0/p1: ptr to y/x position
+
+anim_walk_up:
+  ret
+
+anim_walk_right:
+  ret
+
+anim_walk_left:
+  ret
+
+anim_walk_down:
+  ret
+
+
   ; updates the current animation
   ; an animation is a simple pointer
   ; to an update function
@@ -17,12 +43,14 @@ anim_nop:
   ; to set itself to 0000 when the animation is finisehd 
   ; this is how anim_finished performs its check
 anim_update:
-  ld a, [curr_anim_flags]
+  ld hl, curr_anim ; hl = anim_flags
+  ld a, [hl+] ; a = flag
   and a, ANIM_FREADY
   ret z
 
+  ld a, [hl]
   ld hl, animation_table
-  ld a, [curr_anim_type]
+  ld bc, curr_anim 
   call call_tbl
 
   ret
index 4dfaf442185ab131cfc59c4662e0a8444afccb5d..dc30b06bd9c5105cdc2b78d6219bd80f28f861dd 100644 (file)
 ; animation table entries 
 .se 0
 .de ANIM_TNOP, 1
+.de ANIM_TWALK_UP, 1
+.de ANIM_TWALK_DOWN, 1
+.de ANIM_TWALK_LEFT, 1
+.de ANIM_TWALK_RIGHT, 1
 
   ; anim entry struct 
 .se 0
 .de anim_flags, 1
 .de anim_type, 1
+.de anim_p0, 1
+.de anim_p1, 1
+.de anim_p2, 1
+.de anim_p3, 1 
+.de anim_size, 0
index 2264b6a91cb47a9a38c7486d3a2b3092997d2cc5..9c76d17cfafaa776236b37430e5313478eff22b2 100644 (file)
@@ -97,12 +97,7 @@ anim_step_x: .adv 1
 anim_target_y: .adv 1
 anim_target_x: .adv 1
 
-  ; animation flags
-  ; ANIM_READY is set if the animation can play
-curr_anim_flags: .adv 1
-  ; animation table index 
-curr_anim_type: .adv 2
-
+curr_anim: .adv anim_size
 
   ; collision tile tmp values  
 ct_poy: .adv 1