pallettown.asm 4.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215
  1. PalletTownScript:
  2. CheckEvent EVENT_GOT_POKEBALLS_FROM_OAK
  3. jr z, .next
  4. SetEvent EVENT_PALLET_AFTER_GETTING_POKEBALLS
  5. .next
  6. call EnableAutoTextBoxDrawing
  7. ld hl, PalletTownScriptPointers
  8. ld a, [wPalletTownCurScript]
  9. jp CallFunctionInTable
  10. PalletTownScriptPointers:
  11. dw PalletTownScript0
  12. dw PalletTownScript1
  13. dw PalletTownScript2
  14. dw PalletTownScript3
  15. dw PalletTownScript4
  16. dw PalletTownScript5
  17. dw PalletTownScript6
  18. PalletTownScript0:
  19. CheckEvent EVENT_FOLLOWED_OAK_INTO_LAB
  20. ret nz
  21. ld a, [wYCoord]
  22. cp 1 ; is player near north exit?
  23. ret nz
  24. xor a
  25. ld [hJoyHeld], a
  26. ld a, PLAYER_DIR_DOWN
  27. ld [wPlayerMovingDirection], a
  28. ld a, $FF
  29. call PlaySound ; stop music
  30. ld a, BANK(Music_MeetProfOak)
  31. ld c, a
  32. ld a, MUSIC_MEET_PROF_OAK ; “oak appears” music
  33. call PlayMusic
  34. ld a, $FC
  35. ld [wJoyIgnore], a
  36. SetEvent EVENT_OAK_APPEARED_IN_PALLET
  37. ; trigger the next script
  38. ld a, 1
  39. ld [wPalletTownCurScript], a
  40. ret
  41. PalletTownScript1:
  42. xor a
  43. ld [wcf0d], a
  44. ld a, 1
  45. ld [hSpriteIndexOrTextID], a
  46. call DisplayTextID
  47. ld a, $FF
  48. ld [wJoyIgnore], a
  49. ld a, HS_PALLET_TOWN_OAK
  50. ld [wMissableObjectIndex], a
  51. predef ShowObject
  52. ; trigger the next script
  53. ld a, 2
  54. ld [wPalletTownCurScript], a
  55. ret
  56. PalletTownScript2:
  57. ld a, 1
  58. ld [H_SPRITEINDEX], a
  59. ld a, SPRITE_FACING_UP
  60. ld [hSpriteFacingDirection], a
  61. call SetSpriteFacingDirectionAndDelay
  62. call Delay3
  63. ld a, 1
  64. ld [wYCoord], a
  65. ld a, 1
  66. ld [hNPCPlayerRelativePosPerspective], a
  67. ld a, 1
  68. swap a
  69. ld [hNPCSpriteOffset], a
  70. predef CalcPositionOfPlayerRelativeToNPC
  71. ld hl, hNPCPlayerYDistance
  72. dec [hl]
  73. predef FindPathToPlayer ; load Oak’s movement into wNPCMovementDirections2
  74. ld de, wNPCMovementDirections2
  75. ld a, 1 ; oak
  76. ld [H_SPRITEINDEX], a
  77. call MoveSprite
  78. ld a, $FF
  79. ld [wJoyIgnore], a
  80. ; trigger the next script
  81. ld a, 3
  82. ld [wPalletTownCurScript], a
  83. ret
  84. PalletTownScript3:
  85. ld a, [wd730]
  86. bit 0, a
  87. ret nz
  88. xor a ; ld a, SPRITE_FACING_DOWN
  89. ld [wSpriteStateData1 + 9], a
  90. ld a, 1
  91. ld [wcf0d], a
  92. ld a, $FC
  93. ld [wJoyIgnore], a
  94. ld a, 1
  95. ld [hSpriteIndexOrTextID], a
  96. call DisplayTextID
  97. ; set up movement script that causes the player to follow Oak to his lab
  98. ld a, $FF
  99. ld [wJoyIgnore], a
  100. ld a, 1
  101. ld [wSpriteIndex], a
  102. xor a
  103. ld [wNPCMovementScriptFunctionNum], a
  104. ld a, 1
  105. ld [wNPCMovementScriptPointerTableNum], a
  106. ld a, [H_LOADEDROMBANK]
  107. ld [wNPCMovementScriptBank], a
  108. ; trigger the next script
  109. ld a, 4
  110. ld [wPalletTownCurScript], a
  111. ret
  112. PalletTownScript4:
  113. ld a, [wNPCMovementScriptPointerTableNum]
  114. and a ; is the movement script over?
  115. ret nz
  116. ; trigger the next script
  117. ld a, 5
  118. ld [wPalletTownCurScript], a
  119. ret
  120. PalletTownScript5:
  121. CheckEvent EVENT_DAISY_WALKING
  122. jr nz, .next
  123. CheckBothEventsSet EVENT_GOT_TOWN_MAP, EVENT_ENTERED_BLUES_HOUSE, 1
  124. jr nz, .next
  125. SetEvent EVENT_DAISY_WALKING
  126. ld a, HS_DAISY_SITTING
  127. ld [wMissableObjectIndex], a
  128. predef HideObject
  129. ld a, HS_DAISY_WALKING
  130. ld [wMissableObjectIndex], a
  131. predef_jump ShowObject
  132. .next
  133. CheckEvent EVENT_GOT_POKEBALLS_FROM_OAK
  134. ret z
  135. SetEvent EVENT_PALLET_AFTER_GETTING_POKEBALLS_2
  136. PalletTownScript6:
  137. ret
  138. PalletTownTextPointers:
  139. dw PalletTownText1
  140. dw PalletTownText2
  141. dw PalletTownText3
  142. dw PalletTownText4
  143. dw PalletTownText5
  144. dw PalletTownText6
  145. dw PalletTownText7
  146. PalletTownText1:
  147. TX_ASM
  148. ld a, [wcf0d]
  149. and a
  150. jr nz, .next
  151. ld a, 1
  152. ld [wDoNotWaitForButtonPressAfterDisplayingText], a
  153. ld hl, OakAppearsText
  154. jr .done
  155. .next
  156. ld hl, OakWalksUpText
  157. .done
  158. call PrintText
  159. jp TextScriptEnd
  160. OakAppearsText:
  161. TX_FAR _OakAppearsText
  162. TX_ASM
  163. ld c, 10
  164. call DelayFrames
  165. xor a
  166. ld [wEmotionBubbleSpriteIndex], a ; player's sprite
  167. ld [wWhichEmotionBubble], a ; EXCLAMATION_BUBBLE
  168. predef EmotionBubble
  169. ld a, PLAYER_DIR_DOWN
  170. ld [wPlayerMovingDirection], a
  171. jp TextScriptEnd
  172. OakWalksUpText:
  173. TX_FAR _OakWalksUpText
  174. db "@"
  175. PalletTownText2: ; girl
  176. TX_FAR _PalletTownText2
  177. db "@"
  178. PalletTownText3: ; fat man
  179. TX_FAR _PalletTownText3
  180. db "@"
  181. PalletTownText4: ; sign by lab
  182. TX_FAR _PalletTownText4
  183. db "@"
  184. PalletTownText5: ; sign by fence
  185. TX_FAR _PalletTownText5
  186. db "@"
  187. PalletTownText6: ; sign by Red’s house
  188. TX_FAR _PalletTownText6
  189. db "@"
  190. PalletTownText7: ; sign by Blue’s house
  191. TX_FAR _PalletTownText7
  192. db "@"