daycarem.asm 4.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270
  1. DayCareMScript:
  2. jp EnableAutoTextBoxDrawing
  3. DayCareMTextPointers:
  4. dw DayCareMText1
  5. DayCareMText1:
  6. TX_ASM
  7. call SaveScreenTilesToBuffer2
  8. ld a, [wDayCareInUse]
  9. and a
  10. jp nz, .daycareInUse
  11. ld hl, DayCareIntroText
  12. call PrintText
  13. call YesNoChoice
  14. ld a, [wCurrentMenuItem]
  15. and a
  16. ld hl, DayCareComeAgainText
  17. jp nz, .done
  18. ld a, [wPartyCount]
  19. dec a
  20. ld hl, DayCareOnlyHaveOneMonText
  21. jp z, .done
  22. ld hl, DayCareWhichMonText
  23. call PrintText
  24. xor a
  25. ld [wUpdateSpritesEnabled], a
  26. ld [wPartyMenuTypeOrMessageID], a
  27. ld [wMenuItemToSwap], a
  28. call DisplayPartyMenu
  29. push af
  30. call GBPalWhiteOutWithDelay3
  31. call RestoreScreenTilesAndReloadTilePatterns
  32. call LoadGBPal
  33. pop af
  34. ld hl, DayCareAllRightThenText
  35. jp c, .done
  36. callab KnowsHMMove
  37. ld hl, DayCareCantAcceptMonWithHMText
  38. jp c, .done
  39. xor a
  40. ld [wPartyAndBillsPCSavedMenuItem], a
  41. ld a, [wWhichPokemon]
  42. ld hl, wPartyMonNicks
  43. call GetPartyMonName
  44. ld hl, DayCareWillLookAfterMonText
  45. call PrintText
  46. ld a, 1
  47. ld [wDayCareInUse], a
  48. ld a, PARTY_TO_DAYCARE
  49. ld [wMoveMonType], a
  50. call MoveMon
  51. xor a
  52. ld [wRemoveMonFromBox], a
  53. call RemovePokemon
  54. ld a, [wcf91]
  55. call PlayCry
  56. ld hl, DayCareComeSeeMeInAWhileText
  57. jp .done
  58. .daycareInUse
  59. xor a
  60. ld hl, wDayCareMonName
  61. call GetPartyMonName
  62. ld a, DAYCARE_DATA
  63. ld [wMonDataLocation], a
  64. call LoadMonData
  65. callab CalcLevelFromExperience
  66. ld a, d
  67. cp MAX_LEVEL
  68. jr c, .skipCalcExp
  69. ld d, MAX_LEVEL
  70. callab CalcExperience
  71. ld hl, wDayCareMonExp
  72. ld a, [hExperience]
  73. ld [hli], a
  74. ld a, [hExperience + 1]
  75. ld [hli], a
  76. ld a, [hExperience + 2]
  77. ld [hl], a
  78. ld d, MAX_LEVEL
  79. .skipCalcExp
  80. xor a
  81. ld [wDayCareNumLevelsGrown], a
  82. ld hl, wDayCareMonBoxLevel
  83. ld a, [hl]
  84. ld [wDayCareStartLevel], a
  85. cp d
  86. ld [hl], d
  87. ld hl, DayCareMonNeedsMoreTimeText
  88. jr z, .next
  89. ld a, [wDayCareStartLevel]
  90. ld b, a
  91. ld a, d
  92. sub b
  93. ld [wDayCareNumLevelsGrown], a
  94. ld hl, DayCareMonHasGrownText
  95. .next
  96. call PrintText
  97. ld a, [wPartyCount]
  98. cp PARTY_LENGTH
  99. ld hl, DayCareNoRoomForMonText
  100. jp z, .leaveMonInDayCare
  101. ld de, wDayCareTotalCost
  102. xor a
  103. ld [de], a
  104. inc de
  105. ld [de], a
  106. ld hl, wDayCarePerLevelCost
  107. ld a, $1
  108. ld [hli], a
  109. ld [hl], $0
  110. ld a, [wDayCareNumLevelsGrown]
  111. inc a
  112. ld b, a
  113. ld c, 2
  114. .calcPriceLoop
  115. push hl
  116. push de
  117. push bc
  118. predef AddBCDPredef
  119. pop bc
  120. pop de
  121. pop hl
  122. dec b
  123. jr nz, .calcPriceLoop
  124. ld hl, DayCareOweMoneyText
  125. call PrintText
  126. ld a, MONEY_BOX
  127. ld [wTextBoxID], a
  128. call DisplayTextBoxID
  129. call YesNoChoice
  130. ld hl, DayCareAllRightThenText
  131. ld a, [wCurrentMenuItem]
  132. and a
  133. jp nz, .leaveMonInDayCare
  134. ld hl, wDayCareTotalCost
  135. ld [hMoney], a
  136. ld a, [hli]
  137. ld [hMoney + 1], a
  138. ld a, [hl]
  139. ld [hMoney + 2], a
  140. call HasEnoughMoney
  141. jr nc, .enoughMoney
  142. ld hl, DayCareNotEnoughMoneyText
  143. jp .leaveMonInDayCare
  144. .enoughMoney
  145. xor a
  146. ld [wDayCareInUse], a
  147. ld hl, wDayCareNumLevelsGrown
  148. ld [hli], a
  149. inc hl
  150. ld de, wPlayerMoney + 2
  151. ld c, $3
  152. predef SubBCDPredef
  153. ld a, SFX_PURCHASE
  154. call PlaySoundWaitForCurrent
  155. ld a, MONEY_BOX
  156. ld [wTextBoxID], a
  157. call DisplayTextBoxID
  158. ld hl, DayCareHeresYourMonText
  159. call PrintText
  160. ld a, DAYCARE_TO_PARTY
  161. ld [wMoveMonType], a
  162. call MoveMon
  163. ld a, [wDayCareMonSpecies]
  164. ld [wcf91], a
  165. ld a, [wPartyCount]
  166. dec a
  167. push af
  168. ld bc, wPartyMon2 - wPartyMon1
  169. push bc
  170. ld hl, wPartyMon1Moves
  171. call AddNTimes
  172. ld d, h
  173. ld e, l
  174. ld a, 1
  175. ld [wLearningMovesFromDayCare], a
  176. predef WriteMonMoves
  177. pop bc
  178. pop af
  179. ; set mon's HP to max
  180. ld hl, wPartyMon1HP
  181. call AddNTimes
  182. ld d, h
  183. ld e, l
  184. ld bc, wPartyMon1MaxHP - wPartyMon1HP
  185. add hl, bc
  186. ld a, [hli]
  187. ld [de], a
  188. inc de
  189. ld a, [hl]
  190. ld [de], a
  191. ld a, [wcf91]
  192. call PlayCry
  193. ld hl, DayCareGotMonBackText
  194. jr .done
  195. .leaveMonInDayCare
  196. ld a, [wDayCareStartLevel]
  197. ld [wDayCareMonBoxLevel], a
  198. .done
  199. call PrintText
  200. jp TextScriptEnd
  201. DayCareIntroText:
  202. TX_FAR _DayCareIntroText
  203. db "@"
  204. DayCareWhichMonText:
  205. TX_FAR _DayCareWhichMonText
  206. db "@"
  207. DayCareWillLookAfterMonText:
  208. TX_FAR _DayCareWillLookAfterMonText
  209. db "@"
  210. DayCareComeSeeMeInAWhileText:
  211. TX_FAR _DayCareComeSeeMeInAWhileText
  212. db "@"
  213. DayCareMonHasGrownText:
  214. TX_FAR _DayCareMonHasGrownText
  215. db "@"
  216. DayCareOweMoneyText:
  217. TX_FAR _DayCareOweMoneyText
  218. db "@"
  219. DayCareGotMonBackText:
  220. TX_FAR _DayCareGotMonBackText
  221. db "@"
  222. DayCareMonNeedsMoreTimeText:
  223. TX_FAR _DayCareMonNeedsMoreTimeText
  224. db "@"
  225. DayCareAllRightThenText:
  226. TX_FAR _DayCareAllRightThenText
  227. DayCareComeAgainText:
  228. TX_FAR _DayCareComeAgainText
  229. db "@"
  230. DayCareNoRoomForMonText:
  231. TX_FAR _DayCareNoRoomForMonText
  232. db "@"
  233. DayCareOnlyHaveOneMonText:
  234. TX_FAR _DayCareOnlyHaveOneMonText
  235. db "@"
  236. DayCareCantAcceptMonWithHMText:
  237. TX_FAR _DayCareCantAcceptMonWithHMText
  238. db "@"
  239. DayCareHeresYourMonText:
  240. TX_FAR _DayCareHeresYourMonText
  241. db "@"
  242. DayCareNotEnoughMoneyText:
  243. TX_FAR _DayCareNotEnoughMoneyText
  244. db "@"