animation: Added basic animation update table
authorLukas Krickl <lukas@krickl.dev>
Sun, 26 Jan 2025 05:46:28 +0000 (06:46 +0100)
committerLukas Krickl <lukas@krickl.dev>
Sun, 26 Jan 2025 05:46:28 +0000 (06:46 +0100)
This will limit us to 127 animations but I think this will be
plenty for now. If there is every a point where the table
might run out we might need to introduce a new system.

src/animation.s
src/defs.s
src/wram.s

index af39d6326ba3f9dc8b4ce5c7d3c2bbfbdff39d16..48b8368656aab490ad7ed1eaa900343dba332994 100644 (file)
@@ -2,6 +2,13 @@
 ; each frame the latest animation is 
 ; updated
 
+animation_table:
+  dw anim_nop
+
+anim_nop:
+  ret
+
+
   ; updates the current animation
   ; an animation is a simple pointer
   ; to an update function
   ; to set itself to 0000 when the animation is finisehd 
   ; this is how anim_finished performs its check
 anim_update:
-  ret
+  ld a, [anim_flags]
+  and a, ANIM_FREADY
+  ret z
+
+  ld hl, animation_table
+  ld a, [anim_update_entry]
+  call call_tbl
 
-  ; checks if the current animation is finished
-  ; returns:
-  ;   a: 0 -> animation playing
-  ;   a: 1 -> animation finished 
-anim_finished:
   ret
+
index d676842b4a5941e53886499de51f273817cee007..23d1672edfa1278a18b0cd2ffe9cab1266f2965a 100644 (file)
 .de GM_PAUSE, 1
 .de GAME_OVER, 1
 
+
+  ; animation flags enum 
+.se 1
+  ; set if the animation is ready 
+  ; to be played 
+.de ANIM_FREADY, 1
+
+; animation table entries 
+.se 0
+.de ANIM_TNOP, 1
index ccbe87ed616f9470520db0f0ed1ce9bb6e9fb3c1..88558c000fea8a80235cd4b6bae1636fbada46af 100644 (file)
@@ -97,6 +97,13 @@ 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
+anim_flags: .adv 1
+  ; animation table index 
+anim_update_entry: .adv 2
+
+
   ; collision tile tmp values  
 ct_poy: .adv 1
 ct_pox: .adv 1