ret
- ; advance to the next actor
+ ; sets turn to end
+turn_finish:
+ ld a, 1
+ ld [end_turn], a
+ ret
+
+ ; advance to the next actor if end_turn != 0
; effectively ending the current actor's turn
who_next:
+ ld a, [end_turn]
+ cp a, 0
+ jr z, @skip REL
+
+ xor a, a
+ ld [end_turn], a
+
ld a, [who]
inc a ; who++
; if who > actor_max
; go to player
cp a, ACTORS_MAX
- jr z, @no_player REL
+ jr nz, @no_player REL
ld a, WHO_PLAYER
@no_player:
ld [who], a
+@skip:
ret
; actor table
; inputs:
; hl: pointer to player memory
-player_update:
+player_update:
; update
ld a, [who]
cp a, WHO_PLAYER
; play move animation
; and skip inputs if it is still
; ongoing
- call anim_move
+ call anim_move
cp a, 0
jp nz, @skip_input
ld a, ANIM_MOVE_TILE_SIZE
add a, [hl]
ld [tmp], a
+
+ call turn_finish
@notdown:
input_held BTNUP
ld a, 0xFF - ANIM_MOVE_TILE_SIZE + 1
add a, [hl]
ld [tmp], a
+
+ call turn_finish
@notup:
add a, [hl]
dec hl
ld [tmp+1], a
+
+ call turn_finish
@notleft:
input_held BTNRIGHT
add a, [hl]
dec hl
ld [tmp+1], a
+
+ call turn_finish
@notright:
@action_buttons:
; actors may still run update code like animations
; but may *never* act when they are not currently enabled
who: .adv 1
+ ; if end turn is set who_next will
+ ; give control to the next actor
+end_turn: .adv 1
#define ANIM_MOVE_TILE_SIZE 16
#define ANIM_STEP_DOWN 1