Book a Demo!
CoCalc Logo Icon
StoreFeaturesDocsShareSupportNewsAboutPoliciesSign UpSign In
pret
GitHub Repository: pret/pokered
Path: blob/master/engine/pokemon/bills_pc.asm
1271 views
1
DisplayPCMainMenu::
2
xor a
3
ldh [hAutoBGTransferEnabled], a
4
call SaveScreenTilesToBuffer2
5
ld a, [wNumHoFTeams]
6
and a
7
jr nz, .leaguePCAvailable
8
CheckEvent EVENT_GOT_POKEDEX
9
jr z, .noOaksPC
10
ld a, [wNumHoFTeams]
11
and a
12
jr nz, .leaguePCAvailable
13
hlcoord 0, 0
14
ld b, 8
15
ld c, 14
16
jr .next
17
.noOaksPC
18
hlcoord 0, 0
19
ld b, 6
20
ld c, 14
21
jr .next
22
.leaguePCAvailable
23
hlcoord 0, 0
24
ld b, 10
25
ld c, 14
26
.next
27
call TextBoxBorder
28
call UpdateSprites
29
ld a, 3
30
ld [wMaxMenuItem], a
31
CheckEvent EVENT_MET_BILL
32
jr nz, .metBill
33
hlcoord 2, 2
34
ld de, SomeonesPCText
35
jr .next2
36
.metBill
37
hlcoord 2, 2
38
ld de, BillsPCText
39
.next2
40
call PlaceString
41
hlcoord 2, 4
42
ld de, wPlayerName
43
call PlaceString
44
ld l, c
45
ld h, b
46
ld de, PlayersPCText
47
call PlaceString
48
CheckEvent EVENT_GOT_POKEDEX
49
jr z, .noOaksPC2
50
hlcoord 2, 6
51
ld de, OaksPCText
52
call PlaceString
53
ld a, [wNumHoFTeams]
54
and a
55
jr z, .noLeaguePC
56
ld a, 4
57
ld [wMaxMenuItem], a
58
hlcoord 2, 8
59
ld de, PKMNLeaguePCText
60
call PlaceString
61
hlcoord 2, 10
62
ld de, LogOffPCText
63
jr .next3
64
.noLeaguePC
65
hlcoord 2, 8
66
ld de, LogOffPCText
67
jr .next3
68
.noOaksPC2
69
ld a, $2
70
ld [wMaxMenuItem], a
71
hlcoord 2, 6
72
ld de, LogOffPCText
73
.next3
74
call PlaceString
75
ld a, PAD_A | PAD_B
76
ld [wMenuWatchedKeys], a
77
ld a, 2
78
ld [wTopMenuItemY], a
79
ld a, 1
80
ld [wTopMenuItemX], a
81
xor a
82
ld [wCurrentMenuItem], a
83
ld [wLastMenuItem], a
84
ld a, 1
85
ldh [hAutoBGTransferEnabled], a
86
ret
87
88
SomeonesPCText: db "SOMEONE's PC@"
89
BillsPCText: db "BILL's PC@"
90
PlayersPCText: db "'s PC@"
91
OaksPCText: db "PROF.OAK's PC@"
92
PKMNLeaguePCText: db "<PKMN>LEAGUE@"
93
LogOffPCText: db "LOG OFF@"
94
95
BillsPC_::
96
ld hl, wStatusFlags5
97
set BIT_NO_TEXT_DELAY, [hl]
98
xor a
99
ld [wParentMenuItem], a
100
inc a ; MONSTER_NAME
101
ld [wNameListType], a
102
call LoadHpBarAndStatusTilePatterns
103
ld a, [wListScrollOffset]
104
push af
105
ld a, [wMiscFlags]
106
bit BIT_USING_GENERIC_PC, a
107
jr nz, BillsPCMenu
108
; accessing it directly
109
ld a, SFX_TURN_ON_PC
110
call PlaySound
111
ld hl, SwitchOnText
112
call PrintText
113
114
BillsPCMenu:
115
ld a, [wParentMenuItem]
116
ld [wCurrentMenuItem], a
117
ld hl, vChars2 tile $78
118
ld de, PokeballTileGraphics
119
lb bc, BANK(PokeballTileGraphics), 1
120
call CopyVideoData
121
call LoadScreenTilesFromBuffer2DisableBGTransfer
122
hlcoord 0, 0
123
ld b, 10
124
ld c, 12
125
call TextBoxBorder
126
hlcoord 2, 2
127
ld de, BillsPCMenuText
128
call PlaceString
129
ld hl, wTopMenuItemY
130
ld a, 2
131
ld [hli], a ; wTopMenuItemY
132
dec a
133
ld [hli], a ; wTopMenuItemX
134
inc hl
135
inc hl
136
ld a, 4
137
ld [hli], a ; wMaxMenuItem
138
ld a, PAD_A | PAD_B
139
ld [hli], a ; wMenuWatchedKeys
140
xor a
141
ld [hli], a ; wLastMenuItem
142
ld [hli], a ; wPartyAndBillsPCSavedMenuItem
143
ld hl, wListScrollOffset
144
ld [hli], a ; wListScrollOffset
145
ld [hl], a ; wMenuWatchMovingOutOfBounds
146
ld [wPlayerMonNumber], a
147
ld hl, WhatText
148
call PrintText
149
hlcoord 9, 14
150
ld b, 2
151
ld c, 9
152
call TextBoxBorder
153
ld a, [wCurrentBoxNum]
154
and BOX_NUM_MASK
155
cp 9
156
jr c, .singleDigitBoxNum
157
; two digit box num
158
sub 9
159
hlcoord 17, 16
160
ld [hl], "1"
161
add "0"
162
jr .next
163
.singleDigitBoxNum
164
add "1"
165
.next
166
ldcoord_a 18, 16
167
hlcoord 10, 16
168
ld de, BoxNoPCText
169
call PlaceString
170
ld a, 1
171
ldh [hAutoBGTransferEnabled], a
172
call Delay3
173
call HandleMenuInput
174
bit B_PAD_B, a
175
jp nz, ExitBillsPC
176
call PlaceUnfilledArrowMenuCursor
177
ld a, [wCurrentMenuItem]
178
ld [wParentMenuItem], a
179
and a
180
jp z, BillsPCWithdraw ; withdraw
181
cp $1
182
jp z, BillsPCDeposit ; deposit
183
cp $2
184
jp z, BillsPCRelease ; release
185
cp $3
186
jp z, BillsPCChangeBox ; change box
187
188
ExitBillsPC:
189
ld a, [wMiscFlags]
190
bit BIT_USING_GENERIC_PC, a
191
jr nz, .next
192
; accessing it directly
193
call LoadTextBoxTilePatterns
194
ld a, SFX_TURN_OFF_PC
195
call PlaySound
196
call WaitForSoundToFinish
197
.next
198
ld hl, wMiscFlags
199
res BIT_NO_MENU_BUTTON_SOUND, [hl]
200
call LoadScreenTilesFromBuffer2
201
pop af
202
ld [wListScrollOffset], a
203
ld hl, wStatusFlags5
204
res BIT_NO_TEXT_DELAY, [hl]
205
ret
206
207
BillsPCDeposit:
208
ld a, [wPartyCount]
209
dec a
210
jr nz, .partyLargeEnough
211
ld hl, CantDepositLastMonText
212
call PrintText
213
jp BillsPCMenu
214
.partyLargeEnough
215
ld a, [wBoxCount]
216
cp MONS_PER_BOX
217
jr nz, .boxNotFull
218
ld hl, BoxFullText
219
call PrintText
220
jp BillsPCMenu
221
.boxNotFull
222
ld hl, wPartyCount
223
call DisplayMonListMenu
224
jp c, BillsPCMenu
225
call DisplayDepositWithdrawMenu
226
jp nc, BillsPCMenu
227
ld a, [wCurPartySpecies]
228
call GetCryData
229
call PlaySoundWaitForCurrent
230
ld a, PARTY_TO_BOX
231
ld [wMoveMonType], a
232
call MoveMon
233
xor a
234
ld [wRemoveMonFromBox], a
235
call RemovePokemon
236
call WaitForSoundToFinish
237
ld hl, wBoxNumString
238
ld a, [wCurrentBoxNum]
239
and BOX_NUM_MASK
240
cp 9
241
jr c, .singleDigitBoxNum
242
sub 9
243
ld [hl], "1"
244
inc hl
245
add "0"
246
jr .next
247
.singleDigitBoxNum
248
add "1"
249
.next
250
ld [hli], a
251
ld [hl], "@"
252
ld hl, MonWasStoredText
253
call PrintText
254
jp BillsPCMenu
255
256
BillsPCWithdraw:
257
ld a, [wBoxCount]
258
and a
259
jr nz, .boxNotEmpty
260
ld hl, NoMonText
261
call PrintText
262
jp BillsPCMenu
263
.boxNotEmpty
264
ld a, [wPartyCount]
265
cp PARTY_LENGTH
266
jr nz, .partyNotFull
267
ld hl, CantTakeMonText
268
call PrintText
269
jp BillsPCMenu
270
.partyNotFull
271
ld hl, wBoxCount
272
call DisplayMonListMenu
273
jp c, BillsPCMenu
274
call DisplayDepositWithdrawMenu
275
jp nc, BillsPCMenu
276
ld a, [wWhichPokemon]
277
ld hl, wBoxMonNicks
278
call GetPartyMonName
279
ld a, [wCurPartySpecies]
280
call GetCryData
281
call PlaySoundWaitForCurrent
282
xor a ; BOX_TO_PARTY
283
ld [wMoveMonType], a
284
call MoveMon
285
ld a, 1
286
ld [wRemoveMonFromBox], a
287
call RemovePokemon
288
call WaitForSoundToFinish
289
ld hl, MonIsTakenOutText
290
call PrintText
291
jp BillsPCMenu
292
293
BillsPCRelease:
294
ld a, [wBoxCount]
295
and a
296
jr nz, .loop
297
ld hl, NoMonText
298
call PrintText
299
jp BillsPCMenu
300
.loop
301
ld hl, wBoxCount
302
call DisplayMonListMenu
303
jp c, BillsPCMenu
304
ld hl, OnceReleasedText
305
call PrintText
306
call YesNoChoice
307
ld a, [wCurrentMenuItem]
308
and a
309
jr nz, .loop
310
inc a
311
ld [wRemoveMonFromBox], a
312
call RemovePokemon
313
call WaitForSoundToFinish
314
ld a, [wCurPartySpecies]
315
call PlayCry
316
ld hl, MonWasReleasedText
317
call PrintText
318
jp BillsPCMenu
319
320
BillsPCChangeBox:
321
farcall ChangeBox
322
jp BillsPCMenu
323
324
DisplayMonListMenu:
325
ld a, l
326
ld [wListPointer], a
327
ld a, h
328
ld [wListPointer + 1], a
329
xor a
330
ld [wPrintItemPrices], a
331
ld [wListMenuID], a
332
inc a ; MONSTER_NAME
333
ld [wNameListType], a
334
ld a, [wPartyAndBillsPCSavedMenuItem]
335
ld [wCurrentMenuItem], a
336
call DisplayListMenuID
337
ld a, [wCurrentMenuItem]
338
ld [wPartyAndBillsPCSavedMenuItem], a
339
ret
340
341
BillsPCMenuText:
342
db "WITHDRAW <PKMN>"
343
next "DEPOSIT <PKMN>"
344
next "RELEASE <PKMN>"
345
next "CHANGE BOX"
346
next "SEE YA!"
347
db "@"
348
349
BoxNoPCText:
350
db "BOX No.@"
351
352
KnowsHMMove::
353
; returns whether mon with party index [wWhichPokemon] knows an HM move
354
ld hl, wPartyMon1Moves
355
ld bc, wPartyMon2 - wPartyMon1
356
jr .next
357
; unreachable
358
ld hl, wBoxMon1Moves
359
ld bc, wBoxMon2 - wBoxMon1
360
.next
361
ld a, [wWhichPokemon]
362
call AddNTimes
363
ld b, NUM_MOVES
364
.loop
365
ld a, [hli]
366
push hl
367
push bc
368
ld hl, HMMoveArray
369
ld de, 1
370
call IsInArray
371
pop bc
372
pop hl
373
ret c
374
dec b
375
jr nz, .loop
376
and a
377
ret
378
379
HMMoveArray:
380
INCLUDE "data/moves/hm_moves.asm"
381
382
DisplayDepositWithdrawMenu:
383
hlcoord 9, 10
384
ld b, 6
385
ld c, 9
386
call TextBoxBorder
387
ld a, [wParentMenuItem]
388
and a ; was the Deposit or Withdraw item selected in the parent menu?
389
ld de, DepositPCText
390
jr nz, .next
391
ld de, WithdrawPCText
392
.next
393
hlcoord 11, 12
394
call PlaceString
395
hlcoord 11, 14
396
ld de, StatsCancelPCText
397
call PlaceString
398
ld hl, wTopMenuItemY
399
ld a, 12
400
ld [hli], a ; wTopMenuItemY
401
ld a, 10
402
ld [hli], a ; wTopMenuItemX
403
xor a
404
ld [hli], a ; wCurrentMenuItem
405
inc hl
406
ld a, 2
407
ld [hli], a ; wMaxMenuItem
408
ld a, PAD_A | PAD_B
409
ld [hli], a ; wMenuWatchedKeys
410
xor a
411
ld [hl], a ; wLastMenuItem
412
ld hl, wListScrollOffset
413
ld [hli], a ; wListScrollOffset
414
ld [hl], a ; wMenuWatchMovingOutOfBounds
415
ld [wPlayerMonNumber], a
416
ld [wPartyAndBillsPCSavedMenuItem], a
417
.loop
418
call HandleMenuInput
419
bit B_PAD_B, a
420
jr nz, .exit
421
ld a, [wCurrentMenuItem]
422
and a
423
jr z, .choseDepositWithdraw
424
dec a
425
jr z, .viewStats
426
.exit
427
and a
428
ret
429
.choseDepositWithdraw
430
scf
431
ret
432
.viewStats
433
call SaveScreenTilesToBuffer1
434
ld a, [wParentMenuItem]
435
and a
436
ld a, PLAYER_PARTY_DATA
437
jr nz, .next2
438
ld a, BOX_DATA
439
.next2
440
ld [wMonDataLocation], a
441
predef StatusScreen
442
predef StatusScreen2
443
call LoadScreenTilesFromBuffer1
444
call ReloadTilesetTilePatterns
445
call RunDefaultPaletteCommand
446
call LoadGBPal
447
jr .loop
448
449
DepositPCText: db "DEPOSIT@"
450
WithdrawPCText: db "WITHDRAW@"
451
StatsCancelPCText:
452
db "STATS"
453
next "CANCEL@"
454
455
SwitchOnText:
456
text_far _SwitchOnText
457
text_end
458
459
WhatText:
460
text_far _WhatText
461
text_end
462
463
DepositWhichMonText:
464
text_far _DepositWhichMonText
465
text_end
466
467
MonWasStoredText:
468
text_far _MonWasStoredText
469
text_end
470
471
CantDepositLastMonText:
472
text_far _CantDepositLastMonText
473
text_end
474
475
BoxFullText:
476
text_far _BoxFullText
477
text_end
478
479
MonIsTakenOutText:
480
text_far _MonIsTakenOutText
481
text_end
482
483
NoMonText:
484
text_far _NoMonText
485
text_end
486
487
CantTakeMonText:
488
text_far _CantTakeMonText
489
text_end
490
491
ReleaseWhichMonText:
492
text_far _ReleaseWhichMonText
493
text_end
494
495
OnceReleasedText:
496
text_far _OnceReleasedText
497
text_end
498
499
MonWasReleasedText:
500
text_far _MonWasReleasedText
501
text_end
502
503
CableClubLeftGameboy::
504
ldh a, [hSerialConnectionStatus]
505
cp USING_EXTERNAL_CLOCK
506
ret z
507
ld a, [wSpritePlayerStateData1FacingDirection]
508
cp SPRITE_FACING_RIGHT
509
ret nz
510
ld a, [wCurMap]
511
cp TRADE_CENTER
512
ld a, LINK_STATE_START_TRADE
513
jr z, .next
514
inc a ; LINK_STATE_START_BATTLE
515
.next
516
ld [wLinkState], a
517
call EnableAutoTextBoxDrawing
518
tx_pre_jump JustAMomentText
519
520
CableClubRightGameboy::
521
ldh a, [hSerialConnectionStatus]
522
cp USING_INTERNAL_CLOCK
523
ret z
524
ld a, [wSpritePlayerStateData1FacingDirection]
525
cp SPRITE_FACING_LEFT
526
ret nz
527
ld a, [wCurMap]
528
cp TRADE_CENTER
529
ld a, LINK_STATE_START_TRADE
530
jr z, .next
531
inc a ; LINK_STATE_START_BATTLE
532
.next
533
ld [wLinkState], a
534
call EnableAutoTextBoxDrawing
535
tx_pre_jump JustAMomentText
536
537
JustAMomentText::
538
text_far _JustAMomentText
539
text_end
540
541
UnusedOpenBillsPC: ; unreferenced
542
ld a, [wSpritePlayerStateData1FacingDirection]
543
cp SPRITE_FACING_UP
544
ret nz
545
call EnableAutoTextBoxDrawing
546
tx_pre_jump OpenBillsPCText
547
548
OpenBillsPCText::
549
script_bills_pc
550
551