status_screen.asm 8.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482
  1. DrawHP:
  2. ; Draws the HP bar in the stats screen
  3. call GetPredefRegisters
  4. ld a, $1
  5. jr DrawHP_
  6. DrawHP2:
  7. ; Draws the HP bar in the party screen
  8. call GetPredefRegisters
  9. ld a, $2
  10. DrawHP_:
  11. ld [wHPBarType], a
  12. push hl
  13. ld a, [wLoadedMonHP]
  14. ld b, a
  15. ld a, [wLoadedMonHP + 1]
  16. ld c, a
  17. or b
  18. jr nz, .nonzeroHP
  19. xor a
  20. ld c, a
  21. ld e, a
  22. ld a, $6
  23. ld d, a
  24. jp .drawHPBarAndPrintFraction
  25. .nonzeroHP
  26. ld a, [wLoadedMonMaxHP]
  27. ld d, a
  28. ld a, [wLoadedMonMaxHP + 1]
  29. ld e, a
  30. predef HPBarLength
  31. ld a, $6
  32. ld d, a
  33. ld c, a
  34. .drawHPBarAndPrintFraction
  35. pop hl
  36. push de
  37. push hl
  38. push hl
  39. call DrawHPBar
  40. pop hl
  41. ld a, [hFlags_0xFFF6]
  42. bit 0, a
  43. jr z, .printFractionBelowBar
  44. ld bc, $9 ; right of bar
  45. jr .printFraction
  46. .printFractionBelowBar
  47. ld bc, SCREEN_WIDTH + 1 ; below bar
  48. .printFraction
  49. add hl, bc
  50. ld de, wLoadedMonHP
  51. lb bc, 2, 3
  52. call PrintNumber
  53. ld a, "/"
  54. ld [hli], a
  55. ld de, wLoadedMonMaxHP
  56. lb bc, 2, 3
  57. call PrintNumber
  58. pop hl
  59. pop de
  60. ret
  61. ; Predef 0x37
  62. StatusScreen:
  63. call LoadMonData
  64. ld a, [wMonDataLocation]
  65. cp BOX_DATA
  66. jr c, .DontRecalculate
  67. ; mon is in a box or daycare
  68. ld a, [wLoadedMonBoxLevel]
  69. ld [wLoadedMonLevel], a
  70. ld [wCurEnemyLVL], a
  71. ld hl, wLoadedMonHPExp - 1
  72. ld de, wLoadedMonStats
  73. ld b, $1
  74. call CalcStats ; Recalculate stats
  75. .DontRecalculate
  76. ld hl, wd72c
  77. set 1, [hl]
  78. ld a, $33
  79. ld [rNR50], a ; Reduce the volume
  80. call GBPalWhiteOutWithDelay3
  81. call ClearScreen
  82. call UpdateSprites
  83. call LoadHpBarAndStatusTilePatterns
  84. ld de, BattleHudTiles1 ; source
  85. ld hl, vChars2 + $6d0 ; dest
  86. lb bc, BANK(BattleHudTiles1), $03
  87. call CopyVideoDataDouble ; ·│ :L and halfarrow line end
  88. ld de, BattleHudTiles2
  89. ld hl, vChars2 + $780
  90. lb bc, BANK(BattleHudTiles2), $01
  91. call CopyVideoDataDouble ; │
  92. ld de, BattleHudTiles3
  93. ld hl, vChars2 + $760
  94. lb bc, BANK(BattleHudTiles3), $02
  95. call CopyVideoDataDouble ; ─┘
  96. ld de, PTile
  97. ld hl, vChars2 + $720
  98. lb bc, BANK(PTile), (PTileEnd - PTile) / $8
  99. call CopyVideoDataDouble ; P (for PP), inline
  100. ld a, [hTilesetType]
  101. push af
  102. xor a
  103. ld [hTilesetType], a
  104. coord hl, 19, 1
  105. lb bc, 6, 10
  106. call DrawLineBox ; Draws the box around name, HP and status
  107. ld de, -6
  108. add hl, de
  109. ld [hl], "⠄" ; . after No ("." is a different one)
  110. dec hl
  111. ld [hl], "№"
  112. coord hl, 19, 9
  113. lb bc, 8, 6
  114. call DrawLineBox ; Draws the box around types, ID No. and OT
  115. coord hl, 10, 9
  116. ld de, Type1Text
  117. call PlaceString ; "TYPE1/"
  118. coord hl, 11, 3
  119. predef DrawHP
  120. ld hl, wStatusScreenHPBarColor
  121. call GetHealthBarColor
  122. ld b, SET_PAL_STATUS_SCREEN
  123. call RunPaletteCommand
  124. coord hl, 16, 6
  125. ld de, wLoadedMonStatus
  126. call PrintStatusCondition
  127. jr nz, .StatusWritten
  128. coord hl, 16, 6
  129. ld de, OKText
  130. call PlaceString ; "OK"
  131. .StatusWritten
  132. coord hl, 9, 6
  133. ld de, StatusText
  134. call PlaceString ; "STATUS/"
  135. coord hl, 14, 2
  136. call PrintLevel ; Pokémon level
  137. ld a, [wMonHIndex]
  138. ld [wd11e], a
  139. ld [wd0b5], a
  140. predef IndexToPokedex
  141. coord hl, 3, 7
  142. ld de, wd11e
  143. lb bc, LEADING_ZEROES | 1, 3
  144. call PrintNumber ; Pokémon no.
  145. coord hl, 11, 10
  146. predef PrintMonType
  147. ld hl, NamePointers2
  148. call .GetStringPointer
  149. ld d, h
  150. ld e, l
  151. coord hl, 9, 1
  152. call PlaceString ; Pokémon name
  153. ld hl, OTPointers
  154. call .GetStringPointer
  155. ld d, h
  156. ld e, l
  157. coord hl, 12, 16
  158. call PlaceString ; OT
  159. coord hl, 12, 14
  160. ld de, wLoadedMonOTID
  161. lb bc, LEADING_ZEROES | 2, 5
  162. call PrintNumber ; ID Number
  163. ld d, $0
  164. call PrintStatsBox
  165. call Delay3
  166. call GBPalNormal
  167. coord hl, 1, 0
  168. call LoadFlippedFrontSpriteByMonIndex ; draw Pokémon picture
  169. ld a, [wcf91]
  170. call PlayCry ; play Pokémon cry
  171. call WaitForTextScrollButtonPress ; wait for button
  172. pop af
  173. ld [hTilesetType], a
  174. ret
  175. .GetStringPointer
  176. ld a, [wMonDataLocation]
  177. add a
  178. ld c, a
  179. ld b, 0
  180. add hl, bc
  181. ld a, [hli]
  182. ld h, [hl]
  183. ld l, a
  184. ld a, [wMonDataLocation]
  185. cp DAYCARE_DATA
  186. ret z
  187. ld a, [wWhichPokemon]
  188. jp SkipFixedLengthTextEntries
  189. OTPointers:
  190. dw wPartyMonOT
  191. dw wEnemyMonOT
  192. dw wBoxMonOT
  193. dw wDayCareMonOT
  194. NamePointers2:
  195. dw wPartyMonNicks
  196. dw wEnemyMonNicks
  197. dw wBoxMonNicks
  198. dw wDayCareMonName
  199. Type1Text:
  200. db "TYPE1/", $4e
  201. Type2Text:
  202. db "TYPE2/", $4e
  203. IDNoText:
  204. db $73, "№/", $4e
  205. OTText:
  206. db "OT/"
  207. next "@"
  208. StatusText:
  209. db "STATUS/@"
  210. OKText:
  211. db "OK@"
  212. ; Draws a line starting from hl high b and wide c
  213. DrawLineBox:
  214. ld de, SCREEN_WIDTH ; New line
  215. .PrintVerticalLine
  216. ld [hl], $78 ; │
  217. add hl, de
  218. dec b
  219. jr nz, .PrintVerticalLine
  220. ld [hl], $77 ; ┘
  221. dec hl
  222. .PrintHorizLine
  223. ld [hl], $76 ; ─
  224. dec hl
  225. dec c
  226. jr nz, .PrintHorizLine
  227. ld [hl], $6f ; ← (halfarrow ending)
  228. ret
  229. PTile: ; This is a single 1bpp "P" tile
  230. INCBIN "gfx/p_tile.1bpp"
  231. PTileEnd:
  232. PrintStatsBox:
  233. ld a, d
  234. and a ; a is 0 from the status screen
  235. jr nz, .DifferentBox
  236. coord hl, 0, 8
  237. ld b, 8
  238. ld c, 8
  239. call TextBoxBorder ; Draws the box
  240. coord hl, 1, 9 ; Start printing stats from here
  241. ld bc, $0019 ; Number offset
  242. jr .PrintStats
  243. .DifferentBox
  244. coord hl, 9, 2
  245. ld b, 8
  246. ld c, 9
  247. call TextBoxBorder
  248. coord hl, 11, 3
  249. ld bc, $0018
  250. .PrintStats
  251. push bc
  252. push hl
  253. ld de, StatsText
  254. call PlaceString
  255. pop hl
  256. pop bc
  257. add hl, bc
  258. ld de, wLoadedMonAttack
  259. lb bc, 2, 3
  260. call PrintStat
  261. ld de, wLoadedMonDefense
  262. call PrintStat
  263. ld de, wLoadedMonSpeed
  264. call PrintStat
  265. ld de, wLoadedMonSpecial
  266. jp PrintNumber
  267. PrintStat:
  268. push hl
  269. call PrintNumber
  270. pop hl
  271. ld de, SCREEN_WIDTH * 2
  272. add hl, de
  273. ret
  274. StatsText:
  275. db "ATTACK"
  276. next "DEFENSE"
  277. next "SPEED"
  278. next "SPECIAL@"
  279. StatusScreen2:
  280. ld a, [hTilesetType]
  281. push af
  282. xor a
  283. ld [hTilesetType], a
  284. ld [H_AUTOBGTRANSFERENABLED], a
  285. ld bc, NUM_MOVES + 1
  286. ld hl, wMoves
  287. call FillMemory
  288. ld hl, wLoadedMonMoves
  289. ld de, wMoves
  290. ld bc, NUM_MOVES
  291. call CopyData
  292. callab FormatMovesString
  293. coord hl, 9, 2
  294. lb bc, 5, 10
  295. call ClearScreenArea ; Clear under name
  296. coord hl, 19, 3
  297. ld [hl], $78
  298. coord hl, 0, 8
  299. ld b, 8
  300. ld c, 18
  301. call TextBoxBorder ; Draw move container
  302. coord hl, 2, 9
  303. ld de, wMovesString
  304. call PlaceString ; Print moves
  305. ld a, [wNumMovesMinusOne]
  306. inc a
  307. ld c, a
  308. ld a, $4
  309. sub c
  310. ld b, a ; Number of moves ?
  311. coord hl, 11, 10
  312. ld de, SCREEN_WIDTH * 2
  313. ld a, $72 ; special P tile id
  314. call StatusScreen_PrintPP ; Print "PP"
  315. ld a, b
  316. and a
  317. jr z, .InitPP
  318. ld c, a
  319. ld a, "-"
  320. call StatusScreen_PrintPP ; Fill the rest with --
  321. .InitPP
  322. ld hl, wLoadedMonMoves
  323. coord de, 14, 10
  324. ld b, 0
  325. .PrintPP
  326. ld a, [hli]
  327. and a
  328. jr z, .PPDone
  329. push bc
  330. push hl
  331. push de
  332. ld hl, wCurrentMenuItem
  333. ld a, [hl]
  334. push af
  335. ld a, b
  336. ld [hl], a
  337. push hl
  338. callab GetMaxPP
  339. pop hl
  340. pop af
  341. ld [hl], a
  342. pop de
  343. pop hl
  344. push hl
  345. ld bc, wPartyMon1PP - wPartyMon1Moves - 1
  346. add hl, bc
  347. ld a, [hl]
  348. and $3f
  349. ld [wStatusScreenCurrentPP], a
  350. ld h, d
  351. ld l, e
  352. push hl
  353. ld de, wStatusScreenCurrentPP
  354. lb bc, 1, 2
  355. call PrintNumber
  356. ld a, "/"
  357. ld [hli], a
  358. ld de, wMaxPP
  359. lb bc, 1, 2
  360. call PrintNumber
  361. pop hl
  362. ld de, SCREEN_WIDTH * 2
  363. add hl, de
  364. ld d, h
  365. ld e, l
  366. pop hl
  367. pop bc
  368. inc b
  369. ld a, b
  370. cp $4
  371. jr nz, .PrintPP
  372. .PPDone
  373. coord hl, 9, 3
  374. ld de, StatusScreenExpText
  375. call PlaceString
  376. ld a, [wLoadedMonLevel]
  377. push af
  378. cp MAX_LEVEL
  379. jr z, .Level100
  380. inc a
  381. ld [wLoadedMonLevel], a ; Increase temporarily if not 100
  382. .Level100
  383. coord hl, 14, 6
  384. ld [hl], $70 ; 1-tile "to"
  385. inc hl
  386. inc hl
  387. call PrintLevel
  388. pop af
  389. ld [wLoadedMonLevel], a
  390. ld de, wLoadedMonExp
  391. coord hl, 12, 4
  392. lb bc, 3, 7
  393. call PrintNumber ; exp
  394. call CalcExpToLevelUp
  395. ld de, wLoadedMonExp
  396. coord hl, 7, 6
  397. lb bc, 3, 7
  398. call PrintNumber ; exp needed to level up
  399. coord hl, 9, 0
  400. call StatusScreen_ClearName
  401. coord hl, 9, 1
  402. call StatusScreen_ClearName
  403. ld a, [wMonHIndex]
  404. ld [wd11e], a
  405. call GetMonName
  406. coord hl, 9, 1
  407. call PlaceString
  408. ld a, $1
  409. ld [H_AUTOBGTRANSFERENABLED], a
  410. call Delay3
  411. call WaitForTextScrollButtonPress ; wait for button
  412. pop af
  413. ld [hTilesetType], a
  414. ld hl, wd72c
  415. res 1, [hl]
  416. ld a, $77
  417. ld [rNR50], a
  418. call GBPalWhiteOut
  419. jp ClearScreen
  420. CalcExpToLevelUp:
  421. ld a, [wLoadedMonLevel]
  422. cp MAX_LEVEL
  423. jr z, .atMaxLevel
  424. inc a
  425. ld d, a
  426. callab CalcExperience
  427. ld hl, wLoadedMonExp + 2
  428. ld a, [hExperience + 2]
  429. sub [hl]
  430. ld [hld], a
  431. ld a, [hExperience + 1]
  432. sbc [hl]
  433. ld [hld], a
  434. ld a, [hExperience]
  435. sbc [hl]
  436. ld [hld], a
  437. ret
  438. .atMaxLevel
  439. ld hl, wLoadedMonExp
  440. xor a
  441. ld [hli], a
  442. ld [hli], a
  443. ld [hl], a
  444. ret
  445. StatusScreenExpText:
  446. db "EXP POINTS"
  447. next "LEVEL UP@"
  448. StatusScreen_ClearName:
  449. ld bc, 10
  450. ld a, " "
  451. jp FillMemory
  452. StatusScreen_PrintPP:
  453. ; print PP or -- c times, going down two rows each time
  454. ld [hli], a
  455. ld [hld], a
  456. add hl, de
  457. dec c
  458. jr nz, StatusScreen_PrintPP
  459. ret