Added system for ending turns
authorLukas Krickl <lukas@krickl.dev>
Mon, 18 Nov 2024 17:40:54 +0000 (18:40 +0100)
committerLukas Krickl <lukas@krickl.dev>
Mon, 18 Nov 2024 17:40:54 +0000 (18:40 +0100)
src/actor.s
src/player.s
src/wram.s

index 806cfbef33aee6b048b9d9fb38ee1e261935652c..1470ae1a26faea34bfb56a63da4742d19454ea01 100644 (file)
@@ -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
index d53bf2f12151d5a0436a54947f65d74b8be1be08..e9fc1fdd21e5025ffd357235f543055d1adde6d1 100644 (file)
@@ -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:
index 558b9c6a6e9bf6c24ca776f6c37e427eae5accc5..c4037e972a5917e6c4cbaaac4cfba3584ad9897a 100644 (file)
@@ -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