forked from waicalibre/pokered-eo
-
Notifications
You must be signed in to change notification settings - Fork 0
/
VermilionGym.asm
executable file
·246 lines (212 loc) · 5.11 KB
/
VermilionGym.asm
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
VermilionGym_Script:
ld hl, wCurrentMapScriptFlags
bit 5, [hl]
res 5, [hl]
push hl
call nz, .LoadNames
pop hl
bit 6, [hl]
res 6, [hl]
call nz, VermilionGymSetDoorTile
call EnableAutoTextBoxDrawing
ld hl, VermilionGymTrainerHeader0
ld de, VermilionGym_ScriptPointers
ld a, [wVermilionGymCurScript]
call ExecuteCurMapScriptInTable
ld [wVermilionGymCurScript], a
ret
.LoadNames:
ld hl, .CityName
ld de, .LeaderName
jp LoadGymLeaderAndCityName
.CityName:
db "VERMILION CITY@"
.LeaderName:
db "LT.SURGE@"
VermilionGymSetDoorTile:
CheckEvent EVENT_2ND_LOCK_OPENED
jr nz, .doorsOpen
ld a, $24 ; double door tile ID
jr .replaceTile
.doorsOpen
ld a, SFX_GO_INSIDE
call PlaySound
ld a, $5 ; clear floor tile ID
.replaceTile
ld [wNewTileBlockID], a
lb bc, 2, 2
predef_jump ReplaceTileBlock
VermilionGymResetScripts:
xor a
ld [wJoyIgnore], a
ld [wVermilionGymCurScript], a
ld [wCurMapScript], a
ret
VermilionGym_ScriptPointers:
dw CheckFightingMapTrainers
dw DisplayEnemyTrainerTextAndStartBattle
dw EndTrainerBattle
dw VermilionGymLTSurgePostBattle
VermilionGymLTSurgePostBattle:
ld a, [wIsInBattle]
cp $ff ; did we lose?
jp z, VermilionGymResetScripts
ld a, D_RIGHT | D_LEFT | D_UP | D_DOWN
ld [wJoyIgnore], a
VermilionGymReceiveTM24:
ld a, $6
ldh [hSpriteIndexOrTextID], a
call DisplayTextID
SetEvent EVENT_BEAT_LT_SURGE
lb bc, TM_THUNDERBOLT, 1
call GiveItem
jr nc, .BagFull
ld a, $7
ldh [hSpriteIndexOrTextID], a
call DisplayTextID
SetEvent EVENT_GOT_TM24
jr .gymVictory
.BagFull
ld a, $8
ldh [hSpriteIndexOrTextID], a
call DisplayTextID
.gymVictory
ld hl, wObtainedBadges
set BIT_THUNDERBADGE, [hl]
ld hl, wBeatGymFlags
set BIT_THUNDERBADGE, [hl]
; deactivate gym trainers
SetEventRange EVENT_BEAT_VERMILION_GYM_TRAINER_0, EVENT_BEAT_VERMILION_GYM_TRAINER_2
jp VermilionGymResetScripts
VermilionGym_TextPointers:
dw LTSurgeText
dw VermilionGymTrainerText1
dw VermilionGymTrainerText2
dw VermilionGymTrainerText3
dw VermilionGymFanText
dw LTSurgeThunderbadgeInfoText
dw ReceivedTM24Text
dw TM24NoRoomText
VermilionGymTrainerHeader0:
trainer EVENT_BEAT_VERMILION_GYM_TRAINER_0, 3, VermilionGymBattleText1, VermilionGymEndBattleText1, VermilionGymAfterBattleText1
VermilionGymTrainerHeader1:
trainer EVENT_BEAT_VERMILION_GYM_TRAINER_1, 2, VermilionGymBattleText2, VermilionGymEndBattleText2, VermilionGymAfterBattleText2
VermilionGymTrainerHeader2:
trainer EVENT_BEAT_VERMILION_GYM_TRAINER_2, 3, VermilionGymBattleText3, VermilionGymEndBattleText3, VermilionGymAfterBattleText3
db -1 ; end
LTSurgeText:
text_asm
CheckEvent EVENT_BEAT_LT_SURGE
jr z, .beforeBeat
CheckEventReuseA EVENT_GOT_TM24
jr nz, .afterBeat
call z, VermilionGymReceiveTM24
call DisableWaitingAfterTextDisplay
jr .done
.afterBeat
ld hl, LTSurgePostBattleAdviceText
call PrintText
jr .done
.beforeBeat
ld hl, LTSurgePreBattleText
call PrintText
ld hl, wd72d
set 6, [hl]
set 7, [hl]
ld hl, ReceivedThunderbadgeText
ld de, ReceivedThunderbadgeText
call SaveEndBattleTextPointers
ldh a, [hSpriteIndex]
ld [wSpriteIndex], a
call EngageMapTrainer
call InitBattleEnemyParameters
ld a, $3
ld [wGymLeaderNo], a
xor a
ldh [hJoyHeld], a
ld a, $3 ; set script index to LT Surge post-battle script
ld [wVermilionGymCurScript], a
ld [wCurMapScript], a
.done
jp TextScriptEnd
LTSurgePreBattleText:
text_far _LTSurgePreBattleText
text_end
LTSurgePostBattleAdviceText:
text_far _LTSurgePostBattleAdviceText
text_end
LTSurgeThunderbadgeInfoText:
text_far _LTSurgeThunderbadgeInfoText
text_end
ReceivedTM24Text:
text_far _ReceivedTM24Text
sound_get_key_item
text_far _TM24ExplanationText
text_end
TM24NoRoomText:
text_far _TM24NoRoomText
text_end
ReceivedThunderbadgeText:
text_far _ReceivedThunderbadgeText
text_end
VermilionGymTrainerText1:
text_asm
ld hl, VermilionGymTrainerHeader0
call TalkToTrainer
jp TextScriptEnd
VermilionGymBattleText1:
text_far _VermilionGymBattleText1
text_end
VermilionGymEndBattleText1:
text_far _VermilionGymEndBattleText1
text_end
VermilionGymAfterBattleText1:
text_far _VermilionGymAfterBattleText1
text_end
VermilionGymTrainerText2:
text_asm
ld hl, VermilionGymTrainerHeader1
call TalkToTrainer
jp TextScriptEnd
VermilionGymBattleText2:
text_far _VermilionGymBattleText2
text_end
VermilionGymEndBattleText2:
text_far _VermilionGymEndBattleText2
text_end
VermilionGymAfterBattleText2:
text_far _VermilionGymAfterBattleText2
text_end
VermilionGymTrainerText3:
text_asm
ld hl, VermilionGymTrainerHeader2
call TalkToTrainer
jp TextScriptEnd
VermilionGymBattleText3:
text_far _VermilionGymBattleText3
text_end
VermilionGymEndBattleText3:
text_far _VermilionGymEndBattleText3
text_end
VermilionGymAfterBattleText3:
text_far _VermilionGymAfterBattleText3
text_end
VermilionGymFanText:
text_asm
ld a, [wBeatGymFlags]
bit BIT_THUNDERBADGE, a
jr nz, .afterBeat
ld hl, VermilionGymFanPreBattleText
call PrintText
jr .done
.afterBeat
ld hl, VermilionGymFanPostBattleText
call PrintText
.done
jp TextScriptEnd
VermilionGymFanPreBattleText:
text_far _VermilionGymFanPreBattleText
text_end
VermilionGymFanPostBattleText:
text_far _VermilionGymFanPostBattleText
text_end