From eca5127acf3728188fa3c1bb257c545a5cefbe02 Mon Sep 17 00:00:00 2001 From: Lukas Krickl Date: Sun, 23 Feb 2025 14:56:56 +0100 Subject: [PATCH] actor: removed bat update code This is now replaced with a never ending state machine update. --- src/actor.s | 47 ++++++----------------------------------------- src/defs.s | 1 + src/state.s | 4 +++- 3 files changed, 10 insertions(+), 42 deletions(-) diff --git a/src/actor.s b/src/actor.s index ccfda64..fc94880 100644 --- a/src/actor.s +++ b/src/actor.s @@ -272,49 +272,14 @@ actor_update_bat: actor_check_who jr nz, @skip REL - ld a, [end_turn] - cp a, 0 - jr z, @no_anim REL - - ; transfer bc into hl - ld a, b - ld h, a - ld a, c - ld l, a - inc hl ; hl = y/x ptr + ; call state update + ld a, smt_player_poll_inputs + ; load initial state if required + call sm_load_initial_state + push bc - call anim_move + call sm_call_state pop bc - cp a, 0 ; is animation done? - jr nz, @skip REL - ; play animation at end of turn - call who_next - call anim_clear - jr @skip REL ; darw update -@no_anim: - ; set up movement - call actor_ld_anim_target - - ; move bat in random direction - call rand - and a, 0b11 ; rnadom direction 0-3 - - ; call correct movement setup - cp a, NORTH - call z, actor_up - cp a, SOUTH - call z, actor_down - cp a, WEST - call z, actor_left - cp a, EAST - call z, actor_right - - ; check anim collision - call actor_anim_verify - ; set flags on z - call z, actor_tile_update_rf_flags - - turn_finish @skip: ; load tile to use into tmp diff --git a/src/defs.s b/src/defs.s index 5c2a9c2..96ab9e7 100644 --- a/src/defs.s +++ b/src/defs.s @@ -212,3 +212,4 @@ .de smt_actor_go_south, 1 .de smt_actor_go_east, 1 .de smt_actor_go_west, 1 +.de smt_bat_pick_direction, 1 diff --git a/src/state.s b/src/state.s index 15f85c8..64be0cc 100644 --- a/src/state.s +++ b/src/state.s @@ -14,6 +14,7 @@ state_table: dw anim_walk_south dw anim_walk_east dw anim_walk_west + dw sm_bat_pick_direction sm_nop: ret @@ -199,7 +200,8 @@ sm_load_initial_state: pop hl ret - ; calls the current state machine state + ; calls the current state machine state + ; depends on sm_load_ptr sm_call_state: sm_load_ptr hl ld a, [hl] -- 2.30.2