mon_party_sprites.asm 7.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424
  1. AnimatePartyMon_ForceSpeed1:
  2. xor a
  3. ld [wCurrentMenuItem], a
  4. ld b, a
  5. inc a
  6. jr GetAnimationSpeed
  7. ; wPartyMenuHPBarColors contains the party mon's health bar colors
  8. ; 0: green
  9. ; 1: yellow
  10. ; 2: red
  11. AnimatePartyMon:
  12. ld hl, wPartyMenuHPBarColors
  13. ld a, [wCurrentMenuItem]
  14. ld c, a
  15. ld b, 0
  16. add hl, bc
  17. ld a, [hl]
  18. GetAnimationSpeed:
  19. ld c, a
  20. ld hl, PartyMonSpeeds
  21. add hl, bc
  22. ld a, [wOnSGB]
  23. xor $1
  24. add [hl]
  25. ld c, a
  26. add a
  27. ld b, a
  28. ld a, [wAnimCounter]
  29. and a
  30. jr z, .resetSprites
  31. cp c
  32. jr z, .animateSprite
  33. .incTimer
  34. inc a
  35. cp b
  36. jr nz, .skipResetTimer
  37. xor a ; reset timer
  38. .skipResetTimer
  39. ld [wAnimCounter], a
  40. jp DelayFrame
  41. .resetSprites
  42. push bc
  43. ld hl, wMonPartySpritesSavedOAM
  44. ld de, wOAMBuffer
  45. ld bc, $60
  46. call CopyData
  47. pop bc
  48. xor a
  49. jr .incTimer
  50. .animateSprite
  51. push bc
  52. ld hl, wOAMBuffer + $02 ; OAM tile id
  53. ld bc, $10
  54. ld a, [wCurrentMenuItem]
  55. call AddNTimes
  56. ld c, $40 ; amount to increase the tile id by
  57. ld a, [hl]
  58. cp $4 ; tile ID for SPRITE_BALL_M
  59. jr z, .editCoords
  60. cp $8 ; tile ID for SPRITE_HELIX
  61. jr nz, .editTileIDS
  62. ; SPRITE_BALL_M and SPRITE_HELIX only shake up and down
  63. .editCoords
  64. dec hl
  65. dec hl ; dec hl to the OAM y coord
  66. ld c, $1 ; amount to increase the y coord by
  67. ; otherwise, load a second sprite frame
  68. .editTileIDS
  69. ld b, $4
  70. ld de, $4
  71. .loop
  72. ld a, [hl]
  73. add c
  74. ld [hl], a
  75. add hl, de
  76. dec b
  77. jr nz, .loop
  78. pop bc
  79. ld a, c
  80. jr .incTimer
  81. ; Party mon animations cycle between 2 frames.
  82. ; The members of the PartyMonSpeeds array specify the number of V-blanks
  83. ; that each frame lasts for green HP, yellow HP, and red HP in order.
  84. ; On the naming screen, the yellow HP speed is always used.
  85. PartyMonSpeeds:
  86. db 5, 16, 32
  87. LoadMonPartySpriteGfx:
  88. ; Load mon party sprite tile patterns into VRAM during V-blank.
  89. ld hl, MonPartySpritePointers
  90. ld a, $1c
  91. LoadAnimSpriteGfx:
  92. ; Load animated sprite tile patterns into VRAM during V-blank. hl is the address
  93. ; of an array of structures that contain arguments for CopyVideoData and a is
  94. ; the number of structures in the array.
  95. ld bc, $0
  96. .loop
  97. push af
  98. push bc
  99. push hl
  100. add hl, bc
  101. ld a, [hli]
  102. ld e, a
  103. ld a, [hli]
  104. ld d, a
  105. ld a, [hli]
  106. ld c, a
  107. ld a, [hli]
  108. ld b, a
  109. ld a, [hli]
  110. ld h, [hl]
  111. ld l, a
  112. call CopyVideoData
  113. pop hl
  114. pop bc
  115. ld a, $6
  116. add c
  117. ld c, a
  118. pop af
  119. dec a
  120. jr nz, .loop
  121. ret
  122. LoadMonPartySpriteGfxWithLCDDisabled:
  123. ; Load mon party sprite tile patterns into VRAM immediately by disabling the
  124. ; LCD.
  125. call DisableLCD
  126. ld hl, MonPartySpritePointers
  127. ld a, $1c
  128. ld bc, $0
  129. .loop
  130. push af
  131. push bc
  132. push hl
  133. add hl, bc
  134. ld a, [hli]
  135. ld e, a
  136. ld a, [hli]
  137. ld d, a
  138. push de
  139. ld a, [hli]
  140. ld c, a
  141. swap c
  142. ld b, $0
  143. ld a, [hli]
  144. ld e, [hl]
  145. inc hl
  146. ld d, [hl]
  147. pop hl
  148. call FarCopyData2
  149. pop hl
  150. pop bc
  151. ld a, $6
  152. add c
  153. ld c, a
  154. pop af
  155. dec a
  156. jr nz, .loop
  157. jp EnableLCD
  158. MonPartySpritePointers:
  159. dw SlowbroSprite + $c0
  160. db $40 / $10 ; 40 bytes
  161. db BANK(SlowbroSprite)
  162. dw vSprites
  163. dw BallSprite
  164. db $80 / $10 ; $80 bytes
  165. db BANK(BallSprite)
  166. dw vSprites + $40
  167. dw ClefairySprite + $c0
  168. db $40 / $10 ; $40 bytes
  169. db BANK(ClefairySprite)
  170. dw vSprites + $c0
  171. dw BirdSprite + $c0
  172. db $40 / $10 ; $40 bytes
  173. db BANK(BirdSprite)
  174. dw vSprites + $100
  175. dw SeelSprite
  176. db $40 / $10 ; $40 bytes
  177. db BANK(SeelSprite)
  178. dw vSprites + $140
  179. dw MonPartySprites + $40
  180. db $10 / $10 ; $10 bytes
  181. db BANK(MonPartySprites)
  182. dw vSprites + $180
  183. dw MonPartySprites + $50
  184. db $10 / $10 ; $10 bytes
  185. db BANK(MonPartySprites)
  186. dw vSprites + $1a0
  187. dw MonPartySprites + $60
  188. db $10 / $10 ; $10 bytes
  189. db BANK(MonPartySprites)
  190. dw vSprites + $1c0
  191. dw MonPartySprites + $70
  192. db $10 / $10 ; $10 bytes
  193. db BANK(MonPartySprites)
  194. dw vSprites + $1e0
  195. dw MonPartySprites + $80
  196. db $10 / $10 ; $10 bytes
  197. db BANK(MonPartySprites)
  198. dw vSprites + $200
  199. dw MonPartySprites + $90
  200. db $10 / $10 ; $10 bytes
  201. db BANK(MonPartySprites)
  202. dw vSprites + $220
  203. dw MonPartySprites + $A0
  204. db $10 / $10 ; $10 bytes
  205. db BANK(MonPartySprites)
  206. dw vSprites + $240
  207. dw MonPartySprites + $B0
  208. db $10 / $10 ; $10 bytes
  209. db BANK(MonPartySprites)
  210. dw vSprites + $260
  211. dw MonPartySprites + $100
  212. db $40 / $10 ; $40 bytes
  213. db BANK(MonPartySprites)
  214. dw vSprites + $380
  215. dw SlowbroSprite
  216. db $40 / $10 ; $40 bytes
  217. db BANK(SlowbroSprite)
  218. dw vSprites + $400
  219. dw BallSprite
  220. db $80 / $10 ; $80 bytes
  221. db BANK(BallSprite)
  222. dw vSprites + $440
  223. dw ClefairySprite
  224. db $40 / $10 ; $40 bytes
  225. db BANK(ClefairySprite)
  226. dw vSprites + $4c0
  227. dw BirdSprite
  228. db $40 / $10 ; $40 bytes
  229. db BANK(BirdSprite)
  230. dw vSprites + $500
  231. dw SeelSprite + $C0
  232. db $40 / $10 ; $40 bytes
  233. db BANK(SeelSprite)
  234. dw vSprites + $540
  235. dw MonPartySprites
  236. db $10 / $10 ; $10 bytes
  237. db BANK(MonPartySprites)
  238. dw vSprites + $580
  239. dw MonPartySprites + $10
  240. db $10 / $10 ; $10 bytes
  241. db BANK(MonPartySprites)
  242. dw vSprites + $5a0
  243. dw MonPartySprites + $20
  244. db $10 / $10 ; $10 bytes
  245. db BANK(MonPartySprites)
  246. dw vSprites + $5c0
  247. dw MonPartySprites + $30
  248. db $10 / $10 ; $10 bytes
  249. db BANK(MonPartySprites)
  250. dw vSprites + $5E0
  251. dw MonPartySprites + $C0
  252. db $10 / $10 ; $10 bytes
  253. db BANK(MonPartySprites)
  254. dw vSprites + $600
  255. dw MonPartySprites + $D0
  256. db $10 / $10 ; $10 bytes
  257. db BANK(MonPartySprites)
  258. dw vSprites + $620
  259. dw MonPartySprites + $E0
  260. db $10 / $10 ; $10 bytes
  261. db BANK(MonPartySprites)
  262. dw vSprites + $640
  263. dw MonPartySprites + $F0
  264. db $10 / $10 ; $10 bytes
  265. db BANK(MonPartySprites)
  266. dw vSprites + $660
  267. dw MonPartySprites + $140
  268. db $40 / $10 ; $40 bytes
  269. db BANK(MonPartySprites)
  270. dw vSprites + $780
  271. WriteMonPartySpriteOAMByPartyIndex:
  272. ; Write OAM blocks for the party mon in [hPartyMonIndex].
  273. push hl
  274. push de
  275. push bc
  276. ld a, [hPartyMonIndex]
  277. ld hl, wPartySpecies
  278. ld e, a
  279. ld d, 0
  280. add hl, de
  281. ld a, [hl]
  282. call GetPartyMonSpriteID
  283. ld [wOAMBaseTile], a
  284. call WriteMonPartySpriteOAM
  285. pop bc
  286. pop de
  287. pop hl
  288. ret
  289. WriteMonPartySpriteOAMBySpecies:
  290. ; Write OAM blocks for the party sprite of the species in
  291. ; [wMonPartySpriteSpecies].
  292. xor a
  293. ld [hPartyMonIndex], a
  294. ld a, [wMonPartySpriteSpecies]
  295. call GetPartyMonSpriteID
  296. ld [wOAMBaseTile], a
  297. jr WriteMonPartySpriteOAM
  298. UnusedPartyMonSpriteFunction:
  299. ; This function is unused and doesn't appear to do anything useful. It looks
  300. ; like it may have been intended to load the tile patterns and OAM data for
  301. ; the mon party sprite associated with the species in [wcf91].
  302. ; However, its calculations are off and it loads garbage data.
  303. ld a, [wcf91]
  304. call GetPartyMonSpriteID
  305. push af
  306. ld hl, vSprites
  307. call .LoadTilePatterns
  308. pop af
  309. add $54
  310. ld hl, vSprites + $40
  311. call .LoadTilePatterns
  312. xor a
  313. ld [wMonPartySpriteSpecies], a
  314. jr WriteMonPartySpriteOAMBySpecies
  315. .LoadTilePatterns
  316. push hl
  317. add a
  318. ld c, a
  319. ld b, 0
  320. ld hl, MonPartySpritePointers
  321. add hl, bc
  322. add hl, bc
  323. add hl, bc
  324. ld a, [hli]
  325. ld e, a
  326. ld a, [hli]
  327. ld d, a
  328. ld a, [hli]
  329. ld c, a
  330. ld a, [hli]
  331. ld b, a
  332. pop hl
  333. jp CopyVideoData
  334. WriteMonPartySpriteOAM:
  335. ; Write the OAM blocks for the first animation frame into the OAM buffer and
  336. ; make a copy at wMonPartySpritesSavedOAM.
  337. push af
  338. ld c, $10
  339. ld h, wOAMBuffer / $100
  340. ld a, [hPartyMonIndex]
  341. swap a
  342. ld l, a
  343. add $10
  344. ld b, a
  345. pop af
  346. cp SPRITE_HELIX << 2
  347. jr z, .helix
  348. call WriteSymmetricMonPartySpriteOAM
  349. jr .makeCopy
  350. .helix
  351. call WriteAsymmetricMonPartySpriteOAM
  352. ; Make a copy of the OAM buffer with the first animation frame written so that
  353. ; we can flip back to it from the second frame by copying it back.
  354. .makeCopy
  355. ld hl, wOAMBuffer
  356. ld de, wMonPartySpritesSavedOAM
  357. ld bc, $60
  358. jp CopyData
  359. GetPartyMonSpriteID:
  360. ld [wd11e], a
  361. predef IndexToPokedex
  362. ld a, [wd11e]
  363. ld c, a
  364. dec a
  365. srl a
  366. ld hl, MonPartyData
  367. ld e, a
  368. ld d, 0
  369. add hl, de
  370. ld a, [hl]
  371. bit 0, c
  372. jr nz, .skipSwap
  373. swap a ; use lower nybble if pokedex num is even
  374. .skipSwap
  375. and $f0
  376. srl a
  377. srl a
  378. ret
  379. INCLUDE "data/mon_party_sprites.asm"
  380. MonPartySprites:
  381. INCBIN "gfx/mon_ow_sprites.2bpp"