From 4e62d476b59ffbd2f8fe3844623445b2e3589baf Mon Sep 17 00:00:00 2001 From: Lukas Krickl Date: Sun, 18 May 2025 10:49:59 +0200 Subject: [PATCH] unit: added retry code for next unit selector --- src/unit.s | 15 +++++++++++---- 1 file changed, 11 insertions(+), 4 deletions(-) diff --git a/src/unit.s b/src/unit.s index 9f462d0..302accb 100644 --- a/src/unit.s +++ b/src/unit.s @@ -346,9 +346,9 @@ unit_next: ; set moves of current unit to 0 ld hl, act_moves add hl, de - + ld [hl], 0 ; moves = 0 +@again: xor a, a - ld [hl], a ; moves = 0 ld [unit_next_best_init], a ; clear current ptr @@ -413,12 +413,19 @@ unit_next: dec b jr nz, @unit_next_loop REL - ; TODO: ; if here unit_next_best_act_ptr is still 0000 ; reste all moves and try again - + ld a, [unit_next_bext_act_ptr] + ld b, a + ld a, [unit_next_bext_act_ptr+1] + xor a, b + jr z, @retry REL ret +@retry: + call unit_reset_all_moves + jp @again + ; resets all moves ; of all actors un p0 and p1_unts unit_reset_all_moves: -- 2.30.2