common_text.asm 4.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244
  1. PrintBeginningBattleText:
  2. ld a, [wIsInBattle]
  3. dec a
  4. jr nz, .trainerBattle
  5. ld a, [wCurMap]
  6. cp POKEMONTOWER_3
  7. jr c, .notPokemonTower
  8. cp LAVENDER_HOUSE_1
  9. jr c, .pokemonTower
  10. .notPokemonTower
  11. ld a, [wEnemyMonSpecies2]
  12. call PlayCry
  13. ld hl, WildMonAppearedText
  14. ld a, [wMoveMissed]
  15. and a
  16. jr z, .notFishing
  17. ld hl, HookedMonAttackedText
  18. .notFishing
  19. jr .wildBattle
  20. .trainerBattle
  21. call .playSFX
  22. ld c, 20
  23. call DelayFrames
  24. ld hl, TrainerWantsToFightText
  25. .wildBattle
  26. push hl
  27. callab DrawAllPokeballs
  28. pop hl
  29. call PrintText
  30. jr .done
  31. .pokemonTower
  32. ld b, SILPH_SCOPE
  33. call IsItemInBag
  34. ld a, [wEnemyMonSpecies2]
  35. ld [wcf91], a
  36. cp MAROWAK
  37. jr z, .isMarowak
  38. ld a, b
  39. and a
  40. jr z, .noSilphScope
  41. callab LoadEnemyMonData
  42. jr .notPokemonTower
  43. .noSilphScope
  44. ld hl, EnemyAppearedText
  45. call PrintText
  46. ld hl, GhostCantBeIDdText
  47. call PrintText
  48. jr .done
  49. .isMarowak
  50. ld a, b
  51. and a
  52. jr z, .noSilphScope
  53. ld hl, EnemyAppearedText
  54. call PrintText
  55. ld hl, UnveiledGhostText
  56. call PrintText
  57. callab LoadEnemyMonData
  58. callab MarowakAnim
  59. ld hl, WildMonAppearedText
  60. call PrintText
  61. .playSFX
  62. xor a
  63. ld [wFrequencyModifier], a
  64. ld a, $80
  65. ld [wTempoModifier], a
  66. ld a, SFX_SILPH_SCOPE
  67. call PlaySound
  68. jp WaitForSoundToFinish
  69. .done
  70. ret
  71. WildMonAppearedText:
  72. TX_FAR _WildMonAppearedText
  73. db "@"
  74. HookedMonAttackedText:
  75. TX_FAR _HookedMonAttackedText
  76. db "@"
  77. EnemyAppearedText:
  78. TX_FAR _EnemyAppearedText
  79. db "@"
  80. TrainerWantsToFightText:
  81. TX_FAR _TrainerWantsToFightText
  82. db "@"
  83. UnveiledGhostText:
  84. TX_FAR _UnveiledGhostText
  85. db "@"
  86. GhostCantBeIDdText:
  87. TX_FAR _GhostCantBeIDdText
  88. db "@"
  89. PrintSendOutMonMessage:
  90. ld hl, wEnemyMonHP
  91. ld a, [hli]
  92. or [hl]
  93. ld hl, GoText
  94. jr z, .printText
  95. xor a
  96. ld [H_MULTIPLICAND], a
  97. ld hl, wEnemyMonHP
  98. ld a, [hli]
  99. ld [wLastSwitchInEnemyMonHP], a
  100. ld [H_MULTIPLICAND + 1], a
  101. ld a, [hl]
  102. ld [wLastSwitchInEnemyMonHP + 1], a
  103. ld [H_MULTIPLICAND + 2], a
  104. ld a, 25
  105. ld [H_MULTIPLIER], a
  106. call Multiply
  107. ld hl, wEnemyMonMaxHP
  108. ld a, [hli]
  109. ld b, [hl]
  110. srl a
  111. rr b
  112. srl a
  113. rr b
  114. ld a, b
  115. ld b, 4
  116. ld [H_DIVISOR], a ; enemy mon max HP divided by 4
  117. call Divide
  118. ld a, [H_QUOTIENT + 3] ; a = (enemy mon current HP * 25) / (enemy max HP / 4); this approximates the current percentage of max HP
  119. ld hl, GoText ; 70% or greater
  120. cp 70
  121. jr nc, .printText
  122. ld hl, DoItText ; 40% - 69%
  123. cp 40
  124. jr nc, .printText
  125. ld hl, GetmText ; 10% - 39%
  126. cp 10
  127. jr nc, .printText
  128. ld hl, EnemysWeakText ; 0% - 9%
  129. .printText
  130. jp PrintText
  131. GoText:
  132. TX_FAR _GoText
  133. TX_ASM
  134. jr PrintPlayerMon1Text
  135. DoItText:
  136. TX_FAR _DoItText
  137. TX_ASM
  138. jr PrintPlayerMon1Text
  139. GetmText:
  140. TX_FAR _GetmText
  141. TX_ASM
  142. jr PrintPlayerMon1Text
  143. EnemysWeakText:
  144. TX_FAR _EnemysWeakText
  145. TX_ASM
  146. PrintPlayerMon1Text:
  147. ld hl, PlayerMon1Text
  148. ret
  149. PlayerMon1Text:
  150. TX_FAR _PlayerMon1Text
  151. db "@"
  152. RetreatMon:
  153. ld hl, PlayerMon2Text
  154. jp PrintText
  155. PlayerMon2Text:
  156. TX_FAR _PlayerMon2Text
  157. TX_ASM
  158. push de
  159. push bc
  160. ld hl, wEnemyMonHP + 1
  161. ld de, wLastSwitchInEnemyMonHP + 1
  162. ld b, [hl]
  163. dec hl
  164. ld a, [de]
  165. sub b
  166. ld [H_MULTIPLICAND + 2], a
  167. dec de
  168. ld b, [hl]
  169. ld a, [de]
  170. sbc b
  171. ld [H_MULTIPLICAND + 1], a
  172. ld a, 25
  173. ld [H_MULTIPLIER], a
  174. call Multiply
  175. ld hl, wEnemyMonMaxHP
  176. ld a, [hli]
  177. ld b, [hl]
  178. srl a
  179. rr b
  180. srl a
  181. rr b
  182. ld a, b
  183. ld b, 4
  184. ld [H_DIVISOR], a
  185. call Divide
  186. pop bc
  187. pop de
  188. ld a, [H_QUOTIENT + 3] ; a = ((LastSwitchInEnemyMonHP - CurrentEnemyMonHP) / 25) / (EnemyMonMaxHP / 4)
  189. ; Assuming that the enemy mon hasn't gained HP since the last switch in,
  190. ; a approximates the percentage that the enemy mon's total HP has decreased
  191. ; since the last switch in.
  192. ; If the enemy mon has gained HP, then a is garbage due to wrap-around and
  193. ; can fall in any of the ranges below.
  194. ld hl, EnoughText ; HP stayed the same
  195. and a
  196. ret z
  197. ld hl, ComeBackText ; HP went down 1% - 29%
  198. cp 30
  199. ret c
  200. ld hl, OKExclamationText ; HP went down 30% - 69%
  201. cp 70
  202. ret c
  203. ld hl, GoodText ; HP went down 70% or more
  204. ret
  205. EnoughText:
  206. TX_FAR _EnoughText
  207. TX_ASM
  208. jr PrintComeBackText
  209. OKExclamationText:
  210. TX_FAR _OKExclamationText
  211. TX_ASM
  212. jr PrintComeBackText
  213. GoodText:
  214. TX_FAR _GoodText
  215. TX_ASM
  216. jr PrintComeBackText
  217. PrintComeBackText:
  218. ld hl, ComeBackText
  219. ret
  220. ComeBackText:
  221. TX_FAR _ComeBackText
  222. db "@"