From 7d996595b073663397ca97bbb4bd30d8f2300e8e Mon Sep 17 00:00:00 2001 From: Lukas Krickl Date: Thu, 30 Jan 2025 05:37:45 +0100 Subject: [PATCH] animation: Removed animation setup The first re-write will be replaced with a simpler approach. --- src/animation.s | 98 ++----------------------------------------------- src/combat.s | 2 + src/defs.s | 3 -- src/main.s | 1 + src/update.s | 2 - src/wram.s | 3 +- 6 files changed, 9 insertions(+), 100 deletions(-) create mode 100644 src/combat.s diff --git a/src/animation.s b/src/animation.s index b573d73..6e39ae3 100644 --- a/src/animation.s +++ b/src/animation.s @@ -3,106 +3,16 @@ ; 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 +anim_walk_north: ret - ; animation update calls - ; inputs for all: - ; bc: current animation ptr -animation_table: - dw anim_nop - dw anim_walk_simple - - ; empty animation used as default value -anim_nop: +anim_walk_south: ret - - ; anim walk_simple - ; inputs: - ; anim_p0/p1: ptr to y/x position - ; anim_p2: direction - ; anim_step: frames of movemnet -anim_walk_simple: - ; 1) check direction - - ; bc = anim type - inc bc - ; bc = anim step - push bc ; we need the step ptr again - ld a, [bc] ; a = anim_step - ld d, a ; d = step counter - cp a, 0 - dec bc ; bc = anim type - ; finish animation if step counter is 0 - jp z, anim_finish - - ; go to p0 - inc bc - 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] - pop bc ; bc = anim_step ptr - - ; 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: - +anim_walk_east: ret -@north: - ret -@south: +anim_walk_west: ret - ; updates the current animation - ; an animation is a simple pointer - ; to an update function - ; and a range of parameters (4 freely usable bytes) - ; the animation updte function is expected - ; to set itself to 0000 when the animation is finisehd - ; this is how anim_finished performs its check -anim_update: - ld bc, curr_anim - ld a, [bc] - ld hl, animation_table - call call_tbl - - ret - diff --git a/src/combat.s b/src/combat.s new file mode 100644 index 0000000..2632c22 --- /dev/null +++ b/src/combat.s @@ -0,0 +1,2 @@ +combat_init: + ret diff --git a/src/defs.s b/src/defs.s index 3321db4..fe2b933 100644 --- a/src/defs.s +++ b/src/defs.s @@ -211,7 +211,4 @@ .de anim_step, 1 .de anim_flags, 1 .de anim_p0, 1 -.de anim_p1, 1 -.de anim_p2, 1 -.de anim_p3, 1 .de anim_size, 0 diff --git a/src/main.s b/src/main.s index bacf6d5..21bf3a7 100644 --- a/src/main.s +++ b/src/main.s @@ -65,6 +65,7 @@ main: #include "actor.s" #include "audio.s" #include "animation.s" +#include "combat.s" #include "tiles.inc" diff --git a/src/update.s b/src/update.s index b4d7d19..ad43149 100644 --- a/src/update.s +++ b/src/update.s @@ -10,8 +10,6 @@ update_game_over: update_game: ; tick rng every frame call rand - - call anim_update ; update player ld hl, player diff --git a/src/wram.s b/src/wram.s index 357ad66..992f5e1 100644 --- a/src/wram.s +++ b/src/wram.s @@ -103,7 +103,8 @@ anim_step_x: .adv 1 anim_target_y: .adv 1 anim_target_x: .adv 1 -curr_anim: .adv anim_size + ; 1 animation buffer for each actor + player +anim_table: .adv anim_size * (ACTORS_MAX + 1) ; collision tile tmp values ct_poy: .adv 1 -- 2.30.2