; returns:
; hl: unit ptr or NULL if not found
unit_find_at:
+ ld hl, p0_units
+
+ ; a = loop counter
+ ld a, UNITS_MAX
+
+@loop:
+ push af
+ push hl
+
+ ld de, act_pos_y
+ add hl, de
+ ; hl = y pos
+
+ ; check if positions match
+ ld a, [hl+]
+ cp a, b ; does y match?
+ jr nz, @no_match REL
+
+ ld a, [hl]
+ cp a, c ; does x match?
+ jp z, @found
+
+@no_match:
+ pop hl ; back to start
+ pop af ; restore loop counter
+ ; next unit
+ ld de, act_size
+ add hl, de
+ dec a
+ jp nz, @loop
+
+ ldnull hl
+ ret
+
+@found:
+ pop hl ; hl = start of found act
+ pop af ; af was also saved so we need to pop
ret
st_unit_idle: