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
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
|
SaffronGym_Script:
ld hl, wCurrentMapScriptFlags
bit 6, [hl]
res 6, [hl]
call nz, .LoadNames
call EnableAutoTextBoxDrawing
ld hl, SaffronGymTrainerHeaders
ld de, SaffronGym_ScriptPointers
ld a, [wSaffronGymCurScript]
call ExecuteCurMapScriptInTable
ld [wSaffronGymCurScript], a
ret
.LoadNames:
ld hl, .CityName
ld de, .LeaderName
jp LoadGymLeaderAndCityName
.CityName:
db "SAFFRON CITY@"
.LeaderName:
db "SABRINA@"
SaffronGymResetScripts:
xor a
ld [wJoyIgnore], a
ld [wSaffronGymCurScript], a
ld [wCurMapScript], a
ret
SaffronGym_ScriptPointers:
dw CheckFightingMapTrainers
dw DisplayEnemyTrainerTextAndStartBattle
dw EndTrainerBattle
dw SaffronGymSabrinaPostBattle
SaffronGymSabrinaPostBattle:
ld a, [wIsInBattle]
cp $ff
jp z, SaffronGymResetScripts
ld a, $f0
ld [wJoyIgnore], a
SaffronGymReceiveTM46:
ld a, $a
ldh [hSpriteIndexOrTextID], a
call DisplayTextID
SetEvent EVENT_BEAT_SABRINA
lb bc, TM_PSYWAVE, 1
call GiveItem
jr nc, .BagFull
ld a, $b
ldh [hSpriteIndexOrTextID], a
call DisplayTextID
SetEvent EVENT_GOT_TM46
jr .gymVictory
.BagFull
ld a, $c
ldh [hSpriteIndexOrTextID], a
call DisplayTextID
.gymVictory
ld hl, wObtainedBadges
set BIT_MARSHBADGE, [hl]
ld hl, wBeatGymFlags
set BIT_MARSHBADGE, [hl]
; deactivate gym trainers
SetEventRange EVENT_BEAT_SAFFRON_GYM_TRAINER_0, EVENT_BEAT_SAFFRON_GYM_TRAINER_6
jp SaffronGymResetScripts
SaffronGym_TextPointers:
dw SabrinaText
dw SaffronGymTrainerText1
dw SaffronGymTrainerText2
dw SaffronGymTrainerText3
dw SaffronGymTrainerText4
dw SaffronGymTrainerText5
dw SaffronGymTrainerText6
dw SaffronGymTrainerText7
dw SaffronGymGuideText
dw KogaMarshBadgeInfoText
dw ReceivedTM46Text
dw TM46NoRoomText
SaffronGymTrainerHeaders:
def_trainers 2
SaffronGymTrainerHeader0:
trainer EVENT_BEAT_SAFFRON_GYM_TRAINER_0, 3, SaffronGymBattleText1, SaffronGymEndBattleText1, SaffronGymAfterBattleText1
SaffronGymTrainerHeader1:
trainer EVENT_BEAT_SAFFRON_GYM_TRAINER_1, 3, SaffronGymBattleText2, SaffronGymEndBattleText2, SaffronGymAfterBattleText2
SaffronGymTrainerHeader2:
trainer EVENT_BEAT_SAFFRON_GYM_TRAINER_2, 3, SaffronGymBattleText3, SaffronGymEndBattleText3, SaffronGymAfterBattleText3
SaffronGymTrainerHeader3:
trainer EVENT_BEAT_SAFFRON_GYM_TRAINER_3, 3, SaffronGymBattleText4, SaffronGymEndBattleText4, SaffronGymAfterBattleText4
SaffronGymTrainerHeader4:
trainer EVENT_BEAT_SAFFRON_GYM_TRAINER_4, 3, SaffronGymBattleText5, SaffronGymEndBattleText5, SaffronGymAfterBattleText5
SaffronGymTrainerHeader5:
trainer EVENT_BEAT_SAFFRON_GYM_TRAINER_5, 3, SaffronGymBattleText6, SaffronGymEndBattleText6, SaffronGymAfterBattleText6
SaffronGymTrainerHeader6:
trainer EVENT_BEAT_SAFFRON_GYM_TRAINER_6, 3, SaffronGymBattleText7, SaffronGymEndBattleText7, SaffronGymAfterBattleText7
db -1 ; end
SabrinaText:
text_asm
CheckEvent EVENT_BEAT_SABRINA
jr z, .beforeBeat
CheckEventReuseA EVENT_GOT_TM46
jr nz, .afterBeat
call z, SaffronGymReceiveTM46
call DisableWaitingAfterTextDisplay
jr .done
.afterBeat
ld hl, SabrinaPostBattleAdviceText
call PrintText
jr .done
.beforeBeat
ld hl, SabrinaPreBattleText
call PrintText
ld hl, wd72d
set 6, [hl]
set 7, [hl]
ld hl, ReceivedMarshBadgeText
ld de, ReceivedMarshBadgeText
call SaveEndBattleTextPointers
ldh a, [hSpriteIndex]
ld [wSpriteIndex], a
call EngageMapTrainer
call InitBattleEnemyParameters
ld a, $6
ld [wGymLeaderNo], a
ld a, $3
ld [wSaffronGymCurScript], a
.done
jp TextScriptEnd
SabrinaPreBattleText:
text_far _SabrinaPreBattleText
text_end
ReceivedMarshBadgeText:
text_far _ReceivedMarshBadgeText
sound_get_key_item ; actually plays the second channel of SFX_BALL_POOF due to the wrong music bank being loaded
text_promptbutton
text_end
SabrinaPostBattleAdviceText:
text_far _SabrinaPostBattleAdviceText
text_end
KogaMarshBadgeInfoText:
text_far _KogaMarshBadgeInfoText
text_end
ReceivedTM46Text:
text_far _ReceivedTM46Text
sound_get_item_1
text_far _TM46ExplanationText
text_end
TM46NoRoomText:
text_far _TM46NoRoomText
text_end
SaffronGymTrainerText1:
text_asm
ld hl, SaffronGymTrainerHeader0
call TalkToTrainer
jp TextScriptEnd
SaffronGymTrainerText2:
text_asm
ld hl, SaffronGymTrainerHeader1
call TalkToTrainer
jp TextScriptEnd
SaffronGymTrainerText3:
text_asm
ld hl, SaffronGymTrainerHeader2
call TalkToTrainer
jp TextScriptEnd
SaffronGymTrainerText4:
text_asm
ld hl, SaffronGymTrainerHeader3
call TalkToTrainer
jp TextScriptEnd
SaffronGymTrainerText5:
text_asm
ld hl, SaffronGymTrainerHeader4
call TalkToTrainer
jp TextScriptEnd
SaffronGymTrainerText6:
text_asm
ld hl, SaffronGymTrainerHeader5
call TalkToTrainer
jp TextScriptEnd
SaffronGymTrainerText7:
text_asm
ld hl, SaffronGymTrainerHeader6
call TalkToTrainer
jp TextScriptEnd
SaffronGymGuideText:
text_asm
CheckEvent EVENT_BEAT_SABRINA
jr nz, .afterBeat
ld hl, SaffronGymGuidePreBattleText
call PrintText
jr .done
.afterBeat
ld hl, SaffronGymGuidePostBattleText
call PrintText
.done
jp TextScriptEnd
SaffronGymGuidePreBattleText:
text_far _SaffronGymGuidePreBattleText
text_end
SaffronGymGuidePostBattleText:
text_far _SaffronGymGuidePostBattleText
text_end
SaffronGymBattleText1:
text_far _SaffronGymBattleText1
text_end
SaffronGymEndBattleText1:
text_far _SaffronGymEndBattleText1
text_end
SaffronGymAfterBattleText1:
text_far _SaffronGymAfterBattleText1
text_end
SaffronGymBattleText2:
text_far _SaffronGymBattleText2
text_end
SaffronGymEndBattleText2:
text_far _SaffronGymEndBattleText2
text_end
SaffronGymAfterBattleText2:
text_far _SaffronGymAfterBattleText2
text_end
SaffronGymBattleText3:
text_far _SaffronGymBattleText3
text_end
SaffronGymEndBattleText3:
text_far _SaffronGymEndBattleText3
text_end
SaffronGymAfterBattleText3:
text_far _SaffronGymAfterBattleText3
text_end
SaffronGymBattleText4:
text_far _SaffronGymBattleText4
text_end
SaffronGymEndBattleText4:
text_far _SaffronGymEndBattleText4
text_end
SaffronGymAfterBattleText4:
text_far _SaffronGymAfterBattleText4
text_end
SaffronGymBattleText5:
text_far _SaffronGymBattleText5
text_end
SaffronGymEndBattleText5:
text_far _SaffronGymEndBattleText5
text_end
SaffronGymAfterBattleText5:
text_far _SaffronGymAfterBattleText5
text_end
SaffronGymBattleText6:
text_far _SaffronGymBattleText6
text_end
SaffronGymEndBattleText6:
text_far _SaffronGymEndBattleText6
text_end
SaffronGymAfterBattleText6:
text_far _SaffronGymAfterBattleText6
text_end
SaffronGymBattleText7:
text_far _SaffronGymBattleText7
text_end
SaffronGymEndBattleText7:
text_far _SaffronGymEndBattleText7
text_end
SaffronGymAfterBattleText7:
text_far _SaffronGymAfterBattleText7
text_end
|