From d0df1e615719c6c4ccdbddee1fe6e17d8e653914 Mon Sep 17 00:00:00 2001 From: Lukas Krickl Date: Mon, 18 Nov 2024 18:40:54 +0100 Subject: [PATCH] Added system for ending turns --- src/actor.s | 18 ++++++++++++++++-- src/player.s | 12 ++++++++++-- src/wram.s | 3 +++ 3 files changed, 29 insertions(+), 4 deletions(-) diff --git a/src/actor.s b/src/actor.s index 806cfbe..1470ae1 100644 --- a/src/actor.s +++ b/src/actor.s @@ -129,17 +129,31 @@ anim_move: 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 diff --git a/src/player.s b/src/player.s index d53bf2f..e9fc1fd 100644 --- a/src/player.s +++ b/src/player.s @@ -71,7 +71,7 @@ player_init: ; actor table ; inputs: ; hl: pointer to player memory -player_update: +player_update: ; update ld a, [who] cp a, WHO_PLAYER @@ -80,7 +80,7 @@ player_update: ; play move animation ; and skip inputs if it is still ; ongoing - call anim_move + call anim_move cp a, 0 jp nz, @skip_input @@ -112,6 +112,8 @@ player_update: ld a, ANIM_MOVE_TILE_SIZE add a, [hl] ld [tmp], a + + call turn_finish @notdown: input_held BTNUP @@ -127,6 +129,8 @@ player_update: ld a, 0xFF - ANIM_MOVE_TILE_SIZE + 1 add a, [hl] ld [tmp], a + + call turn_finish @notup: @@ -145,6 +149,8 @@ player_update: add a, [hl] dec hl ld [tmp+1], a + + call turn_finish @notleft: input_held BTNRIGHT @@ -162,6 +168,8 @@ player_update: add a, [hl] dec hl ld [tmp+1], a + + call turn_finish @notright: @action_buttons: diff --git a/src/wram.s b/src/wram.s index 558b9c6..c4037e9 100644 --- a/src/wram.s +++ b/src/wram.s @@ -151,6 +151,9 @@ game_mode: .adv 1 ; 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 -- 2.30.2