Advertisement
KDLPro

Find Alive Enemy Mons

Mar 13th, 2021
490
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. FindAliveEnemyMons:
  2.     ld a, [wOTPartyCount]
  3.     cp 2
  4.     jr c, .only_one
  5.  
  6.     ld d, a
  7.     ld e, 0
  8.     ld b, 1 << (PARTY_LENGTH - 1)
  9.     ld c, 0
  10.     ld hl, wOTPartyMon1HP
  11.  
  12. .loop
  13.     ld a, [wCurOTMon]
  14.     cp e
  15.     jr z, .next
  16.  
  17.     push bc
  18.     ld b, [hl]
  19.     inc hl
  20.     ld a, [hld]
  21.     or b
  22.     pop bc
  23.     jr z, .next
  24.  
  25.     ld a, c
  26.     or b
  27.     ld c, a
  28.  
  29. .next
  30.     srl b
  31.     push bc
  32.     ld bc, PARTYMON_STRUCT_LENGTH
  33.     add hl, bc
  34.     pop bc
  35.     inc e
  36.     dec d
  37.     jr nz, .loop
  38.  
  39.     ld a, c
  40.     and a
  41.     jr nz, .more_than_one
  42.  
  43. .only_one
  44.     scf
  45.     ret
  46.  
  47. .more_than_one
  48.     and a
  49.     ret
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement