evolution.asm 2.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161
  1. EvolveMon:
  2. push hl
  3. push de
  4. push bc
  5. ld a, [wcf91]
  6. push af
  7. ld a, [wd0b5]
  8. push af
  9. xor a
  10. ld [wLowHealthAlarm], a
  11. ld [wChannelSoundIDs + Ch4], a
  12. dec a
  13. ld [wNewSoundID], a
  14. call PlaySound
  15. ld a, $1
  16. ld [H_AUTOBGTRANSFERENABLED], a
  17. ld a, SFX_TINK
  18. call PlaySound
  19. call Delay3
  20. xor a
  21. ld [H_AUTOBGTRANSFERENABLED], a
  22. ld [hTilesetType], a
  23. ld a, [wEvoOldSpecies]
  24. ld [wWholeScreenPaletteMonSpecies], a
  25. ld c, 0
  26. call EvolutionSetWholeScreenPalette
  27. ld a, [wEvoNewSpecies]
  28. ld [wcf91], a
  29. ld [wd0b5], a
  30. call Evolution_LoadPic
  31. ld de, vFrontPic
  32. ld hl, vBackPic
  33. ld bc, 7 * 7
  34. call CopyVideoData
  35. ld a, [wEvoOldSpecies]
  36. ld [wcf91], a
  37. ld [wd0b5], a
  38. call Evolution_LoadPic
  39. ld a, $1
  40. ld [H_AUTOBGTRANSFERENABLED], a
  41. ld a, [wEvoOldSpecies]
  42. call PlayCry
  43. call WaitForSoundToFinish
  44. ld c, BANK(Music_SafariZone)
  45. ld a, MUSIC_SAFARI_ZONE
  46. call PlayMusic
  47. ld c, 80
  48. call DelayFrames
  49. ld c, 1 ; set PAL_BLACK instead of mon palette
  50. call EvolutionSetWholeScreenPalette
  51. lb bc, $1, $10
  52. .animLoop
  53. push bc
  54. call Evolution_CheckForCancel
  55. jr c, .evolutionCancelled
  56. call Evolution_BackAndForthAnim
  57. pop bc
  58. inc b
  59. dec c
  60. dec c
  61. jr nz, .animLoop
  62. xor a
  63. ld [wEvoCancelled], a
  64. ld a, $31
  65. ld [wEvoMonTileOffset], a
  66. call Evolution_ChangeMonPic ; show the new species pic
  67. ld a, [wEvoNewSpecies]
  68. .done
  69. ld [wWholeScreenPaletteMonSpecies], a
  70. ld a, $ff
  71. ld [wNewSoundID], a
  72. call PlaySound
  73. ld a, [wWholeScreenPaletteMonSpecies]
  74. call PlayCry
  75. ld c, 0
  76. call EvolutionSetWholeScreenPalette
  77. pop af
  78. ld [wd0b5], a
  79. pop af
  80. ld [wcf91], a
  81. pop bc
  82. pop de
  83. pop hl
  84. ld a, [wEvoCancelled]
  85. and a
  86. ret z
  87. scf
  88. ret
  89. .evolutionCancelled
  90. pop bc
  91. ld a, 1
  92. ld [wEvoCancelled], a
  93. ld a, [wEvoOldSpecies]
  94. jr .done
  95. EvolutionSetWholeScreenPalette:
  96. ld b, SET_PAL_POKEMON_WHOLE_SCREEN
  97. jp RunPaletteCommand
  98. Evolution_LoadPic:
  99. call GetMonHeader
  100. coord hl, 7, 2
  101. jp LoadFlippedFrontSpriteByMonIndex
  102. Evolution_BackAndForthAnim:
  103. ; show the mon change back and forth between the new and old species b times
  104. ld a, $31
  105. ld [wEvoMonTileOffset], a
  106. call Evolution_ChangeMonPic
  107. ld a, -$31
  108. ld [wEvoMonTileOffset], a
  109. call Evolution_ChangeMonPic
  110. dec b
  111. jr nz, Evolution_BackAndForthAnim
  112. ret
  113. Evolution_ChangeMonPic:
  114. push bc
  115. xor a
  116. ld [H_AUTOBGTRANSFERENABLED], a
  117. coord hl, 7, 2
  118. lb bc, 7, 7
  119. ld de, SCREEN_WIDTH - 7
  120. .loop
  121. push bc
  122. .innerLoop
  123. ld a, [wEvoMonTileOffset]
  124. add [hl]
  125. ld [hli], a
  126. dec c
  127. jr nz, .innerLoop
  128. pop bc
  129. add hl, de
  130. dec b
  131. jr nz, .loop
  132. ld a, 1
  133. ld [H_AUTOBGTRANSFERENABLED], a
  134. call Delay3
  135. pop bc
  136. ret
  137. Evolution_CheckForCancel:
  138. call DelayFrame
  139. push bc
  140. call JoypadLowSensitivity
  141. ld a, [hJoy5]
  142. pop bc
  143. and B_BUTTON
  144. jr nz, .pressedB
  145. .notAllowedToCancel
  146. dec c
  147. jr nz, Evolution_CheckForCancel
  148. and a
  149. ret
  150. .pressedB
  151. ld a, [wForceEvolution]
  152. and a
  153. jr nz, .notAllowedToCancel
  154. scf
  155. ret