From e19a3cbb41686dc2982c5f8cfe259ab6e0514bd7 Mon Sep 17 00:00:00 2001 From: Lukas Krickl Date: Fri, 31 Jan 2025 05:36:51 +0100 Subject: [PATCH] animation: Added animation ptr handling --- src/actor.s | 5 +++++ src/animation.s | 30 ++++++++++++++++++++++++++++++ src/mem.s | 1 + src/wram.s | 4 ++++ 4 files changed, 40 insertions(+) diff --git a/src/actor.s b/src/actor.s index a02a9c1..b5036e1 100644 --- a/src/actor.s +++ b/src/actor.s @@ -526,4 +526,9 @@ who_next: ld a, WHO_PLAYER @no_player: ld [who], a + + ; advance some other values + ; related to the next turn starting + call anim_next + ret diff --git a/src/animation.s b/src/animation.s index 6e39ae3..5fc9ea2 100644 --- a/src/animation.s +++ b/src/animation.s @@ -2,6 +2,36 @@ ; each frame the latest animation is ; updated + ; sets up animation ptr +anim_init: + ld hl, anim_table + ld a, l + ld [anim_ptr], a + ld a, h + ld [anim_ptr+1], a + ret + + ; advances animation ptr to + ; its next value +anim_next: + ld a, [who] + cp a, 0 + jp z, anim_init + + ld a, [anim_ptr] + ld l, a + ld a, [anim_ptr+1] + ld h, a + + ld de, anim_size + add hl, de ; hl = next animation ptr + + ld a, l + ld [anim_ptr], a + ld a, h + ld [anim_ptr+1], a + + ret anim_walk_north: ret diff --git a/src/mem.s b/src/mem.s index 7e24aab..df73aa6 100644 --- a/src/mem.s +++ b/src/mem.s @@ -6,6 +6,7 @@ mem_init: call memset call rand_init + call anim_init ; copy shadow oam dma function ld de, shadow_oam_to_oam diff --git a/src/wram.s b/src/wram.s index 992f5e1..2ab803b 100644 --- a/src/wram.s +++ b/src/wram.s @@ -103,6 +103,10 @@ anim_step_x: .adv 1 anim_target_y: .adv 1 anim_target_x: .adv 1 + ; pointing to current animation + ; advanced in who_next + ; l/h ptr +anim_ptr: .adv 2 ; 1 animation buffer for each actor + player anim_table: .adv anim_size * (ACTORS_MAX + 1) -- 2.30.2