summaryrefslogtreecommitdiff
path: root/scripts/silphco11.asm
blob: cd5a818da2d5ec680a455f4361479671c63552fd (plain)
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
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
SilphCo11Script:
	call SilphCo11Script_62127
	call EnableAutoTextBoxDrawing
	ld hl, SilphCo11TrainerHeaders
	ld de, SilphCo11ScriptPointers
	ld a, [wSilphCo11CurScript]
	call ExecuteCurMapScriptInTable
	ld [wSilphCo11CurScript], a
	ret

SilphCo11Script_62127:
	ld hl, wCurrentMapScriptFlags
	bit 5, [hl]
	res 5, [hl]
	ret z
	ld hl, SilphCo11GateCoords
	call SilphCo11Script_6214f
	call SilphCo11Script_6217b
	CheckEvent EVENT_SILPH_CO_11_UNLOCKED_DOOR
	ret nz
	ld a, $20
	ld [wNewTileBlockID], a
	lb bc, 6, 3
	predef ReplaceTileBlock
	ret

SilphCo11GateCoords:
	db $06,$03
	db $FF

SilphCo11Script_6214f:
	push hl
	ld hl, wCardKeyDoorY
	ld a, [hli]
	ld b, a
	ld a, [hl]
	ld c, a
	xor a
	ld [$ffe0], a
	pop hl
.asm_62143
	ld a, [hli]
	cp $ff
	jr z, .asm_6215f
	push hl
	ld hl, $ffe0
	inc [hl]
	pop hl
	cp b
	jr z, .asm_62154
	inc hl
	jr .asm_62143
.asm_62154
	ld a, [hli]
	cp c
	jr nz, .asm_62143
	ld hl, wCardKeyDoorY
	xor a
	ld [hli], a
	ld [hl], a
	ret
.asm_6215f
	xor a
	ld [$ffe0], a
	ret

SilphCo11Script_6217b:
	ld a, [$ffe0]
	and a
	ret z
	SetEvent EVENT_SILPH_CO_11_UNLOCKED_DOOR
	ret

SilphCo11Script_62185:
	xor a
	ld [wJoyIgnore], a
SilphCo11Script_62189:
	ld [wSilphCo11CurScript], a
	ld [wCurMapScript], a
	ret

SilphCo11ScriptPointers:
	dw SilphCo11Script0
	dw DisplayEnemyTrainerTextAndStartBattle
	dw EndTrainerBattle
	dw SilphCo11Script3
	dw SilphCo11Script4
	dw SilphCo11Script5
	dw SilphCo11Script6
	dw SilphCo11Script7
	dw SilphCo11Script8
	dw SilphCo11Script9
	dw SilphCo11Script10
	dw SilphCo11Script11
	dw SilphCo11Script12
	dw SilphCo11Script13
	dw SilphCo11Script14

SilphCo11Script0:
	CheckEvent EVENT_BEAT_SILPH_CO_11F_TRAINER_0
	call z, SilphCo11Script_6229c
	CheckEvent EVENT_782
	ret nz
	CheckEvent EVENT_BEAT_SILPH_CO_GIOVANNI
	call z, SilphCo11Script_621c5
	ret

SilphCo11Script_621c5:
	ld hl, CoordsData_62211
	call ArePlayerCoordsInArray
	jp nc, CheckFightingMapTrainers
	ld a, [wCoordIndex]
	ld [wcf0d], a
	xor a
	ld [hJoyHeld], a
	ld a, $f0
	ld [wJoyIgnore], a
	ld a, $3
	ld [hSpriteIndexOrTextID], a
	call DisplayTextID
	ld a, $3
	ld [H_SPRITEINDEX], a
	call SetSpriteMovementBytesToFF
	ld de, MovementData_62216
	call MoveSprite
	ld a, $4
	call SilphCo11Script_62189
	ret

CoordsData_62211:
	db $0D,$06
	db $0C,$07
	db $FF

MovementData_62216:
	db NPC_MOVEMENT_DOWN
	db NPC_MOVEMENT_DOWN
	db NPC_MOVEMENT_DOWN
	db $FF

SilphCo11Script_621ff:
	ld [wPlayerMovingDirection], a
	ld a, b
	ld [wSpriteStateData1 + 3 * $10 + 9], a
	ld a, $2
	ld [wSpriteStateData1 + 3 * $10 + 1], a
	ret

SilphCo11Script3:
	ld a, [wIsInBattle]
	cp $ff
	jp z, SilphCo11Script_62185
	ld a, [wcf0d]
	cp $1
	jr z, .asm_6223c
	ld a, PLAYER_DIR_LEFT
	ld b, SPRITE_FACING_RIGHT
	jr .asm_62240
.asm_6223c
	ld a, PLAYER_DIR_UP
	ld b, SPRITE_FACING_DOWN
.asm_62240
	call SilphCo11Script_621ff
	ld a, $f0
	ld [wJoyIgnore], a
	ld a, $7
	ld [hSpriteIndexOrTextID], a
	call DisplayTextID
	call GBFadeOutToBlack
	callba Func_f25a0
	call UpdateSprites
	call Delay3
	call GBFadeInFromBlack
	SetEvent EVENT_BEAT_SILPH_CO_GIOVANNI
	xor a
	ld [wJoyIgnore], a
	jp SilphCo11Script_62189

SilphCo11Script4:
	ld a, [wd730]
	bit 0, a
	ret nz
	ld a, $3
	ld [H_SPRITEINDEX], a
	call SetSpriteMovementBytesToFF
	ld a, [wcf0d]
	cp $1
	jr z, .asm_62284
	ld a, PLAYER_DIR_LEFT
	ld b, SPRITE_FACING_RIGHT
	jr .asm_62288
.asm_62284
	ld a, PLAYER_DIR_UP
	ld b, SPRITE_FACING_DOWN
.asm_62288
	call SilphCo11Script_621ff
	call Delay3
	xor a
	ld [wJoyIgnore], a
	ld hl, wd72d
	set 6, [hl]
	set 7, [hl]
	ld hl, SilphCo10Text_62528
	ld de, SilphCo10Text_62528
	call SaveEndBattleTextPointers
	ld a, [H_SPRITEINDEX]
	ld [wSpriteIndex], a
	call EngageMapTrainer
	call InitBattleEnemyParameters
	ld a, $3
	jp SilphCo11Script_62189

SilphCo11Script_6229c:
	ld a, [wYCoord]
	cp $3
	ret nz
	ld a, [wXCoord]
	cp $4
	ret nc
	ResetEvents EVENT_780, EVENT_781
	ld a, [wXCoord]
	cp $3
	jr z, .asm_622c3
	SetEventReuseHL EVENT_780
	ld a, [wXCoord]
	cp $2
	jr z, .asm_622c3
	ResetEventReuseHL EVENT_780
	SetEventReuseHL EVENT_781
.asm_622c3
	call StopAllMusic
	ld c, BANK(Music_MeetJessieJames)
	ld a, MUSIC_MEET_JESSIE_JAMES
	call PlayMusic
	xor a
	ld [hJoyHeld], a
	ld a, $fc
	ld [wJoyIgnore], a
	ld a, $1
	ld [wDoNotWaitForButtonPressAfterDisplayingText], a
	ld a, $8
	ld [hSpriteIndexOrTextID], a
	call DisplayTextID
	xor a
	ld [wDoNotWaitForButtonPressAfterDisplayingText], a
	ld a, $ff
	ld [wJoyIgnore], a
	SetEvent EVENT_782
	ld a, $5
	call SilphCo11Script_62189
	ret
; 622f4

SilphCo11MovementData_622f5:
	db $5
	db $5
	db $5
	db $5
	db $5
	db $ff

SilphCo11MovementData_622fb:
	db $5
	db $5
	db $5
	db $5
	db $ff

SilphCo11MovementData_62300:
	db $5
	db $5
	db $5
	db $5
	db $ff

SilphCo11MovementData_62305:
	db $5
	db $5
	db $5
	db $5
	db $5
	db $ff

SilphCo11MovementData_6230b:
	db $5
	db $5
	db $6
	db $5
	db $5
	db $ff

SilphCo11MovementData_62311:
	db $5
	db $5
	db $5
	db $6
	db $5
	db $5
	db $ff

SilphCo11Script5:
	ld de, SilphCo11MovementData_622f5
	CheckEitherEventSet EVENT_780, EVENT_781
	and a
	jr z, .asm_6232d
	ld de, SilphCo11MovementData_62300
	cp $1
	jr z, .asm_6232d
	ld de, SilphCo11MovementData_6230b
.asm_6232d
	ld a, $4
	ld [hSpriteIndexOrTextID], a
	call MoveSprite
	ld a, $ff
	ld [wJoyIgnore], a
	ld a, $6
	call SilphCo11Script_62189
	ret

SilphCo11Script6:
	ld a, $ff
	ld [wJoyIgnore], a
	ld a, [wd730]
	bit 0, a
	ret nz
SilphCo11Script7:
	ld a, $2
	ld [wSpriteStateData1 + 4 * $10 + 1], a
	ld hl, wSpriteStateData1 + 4 * $10 + 9
	ld [hl], SPRITE_FACING_RIGHT
	CheckEitherEventSet EVENT_780, EVENT_781
	and a
	jr z, .asm_6235e
	ld [hl], SPRITE_FACING_UP
.asm_6235e
	call Delay3
	ld a, $fc
	ld [wJoyIgnore], a
SilphCo11Script8:
	ld de, SilphCo11MovementData_622fb
	CheckEitherEventSet EVENT_780, EVENT_781
	and a
	jr z, .asm_6237b
	ld de, SilphCo11MovementData_62305
	cp $1
	jr z, .asm_6237b
	ld de, SilphCo11MovementData_62311
.asm_6237b
	ld a, $6
	ld [hSpriteIndexOrTextID], a
	call MoveSprite
	ld a, $ff
	ld [wJoyIgnore], a
	ld a, $9
	call SilphCo11Script_62189
	ret

SilphCo11Script9:
	ld a, $ff
	ld [wJoyIgnore], a
	ld a, [wd730]
	bit 0, a
	ret nz
	ld a, $fc
	ld [wJoyIgnore], a
SilphCo11Script10:
	ld a, $2
	ld [wSpriteStateData1 + 6 * $10 + 1], a
	ld hl, wSpriteStateData1 + 6 * $10 + 9
	ld [hl], SPRITE_FACING_UP
	CheckEitherEventSet EVENT_780, EVENT_781
	and a
	jr z, .asm_623b1
	ld [hl], SPRITE_FACING_LEFT
.asm_623b1
	call Delay3
	ld a, $9
	ld [hSpriteIndexOrTextID], a
	call DisplayTextID
SilphCo11Script11:
	ld hl, wd72d
	set 6, [hl]
	set 7, [hl]
	ld hl, SilphCo11Text_624c2
	ld de, SilphCo11Text_624c2
	call SaveEndBattleTextPointers
	ld a, OPP_ROCKET
	ld [wCurOpponent], a
	ld a, $2d
	ld [wTrainerNo], a
	xor a
	ld [hJoyHeld], a
	ld [wJoyIgnore], a
	ld a, $c
	call SilphCo11Script_62189
	ret

SilphCo11Script12:
	ld a, $ff
	ld [wJoyIgnore], a
	ld a, [wIsInBattle]
	cp $ff
	jp z, SilphCo11Script_62185
	ld a, $2
	ld [wSpriteStateData1 + 4 * $10 + 1], a
	ld [wSpriteStateData1 + 6 * $10 + 1], a
	xor a
	ld [wSpriteStateData1 + 4 * $10 + 9], a
	ld [wSpriteStateData1 + 6 * $10 + 9], a
	ld a, $fc
	ld [wJoyIgnore], a
	ld a, $1
	ld [wDoNotWaitForButtonPressAfterDisplayingText], a
	ld a, $a
	ld [hSpriteIndexOrTextID], a
	call DisplayTextID
	xor a
	ld [wDoNotWaitForButtonPressAfterDisplayingText], a
	call StopAllMusic
	ld c, BANK(Music_MeetJessieJames)
	ld a, MUSIC_MEET_JESSIE_JAMES
	call PlayMusic
	ld a, $ff
	ld [wJoyIgnore], a
	ld a, $d
	call SilphCo11Script_62189
	ret

SilphCo11Script13:
	ld a, $ff
	ld [wJoyIgnore], a
	call GBFadeOutToBlack
	ld a, HS_SILPH_CO_11F_JAMES
	call SilphCo11Script_6246d
	ld a, HS_SILPH_CO_11F_JESSIE
	call SilphCo11Script_6246d
	call UpdateSprites
	call Delay3
	call GBFadeInFromBlack
	ld a, $e
	call SilphCo11Script_62189
	ret

SilphCo11Script14:
	call PlayDefaultMusic
	xor a
	ld [hJoyHeld], a
	ld [wJoyIgnore], a
	ResetEvent EVENT_782
	SetEventReuseHL EVENT_BEAT_SILPH_CO_11F_TRAINER_0
	ld a, $0
	call SilphCo11Script_62189
	ret

SilphCo11Script_6245e:
	ld [wMissableObjectIndex], a
	predef ShowObject
	call UpdateSprites
	call Delay3
	ret

SilphCo11Script_6246d:
	ld [wMissableObjectIndex], a
	predef HideObject
	ret

SilphCo11TextPointers:
	dw SilphCo11Text1
	dw SilphCo11Text2
	dw SilphCo11Text3
	dw SilphCo11Text4
	dw SilphCo11Text5
	dw SilphCo11Text6
	dw SilphCo11Text7
	dw SilphCo11Text8
	dw SilphCo11Text9
	dw SilphCo11Text10

SilphCo11TrainerHeaders:
SilphCo11TrainerHeader0:
	dbEventFlagBit EVENT_BEAT_SILPH_CO_11F_TRAINER_1
	db ($3 << 4)
	dwEventFlagAddress EVENT_BEAT_SILPH_CO_11F_TRAINER_1
	dw SilphCo11Trainer1BattleText
	dw SilphCo11Trainer1AfterBattleText
	dw SilphCo11Trainer1EndBattleText
	dw SilphCo11Trainer1EndBattleText

	db $ff ; no more trainers

SilphCo11Text4:
SilphCo11Text6:
SilphCo11Text8:
	TX_FAR _SilphCoJessieJamesText1
	TX_ASM
	ld c, 10
	call DelayFrames
	ld a, $4
	ld [wPlayerMovingDirection], a
	ld a, $0
	ld [wEmotionBubbleSpriteIndex], a
	ld a, $0
	ld [wWhichEmotionBubble], a
	predef EmotionBubble
	ld c, 20
	call DelayFrames
	jp TextScriptEnd

SilphCo11Text9:
	TX_FAR _SilphCoJessieJamesText2
	db "@"

SilphCo11Text_624c2:
	TX_FAR _SilphCoJessieJamesText3
	db "@"

SilphCo11Text10:
	TX_FAR _SilphCoJessieJamesText4
	TX_ASM
	ld c, 64
	call DelayFrames
	jp TextScriptEnd

SilphCo11Text1:
	TX_ASM
	CheckEvent EVENT_GOT_MASTER_BALL
	jp nz, .asm_62500
	ld hl, SilphCo11Text_62509
	call PrintText
	lb bc, MASTER_BALL, 1
	call GiveItem
	jr nc, .asm_624f8
	ld hl, SilphCo11Text_6250e
	call PrintText
	SetEvent EVENT_GOT_MASTER_BALL
	jr .asm_62506
.asm_624f8
	ld hl, SilphCo11Text_62519
	call PrintText
	jr .asm_62506

.asm_62500
	ld hl, SilphCo11Text_62514
	call PrintText
.asm_62506
	jp TextScriptEnd

SilphCo11Text_62509:
	TX_FAR _SilphCoPresidentText
	db "@"

SilphCo11Text_6250e:
	TX_FAR _ReceivedSilphCoMasterBallText
	TX_SFX_KEY_ITEM
	db "@"

SilphCo11Text_62514:
	TX_FAR _SilphCo10Text_6231c
	db "@"

SilphCo11Text_62519:
	TX_FAR _SilphCoMasterBallNoRoomText
	db "@"

SilphCo11Text2:
	TX_FAR _SilphCo11Text2
	db "@"

SilphCo11Text3:
	TX_FAR _SilphCo11Text3
	db "@"

SilphCo10Text_62528:
	TX_FAR _SilphCo10Text_62330
	db "@"

SilphCo11Text7:
	TX_FAR _SilphCo10Text_62335
	db "@"

SilphCo11Text5:
	TX_ASM
	ld hl, SilphCo11TrainerHeader0
	call TalkToTrainer
	jp TextScriptEnd

SilphCo11Trainer1BattleText:
	TX_FAR _SilphCo11BattleText2
	db "@"

SilphCo11Trainer1EndBattleText:
	TX_FAR _SilphCo11EndBattleText2
	db "@"

SilphCo11Trainer1AfterBattleText:
	TX_FAR _SilphCo11AfterBattleText2
	db "@"