From b842a18928d6c9819541ae3528ebcbe3a4988503 Mon Sep 17 00:00:00 2001 From: Lukas Krickl Date: Sat, 13 Sep 2025 05:52:30 +0200 Subject: [PATCH] animations: Added stub for animation switching --- src/animation.s | 43 +++++++++++++++++++++++++++++++++++++++++++ src/defs.s | 15 +++++++++++++-- src/player.s | 2 +- src/unit_demo.s | 6 +++--- 4 files changed, 60 insertions(+), 6 deletions(-) diff --git a/src/animation.s b/src/animation.s index 879dfc7..71fccb8 100644 --- a/src/animation.s +++ b/src/animation.s @@ -10,6 +10,32 @@ player_anim_table_f2: anim_ent 1, 0, 0x8E, OAM_FXFLIP anim_ent 0, 0, 0x00, 0 + ; table that maps actor type to + ; a list of animations +anim_actor_table: + dw anim_list_player + dw anim_list_guard + dw anim_list_dog + dw anim_list_hazmat + + +anim_list_player: + ; TDLE_NEUTRAL + dw player_anim_table + ; ATTACK LEFT + dw player_anim_table + ; ATTACK RIGHT + dw player_anim_table + ; ATTACK_UP + dw player_anim_table + ; ATTACK_DOWN + dw player_anim_table + +anim_list_guard: +anim_list_dog: +anim_list_hazmat: + + ; translates tile to screen ; inputs: ; $1: Y/X offset @@ -21,6 +47,23 @@ player_anim_table_f2: sub a, $2 #endmacro + ; loads an animation for the current acotr + ; based on its type + ; and the requested animation entry + ; inputs: + ; de: actor + ; b: the animation + ; writes: + ; new animation into selected actor +anim_load_type: + ; TODO: + ; 1) load animation list based on type + + ; 2) load animation table based on requested animation + + ; 3) write animation to animation entry + ret + ; performs no drawing unit_nop_draw: ldnull bc diff --git a/src/defs.s b/src/defs.s index ae46130..bea6255 100644 --- a/src/defs.s +++ b/src/defs.s @@ -146,8 +146,10 @@ ; actor type enum .se 0 .de ACT_T_NULL, 1 -.de ACT_T_CURSOR, 1 -.de ACT_T_DEMO_1, 1 +.de ACT_T_PLAYER, 1 +.de ACT_T_GUARD, 1 +.de ACT_T_DOG, 1 +.de ACT_T_HAZMAT, 1 ; actor struct (unit's are instances of actors) ; actor structs are basically just states @@ -337,6 +339,15 @@ .de anim_ent_oam_flags, 1 .de anim_ent_size, 0 +; animation types +.se 0 +.de ANIM_T_IDLE_NEUTRAL, 1 +.de ANIM_T_ATTACK_LEFT, 1 +.de ANIM_T_ATTACK_RIGHT, 1 +.de ANIM_T_ATTACK_UP, 1 +.de ANIM_T_ATTACK_DOWN, 1 + + ; special text commands ; consumes the command diff --git a/src/player.s b/src/player.s index 1c37328..0155ce9 100644 --- a/src/player.s +++ b/src/player.s @@ -319,7 +319,7 @@ unit_player_attack: unit_player: st_def 0x00, unit_player_init, st_unit_idle - act_def ACT_T_DEMO_1, 0, 2, 2, 0 + act_def ACT_T_PLAYER, 0, 2, 2, 0 act_stat_def1 1, 3, 1, 1 act_stat_def2 1, 1, 90, 1 act_st_def st_unit_player_update, st_unit_idle diff --git a/src/unit_demo.s b/src/unit_demo.s index 653a734..d301171 100644 --- a/src/unit_demo.s +++ b/src/unit_demo.s @@ -34,7 +34,7 @@ unit_demo_1_cpu_update_idle: unit_demo_guard: st_def 0x00, unit_demo_1_init, st_unit_demo_1_cpu_update - act_def ACT_T_DEMO_1, 0, 9, 9, 0 + act_def ACT_T_GUARD, 0, 9, 9, 0 act_stat_def1 1, 3, 1, 1 act_stat_def2 1, 1, 32, 1 act_st_def st_unit_demo_1_cpu_update, st_unit_idle @@ -42,7 +42,7 @@ unit_demo_guard: unit_demo_dog: st_def 0x00, unit_demo_1_init, st_unit_demo_1_cpu_update - act_def ACT_T_DEMO_1, 0, 9, 9, 0 + act_def ACT_T_DOG, 0, 9, 9, 0 act_stat_def1 1, 2, 1, 1 act_stat_def2 1, 1, 32, 1 act_st_def st_unit_demo_1_cpu_update, st_unit_idle @@ -51,7 +51,7 @@ unit_demo_dog: unit_demo_hazmat: st_def 0x00, unit_demo_1_init, st_unit_demo_1_cpu_update - act_def ACT_T_DEMO_1, 0, 9, 9, 0 + act_def ACT_T_HAZMAT, 0, 9, 9, 0 act_stat_def1 1, 1, 1, 1 act_stat_def2 1, 1, 32, 1 act_st_def st_unit_demo_1_cpu_update, st_unit_idle -- 2.30.2