lorelei.asm 3.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154
  1. LoreleiScript:
  2. call LoreleiShowOrHideExitBlock
  3. call EnableAutoTextBoxDrawing
  4. ld hl, LoreleiTrainerHeader0
  5. ld de, LoreleiScriptPointers
  6. ld a, [wLoreleiCurScript]
  7. call ExecuteCurMapScriptInTable
  8. ld [wLoreleiCurScript], a
  9. ret
  10. LoreleiShowOrHideExitBlock:
  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. ld hl, wBeatLorelei
  17. set 1, [hl]
  18. CheckEvent EVENT_BEAT_LORELEIS_ROOM_TRAINER_0
  19. jr z, .blockExitToNextRoom
  20. ld a, $5
  21. jr .setExitBlock
  22. .blockExitToNextRoom
  23. ld a, $24
  24. .setExitBlock
  25. ld [wNewTileBlockID], a
  26. lb bc, 0, 2
  27. predef_jump ReplaceTileBlock
  28. ResetLoreleiScript:
  29. xor a
  30. ld [wLoreleiCurScript], a
  31. ret
  32. LoreleiScriptPointers:
  33. dw LoreleiScript0
  34. dw DisplayEnemyTrainerTextAndStartBattle
  35. dw LoreleiScript2
  36. dw LoreleiScript3
  37. dw LoreleiScript4
  38. LoreleiScript4:
  39. ret
  40. LoreleiScriptWalkIntoRoom:
  41. ; Walk six steps upward.
  42. ld hl, wSimulatedJoypadStatesEnd
  43. ld a, D_UP
  44. ld [hli], a
  45. ld [hli], a
  46. ld [hli], a
  47. ld [hli], a
  48. ld [hli], a
  49. ld [hl], a
  50. ld a, $6
  51. ld [wSimulatedJoypadStatesIndex], a
  52. call StartSimulatingJoypadStates
  53. ld a, $3
  54. ld [wLoreleiCurScript], a
  55. ld [wCurMapScript], a
  56. ret
  57. LoreleiScript0:
  58. ld hl, LoreleiEntranceCoords
  59. call ArePlayerCoordsInArray
  60. jp nc, CheckFightingMapTrainers
  61. xor a
  62. ld [hJoyPressed], a
  63. ld [hJoyHeld], a
  64. ld [wSimulatedJoypadStatesEnd], a
  65. ld [wSimulatedJoypadStatesIndex], a
  66. ld a, [wCoordIndex]
  67. cp $3 ; Is player standing one tile above the exit?
  68. jr c, .stopPlayerFromLeaving
  69. CheckAndSetEvent EVENT_AUTOWALKED_INTO_LORELEIS_ROOM
  70. jr z, LoreleiScriptWalkIntoRoom
  71. .stopPlayerFromLeaving
  72. ld a, $2
  73. ld [hSpriteIndexOrTextID], a
  74. call DisplayTextID ; "Don't run away!"
  75. ld a, D_UP
  76. ld [wSimulatedJoypadStatesEnd], a
  77. ld a, $1
  78. ld [wSimulatedJoypadStatesIndex], a
  79. call StartSimulatingJoypadStates
  80. ld a, $3
  81. ld [wLoreleiCurScript], a
  82. ld [wCurMapScript], a
  83. ret
  84. LoreleiEntranceCoords:
  85. db $0A,$04
  86. db $0A,$05
  87. db $0B,$04
  88. db $0B,$05
  89. db $FF
  90. LoreleiScript3:
  91. ld a, [wSimulatedJoypadStatesIndex]
  92. and a
  93. ret nz
  94. call Delay3
  95. xor a
  96. ld [wJoyIgnore], a
  97. ld [wLoreleiCurScript], a
  98. ld [wCurMapScript], a
  99. ret
  100. LoreleiScript2:
  101. call EndTrainerBattle
  102. ld a, [wIsInBattle]
  103. cp $ff
  104. jp z, ResetLoreleiScript
  105. ld a, $1
  106. ld [hSpriteIndexOrTextID], a
  107. jp DisplayTextID
  108. LoreleiTextPointers:
  109. dw LoreleiText1
  110. dw LoreleiDontRunAwayText
  111. LoreleiTrainerHeader0:
  112. dbEventFlagBit EVENT_BEAT_LORELEIS_ROOM_TRAINER_0
  113. db ($0 << 4) ; trainer's view range
  114. dwEventFlagAddress EVENT_BEAT_LORELEIS_ROOM_TRAINER_0
  115. dw LoreleiBeforeBattleText ; TextBeforeBattle
  116. dw LoreleiAfterBattleText ; TextAfterBattle
  117. dw LoreleiEndBattleText ; TextEndBattle
  118. dw LoreleiEndBattleText ; TextEndBattle
  119. db $ff
  120. LoreleiText1:
  121. TX_ASM
  122. ld hl, LoreleiTrainerHeader0
  123. call TalkToTrainer
  124. jp TextScriptEnd
  125. LoreleiBeforeBattleText:
  126. TX_FAR _LoreleiBeforeBattleText
  127. db "@"
  128. LoreleiEndBattleText:
  129. TX_FAR _LoreleiEndBattleText
  130. db "@"
  131. LoreleiAfterBattleText:
  132. TX_FAR _LoreleiAfterBattleText
  133. db "@"
  134. LoreleiDontRunAwayText:
  135. TX_FAR _LoreleiDontRunAwayText
  136. db "@"