; skips a turn by calling turn_finish
; and who_next
-#macro actor_skip_turn
+#macro actor_end_turn
turn_finish
call who_next
#endmacro
.db BAT_TILE_IDLE2
.db BAT_TILE_IDLE2
+ ; generic actor movement calls
+ ; up, down, left, right
+ ; inputs:
+ ; bc: actor_ptr
+ ; actor_soam_ptr: next soam item
+actor_up:
+ ret
+
+actor_down:
+ ld a, ANIM_MOVE_TILE_SIZE
+ ld [anim_move_y], a
+ ld a, ANIM_STEP_DOWN
+ ld [anim_step_y], a
+
+ xor a, a
+ ld [anim_step_x], a
+ ld [anim_move_x], a
+ ret
+
+actor_left:
+ ret
+
+actor_right:
+ ret
; function ptrs for each actor type
; inputs:
actor_check_who
ret nz
- ; actor_skip_turn
+ ; actor_end_turn
turn_finish
jp who_next
actor_check_who
jr nz, @skip REL
- actor_skip_turn
+ 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 anim_move
+ cp a, 0 ; is animation done?
+ jr nz, @skip REL
+ ; play animation at end of turn
+ call who_next
+ jr @skip REL ; darw update
+@no_anim:
+ ; move bat in random direction
+ call rand
+ and a, 0b11 ; rnadom direction 0-3
+
+ ; call correct movement setup
+ cp a, 0
+ call z, actor_up
+ cp a, 1
+ call z, actor_down
+ cp a, 2
+ call z, actor_left
+ cp a, 3
+ call z, actor_right
+
+ turn_finish
@skip:
; load tile to use into tmp
actor_check_who
jr nz, @skip REL
- actor_skip_turn
+ actor_end_turn
@skip: