Book a Demo!
CoCalc Logo Icon
StoreFeaturesDocsShareSupportNewsAboutPoliciesSign UpSign In
pret
GitHub Repository: pret/pokered
Path: blob/master/engine/overworld/special_warps.asm
1271 views
1
PrepareForSpecialWarp::
2
call LoadSpecialWarpData
3
predef LoadTilesetHeader
4
ld hl, wStatusFlags6
5
bit BIT_FLY_OR_DUNGEON_WARP, [hl]
6
res BIT_FLY_OR_DUNGEON_WARP, [hl]
7
jr z, .debugNewGameWarp
8
ld a, [wDestinationMap]
9
jr .next
10
.debugNewGameWarp
11
bit BIT_DEBUG_MODE, [hl]
12
jr z, .setNewGameMatWarp ; apply to StartNewGameDebug only
13
call PrepareNewGameDebug
14
.setNewGameMatWarp
15
; This is called by OakSpeech during StartNewGame and
16
; loads the first warp event for the specified map index.
17
ld a, PALLET_TOWN
18
.next
19
ld b, a
20
ld a, [wStatusFlags3]
21
and a ; ???
22
jr nz, .next2
23
ld a, b
24
.next2
25
ld hl, wStatusFlags6
26
bit BIT_DUNGEON_WARP, [hl]
27
ret nz
28
ld [wLastMap], a
29
ret
30
31
LoadSpecialWarpData:
32
ld a, [wCableClubDestinationMap]
33
cp TRADE_CENTER
34
jr nz, .notTradeCenter
35
ld hl, TradeCenterPlayerWarp
36
ldh a, [hSerialConnectionStatus]
37
cp USING_INTERNAL_CLOCK
38
jr z, .copyWarpData
39
ld hl, TradeCenterFriendWarp
40
jr .copyWarpData
41
.notTradeCenter
42
cp COLOSSEUM
43
jr nz, .notColosseum
44
ld hl, ColosseumPlayerWarp
45
ldh a, [hSerialConnectionStatus]
46
cp USING_INTERNAL_CLOCK
47
jr z, .copyWarpData
48
ld hl, ColosseumFriendWarp
49
jr .copyWarpData
50
.notColosseum
51
ld a, [wStatusFlags6]
52
bit BIT_DEBUG_MODE, a
53
; warp to wLastMap (PALLET_TOWN) for StartNewGameDebug
54
jr nz, .notNewGameWarp
55
bit BIT_FLY_OR_DUNGEON_WARP, a
56
jr nz, .notNewGameWarp
57
ld hl, NewGameWarp
58
.copyWarpData
59
ld de, wCurMap
60
ld c, $7
61
.copyWarpDataLoop
62
ld a, [hli]
63
ld [de], a
64
inc de
65
dec c
66
jr nz, .copyWarpDataLoop
67
ld a, [hli]
68
ld [wCurMapTileset], a
69
xor a
70
jr .done
71
.notNewGameWarp
72
ld a, [wLastMap] ; this value is overwritten before it's ever read
73
ld hl, wStatusFlags6
74
bit BIT_DUNGEON_WARP, [hl]
75
jr nz, .usedDungeonWarp
76
bit BIT_ESCAPE_WARP, [hl]
77
res BIT_ESCAPE_WARP, [hl]
78
jr z, .otherDestination
79
ld a, [wLastBlackoutMap]
80
jr .usedFlyWarp
81
.usedDungeonWarp
82
ld hl, wStatusFlags3
83
res BIT_ON_DUNGEON_WARP, [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, -1 ; exclude normal warps
145
ld [wDestinationWarpID], a
146
ret
147
148
INCLUDE "data/maps/special_warps.asm"
149
150