From 4b6e78eae18dc6796e7e853058ca3d7c502c380c Mon Sep 17 00:00:00 2001 From: Lukas Krickl Date: Mon, 27 Jan 2025 13:31:16 +0100 Subject: [PATCH] anim: added static animation step variable --- src/animation.s | 20 +++++++++++++++++--- src/defs.s | 1 + 2 files changed, 18 insertions(+), 3 deletions(-) diff --git a/src/animation.s b/src/animation.s index ff8359e..b573d73 100644 --- a/src/animation.s +++ b/src/animation.s @@ -28,15 +28,28 @@ anim_nop: ; inputs: ; anim_p0/p1: ptr to y/x position ; anim_p2: direction - ; anim_p3: frames of movemnet + ; anim_step: frames of movemnet anim_walk_simple: ; 1) check direction ; bc = anim type inc bc - inc bc + ; bc = anim step + push bc ; we need the step ptr again + ld a, [bc] ; a = anim_step + ld d, a ; d = step counter + cp a, 0 + dec bc ; bc = anim type + ; finish animation if step counter is 0 + jp z, anim_finish + + ; go to p0 + inc bc + inc bc + inc bc ; bc = p0 + ; load ptr to y/x inc bc ld a, [bc] @@ -48,7 +61,8 @@ anim_walk_simple: ; bc = p2 ld a, [bc] - + pop bc ; bc = anim_step ptr + ; jump to direction cp a, NORTH jr z, @north REL diff --git a/src/defs.s b/src/defs.s index 9100bdb..3321db4 100644 --- a/src/defs.s +++ b/src/defs.s @@ -208,6 +208,7 @@ ; anim entry struct .se 0 .de anim_type, 1 +.de anim_step, 1 .de anim_flags, 1 .de anim_p0, 1 .de anim_p1, 1 -- 2.30.2