draw_hud_pokeball_gfx.asm 3.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193
  1. DrawAllPokeballs:
  2. call LoadPartyPokeballGfx
  3. call SetupOwnPartyPokeballs
  4. ld a, [wIsInBattle]
  5. dec a
  6. ret z ; return if wild pokémon
  7. jp SetupEnemyPartyPokeballs
  8. DrawEnemyPokeballs:
  9. call LoadPartyPokeballGfx
  10. jp SetupEnemyPartyPokeballs
  11. LoadPartyPokeballGfx:
  12. ld de, PokeballTileGraphics
  13. ld hl, vSprites + $310
  14. lb bc, BANK(PokeballTileGraphics), (PokeballTileGraphicsEnd - PokeballTileGraphics) / $10
  15. jp CopyVideoData
  16. SetupOwnPartyPokeballs:
  17. call PlacePlayerHUDTiles
  18. ld hl, wPartyMon1
  19. ld de, wPartyCount
  20. call SetupPokeballs
  21. ld a, $60
  22. ld hl, wBaseCoordX
  23. ld [hli], a
  24. ld [hl], a
  25. ld a, 8
  26. ld [wHUDPokeballGfxOffsetX], a
  27. ld hl, wOAMBuffer
  28. jp WritePokeballOAMData
  29. SetupEnemyPartyPokeballs:
  30. call PlaceEnemyHUDTiles
  31. ld hl, wEnemyMons
  32. ld de, wEnemyPartyCount
  33. call SetupPokeballs
  34. ld hl, wBaseCoordX
  35. ld a, $48
  36. ld [hli], a
  37. ld [hl], $20
  38. ld a, -8
  39. ld [wHUDPokeballGfxOffsetX], a
  40. ld hl, wOAMBuffer + PARTY_LENGTH * 4
  41. jp WritePokeballOAMData
  42. SetupPokeballs:
  43. ld a, [de]
  44. push af
  45. ld de, wBuffer
  46. ld c, PARTY_LENGTH
  47. ld a, $34 ; empty pokeball
  48. .emptyloop
  49. ld [de], a
  50. inc de
  51. dec c
  52. jr nz, .emptyloop
  53. pop af
  54. ld de, wBuffer
  55. .monloop
  56. push af
  57. call PickPokeball
  58. inc de
  59. pop af
  60. dec a
  61. jr nz, .monloop
  62. ret
  63. PickPokeball:
  64. inc hl
  65. ld a, [hli]
  66. and a
  67. jr nz, .alive
  68. ld a, [hl]
  69. and a
  70. ld b, $33 ; crossed ball (fainted)
  71. jr z, .done_fainted
  72. .alive
  73. inc hl
  74. inc hl
  75. ld a, [hl] ; status
  76. and a
  77. ld b, $32 ; black ball (status)
  78. jr nz, .done
  79. dec b ; regular ball
  80. jr .done
  81. .done_fainted
  82. inc hl
  83. inc hl
  84. .done
  85. ld a, b
  86. ld [de], a
  87. ld bc, wPartyMon2 - wPartyMon1Status
  88. add hl, bc ; next mon struct
  89. ret
  90. WritePokeballOAMData:
  91. ld de, wBuffer
  92. ld c, PARTY_LENGTH
  93. .loop
  94. ld a, [wBaseCoordY]
  95. ld [hli], a
  96. ld a, [wBaseCoordX]
  97. ld [hli], a
  98. ld a, [de]
  99. ld [hli], a
  100. xor a
  101. ld [hli], a
  102. ld a, [wBaseCoordX]
  103. ld b, a
  104. ld a, [wHUDPokeballGfxOffsetX]
  105. add b
  106. ld [wBaseCoordX], a
  107. inc de
  108. dec c
  109. jr nz, .loop
  110. ret
  111. PlacePlayerHUDTiles:
  112. ld hl, PlayerBattleHUDGraphicsTiles
  113. ld de, wHUDGraphicsTiles
  114. ld bc, $3
  115. call CopyData
  116. coord hl, 18, 10
  117. ld de, -1
  118. jr PlaceHUDTiles
  119. PlayerBattleHUDGraphicsTiles:
  120. ; The tile numbers for specific parts of the battle display for the player's pokemon
  121. db $73 ; unused ($73 is hardcoded into the routine that uses these bytes)
  122. db $77 ; lower-right corner tile of the HUD
  123. db $6F ; lower-left triangle tile of the HUD
  124. PlaceEnemyHUDTiles:
  125. ld hl, EnemyBattleHUDGraphicsTiles
  126. ld de, wHUDGraphicsTiles
  127. ld bc, $3
  128. call CopyData
  129. coord hl, 1, 2
  130. ld de, $1
  131. jr PlaceHUDTiles
  132. EnemyBattleHUDGraphicsTiles:
  133. ; The tile numbers for specific parts of the battle display for the enemy
  134. db $73 ; unused ($73 is hardcoded in the routine that uses these bytes)
  135. db $74 ; lower-left corner tile of the HUD
  136. db $78 ; lower-right triangle tile of the HUD
  137. PlaceHUDTiles:
  138. ld [hl], $73
  139. ld bc, SCREEN_WIDTH
  140. add hl, bc
  141. ld a, [wHUDGraphicsTiles + 1] ; leftmost tile
  142. ld [hl], a
  143. ld a, 8
  144. .loop
  145. add hl, de
  146. ld [hl], $76
  147. dec a
  148. jr nz, .loop
  149. add hl, de
  150. ld a, [wHUDGraphicsTiles + 2] ; rightmost tile
  151. ld [hl], a
  152. ret
  153. SetupPlayerAndEnemyPokeballs:
  154. call LoadPartyPokeballGfx
  155. ld hl, wPartyMons
  156. ld de, wPartyCount
  157. call SetupPokeballs
  158. ld hl, wBaseCoordX
  159. ld a, $50
  160. ld [hli], a
  161. ld [hl], $40
  162. ld a, 8
  163. ld [wHUDPokeballGfxOffsetX], a
  164. ld hl, wOAMBuffer
  165. call WritePokeballOAMData
  166. ld hl, wEnemyMons
  167. ld de, wEnemyPartyCount
  168. call SetupPokeballs
  169. ld hl, wBaseCoordX
  170. ld a, $50
  171. ld [hli], a
  172. ld [hl], $68
  173. ld hl, wOAMBuffer + $18
  174. jp WritePokeballOAMData
  175. ; four tiles: pokeball, black pokeball (status ailment), crossed out pokeball (fainted) and pokeball slot (no mon)
  176. PokeballTileGraphics::
  177. INCBIN "gfx/pokeball.2bpp"
  178. PokeballTileGraphicsEnd: