summaryrefslogtreecommitdiff
path: root/scripts/celadongamecorner.asm
blob: dd534dba41a5bb9ef98f61c718c259afdf67c21a (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
CeladonGameCornerScript: ; 48bbd (12:4bbd)
	call CeladonGameCornerScript_48bcf
	call CeladonGameCornerScript_48bec
	call EnableAutoTextBoxDrawing
	ld hl, CeladonGameCornerScriptPointers
	ld a, [wCeladonGameCornerCurScript]
	jp CallFunctionInTable

CeladonGameCornerScript_48bcf: ; 48bcf (12:4bcf)
	ld hl, wd126
	bit 6, [hl]
	res 6, [hl]
	ret z
	call Random
	ld a, [hRandomAdd]
	cp $7
	jr nc, .asm_48be2
	ld a, $8
.asm_48be2
	srl a
	srl a
	srl a
	ld [wLuckySlotHiddenObjectIndex], a
	ret

CeladonGameCornerScript_48bec: ; 48bec (12:4bec)
	ld hl, wd126
	bit 5, [hl]
	res 5, [hl]
	ret z
	CheckEvent EVENT_FOUND_ROCKET_HIDEOUT
	ret nz
	ld a, $2a
	ld [wNewTileBlockID], a
	lb bc, 2, 8
	predef_jump ReplaceTileBlock

CeladonGameCornerScript_48c07: ; 48c07 (12:4c07)
	xor a
	ld [wJoyIgnore], a
	ld [wCeladonGameCornerCurScript], a
	ld [wCurMapScript], a
	ret

CeladonGameCornerScriptPointers: ; 48c12 (12:4c12)
	dw CeladonGameCornerScript0
	dw CeladonGameCornerScript1
	dw CeladonGameCornerScript2

CeladonGameCornerScript0: ; 48c18 (12:4c18)
	ret

CeladonGameCornerScript1: ; 48c19 (12:4c19)
	ld a, [wIsInBattle]
	cp $ff
	jp z, CeladonGameCornerScript_48c07
	ld a, $f0
	ld [wJoyIgnore], a
	ld a, $d
	ld [hSpriteIndexOrTextID], a
	call DisplayTextID
	ld a, $b
	ld [H_SPRITEINDEX], a
	call SetSpriteMovementBytesToFF
	ld de, MovementData_48c5a
	ld a, [wYCoord]
	cp $6
	jr nz, .asm_48c43
	ld de, MovementData_48c63
	jr .asm_48c4d
.asm_48c43
	ld a, [wXCoord]
	cp $8
	jr nz, .asm_48c4d
	ld de, MovementData_48c63
.asm_48c4d
	ld a, $b
	ld [H_SPRITEINDEX], a
	call MoveSprite
	ld a, $2
	ld [wCeladonGameCornerCurScript], a
	ret

MovementData_48c5a: ; 48c5a (12:4c5a)
	db NPC_MOVEMENT_DOWN
	db NPC_MOVEMENT_RIGHT
	db NPC_MOVEMENT_RIGHT
	db NPC_MOVEMENT_UP
	db NPC_MOVEMENT_RIGHT
	db NPC_MOVEMENT_RIGHT
	db NPC_MOVEMENT_RIGHT
	db NPC_MOVEMENT_RIGHT
	db $FF

MovementData_48c63: ; 48c63 (12:4c63)
	db NPC_MOVEMENT_RIGHT
	db NPC_MOVEMENT_RIGHT
	db NPC_MOVEMENT_RIGHT
	db NPC_MOVEMENT_RIGHT
	db NPC_MOVEMENT_RIGHT
	db $FF

CeladonGameCornerScript2: ; 48c69 (12:4c69)
	ld a, [wd730]
	bit 0, a
	ret nz
	xor a
	ld [wJoyIgnore], a
	ld a, HS_GAME_CORNER_ROCKET
	ld [wMissableObjectIndex], a
	predef HideObject
	ld hl, wd126
	set 5, [hl]
	set 6, [hl]
	ld a, $0
	ld [wCeladonGameCornerCurScript], a
	ret

CeladonGameCornerTextPointers: ; 48c8a (12:4c8a)
	dw CeladonGameCornerText1
	dw CeladonGameCornerText2
	dw CeladonGameCornerText3
	dw CeladonGameCornerText4
	dw CeladonGameCornerText5
	dw CeladonGameCornerText6
	dw CeladonGameCornerText7
	dw CeladonGameCornerText8
	dw CeladonGameCornerText9
	dw CeladonGameCornerText10
	dw CeladonGameCornerText11
	dw CeladonGameCornerText12
	dw CeladonGameCornerText13

CeladonGameCornerText1: ; 48ca4 (12:4ca4)
	TX_FAR _CeladonGameCornerText1
	db "@"

CeladonGameCornerText2: ; 48ca9 (12:4ca9)
	TX_ASM
	call CeladonGameCornerScript_48f1e
	ld hl, CeladonGameCornerText_48d22
	call PrintText
	call YesNoChoice
	ld a, [wCurrentMenuItem]
	and a
	jr nz, .asm_48d0f
	ld b,COIN_CASE
	call IsItemInBag
	jr z, .asm_48d19
	call Has9990Coins
	jr nc, .asm_48d14
	xor a
	ld [hMoney], a
	ld [hMoney + 2], a
	ld a, $10
	ld [hMoney + 1], a
	call HasEnoughMoney
	jr nc, .asm_48cdb
	ld hl, CeladonGameCornerText_48d31
	jr .asm_48d1c
.asm_48cdb
	xor a
	ld [hMoney], a
	ld [hMoney + 2], a
	ld a, $10
	ld [hMoney + 1], a
	ld hl, hMoney + 2
	ld de, wPlayerMoney + 2
	ld c, $3
	predef SubBCDPredef
	xor a
	ld [hUnusedCoinsByte], a
	ld [hCoins], a
	ld a, $50
	ld [hCoins + 1], a
	ld de, wPlayerCoins + 1
	ld hl, hCoins + 1
	ld c, $2
	predef AddBCDPredef
	call CeladonGameCornerScript_48f1e
	ld hl, CeladonGameCornerText_48d27
	jr .asm_48d1c
.asm_48d0f
	ld hl, CeladonGameCornerText_48d2c
	jr .asm_48d1c
.asm_48d14
	ld hl, CeladonGameCornerText_48d36
	jr .asm_48d1c
.asm_48d19
	ld hl, CeladonGameCornerText_48d3b
.asm_48d1c
	call PrintText
	jp TextScriptEnd

CeladonGameCornerText_48d22: ; 48d22 (12:4d22)
	TX_FAR _CeladonGameCornerText_48d22
	db "@"

CeladonGameCornerText_48d27: ; 48d27 (12:4d27)
	TX_FAR _CeladonGameCornerText_48d27
	db "@"

CeladonGameCornerText_48d2c: ; 48d2c (12:4d2c)
	TX_FAR _CeladonGameCornerText_48d2c
	db "@"

CeladonGameCornerText_48d31: ; 48d31 (12:4d31)
	TX_FAR _CeladonGameCornerText_48d31
	db "@"

CeladonGameCornerText_48d36: ; 48d36 (12:4d36)
	TX_FAR _CeladonGameCornerText_48d36
	db "@"

CeladonGameCornerText_48d3b: ; 48d3b (12:4d3b)
	TX_FAR _CeladonGameCornerText_48d3b
	db "@"

CeladonGameCornerText3: ; 48d40 (12:4d40)
	TX_FAR _CeladonGameCornerText3
	db "@"

CeladonGameCornerText4: ; 48d45 (12:4d45)
	TX_FAR _CeladonGameCornerText4
	db "@"

CeladonGameCornerText5: ; 48d4a (12:4d4a)
	TX_ASM
	CheckEvent EVENT_GOT_10_COINS
	jr nz, .asm_48d89
	ld hl, CeladonGameCornerText_48d9c
	call PrintText
	ld b, COIN_CASE
	call IsItemInBag
	jr z, .asm_48d93
	call Has9990Coins
	jr nc, .asm_48d8e
	xor a
	ld [hUnusedCoinsByte], a
	ld [hCoins], a
	ld a, $10
	ld [hCoins + 1], a
	ld de, wPlayerCoins + 1
	ld hl, hCoins + 1
	ld c, $2
	predef AddBCDPredef
	SetEvent EVENT_GOT_10_COINS
	ld a, $1
	ld [wDoNotWaitForButtonPressAfterDisplayingText], a
	ld hl, Received10CoinsText
	jr .asm_48d96
.asm_48d89
	ld hl, CeladonGameCornerText_48dac
	jr .asm_48d96
.asm_48d8e
	ld hl, CeladonGameCornerText_48da7
	jr .asm_48d96
.asm_48d93
	ld hl, CeladonGameCornerText_48f19
.asm_48d96
	call PrintText
	jp TextScriptEnd

CeladonGameCornerText_48d9c: ; 48d9c (12:4d9c)
	TX_FAR _CeladonGameCornerText_48d9c
	db "@"

Received10CoinsText: ; 48da1 (12:4da1)
	TX_FAR _Received10CoinsText
	db $0B, "@"

CeladonGameCornerText_48da7: ; 48da7 (12:4da7)
	TX_FAR _CeladonGameCornerText_48da7
	db "@"

CeladonGameCornerText_48dac: ; 48dac (12:4dac)
	TX_FAR _CeladonGameCornerText_48dac
	db "@"

CeladonGameCornerText6: ; 48db1 (12:4db1)
	TX_FAR _CeladonGameCornerText6
	db "@"

CeladonGameCornerText7: ; 48db6 (12:4db6)
	TX_ASM
	CheckEvent EVENT_BEAT_ERIKA
	ld hl, CeladonGameCornerText_48dca
	jr z, .asm_48dc4
	ld hl, CeladonGameCornerText_48dcf
.asm_48dc4
	call PrintText
	jp TextScriptEnd

CeladonGameCornerText_48dca: ; 48dca (12:4dca)
	TX_FAR _CeladonGameCornerText_48dca
	db "@"

CeladonGameCornerText_48dcf: ; 48dcf (12:4dcf)
	TX_FAR _CeladonGameCornerText_48dcf
	db "@"

CeladonGameCornerText8: ; 48dd4 (12:4dd4)
	TX_FAR _CeladonGameCornerText8
	db "@"

CeladonGameCornerText9: ; 48dd9 (12:4dd9)
	TX_ASM
	CheckEvent EVENT_GOT_20_COINS_2
	jr nz, .asm_48e13
	ld hl, CeladonGameCornerText_48e26
	call PrintText
	ld b, COIN_CASE
	call IsItemInBag
	jr z, .asm_48e1d
	call Has9990Coins
	jr nc, .asm_48e18
	xor a
	ld [hUnusedCoinsByte], a
	ld [hCoins], a
	ld a, $20
	ld [hCoins + 1], a
	ld de, wPlayerCoins + 1
	ld hl, hCoins + 1
	ld c, $2
	predef AddBCDPredef
	SetEvent EVENT_GOT_20_COINS_2
	ld hl, Received20CoinsText
	jr .asm_48e20
.asm_48e13
	ld hl, CeladonGameCornerText_48e36
	jr .asm_48e20
.asm_48e18
	ld hl, CeladonGameCornerText_48e31
	jr .asm_48e20
.asm_48e1d
	ld hl, CeladonGameCornerText_48f19
.asm_48e20
	call PrintText
	jp TextScriptEnd

CeladonGameCornerText_48e26: ; 48e26 (12:4e26)
	TX_FAR _CeladonGameCornerText_48e26
	db "@"

Received20CoinsText: ; 48e2b (12:4e2b)
	TX_FAR _Received20CoinsText
	db $0B, "@"

CeladonGameCornerText_48e31: ; 48e31 (12:4e31)
	TX_FAR _CeladonGameCornerText_48e31
	db "@"

CeladonGameCornerText_48e36: ; 48e36 (12:4e36)
	TX_FAR _CeladonGameCornerText_48e36
	db "@"

CeladonGameCornerText10: ; 48e3b (12:4e3b)
	TX_ASM
	CheckEvent EVENT_GOT_20_COINS
	jr nz, .asm_48e75
	ld hl, CeladonGameCornerText_48e88
	call PrintText
	ld b,COIN_CASE
	call IsItemInBag
	jr z, .asm_48e7f
	call Has9990Coins
	jr z, .asm_48e7a
	xor a
	ld [hUnusedCoinsByte], a
	ld [hCoins], a
	ld a, $20
	ld [hCoins + 1], a
	ld de, wPlayerCoins + 1
	ld hl, hCoins + 1
	ld c, $2
	predef AddBCDPredef
	SetEvent EVENT_GOT_20_COINS
	ld hl, CeladonGameCornerText_48e8d
	jr .asm_48e82
.asm_48e75
	ld hl, CeladonGameCornerText_48e98
	jr .asm_48e82
.asm_48e7a
	ld hl, CeladonGameCornerText_48e93
	jr .asm_48e82
.asm_48e7f
	ld hl, CeladonGameCornerText_48f19
.asm_48e82
	call PrintText
	jp TextScriptEnd

CeladonGameCornerText_48e88: ; 48e88 (12:4e88)
	TX_FAR _CeladonGameCornerText_48e88
	db "@"

CeladonGameCornerText_48e8d: ; 48e8d (12:4e8d)
	TX_FAR _CeladonGameCornerText_48e8d
	db $0B, "@"

CeladonGameCornerText_48e93: ; 48e93 (12:4e93)
	TX_FAR _CeladonGameCornerText_48e93
	db "@"

CeladonGameCornerText_48e98: ; 48e98 (12:4e98)
	TX_FAR _CeladonGameCornerText_48e98
	db "@"

CeladonGameCornerText11: ; 48e9d (12:4e9d)
	TX_ASM
	ld hl, CeladonGameCornerText_48ece
	call PrintText
	ld hl, wd72d
	set 6, [hl]
	set 7, [hl]
	ld hl, CeladonGameCornerText_48ed3
	ld de, CeladonGameCornerText_48ed3
	call SaveEndBattleTextPointers
	ld a, [H_SPRITEINDEX]
	ld [wSpriteIndex], a
	call EngageMapTrainer
	call InitBattleEnemyParameters
	xor a
	ld [hJoyHeld], a
	ld [hJoyPressed], a
	ld [hJoyReleased], a
	ld a, $1
	ld [wCeladonGameCornerCurScript], a
	jp TextScriptEnd

CeladonGameCornerText_48ece: ; 48ece (12:4ece)
	TX_FAR _CeladonGameCornerText_48ece
	db "@"

CeladonGameCornerText_48ed3: ; 48ed3 (12:4ed3)
	TX_FAR _CeladonGameCornerText_48ed3
	db "@"

CeladonGameCornerText13: ; 48ed8 (12:4ed8)
	TX_FAR _CeladonGameCornerText_48ed8
	db "@"

CeladonGameCornerText12: ; 48edd (12:4edd)
	TX_ASM
	ld a, $1
	ld [wDoNotWaitForButtonPressAfterDisplayingText], a
	ld hl, CeladonGameCornerText_48f09
	call PrintText
	call WaitForSoundToFinish
	ld a, SFX_GO_INSIDE
	call PlaySound
	call WaitForSoundToFinish
	SetEvent EVENT_FOUND_ROCKET_HIDEOUT
	ld a, $43
	ld [wNewTileBlockID], a
	lb bc, 2, 8
	predef ReplaceTileBlock
	jp TextScriptEnd

CeladonGameCornerText_48f09: ; 48f09 (12:4f09)
	TX_FAR _CeladonGameCornerText_48f09
	TX_ASM
	ld a, SFX_SWITCH
	call PlaySound
	call WaitForSoundToFinish
	jp TextScriptEnd

CeladonGameCornerText_48f19: ; 48f19 (12:4f19)
	TX_FAR _CeladonGameCornerText_48f19
	db "@"

CeladonGameCornerScript_48f1e: ; 48f1e (12:4f1e)
	ld hl, wd730
	set 6, [hl]
	coord hl, 11, 0
	ld b, $5
	ld c, $7
	call TextBoxBorder
	call UpdateSprites
	coord hl, 12, 1
	ld b, 4
	ld c, 7
	call ClearScreenArea
	coord hl, 12, 2
	ld de, GameCornerMoneyText
	call PlaceString
	coord hl, 12, 3
	ld de, GameCornerBlankText1
	call PlaceString
	coord hl, 12, 3
	ld de, wPlayerMoney
	ld c, $a3
	call PrintBCDNumber
	coord hl, 12, 4
	ld de, GameCornerCoinText
	call PlaceString
	coord hl, 12, 5
	ld de, GameCornerBlankText2
	call PlaceString
	coord hl, 15, 5
	ld de, wPlayerCoins
	ld c, $82
	call PrintBCDNumber
	ld hl, wd730
	res 6, [hl]
	ret

GameCornerMoneyText: ; 48f7a (12:4f7a)
	db "MONEY@"

GameCornerCoinText: ; 48f80 (12:4f80)
	db "COIN@"

GameCornerBlankText1: ; 48f85 (12:4f85)
	db "       @"

GameCornerBlankText2: ; 48f8d (12:4f8d)
	db "       @"

Has9990Coins: ; 48f95 (12:4f95)
	ld a, $99
	ld [hCoins], a
	ld a, $90
	ld [hCoins + 1], a
	jp HasEnoughCoins