From: Lukas Krickl Date: Tue, 26 Nov 2024 07:28:59 +0000 (+0100) Subject: Moved animation loading to a macro X-Git-Url: https://git.krickl.dev/?a=commitdiff_plain;h=822cbb88a522cd835e3435ef7bf2143618a33edf;p=gbrg%2F.git Moved animation loading to a macro --- 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