jr nz, @skip REL
; call state update
- ld a, smt_player_poll_inputs
+ ld a, smt_bat_pick_direction
; load initial state if required
call sm_load_initial_state
; after verifying collision
; otherwise -> end turn
sm_bat_pick_direction:
- ; hl = sm ptr
- sm_load_ptr hl
-
push bc
; move bat in random direction
call rand
and a, 0b11 ; rnadom direction 0-3
+ push af
+ ; hl = sm ptr
+ sm_load_ptr hl
+ pop af
+
; call correct movement setup
cp a, NORTH
jr nz, @not_north REL
+ ; set animation params
+ ld a, smt_actor_go_north
+ ld [hl+], a ; set next state
+ ld a, ANIM_PLAYER_WALK_FRAMES
+ ld [hl], a ; set param[0]
@not_north:
cp a, SOUTH
jr nz, @not_south REL
+ ; set animation params
+ ld a, smt_actor_go_south
+ ld [hl+], a ; set next state
+ ld a, ANIM_PLAYER_WALK_FRAMES
+ ld [hl], a ; set param[0]
+
@not_south:
cp a, WEST
jr nz, @not_west REL
+ ; set animation params
+ ld a, smt_actor_go_west
+ ld [hl+], a ; set next state
+ ld a, ANIM_PLAYER_WALK_FRAMES
+ ld [hl], a ; set param[0]
+
@not_west:
cp a, EAST
jr nz, @not_east REL
+ ; set animation params
+ ld a, smt_actor_go_east
+ ld [hl+], a ; set next state
+ ld a, ANIM_PLAYER_WALK_FRAMES
+ ld [hl], a ; set param[0]
+
@not_east:
; verify collision