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.
; 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
+
.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
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