special_warps.asm 2.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150
  1. SpecialWarpIn:
  2. call LoadSpecialWarpData
  3. predef LoadTilesetHeader
  4. ld hl, wd732
  5. bit 2, [hl] ; dungeon warp or fly warp?
  6. res 2, [hl]
  7. jr z, .next
  8. ; if dungeon warp or fly warp
  9. ld a, [wDestinationMap]
  10. jr .next2
  11. .next
  12. bit 1, [hl]
  13. jr z, .next3
  14. call EmptyFunc
  15. .next3
  16. ld a, 0
  17. .next2
  18. ld b, a
  19. ld a, [wd72d]
  20. and a
  21. jr nz, .next4
  22. ld a, b
  23. .next4
  24. ld hl, wd732
  25. bit 4, [hl] ; dungeon warp?
  26. ret nz
  27. ; if not dungeon warp
  28. ld [wLastMap], a
  29. ret
  30. ; gets the map ID, tile block map view pointer, tileset, and coordinates
  31. LoadSpecialWarpData:
  32. ld a, [wd72d]
  33. cp TRADE_CENTER
  34. jr nz, .notTradeCenter
  35. ld hl, TradeCenterSpec1
  36. ld a, [hSerialConnectionStatus]
  37. cp USING_INTERNAL_CLOCK ; which gameboy is clocking determines who is on the left and who is on the right
  38. jr z, .copyWarpData
  39. ld hl, TradeCenterSpec2
  40. jr .copyWarpData
  41. .notTradeCenter
  42. cp COLOSSEUM
  43. jr nz, .notColosseum
  44. ld hl, ColosseumSpec1
  45. ld a, [hSerialConnectionStatus]
  46. cp USING_INTERNAL_CLOCK
  47. jr z, .copyWarpData
  48. ld hl, ColosseumSpec2
  49. jr .copyWarpData
  50. .notColosseum
  51. ld a, [wd732]
  52. bit 1, a
  53. jr nz, .notFirstMap
  54. bit 2, a
  55. jr nz, .notFirstMap
  56. ld hl, FirstMapSpec
  57. .copyWarpData
  58. ld de, wCurMap
  59. ld c, $7
  60. .copyWarpDataLoop
  61. ld a, [hli]
  62. ld [de], a
  63. inc de
  64. dec c
  65. jr nz, .copyWarpDataLoop
  66. ld a, [hli]
  67. ld [wCurMapTileset], a
  68. xor a
  69. jr .done
  70. .notFirstMap
  71. ld a, [wLastMap] ; this value is overwritten before it's ever read
  72. ld hl, wd732
  73. bit 4, [hl] ; used dungeon warp (jumped down hole/waterfall)?
  74. jr nz, .usedDunegonWarp
  75. bit 6, [hl] ; return to last pokemon center (or player's house)?
  76. res 6, [hl]
  77. jr z, .otherDestination
  78. ; return to last pokemon center or player's house
  79. ld a, [wLastBlackoutMap]
  80. jr .usedFlyWarp
  81. .usedDunegonWarp
  82. ld hl, wd72d
  83. res 4, [hl]
  84. ld a, [wDungeonWarpDestinationMap]
  85. ld b, a
  86. ld [wCurMap], a
  87. ld a, [wWhichDungeonWarp]
  88. ld c, a
  89. ld hl, DungeonWarpList
  90. ld de, 0
  91. ld a, 6
  92. ld [wDungeonWarpDataEntrySize], a
  93. .dungeonWarpListLoop
  94. ld a, [hli]
  95. cp b
  96. jr z, .matchedDungeonWarpDestinationMap
  97. inc hl
  98. jr .nextDungeonWarp
  99. .matchedDungeonWarpDestinationMap
  100. ld a, [hli]
  101. cp c
  102. jr z, .matchedDungeonWarpID
  103. .nextDungeonWarp
  104. ld a, [wDungeonWarpDataEntrySize]
  105. add e
  106. ld e, a
  107. jr .dungeonWarpListLoop
  108. .matchedDungeonWarpID
  109. ld hl, DungeonWarpData
  110. add hl, de
  111. jr .copyWarpData2
  112. .otherDestination
  113. ld a, [wDestinationMap]
  114. .usedFlyWarp
  115. ld b, a
  116. ld [wCurMap], a
  117. ld hl, FlyWarpDataPtr
  118. .flyWarpDataPtrLoop
  119. ld a, [hli]
  120. inc hl
  121. cp b
  122. jr z, .foundFlyWarpMatch
  123. inc hl
  124. inc hl
  125. jr .flyWarpDataPtrLoop
  126. .foundFlyWarpMatch
  127. ld a, [hli]
  128. ld h, [hl]
  129. ld l, a
  130. .copyWarpData2
  131. ld de, wCurrentTileBlockMapViewPointer
  132. ld c, $6
  133. .copyWarpDataLoop2
  134. ld a, [hli]
  135. ld [de], a
  136. inc de
  137. dec c
  138. jr nz, .copyWarpDataLoop2
  139. xor a ; OVERWORLD
  140. ld [wCurMapTileset], a
  141. .done
  142. ld [wYOffsetSinceLastSpecialWarp], a
  143. ld [wXOffsetSinceLastSpecialWarp], a
  144. ld a, $ff ; the player's coordinates have already been updated using a special warp, so don't use any of the normal warps
  145. ld [wDestinationWarpID], a
  146. ret
  147. INCLUDE "data/special_warps.asm"