learn_move.asm 3.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227
  1. LearnMove:
  2. call SaveScreenTilesToBuffer1
  3. ld a, [wWhichPokemon]
  4. ld hl, wPartyMonNicks
  5. call GetPartyMonName
  6. ld hl, wcd6d
  7. ld de, wLearnMoveMonName
  8. ld bc, NAME_LENGTH
  9. call CopyData
  10. DontAbandonLearning:
  11. ld hl, wPartyMon1Moves
  12. ld bc, wPartyMon2Moves - wPartyMon1Moves
  13. ld a, [wWhichPokemon]
  14. call AddNTimes
  15. ld d, h
  16. ld e, l
  17. ld b, NUM_MOVES
  18. .findEmptyMoveSlotLoop
  19. ld a, [hl]
  20. and a
  21. jr z, .next
  22. inc hl
  23. dec b
  24. jr nz, .findEmptyMoveSlotLoop
  25. push de
  26. call TryingToLearn
  27. pop de
  28. jp c, AbandonLearning
  29. push hl
  30. push de
  31. ld [wd11e], a
  32. call GetMoveName
  33. ld hl, OneTwoAndText
  34. call PrintText
  35. pop de
  36. pop hl
  37. .next
  38. ld a, [wMoveNum]
  39. ld [hl], a
  40. ld bc, wPartyMon1PP - wPartyMon1Moves
  41. add hl, bc
  42. push hl
  43. push de
  44. dec a
  45. ld hl, Moves
  46. ld bc, MoveEnd - Moves
  47. call AddNTimes
  48. ld de, wBuffer
  49. ld a, BANK(Moves)
  50. call FarCopyData
  51. ld a, [wBuffer + 5] ; a = move's max PP
  52. pop de
  53. pop hl
  54. ld [hl], a
  55. ld a, [wIsInBattle]
  56. and a
  57. jp z, PrintLearnedMove
  58. ld a, [wWhichPokemon]
  59. ld b, a
  60. ld a, [wPlayerMonNumber]
  61. cp b
  62. jp nz, PrintLearnedMove
  63. ld h, d
  64. ld l, e
  65. ld de, wBattleMonMoves
  66. ld bc, NUM_MOVES
  67. call CopyData
  68. ld bc, wPartyMon1PP - wPartyMon1OTID
  69. add hl, bc
  70. ld de, wBattleMonPP
  71. ld bc, NUM_MOVES
  72. call CopyData
  73. jp PrintLearnedMove
  74. AbandonLearning:
  75. ld hl, AbandonLearningText
  76. call PrintText
  77. coord hl, 14, 7
  78. lb bc, 8, 15
  79. ld a, TWO_OPTION_MENU
  80. ld [wTextBoxID], a
  81. call DisplayTextBoxID ; yes/no menu
  82. ld a, [wCurrentMenuItem]
  83. and a
  84. jp nz, DontAbandonLearning
  85. ld hl, DidNotLearnText
  86. call PrintText
  87. ld b, 0
  88. ret
  89. PrintLearnedMove:
  90. ld hl, LearnedMove1Text
  91. call PrintText
  92. ld b, 1
  93. ret
  94. TryingToLearn:
  95. push hl
  96. ld hl, TryingToLearnText
  97. call PrintText
  98. coord hl, 14, 7
  99. lb bc, 8, 15
  100. ld a, TWO_OPTION_MENU
  101. ld [wTextBoxID], a
  102. call DisplayTextBoxID ; yes/no menu
  103. pop hl
  104. ld a, [wCurrentMenuItem]
  105. rra
  106. ret c
  107. ld bc, -NUM_MOVES
  108. add hl, bc
  109. push hl
  110. ld de, wMoves
  111. ld bc, NUM_MOVES
  112. call CopyData
  113. callab FormatMovesString
  114. pop hl
  115. .loop
  116. push hl
  117. ld hl, WhichMoveToForgetText
  118. call PrintText
  119. coord hl, 4, 7
  120. ld b, 4
  121. ld c, 14
  122. call TextBoxBorder
  123. coord hl, 6, 8
  124. ld de, wMovesString
  125. ld a, [hFlags_0xFFF6]
  126. set 2, a
  127. ld [hFlags_0xFFF6], a
  128. call PlaceString
  129. ld a, [hFlags_0xFFF6]
  130. res 2, a
  131. ld [hFlags_0xFFF6], a
  132. ld hl, wTopMenuItemY
  133. ld a, 8
  134. ld [hli], a ; wTopMenuItemY
  135. ld a, 5
  136. ld [hli], a ; wTopMenuItemX
  137. xor a
  138. ld [hli], a ; wCurrentMenuItem
  139. inc hl
  140. ld a, [wNumMovesMinusOne]
  141. ld [hli], a ; wMaxMenuItem
  142. ld a, A_BUTTON | B_BUTTON
  143. ld [hli], a ; wMenuWatchedKeys
  144. ld [hl], 0 ; wLastMenuItem
  145. ld hl, hFlags_0xFFF6
  146. set 1, [hl]
  147. call HandleMenuInput
  148. ld hl, hFlags_0xFFF6
  149. res 1, [hl]
  150. push af
  151. call LoadScreenTilesFromBuffer1
  152. pop af
  153. pop hl
  154. bit 1, a ; pressed b
  155. jr nz, .cancel
  156. push hl
  157. ld a, [wCurrentMenuItem]
  158. ld c, a
  159. ld b, 0
  160. add hl, bc
  161. ld a, [hl]
  162. push af
  163. push bc
  164. call IsMoveHM
  165. pop bc
  166. pop de
  167. ld a, d
  168. jr c, .hm
  169. pop hl
  170. add hl, bc
  171. and a
  172. ret
  173. .hm
  174. ld hl, HMCantDeleteText
  175. call PrintText
  176. pop hl
  177. jr .loop
  178. .cancel
  179. scf
  180. ret
  181. LearnedMove1Text:
  182. TX_FAR _LearnedMove1Text
  183. TX_SFX_ITEM_1 ; plays SFX_GET_ITEM_1 in the party menu (rare candy) and plays SFX_LEVEL_UP in battle
  184. TX_BLINK
  185. db "@"
  186. WhichMoveToForgetText:
  187. TX_FAR _WhichMoveToForgetText
  188. db "@"
  189. AbandonLearningText:
  190. TX_FAR _AbandonLearningText
  191. db "@"
  192. DidNotLearnText:
  193. TX_FAR _DidNotLearnText
  194. db "@"
  195. TryingToLearnText:
  196. TX_FAR _TryingToLearnText
  197. db "@"
  198. OneTwoAndText:
  199. TX_FAR _OneTwoAndText
  200. TX_DELAY
  201. TX_ASM
  202. ld a, SFX_SWAP
  203. call PlaySoundWaitForCurrent
  204. ld hl, PoofText
  205. ret
  206. PoofText:
  207. TX_FAR _PoofText
  208. TX_DELAY
  209. ForgotAndText:
  210. TX_FAR _ForgotAndText
  211. db "@"
  212. HMCantDeleteText:
  213. TX_FAR _HMCantDeleteText
  214. db "@"