party_menu.asm 6.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326
  1. ; [wPartyMenuTypeOrMessageID] = menu type / message ID
  2. ; if less than $F0, it is a menu type
  3. ; menu types:
  4. ; 00: normal pokemon menu (e.g. Start menu)
  5. ; 01: use healing item on pokemon menu
  6. ; 02: in-battle switch pokemon menu
  7. ; 03: learn TM/HM menu
  8. ; 04: swap pokemon positions menu
  9. ; 05: use evolution stone on pokemon menu
  10. ; otherwise, it is a message ID
  11. ; f0: poison healed
  12. ; f1: burn healed
  13. ; f2: freeze healed
  14. ; f3: sleep healed
  15. ; f4: paralysis healed
  16. ; f5: HP healed
  17. ; f6: health returned
  18. ; f7: revitalized
  19. ; f8: leveled up
  20. DrawPartyMenu_:
  21. xor a
  22. ld [H_AUTOBGTRANSFERENABLED], a
  23. call ClearScreen
  24. call UpdateSprites
  25. callba LoadMonPartySpriteGfxWithLCDDisabled ; load pokemon icon graphics
  26. RedrawPartyMenu_:
  27. ld a, [wPartyMenuTypeOrMessageID]
  28. cp SWAP_MONS_PARTY_MENU
  29. jp z, .printMessage
  30. call ErasePartyMenuCursors
  31. callba InitPartyMenuBlkPacket
  32. coord hl, 3, 0
  33. ld de, wPartySpecies
  34. xor a
  35. ld c, a
  36. ld [hPartyMonIndex], a
  37. ld [wWhichPartyMenuHPBar], a
  38. .loop
  39. ld a, [de]
  40. cp $FF ; reached the terminator?
  41. jp z, .afterDrawingMonEntries
  42. push bc
  43. push de
  44. push hl
  45. ld a, c
  46. push hl
  47. ld hl, wPartyMonNicks
  48. call GetPartyMonName
  49. pop hl
  50. call PlaceString ; print the pokemon's name
  51. callba WriteMonPartySpriteOAMByPartyIndex ; place the appropriate pokemon icon
  52. ld a, [hPartyMonIndex]
  53. ld [wWhichPokemon], a
  54. inc a
  55. ld [hPartyMonIndex], a
  56. call LoadMonData
  57. pop hl
  58. push hl
  59. ld a, [wMenuItemToSwap]
  60. and a ; is the player swapping pokemon positions?
  61. jr z, .skipUnfilledRightArrow
  62. ; if the player is swapping pokemon positions
  63. dec a
  64. ld b, a
  65. ld a, [wWhichPokemon]
  66. cp b ; is the player swapping the current pokemon in the list?
  67. jr nz, .skipUnfilledRightArrow
  68. ; the player is swapping the current pokemon in the list
  69. dec hl
  70. dec hl
  71. dec hl
  72. ld a, "▷" ; unfilled right arrow menu cursor
  73. ld [hli], a ; place the cursor
  74. inc hl
  75. inc hl
  76. .skipUnfilledRightArrow
  77. ld a, [wPartyMenuTypeOrMessageID] ; menu type
  78. cp TMHM_PARTY_MENU
  79. jr z, .teachMoveMenu
  80. cp EVO_STONE_PARTY_MENU
  81. jr z, .evolutionStoneMenu
  82. push hl
  83. ld bc, 14 ; 14 columns to the right
  84. add hl, bc
  85. ld de, wLoadedMonStatus
  86. call PrintStatusCondition
  87. pop hl
  88. push hl
  89. ld bc, SCREEN_WIDTH + 1 ; down 1 row and right 1 column
  90. ld a, [hFlags_0xFFF6]
  91. set 0, a
  92. ld [hFlags_0xFFF6], a
  93. add hl, bc
  94. predef DrawHP2 ; draw HP bar and prints current / max HP
  95. ld a, [hFlags_0xFFF6]
  96. res 0, a
  97. ld [hFlags_0xFFF6], a
  98. call SetPartyMenuHPBarColor ; color the HP bar (on SGB)
  99. pop hl
  100. jr .printLevel
  101. .teachMoveMenu
  102. push hl
  103. predef CanLearnTM ; check if the pokemon can learn the move
  104. pop hl
  105. ld de, .ableToLearnMoveText
  106. ld a, c
  107. and a
  108. jr nz, .placeMoveLearnabilityString
  109. ld de, .notAbleToLearnMoveText
  110. .placeMoveLearnabilityString
  111. ld bc, 20 + 9 ; down 1 row and right 9 columns
  112. push hl
  113. add hl, bc
  114. call PlaceString
  115. pop hl
  116. .printLevel
  117. ld bc, 10 ; move 10 columns to the right
  118. add hl, bc
  119. call PrintLevel
  120. pop hl
  121. pop de
  122. inc de
  123. ld bc, 2 * 20
  124. add hl, bc
  125. pop bc
  126. inc c
  127. jp .loop
  128. .ableToLearnMoveText
  129. db "ABLE@"
  130. .notAbleToLearnMoveText
  131. db "NOT ABLE@"
  132. .evolutionStoneMenu
  133. push hl
  134. ld hl, EvosMovesPointerTable
  135. ld b, 0
  136. ld a, [wLoadedMonSpecies]
  137. dec a
  138. add a
  139. rl b
  140. ld c, a
  141. add hl, bc
  142. ld de, wEvosMoves
  143. ld a, BANK(EvosMovesPointerTable)
  144. ld bc, 2
  145. call FarCopyData
  146. ld hl, wEvosMoves
  147. ld a, [hli]
  148. ld h, [hl]
  149. ld l, a
  150. ld de, wEvosMoves
  151. ld a, BANK(EvosMovesPointerTable)
  152. ld bc, wEvosMoves.end - wEvosMoves
  153. call FarCopyData
  154. ld hl, wEvosMoves
  155. ld de, .notAbleToEvolveText
  156. ; loop through the pokemon's evolution entries
  157. .checkEvolutionsLoop
  158. ld a, [hli]
  159. and a ; reached terminator?
  160. jr z, .placeEvolutionStoneString ; if so, place the "NOT ABLE" string
  161. inc hl
  162. inc hl
  163. cp EV_ITEM
  164. jr nz, .checkEvolutionsLoop
  165. ; if it's a stone evolution entry
  166. dec hl
  167. dec hl
  168. ld b, [hl]
  169. ld a, [wEvoStoneItemID] ; the stone the player used
  170. inc hl
  171. inc hl
  172. inc hl
  173. cp b ; does the player's stone match this evolution entry's stone?
  174. jr nz, .checkEvolutionsLoop
  175. ; if it does match
  176. ld de, .ableToEvolveText
  177. .placeEvolutionStoneString
  178. ld bc, 20 + 9 ; down 1 row and right 9 columns
  179. pop hl
  180. push hl
  181. add hl, bc
  182. call PlaceString
  183. pop hl
  184. jr .printLevel
  185. .ableToEvolveText
  186. db "ABLE@"
  187. .notAbleToEvolveText
  188. db "NOT ABLE@"
  189. .afterDrawingMonEntries
  190. ld b, SET_PAL_PARTY_MENU
  191. call RunPaletteCommand
  192. .printMessage
  193. ld hl, wd730
  194. ld a, [hl]
  195. push af
  196. push hl
  197. set 6, [hl] ; turn off letter printing delay
  198. ld a, [wPartyMenuTypeOrMessageID] ; message ID
  199. cp $F0
  200. jr nc, .printItemUseMessage
  201. add a
  202. ld hl, PartyMenuMessagePointers
  203. ld b, 0
  204. ld c, a
  205. add hl, bc
  206. ld a, [hli]
  207. ld h, [hl]
  208. ld l, a
  209. call PrintText
  210. .done
  211. pop hl
  212. pop af
  213. ld [hl], a
  214. ld a, 1
  215. ld [H_AUTOBGTRANSFERENABLED], a
  216. call Delay3
  217. jp GBPalNormal
  218. .printItemUseMessage
  219. and $0F
  220. ld hl, PartyMenuItemUseMessagePointers
  221. add a
  222. ld c, a
  223. ld b, 0
  224. add hl, bc
  225. ld a, [hli]
  226. ld h, [hl]
  227. ld l, a
  228. push hl
  229. ld a, [wUsedItemOnWhichPokemon]
  230. ld hl, wPartyMonNicks
  231. call GetPartyMonName
  232. pop hl
  233. call PrintText
  234. jr .done
  235. PartyMenuItemUseMessagePointers:
  236. dw AntidoteText
  237. dw BurnHealText
  238. dw IceHealText
  239. dw AwakeningText
  240. dw ParlyzHealText
  241. dw PotionText
  242. dw FullHealText
  243. dw ReviveText
  244. dw RareCandyText
  245. PartyMenuMessagePointers:
  246. dw PartyMenuNormalText
  247. dw PartyMenuItemUseText
  248. dw PartyMenuBattleText
  249. dw PartyMenuUseTMText
  250. dw PartyMenuSwapMonText
  251. dw PartyMenuItemUseText
  252. PartyMenuNormalText:
  253. TX_FAR _PartyMenuNormalText
  254. db "@"
  255. PartyMenuItemUseText:
  256. TX_FAR _PartyMenuItemUseText
  257. db "@"
  258. PartyMenuBattleText:
  259. TX_FAR _PartyMenuBattleText
  260. db "@"
  261. PartyMenuUseTMText:
  262. TX_FAR _PartyMenuUseTMText
  263. db "@"
  264. PartyMenuSwapMonText:
  265. TX_FAR _PartyMenuSwapMonText
  266. db "@"
  267. PotionText:
  268. TX_FAR _PotionText
  269. db "@"
  270. AntidoteText:
  271. TX_FAR _AntidoteText
  272. db "@"
  273. ParlyzHealText:
  274. TX_FAR _ParlyzHealText
  275. db "@"
  276. BurnHealText:
  277. TX_FAR _BurnHealText
  278. db "@"
  279. IceHealText:
  280. TX_FAR _IceHealText
  281. db "@"
  282. AwakeningText:
  283. TX_FAR _AwakeningText
  284. db "@"
  285. FullHealText:
  286. TX_FAR _FullHealText
  287. db "@"
  288. ReviveText:
  289. TX_FAR _ReviveText
  290. db "@"
  291. RareCandyText:
  292. TX_FAR _RareCandyText
  293. TX_SFX_ITEM_1 ; probably supposed to play SFX_LEVEL_UP but the wrong music bank is loaded
  294. TX_BLINK
  295. db "@"
  296. SetPartyMenuHPBarColor:
  297. ld hl, wPartyMenuHPBarColors
  298. ld a, [wWhichPartyMenuHPBar]
  299. ld c, a
  300. ld b, 0
  301. add hl, bc
  302. call GetHealthBarColor
  303. ld b, UPDATE_PARTY_MENU_BLK_PACKET
  304. call RunPaletteCommand
  305. ld hl, wWhichPartyMenuHPBar
  306. inc [hl]
  307. ret