attack: replaced binary flag for ongoing attacks with a counter
authorLukas Krickl <lukas@krickl.dev>
Sat, 30 Aug 2025 03:27:13 +0000 (05:27 +0200)
committerLukas Krickl <lukas@krickl.dev>
Sat, 30 Aug 2025 03:27:13 +0000 (05:27 +0200)
src/action.s
src/defs.s
src/map.s
src/player.s
src/unit.s
src/wram.s

index 3670d285996eec977b325129bd5553d526b5fc20..d8080b7c8ffdd605ec5481c406caede4f70e1e8a 100644 (file)
@@ -212,9 +212,9 @@ unit_action_attack:
 
 @done:
        ; unset flag
-       ld a, [gameplay_flags]
-       and a, ~GPF_ATTACK_ONGOING & 0xFF
-       ld [gameplay_flags], a
+       ld a, [gpf_attack_ongoing]
+       dec a
+       ld [gpf_attack_ongoing], a
 
        ; set animation timer and delay
        ld bc, st_unit_delay_to_active_template 
@@ -228,9 +228,9 @@ unit_action_attack:
 unit_action_attack_damage_calc:
 
        ;  set flag
-       ld a, [gameplay_flags]
-       or a, GPF_ATTACK_ONGOING
-       ld [gameplay_flags], a
+       ld a, [gpf_attack_ongoing]
+       inc a 
+       ld [gpf_attack_ongoing], a
        
        ; calculate damage
        push de
index f31e402ae861f0dd586adcb7c1cf5f0f3a5666cd..9c4768183a341fcda79ab0abe46a89349d8618ea 100644 (file)
        ; this will allow all other units to 
        ; perform their update
 .de GPF_PLAYER_TURN_TAKEN, 2 
-       ; set while an attack animation is playing
-       ; delay to active actor stats should wait until this
-       ; is cleared
-.de GPF_ATTACK_ONGOING, 4
 
   ; cell flags
 .se 1 
index 903e464170fd6889ba2ce3dbbac37ba1bc6e69d6..045cb6076bd1327cd05786c75f65191f1b64f352 100644 (file)
--- a/src/map.s
+++ b/src/map.s
@@ -8,6 +8,9 @@ map_load_start:
   call disableinterrutpts
   call next_vblank_wait 
   call lcd_off
+
+       xor a, a
+       ld [gpf_attack_ongoing], a
        ret
        
        ; draws the map
index 52b016ac3af83bd941862e298d35c938963cd1fb..5ca6c0bf423e059f5a936bdd83e6e7e0f49a6cb6 100644 (file)
@@ -23,6 +23,11 @@ unit_player_update:
        ld a, [gameplay_flags]
        and a, GPF_PLAYER_TURN_TAKEN
        ret nz
+       
+       ; check if an attack is ongoing
+       ld a, [gpf_attack_ongoing]
+       cp a, 0
+       ret nz
 
   push de
   ld hl, act_oam_flags
index 6202662a65f24a36997bb513c8a6e0f2e805228c..d1fb5f77fe87b7fc9e37e354cc880f8229b8fd1e 100644 (file)
@@ -769,8 +769,8 @@ unit_delay_to_active:
 
 @not_player:
        ; do not proceed if an attack animation is ongoing
-       ld a, [gameplay_flags]
-       and a, GPF_ATTACK_ONGOING
+       ld a, [gpf_attack_ongoing]
+       cp a, 0
        jr nz, @delay_again REL
 
   ldnull bc
index 3537764c9fcc8757bb429016cba89be1cce738f7..e506ce1c77b4a139caa1d42097417712f32b0de4 100644 (file)
@@ -79,6 +79,10 @@ redraw_steps: .adv 1
 ; dummy oam 
 ; same memory as empty_unit
 empty_oam: .adv oamsize
+       
+        ; > 0 if  an actor has an ongoing attack
+        ; used to delay other actors during the animation
+gpf_attack_ongoing: .adv 0
 
 
   ; can be used for custom state transtions