end_of_battle.asm 1.6 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889
  1. EndOfBattle:
  2. ld a, [wLinkState]
  3. cp LINK_STATE_BATTLING
  4. jr nz, .notLinkBattle
  5. ; link battle
  6. ld a, [wEnemyMonPartyPos]
  7. ld hl, wEnemyMon1Status
  8. ld bc, wEnemyMon2 - wEnemyMon1
  9. call AddNTimes
  10. ld a, [wEnemyMonStatus]
  11. ld [hl], a
  12. call ClearScreen
  13. callab DisplayLinkBattleVersusTextBox
  14. ld a, [wBattleResult]
  15. cp $1
  16. ld de, YouWinText
  17. jr c, .placeWinOrLoseString
  18. ld de, YouLoseText
  19. jr z, .placeWinOrLoseString
  20. ld de, DrawText
  21. .placeWinOrLoseString
  22. coord hl, 6, 8
  23. call PlaceString
  24. ld c, 200
  25. call DelayFrames
  26. jr .evolution
  27. .notLinkBattle
  28. ld a, [wBattleResult]
  29. and a
  30. jr nz, .resetVariables
  31. ld hl, wTotalPayDayMoney
  32. ld a, [hli]
  33. or [hl]
  34. inc hl
  35. or [hl]
  36. jr z, .evolution ; if pay day money is 0, jump
  37. ld de, wPlayerMoney + 2
  38. ld c, $3
  39. predef AddBCDPredef
  40. ld hl, PickUpPayDayMoneyText
  41. call PrintText
  42. .evolution
  43. xor a
  44. ld [wForceEvolution], a
  45. predef EvolutionAfterBattle
  46. .resetVariables
  47. xor a
  48. ld [wLowHealthAlarm], a ;disable low health alarm
  49. ld [wChannelSoundIDs + Ch4], a
  50. ld [wIsInBattle], a
  51. ld [wBattleType], a
  52. ld [wMoveMissed], a
  53. ld [wCurOpponent], a
  54. ld [wForcePlayerToChooseMon], a
  55. ld [wNumRunAttempts], a
  56. ld [wEscapedFromBattle], a
  57. ld hl, wPartyAndBillsPCSavedMenuItem
  58. ld [hli], a
  59. ld [hli], a
  60. ld [hli], a
  61. ld [hl], a
  62. ld [wListScrollOffset], a
  63. ld hl, wPlayerStatsToDouble
  64. ld b, $18
  65. .loop
  66. ld [hli], a
  67. dec b
  68. jr nz, .loop
  69. ld hl, wd72c
  70. set 0, [hl]
  71. call WaitForSoundToFinish
  72. call GBPalWhiteOut
  73. ld a, $ff
  74. ld [wDestinationWarpID], a
  75. ret
  76. YouWinText:
  77. db "YOU WIN@"
  78. YouLoseText:
  79. db "YOU LOSE@"
  80. DrawText:
  81. db " DRAW@"
  82. PickUpPayDayMoneyText:
  83. TX_FAR _PickUpPayDayMoneyText
  84. db "@"