From 822cbb88a522cd835e3435ef7bf2143618a33edf Mon Sep 17 00:00:00 2001 From: Lukas Krickl Date: Tue, 26 Nov 2024 08:28:59 +0100 Subject: [PATCH] Moved animation loading to a macro --- src/actor.s | 26 +++++++++++++++++++------- 1 file changed, 19 insertions(+), 7 deletions(-) diff --git a/src/actor.s b/src/actor.s index 9a32880..fbda9c9 100644 --- a/src/actor.s +++ b/src/actor.s @@ -31,6 +31,24 @@ ld [actor_soam_ptr], a #endmacro + ; loads an animation frame + ; from a table + ; uses hl and a + ; inputs: + ; $1: table + ; $2: max frames (mask) + ; returns: + ; a: the frame +#macro load_anim_frame + ld hl, $1 + ld a, [frame_count] + and a, $2 ; max frames + ld d, 0 + ld e, a + add hl, de ; hl = correct tile index + ld a, [hl] +#endmacro + actor_anim_table_bat: .db BAT_TILE_IDLE1 .db BAT_TILE_IDLE1 @@ -77,13 +95,7 @@ actor_update_bat: @skip: ; load tile to use into tmp - ld hl, actor_anim_table_bat - ld a, [frame_count] - and a, 0b1111 ; even and odd frames - ld d, 0 - ld e, a - add hl, de ; hl = correct tile index - ld a, [hl] + load_anim_frame actor_anim_table_bat, 0b1111 ld [tmp], a ; load oam ptr -- 2.30.2