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
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
|
PrintNewBikeText:
call EnableAutoTextBoxDrawing
tx_pre_jump NewBicycleText
NewBicycleText:
TX_FAR _NewBicycleText
db "@"
DisplayOakLabLeftPoster:
call EnableAutoTextBoxDrawing
tx_pre_jump PushStartText
PushStartText:
TX_FAR _PushStartText
db "@"
DisplayOakLabRightPoster:
call EnableAutoTextBoxDrawing
ld hl, wPokedexOwned
ld b, wPokedexOwnedEnd - wPokedexOwned
call CountSetBits
ld a, [wNumSetBits]
cp 2
tx_pre_id SaveOptionText
jr c, .ownLessThanTwo
; own two or more mon
tx_pre_id StrengthsAndWeaknessesText
.ownLessThanTwo
jp PrintPredefTextID
SaveOptionText:
TX_FAR _SaveOptionText
db "@"
StrengthsAndWeaknessesText:
TX_FAR _StrengthsAndWeaknessesText
db "@"
SafariZoneCheck:
CheckEventHL EVENT_IN_SAFARI_ZONE ; if we are not in the Safari Zone,
jr z, SafariZoneGameStillGoing ; don't bother printing game over text
ld a, [wNumSafariBalls]
and a
jr z, SafariZoneGameOver
jr SafariZoneGameStillGoing
SafariZoneCheckSteps:
ld a, [wSafariSteps]
ld b, a
ld a, [wSafariSteps + 1]
ld c, a
or b
jr z, SafariZoneGameOver
dec bc
ld a, b
ld [wSafariSteps], a
ld a, c
ld [wSafariSteps + 1], a
SafariZoneGameStillGoing:
xor a
ld [wSafariZoneGameOver], a
ret
SafariZoneGameOver:
call EnableAutoTextBoxDrawing
xor a
ld [wAudioFadeOutControl], a
dec a
call PlaySound
ld c, BANK(SFX_Safari_Zone_PA)
ld a, SFX_SAFARI_ZONE_PA
call PlayMusic
.waitForMusicToPlay
ld a, [wChannelSoundIDs + CH4]
cp SFX_SAFARI_ZONE_PA
jr nz, .waitForMusicToPlay
ld a, TEXT_SAFARI_GAME_OVER
ld [hSpriteIndexOrTextID], a
call DisplayTextID
xor a
ld [wPlayerMovingDirection], a
ld a, SAFARI_ZONE_ENTRANCE
ld [hWarpDestinationMap], a
ld a, $3
ld [wDestinationWarpID], a
ld a, $5
ld [wSafariZoneEntranceCurScript], a
SetEvent EVENT_SAFARI_GAME_OVER
ld a, 1
ld [wSafariZoneGameOver], a
ret
PrintSafariGameOverText:
xor a
ld [wJoyIgnore], a
ld hl, SafariGameOverText
jp PrintText
SafariGameOverText:
TX_ASM
ld a, [wNumSafariBalls]
and a
jr z, .noMoreSafariBalls
ld hl, TimesUpText
call PrintText
.noMoreSafariBalls
ld hl, GameOverText
call PrintText
jp TextScriptEnd
TimesUpText:
TX_FAR _TimesUpText
db "@"
GameOverText:
TX_FAR _GameOverText
db "@"
PrintCinnabarQuiz:
ld a, [wSpriteStateData1 + 9]
cp SPRITE_FACING_UP
ret nz
call EnableAutoTextBoxDrawing
tx_pre_jump CinnabarGymQuiz
CinnabarGymQuiz:
TX_ASM
xor a
ld [wOpponentAfterWrongAnswer], a
ld a, [wHiddenObjectFunctionArgument]
push af
and $f
ld [hGymGateIndex], a
pop af
and $f0
swap a
ld [$ffdc], a
ld hl, CinnabarGymQuizIntroText
call PrintText
ld a, [hGymGateIndex]
dec a
add a
ld d, 0
ld e, a
ld hl, CinnabarQuizQuestions
add hl, de
ld a, [hli]
ld h, [hl]
ld l, a
call PrintText
ld a, 1
ld [wDoNotWaitForButtonPressAfterDisplayingText], a
call CinnabarGymQuiz_1ea92
jp TextScriptEnd
CinnabarGymQuizIntroText:
TX_FAR _CinnabarGymQuizIntroText
db "@"
CinnabarQuizQuestions:
dw CinnabarQuizQuestionsText1
dw CinnabarQuizQuestionsText2
dw CinnabarQuizQuestionsText3
dw CinnabarQuizQuestionsText4
dw CinnabarQuizQuestionsText5
dw CinnabarQuizQuestionsText6
CinnabarQuizQuestionsText1:
TX_FAR _CinnabarQuizQuestionsText1
db "@"
CinnabarQuizQuestionsText2:
TX_FAR _CinnabarQuizQuestionsText2
db "@"
CinnabarQuizQuestionsText3:
TX_FAR _CinnabarQuizQuestionsText3
db "@"
CinnabarQuizQuestionsText4:
TX_FAR _CinnabarQuizQuestionsText4
db "@"
CinnabarQuizQuestionsText5:
TX_FAR _CinnabarQuizQuestionsText5
db "@"
CinnabarQuizQuestionsText6:
TX_FAR _CinnabarQuizQuestionsText6
db "@"
CinnabarGymGateFlagAction:
EventFlagAddress hl, EVENT_CINNABAR_GYM_GATE0_UNLOCKED
predef_jump FlagActionPredef
CinnabarGymQuiz_1ea92:
call YesNoChoice
ld a, [$ffdc]
ld c, a
ld a, [wCurrentMenuItem]
cp c
jr nz, .wrongAnswer
ld hl, wCurrentMapScriptFlags
set 5, [hl]
ld a, [hGymGateIndex]
ld [$ffe0], a
ld hl, CinnabarGymQuizCorrectText
call PrintText
ld a, [$ffe0]
AdjustEventBit EVENT_CINNABAR_GYM_GATE0_UNLOCKED, 0
ld c, a
ld b, FLAG_SET
call CinnabarGymGateFlagAction
jp UpdateCinnabarGymGateTileBlocks_
.wrongAnswer
call WaitForSoundToFinish
ld a, SFX_DENIED
call PlaySound
call WaitForSoundToFinish
ld hl, CinnabarGymQuizIncorrectText
call PrintText
ld a, [hGymGateIndex]
add $2
AdjustEventBit EVENT_BEAT_CINNABAR_GYM_TRAINER_0, 2
ld c, a
ld b, FLAG_TEST
EventFlagAddress hl, EVENT_BEAT_CINNABAR_GYM_TRAINER_0
predef FlagActionPredef
ld a, c
and a
ret nz
ld a, [hGymGateIndex]
add $2
ld [wOpponentAfterWrongAnswer], a
ret
CinnabarGymQuizCorrectText:
db $0b
TX_FAR _CinnabarGymQuizCorrectText
db $06
TX_ASM
ld a, [$ffe0]
AdjustEventBit EVENT_CINNABAR_GYM_GATE0_UNLOCKED, 0
ld c, a
ld b, FLAG_TEST
call CinnabarGymGateFlagAction
ld a, c
and a
jp nz, TextScriptEnd
call WaitForSoundToFinish
ld a, SFX_GO_INSIDE
call PlaySound
call WaitForSoundToFinish
jp TextScriptEnd
CinnabarGymQuizIncorrectText:
TX_FAR _CinnabarGymQuizIncorrectText
db "@"
UpdateCinnabarGymGateTileBlocks_:
; Update the overworld map with open floor blocks or locked gate blocks
; depending on event flags.
ld a, 6
ld [hGymGateIndex], a
.loop
ld a, [hGymGateIndex]
dec a
add a
add a
ld d, 0
ld e, a
ld hl, CinnabarGymGateCoords
add hl, de
ld a, [hli]
ld b, [hl]
ld c, a
inc hl
ld a, [hl]
ld [wGymGateTileBlock], a
push bc
ld a, [hGymGateIndex]
ld [$ffe0], a
AdjustEventBit EVENT_CINNABAR_GYM_GATE0_UNLOCKED, 0
ld c, a
ld b, FLAG_TEST
call CinnabarGymGateFlagAction
ld a, c
and a
jr nz, .unlocked
ld a, [wGymGateTileBlock]
jr .next
.unlocked
ld a, $e
.next
pop bc
ld [wNewTileBlockID], a
predef ReplaceTileBlock
ld hl, hGymGateIndex
dec [hl]
jr nz, .loop
ret
CinnabarGymGateCoords:
; format: x-coord, y-coord, direction, padding
; direction: $54 = horizontal gate, $5f = vertical gate
db $09,$03,$54,$00
db $06,$03,$54,$00
db $06,$06,$54,$00
db $03,$08,$5f,$00
db $02,$06,$54,$00
db $02,$03,$54,$00
PrintMagazinesText:
call EnableAutoTextBoxDrawing
tx_pre MagazinesText
ret
MagazinesText:
TX_FAR _MagazinesText
db "@"
BillsHousePC:
call EnableAutoTextBoxDrawing
ld a, [wSpriteStateData1 + 9]
cp SPRITE_FACING_UP
ret nz
CheckEvent EVENT_LEFT_BILLS_HOUSE_AFTER_HELPING
jr nz, .displayBillsHousePokemonList
CheckEventReuseA EVENT_USED_CELL_SEPARATOR_ON_BILL
jr nz, .displayBillsHouseMonitorText
CheckEventReuseA EVENT_BILL_SAID_USE_CELL_SEPARATOR
jr nz, .doCellSeparator
.displayBillsHouseMonitorText
tx_pre_jump BillsHouseMonitorText
.doCellSeparator
ld a, $1
ld [wDoNotWaitForButtonPressAfterDisplayingText], a
tx_pre BillsHouseInitiatedText
ld c, 32
call DelayFrames
ld a, SFX_TINK
call PlaySound
call WaitForSoundToFinish
ld c, 80
call DelayFrames
ld a, SFX_SHRINK
call PlaySound
call WaitForSoundToFinish
ld c, 48
call DelayFrames
ld a, SFX_TINK
call PlaySound
call WaitForSoundToFinish
ld c, 32
call DelayFrames
ld a, SFX_GET_ITEM_1
call PlaySound
call WaitForSoundToFinish
call PlayDefaultMusic
SetEvent EVENT_USED_CELL_SEPARATOR_ON_BILL
ret
.displayBillsHousePokemonList
ld a, $1
ld [wDoNotWaitForButtonPressAfterDisplayingText], a
tx_pre BillsHousePokemonList
ret
BillsHouseMonitorText:
TX_FAR _BillsHouseMonitorText
db "@"
BillsHouseInitiatedText:
TX_FAR _BillsHouseInitiatedText
db $06
TX_ASM
ld a, $ff
ld [wNewSoundID], a
call PlaySound
ld c, 16
call DelayFrames
ld a, SFX_SWITCH
call PlaySound
call WaitForSoundToFinish
ld c, 60
call DelayFrames
jp TextScriptEnd
BillsHousePokemonList:
TX_ASM
call SaveScreenTilesToBuffer1
ld hl, BillsHousePokemonListText1
call PrintText
xor a
ld [wMenuItemOffset], a ; not used
ld [wCurrentMenuItem], a
ld [wLastMenuItem], a
ld a, A_BUTTON | B_BUTTON
ld [wMenuWatchedKeys], a
ld a, 4
ld [wMaxMenuItem], a
ld a, 2
ld [wTopMenuItemY], a
ld a, 1
ld [wTopMenuItemX], a
.billsPokemonLoop
ld hl, wd730
set 6, [hl]
coord hl, 0, 0
ld b, 10
ld c, 9
call TextBoxBorder
coord hl, 2, 2
ld de, BillsMonListText
call PlaceString
ld hl, BillsHousePokemonListText2
call PrintText
call SaveScreenTilesToBuffer2
call HandleMenuInput
bit 1, a ; pressed b
jr nz, .cancel
ld a, [wCurrentMenuItem]
add EEVEE
cp EEVEE
jr z, .displayPokedex
cp FLAREON
jr z, .displayPokedex
cp JOLTEON
jr z, .displayPokedex
cp VAPOREON
jr z, .displayPokedex
jr .cancel
.displayPokedex
call DisplayPokedex
call LoadScreenTilesFromBuffer2
jr .billsPokemonLoop
.cancel
ld hl, wd730
res 6, [hl]
call LoadScreenTilesFromBuffer2
jp TextScriptEnd
BillsHousePokemonListText1:
TX_FAR _BillsHousePokemonListText1
db "@"
BillsMonListText:
db "EEVEE"
next "FLAREON"
next "JOLTEON"
next "VAPOREON"
next "CANCEL@"
BillsHousePokemonListText2:
TX_FAR _BillsHousePokemonListText2
db "@"
DisplayOakLabEmailText:
ld a, [wSpriteStateData1 + 9]
cp SPRITE_FACING_UP
ret nz
call EnableAutoTextBoxDrawing
tx_pre_jump OakLabEmailText
OakLabEmailText:
TX_FAR _OakLabEmailText
db "@"
|