agatha.asm 2.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155
  1. AgathaScript:
  2. call AgathaShowOrHideExitBlock
  3. call EnableAutoTextBoxDrawing
  4. ld hl, AgathaTrainerHeader0
  5. ld de, AgathaScriptPointers
  6. ld a, [wAgathaCurScript]
  7. call ExecuteCurMapScriptInTable
  8. ld [wAgathaCurScript], a
  9. ret
  10. AgathaShowOrHideExitBlock:
  11. ; Blocks or clears the exit to the next room.
  12. ld hl, wCurrentMapScriptFlags
  13. bit 5, [hl]
  14. res 5, [hl]
  15. ret z
  16. CheckEvent EVENT_BEAT_AGATHAS_ROOM_TRAINER_0
  17. jr z, .blockExitToNextRoom
  18. ld a, $e
  19. jp .setExitBlock
  20. .blockExitToNextRoom
  21. ld a, $3b
  22. .setExitBlock:
  23. ld [wNewTileBlockID], a
  24. lb bc, 0, 2
  25. predef_jump ReplaceTileBlock
  26. ResetAgathaScript:
  27. xor a
  28. ld [wAgathaCurScript], a
  29. ret
  30. AgathaScriptPointers:
  31. dw AgathaScript0
  32. dw DisplayEnemyTrainerTextAndStartBattle
  33. dw AgathaScript2
  34. dw AgathaScript3
  35. dw AgathaScript4
  36. AgathaScript4:
  37. ret
  38. AgathaScriptWalkIntoRoom:
  39. ; Walk six steps upward.
  40. ld hl, wSimulatedJoypadStatesEnd
  41. ld a, D_UP
  42. ld [hli], a
  43. ld [hli], a
  44. ld [hli], a
  45. ld [hli], a
  46. ld [hli], a
  47. ld [hl], a
  48. ld a, $6
  49. ld [wSimulatedJoypadStatesIndex], a
  50. call StartSimulatingJoypadStates
  51. ld a, $3
  52. ld [wAgathaCurScript], a
  53. ld [wCurMapScript], a
  54. ret
  55. AgathaScript0:
  56. ld hl, AgathaEntranceCoords
  57. call ArePlayerCoordsInArray
  58. jp nc, CheckFightingMapTrainers
  59. xor a
  60. ld [hJoyPressed], a
  61. ld [hJoyHeld], a
  62. ld [wSimulatedJoypadStatesEnd], a
  63. ld [wSimulatedJoypadStatesIndex], a
  64. ld a, [wCoordIndex]
  65. cp $3 ; Is player standing one tile above the exit?
  66. jr c, .stopPlayerFromLeaving
  67. CheckAndSetEvent EVENT_AUTOWALKED_INTO_AGATHAS_ROOM
  68. jr z, AgathaScriptWalkIntoRoom
  69. .stopPlayerFromLeaving
  70. ld a, $2
  71. ld [hSpriteIndexOrTextID], a
  72. call DisplayTextID ; "Don't run away!"
  73. ld a, D_UP
  74. ld [wSimulatedJoypadStatesEnd], a
  75. ld a, $1
  76. ld [wSimulatedJoypadStatesIndex], a
  77. call StartSimulatingJoypadStates
  78. ld a, $3
  79. ld [wAgathaCurScript], a
  80. ld [wCurMapScript], a
  81. ret
  82. AgathaEntranceCoords:
  83. db $0A,$04
  84. db $0A,$05
  85. db $0B,$04
  86. db $0B,$05
  87. db $FF
  88. AgathaScript3:
  89. ld a, [wSimulatedJoypadStatesIndex]
  90. and a
  91. ret nz
  92. call Delay3
  93. xor a
  94. ld [wJoyIgnore], a
  95. ld [wAgathaCurScript], a
  96. ld [wCurMapScript], a
  97. ret
  98. AgathaScript2:
  99. call EndTrainerBattle
  100. ld a, [wIsInBattle]
  101. cp $ff
  102. jp z, ResetAgathaScript
  103. ld a, $1
  104. ld [hSpriteIndexOrTextID], a
  105. call DisplayTextID
  106. ld a, $1
  107. ld [wGaryCurScript], a
  108. ret
  109. AgathaTextPointers:
  110. dw AgathaText1
  111. dw AgathaDontRunAwayText
  112. AgathaTrainerHeader0:
  113. dbEventFlagBit EVENT_BEAT_AGATHAS_ROOM_TRAINER_0
  114. db ($0 << 4) ; trainer's view range
  115. dwEventFlagAddress EVENT_BEAT_AGATHAS_ROOM_TRAINER_0
  116. dw AgathaBeforeBattleText ; TextBeforeBattle
  117. dw AgathaAfterBattleText ; TextAfterBattle
  118. dw AgathaEndBattleText ; TextEndBattle
  119. dw AgathaEndBattleText ; TextEndBattle
  120. db $ff
  121. AgathaText1:
  122. TX_ASM
  123. ld hl, AgathaTrainerHeader0
  124. call TalkToTrainer
  125. jp TextScriptEnd
  126. AgathaBeforeBattleText:
  127. TX_FAR _AgathaBeforeBattleText
  128. db "@"
  129. AgathaEndBattleText:
  130. TX_FAR _AgathaEndBattleText
  131. db "@"
  132. AgathaAfterBattleText:
  133. TX_FAR _AgathaAfterBattleText
  134. db "@"
  135. AgathaDontRunAwayText:
  136. TX_FAR _AgathaDontRunAwayText
  137. db "@"