Advertisement
Guest User

Untitled

a guest
Jan 22nd, 2012
114
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 3.24 KB | None | 0 0
  1. SubstituteEffectHandler:
  2. ROM5:7DAD 0E 32 ld c,32
  3. ROM5:7DAF CD 39 37 call 3739 ;wait 50 frames..
  4. ROM5:7DB2 21 23 D0 ld hl,d023 ;HL: player max hp
  5. ROM5:7DB5 11 D7 CC ld de,ccd7 ;DE: subtracted health
  6. ROM5:7DB8 01 63 D0 ld bc,d063 ;BC: player flags
  7. ROM5:7DBB F0 F3 ld a,(ff00+f3) ;whose turn?
  8. ROM5:7DBD A7 and a
  9. ROM5:7DBE 28 09 jr z,7dc9(.notEnemy)
  10. ROM5:7DC0 21 F4 CF ld hl,cff4 ;opponent max hp
  11. ROM5:7DC3 11 D8 CC ld de,ccd8 ;subtracted health
  12. ROM5:7DC6 01 68 D0 ld bc,d068 ;opponent flags
  13. .notEnemy
  14. ROM5:7DC9 0A ld a,(bc) ;load flags
  15. ROM5:7DCA CB 67 bit 4,a ;user already has substitute?
  16. ROM5:7DCC 20 44 jr nz,7e12 ;skip this code if so
  17. ;user doesn't have a substitute (yet)
  18. ROM5:7DCE C5 push bc
  19. ROM5:7DCF 2A ldi a,(hl) ;load max hp
  20. ROM5:7DD0 46 ld b,(hl)
  21. ROM5:7DD1 CB 3F slr a ;max hp / 4, (quarter health to remove from user)
  22. ROM5:7DD3 CB 18 rr b
  23. ROM5:7DD5 CB 3F slr a
  24. ROM5:7DD7 CB 18 rr b
  25. ROM5:7DD9 D5 push de
  26. ROM5:7DDA 11 F2 FF ld de,fff2 ;subtract 8 to point to (current hp) instead of (max hp)
  27. ROM5:7DDD 19 add hl,de ;HL -= 8
  28. ROM5:7DDE D1 pop de
  29. ROM5:7DDF 78 ld a,b
  30. ROM5:7DE0 12 ld (de),a ;save copy of HP to subtract in ccd7/ccd8 (how much HP substitute has)
  31. ROM5:7DE1 3A ldd a,(hl) ;load current hp
  32. ROM5:7DE2 90 sub b ;subtract (max hp / 4)
  33. ROM5:7DE3 57 ld d,a ;save low byte result in D
  34. ROM5:7DE4 7E ld a,(hl)
  35. ROM5:7DE5 DE 00 sbc a,00 ;borrow from high byte if needed
  36. ROM5:7DE7 C1 pop bc
  37. ROM5:7DE8 38 2D jr c,7e17(notEnoughHP) ;underflow means user would be left with negative health
  38. ;bug: note since it only brances on carry, it will possibly leave user with 0HP
  39. .userHasZeroOrMoreHP
  40. ROM5:7DEA 22 ldi (hl),a ;store high byte HP
  41. ROM5:7DEB 72 ld (hl),d ;store low byte HP
  42. ROM5:7DEC 60 ld h,b
  43. ROM5:7DED 69 ld l,c
  44. ROM5:7DEE CB E6 set 4,(hl) ;set bit 4 of flags, user now has substitute
  45. ROM5:7DF0 FA 55 D3 ld a,(d355) ;load options
  46. ROM5:7DF3 CB 7F bit 7,a ;battle animation is enabled?
  47. ROM5:7DF5 21 A8 7B ld hl,7ba8 ;animation enabled: 0F:7BA8
  48. ROM5:7DF8 06 0F ld b,0f
  49. ROM5:7DFA 28 05 jr z,7e01(.animationEnabled)
  50. ROM5:7DFC 21 E0 56 ld hl,56e0 ;animation disabled: 1E:56E0
  51. ROM5:7DFF 06 1E ld b,1e
  52. .animationEnabled
  53. ROM5:7E01 CD D6 35 call 35d6 ;jump to routine depending on animation setting
  54. ROM5:7E04 21 1D 7E ld hl,7e1d ;"it created a substitute"
  55. ROM5:7E07 CD 49 3C call 3c49 ;print text
  56. ROM5:7E0A 21 5A 4D ld hl,4d5a
  57. ROM5:7E0D 06 0F ld b,0f
  58. ROM5:7E0F C3 D6 35 jp 35d6 ;jump to 0F:4D5A
  59. .alreadyHasSubstitute
  60. ROM5:7E12 21 22 7E ld hl,7e22 ;"____ has a substitute"
  61. ROM5:7E15 18 03 jr 7e1a
  62. .notEnoughHP
  63. ROM5:7E17 21 27 7E ld hl,7e27 ;"too weak to make substitute"
  64. ROM5:7E1A C3 49 3C jp 3c49 ;print text
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement