summaryrefslogtreecommitdiff
path: root/scripts/silphco11.asm
blob: d4bd6ba009b173aa1b613cb2429a6271c1c0becf (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
SilphCo11Script: ; 620fa (18:60fa)
	call SilphCo11Script_62110
	call EnableAutoTextBoxDrawing
	ld hl, SilphCo11TrainerHeaders
	ld de, SilphCo11ScriptPointers
	ld a, [W_SILPHCO11CURSCRIPT]
	call ExecuteCurMapScriptInTable
	ld [W_SILPHCO11CURSCRIPT], a
	ret

SilphCo11Script_62110: ; 62110 (18:6110)
	ld hl, $d126
	bit 5, [hl]
	res 5, [hl]
	ret z
	ld hl, DataTable_62134 ; $6134
	call SilphCo11Script_62137
	call SilphCo11Script_62163
	ld a, [$d838]
	bit 0, a
	ret nz
	ld a, $20
	ld [$d09f], a
	ld bc, $603
	ld a, $17
	jp Predef ; indirect jump to Func_ee9e (ee9e (3:6e9e))

DataTable_62134: ; 62134 (18:6134)
	db $06,$03,$FF

SilphCo11Script_62137: ; 62137 (18:6137)
	push hl
	ld hl, $d73f
	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, $d73f
	xor a
	ld [hli], a
	ld [hl], a
	ret
.asm_6215f
	xor a
	ld [$ffe0], a
	ret

SilphCo11Script_62163: ; 62163 (18:6163)
	ld a, [$ffe0]
	and a
	ret z
	ld hl, $d838
	set 0, [hl]
	ret

SilphCo11Script_6216d: ; 6216d (18:616d)
	ld hl, MissableObjectIDs_6219b ; $619b
.asm_62170
	ld a, [hli]
	cp $ff
	jr z, .asm_62181
	push hl
	ld [$cc4d], a
	ld a, $11
	call Predef ; indirect jump to RemoveMissableObject (f1d7 (3:71d7))
	pop hl
	jr .asm_62170
.asm_62181
	ld hl, MissableObjectIDs_62194 ; $6194
.asm_62184
	ld a, [hli]
	cp $ff
	ret z
	push hl
	ld [$cc4d], a
	ld a, $15
	call Predef ; indirect jump to AddMissableObject (f1c8 (3:71c8))
	pop hl
	jr .asm_62184

MissableObjectIDs_62194: ; 62194 (18:6194)
	db $11,$12,$13,$14,$15,$16,$FF

MissableObjectIDs_6219b: ; 6219b (18:619b)
	db $0A,$0B,$0C,$0D,$0E,$0F,$10,$17
	db $18,$8A,$8B,$8C,$8D,$8E,$8F,$91
	db $92,$93,$97,$98,$99,$9A,$9E,$9F
	db $A0,$A3,$A4,$A5,$A6,$AB,$AC,$AD
	db $AE,$AF,$B0,$B1,$B2,$B7,$B8,$B9
	db $FF

SilphCo11Script_621c4: ; 621c4 (18:61c4)
	xor a
	ld [wJoyIgnore], a

SilphCo11Script_621c8: ; 621c8 (18:61c8)
	ld [W_SILPHCO11CURSCRIPT], a
	ld [W_CURMAPSCRIPT], a
	ret

SilphCo11ScriptPointers: ; 621cf (18:61cf)
	dw SilphCo11Script0
	dw Func_324c
	dw EndTrainerBattle
	dw SilphCo11Script3
	dw SilphCo11Script4
	dw SilphCo11Script5

SilphCo11Script0: ; 621db (18:61db)
	ld a, [$d838]
	bit 7, a
	ret nz
	ld hl, CoordsData_62211 ; $6211
	call ArePlayerCoordsInArray
	jp nc, CheckFightingMapTrainers
	ld a, [wWhichTrade] ; $cd3d
	ld [$cf0d], a
	xor a
	ld [hJoyHeld], a
	ld a, $f0
	ld [wJoyIgnore], a
	ld a, $3
	ld [H_DOWNARROWBLINKCNT2], a ; $ff8c
	call DisplayTextID
	ld a, $3
	ld [H_DOWNARROWBLINKCNT2], a ; $ff8c
	call SetSpriteMovementBytesToFF
	ld de, MovementData_62216
	call MoveSprite
	ld a, $3
	jp SilphCo11Script_621c8

CoordsData_62211: ; 62211 (18:6211)
	db $0D,$06
	db $0C,$07
	db $FF

MovementData_62216: ; 62216 (18:6216)
	db $00,$00,$00,$FF

SilphCo11Script_6221a: ; 6221a (18:621a)
	ld [$d528], a
	ld a, $3
	ld [H_DOWNARROWBLINKCNT2], a ; $ff8c
	ld a, b
	ld [$ff8d], a
	jp Func_34a6

SilphCo11Script5: ; 62227 (18:6227)
	ld a, [W_ISINBATTLE] ; $d057
	cp $ff
	jp z, SilphCo11Script_621c4
	ld a, [$cf0d]
	cp $1
	jr z, .asm_6223c
	ld a, $2
	ld b, $c
	jr .asm_62240
.asm_6223c
	ld a, $8
	ld b, $0
.asm_62240
	call SilphCo11Script_6221a
	ld a, $f0
	ld [wJoyIgnore], a
	ld a, $6
	ld [H_DOWNARROWBLINKCNT2], a ; $ff8c
	call DisplayTextID
	call GBFadeIn1
	call SilphCo11Script_6216d
	call UpdateSprites
	call Delay3
	call GBFadeOut1
	ld hl, $d838
	set 7, [hl]
	xor a
	ld [wJoyIgnore], a
	jp SilphCo11Script_621c8

SilphCo11Script3: ; 6226a (18:626a)
	ld a, [$d730]
	bit 0, a
	ret nz
	ld a, $3
	ld [H_DOWNARROWBLINKCNT2], a ; $ff8c
	call SetSpriteMovementBytesToFF
	ld a, [$cf0d]
	cp $1
	jr z, .asm_62284
	ld a, $2
	ld b, $c
	jr .asm_62288
.asm_62284
	ld a, $8
	ld b, $0
.asm_62288
	call SilphCo11Script_6221a
	call Delay3
	ld a, $4
	jp SilphCo11Script_621c8

SilphCo11Script4: ; 62293 (18:6293)
	ld hl, $d72d
	set 6, [hl]
	set 7, [hl]
	ld hl, SilphCo10Text_62330 ; $6330
	ld de, SilphCo10Text_62330 ; $6330
	call PreBattleSaveRegisters
	ld a, [H_DOWNARROWBLINKCNT2] ; $ff8c
	ld [$cf13], a
	call EngageMapTrainer
	call InitBattleEnemyParameters
	xor a
	ld [wJoyIgnore], a
	ld a, $5
	jp SilphCo11Script_621c8

SilphCo11TextPointers: ; 622b7 (18:62b7)
	dw SilphCo11Text1
	dw SilphCo11Text2
	dw SilphCo11Text3
	dw SilphCo11Text4
	dw SilphCo11Text5
	dw SilphCo11Text6

SilphCo11TrainerHeaders: ; 622c3 (18:62c3)
SilphCo11TrainerHeader0: ; 622c3 (18:62c3)
	db $4 ; flag's bit
	db ($4 << 4) ; trainer's view range
	dw $d837 ; flag's byte
	dw SilphCo11BattleText1 ; 0x6344 TextBeforeBattle
	dw SilphCo11AfterBattleText1 ; 0x634e TextAfterBattle
	dw SilphCo11EndBattleText1 ; 0x6349 TextEndBattle
	dw SilphCo11EndBattleText1 ; 0x6349 TextEndBattle

SilphCo11TrainerHeader1: ; 622cf (18:62cf)
	db $5 ; flag's bit
	db ($3 << 4) ; trainer's view range
	dw $d837 ; flag's byte
	dw SilphCo11BattleText2 ; 0x635d TextBeforeBattle
	dw SilphCo11AfterBattleText2 ; 0x6367 TextAfterBattle
	dw SilphCo11EndBattleText2 ; 0x6362 TextEndBattle
	dw SilphCo11EndBattleText2 ; 0x6362 TextEndBattle

	db $ff

SilphCo11Text1: ; 622dc (18:62dc)
	db $08 ; asm
	ld a, [$d838]
	bit 5, a
	jp nz, .asm_62308
	ld hl, SilphCoPresidentText
	call PrintText
	ld bc, (MASTER_BALL << 8) | 1
	call GiveItem
	jr nc, .BagFull
	ld hl, ReceivedSilphCoMasterBallText
	call PrintText
	ld hl, $d838
	set 5, [hl]
	jr .asm_fd405 ; 0x622fe
.BagFull
	ld hl, SilphCoMasterBallNoRoomText
	call PrintText
	jr .asm_fd405 ; 0x62306
.asm_62308 ; 0x62308
	ld hl, SilphCo10Text_6231c
	call PrintText
.asm_fd405 ; 0x6230e
	jp TextScriptEnd

SilphCoPresidentText: ; 62311 (18:6311)
	TX_FAR _SilphCoPresidentText
	db "@"

ReceivedSilphCoMasterBallText: ; 62316 (18:6316)
	TX_FAR _ReceivedSilphCoMasterBallText
	db $11, "@"

SilphCo10Text_6231c: ; 6231c (18:631c)
	TX_FAR _SilphCo10Text_6231c
	db "@"

SilphCoMasterBallNoRoomText: ; 62321 (18:6321)
	TX_FAR _SilphCoMasterBallNoRoomText
	db "@"

SilphCo11Text2: ; 62326 (18:6326)
	TX_FAR _SilphCo11Text2
	db "@"

SilphCo11Text3: ; 6232b (18:632b)
	TX_FAR _SilphCo11Text3
	db "@"

SilphCo10Text_62330: ; 62330 (18:6330)
	TX_FAR _SilphCo10Text_62330
	db "@"

SilphCo11Text6: ; 62335 (18:6335)
	TX_FAR _SilphCo10Text_62335
	db "@"

SilphCo11Text4: ; 6233a (18:633a)
	db $08 ; asm
	ld hl, SilphCo11TrainerHeader0
	call TalkToTrainer
	jp TextScriptEnd

SilphCo11BattleText1: ; 62344 (18:6344)
	TX_FAR _SilphCo11BattleText1
	db "@"

SilphCo11EndBattleText1: ; 62349 (18:6349)
	TX_FAR _SilphCo11EndBattleText1
	db "@"

SilphCo11AfterBattleText1: ; 6234e (18:634e)
	TX_FAR _SilphCo11AfterBattleText1
	db "@"

SilphCo11Text5: ; 62353 (18:6353)
	db $08 ; asm
	ld hl, SilphCo11TrainerHeader1
	call TalkToTrainer
	jp TextScriptEnd

SilphCo11BattleText2: ; 6235d (18:635d)
	TX_FAR _SilphCo11BattleText2
	db "@"

SilphCo11EndBattleText2: ; 62362 (18:6362)
	TX_FAR _SilphCo11EndBattleText2
	db "@"

SilphCo11AfterBattleText2: ; 62367 (18:6367)
	TX_FAR _SilphCo11AfterBattleText2
	db "@"

SilphCo10Text_6236c: ; 6236c (18:636c)
	db $8
	ld hl, SilphCo10Text_6237b
	call PrintText
	ld a, PORYGON
	call DisplayPokedex
	jp TextScriptEnd

SilphCo10Text_6237b: ; 6237b (18:637b)
	TX_FAR _SilphCo10Text_6237b
	db "@"