From 6416a20022d36eec09c6e4dccd43d7e813ec796b Mon Sep 17 00:00:00 2001 From: Lukas Krickl Date: Mon, 27 Jan 2025 10:25:36 +0100 Subject: [PATCH] anim: Added setup for movement animation --- src/animation.s | 55 ++++++++++++++++++++++++++++++++++++++++++++++++- src/defs.s | 2 +- 2 files changed, 55 insertions(+), 2 deletions(-) diff --git a/src/animation.s b/src/animation.s index 9df3eb3..ff8359e 100644 --- a/src/animation.s +++ b/src/animation.s @@ -3,6 +3,15 @@ ; updated + ; finish the current animation + ; and transfer control to the next frame + ; input: + ; bc: animation ptr +anim_finish: + xor a, a ; set type to 0 + ld [bc], a + ret + ; animation update calls ; inputs for all: ; bc: current animation ptr @@ -19,8 +28,52 @@ anim_nop: ; inputs: ; anim_p0/p1: ptr to y/x position ; anim_p2: direction - + ; anim_p3: frames of movemnet anim_walk_simple: + ; 1) check direction + + ; bc = anim type + inc bc + inc bc + ; bc = p0 + + ; load ptr to y/x + inc bc + ld a, [bc] + ld h, a + inc bc + ld a, [bc] + ld l, a + ; hl = ptr to y/x + + ; bc = p2 + ld a, [bc] + + ; jump to direction + cp a, NORTH + jr z, @north REL + + cp a, SOUTH + jr z, @south REL + + cp a, EAST + jr z, @east REL + + cp a, WEST + jr z, @west REL + + ; invalid direction PANIC + jp panic +@west: + + ret +@east: + + ret +@north: + + ret +@south: ret diff --git a/src/defs.s b/src/defs.s index 73d0336..9100bdb 100644 --- a/src/defs.s +++ b/src/defs.s @@ -207,8 +207,8 @@ ; anim entry struct .se 0 -.de anim_flags, 1 .de anim_type, 1 +.de anim_flags, 1 .de anim_p0, 1 .de anim_p1, 1 .de anim_p2, 1 -- 2.30.2