Advertisement
luckytyphlosion

chaos effect range test

Apr 14th, 2016
250
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. AreChaosEffectsBetweenBCAndDEActive::
  2. ; input:
  3. ; bc: start index
  4. ; de: end index
  5. ; a: type
  6. ; return result in the flagarray wChaosEffectRangeFlagArray (40 flags)
  7.     push hl
  8.     call GetChaosEffectListPointer
  9. .loop
  10. ; check for terminator
  11.     ld a, [hli]
  12.     or [hl]
  13.     jr z, .done
  14. ; compare bc and [hl]
  15.     ld a, c
  16.     sub [hl]
  17.     dec hl
  18.     ld a, b
  19.     sbc [hl]
  20. ; if bc > [hl], try again
  21.     jr c, .notInRange
  22. ; compare de and [hl]
  23.     inc hl
  24.     ld a, e
  25.     sub [hl]
  26.     dec hl
  27.     ld a, d
  28.     sbc [hl]
  29. ; if equal, we're in the range
  30.     jr z, .inRange
  31. ; else, if we're greater, we're not in the range
  32.     jr nc, .notInRange
  33. .inRange
  34.     push hl
  35.     push bc
  36.     inc hl
  37. ; read the lower byte of the chaos effect
  38.     ld a, [hl]
  39. ; a - c to get difference
  40. ; since the maximum difference is only 40 bytes anyway an 8-bit comparison shouldn't affect anything
  41.     sub c
  42.     ld c, a
  43. ; flag action predef
  44.     ld hl, wChaosEffectRangeFlagArray
  45.     ld b, FLAG_SET
  46.     predef FlagActionPredef
  47.     pop bc
  48.     pop hl
  49. .notInRange
  50.     inc hl
  51.     inc hl
  52.     jr .loop
  53. .done
  54.     pop hl
  55.     ret
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement