From: Lukas Krickl Date: Sun, 26 Jan 2025 05:46:28 +0000 (+0100) Subject: animation: Added basic animation update table X-Git-Url: https://git.krickl.dev/?a=commitdiff_plain;h=3497af45199c493847d1de4a4f6bcb18fd12d862;p=gbrg%2F.git animation: Added basic animation update table 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. --- diff --git a/src/animation.s b/src/animation.s index af39d63..48b8368 100644 --- a/src/animation.s +++ b/src/animation.s @@ -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 @@ -10,11 +17,13 @@ ; 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 + diff --git a/src/defs.s b/src/defs.s index d676842..23d1672 100644 --- a/src/defs.s +++ b/src/defs.s @@ -195,3 +195,13 @@ .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 diff --git a/src/wram.s b/src/wram.s index ccbe87e..88558c0 100644 --- a/src/wram.s +++ b/src/wram.s @@ -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