forked from waicalibre/pokered-eo
-
Notifications
You must be signed in to change notification settings - Fork 0
/
bills_pc.asm
549 lines (516 loc) · 9.68 KB
/
bills_pc.asm
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
DisplayPCMainMenu::
xor a
ldh [hAutoBGTransferEnabled], a
call SaveScreenTilesToBuffer2
ld a, [wNumHoFTeams]
and a
jr nz, .leaguePCAvailable
CheckEvent EVENT_GOT_POKEDEX
jr z, .noOaksPC
ld a, [wNumHoFTeams]
and a
jr nz, .leaguePCAvailable
hlcoord 0, 0
ld b, 8
ld c, 14
jr .next
.noOaksPC
hlcoord 0, 0
ld b, 6
ld c, 14
jr .next
.leaguePCAvailable
hlcoord 0, 0
ld b, 10
ld c, 14
.next
call TextBoxBorder
call UpdateSprites
ld a, 3
ld [wMaxMenuItem], a
CheckEvent EVENT_MET_BILL
jr nz, .metBill
hlcoord 2, 2
ld de, SomeonesPCText
jr .next2
.metBill
hlcoord 2, 2
ld de, BillsPCText
.next2
call PlaceString
hlcoord 2, 4
ld de, wPlayerName
call PlaceString
ld l, c
ld h, b
ld de, PlayersPCText
call PlaceString
CheckEvent EVENT_GOT_POKEDEX
jr z, .noOaksPC2
hlcoord 2, 6
ld de, OaksPCText
call PlaceString
ld a, [wNumHoFTeams]
and a
jr z, .noLeaguePC
ld a, 4
ld [wMaxMenuItem], a
hlcoord 2, 8
ld de, PKMNLeaguePCText
call PlaceString
hlcoord 2, 10
ld de, LogOffPCText
jr .next3
.noLeaguePC
hlcoord 2, 8
ld de, LogOffPCText
jr .next3
.noOaksPC2
ld a, $2
ld [wMaxMenuItem], a
hlcoord 2, 6
ld de, LogOffPCText
.next3
call PlaceString
ld a, A_BUTTON | B_BUTTON
ld [wMenuWatchedKeys], a
ld a, 2
ld [wTopMenuItemY], a
ld a, 1
ld [wTopMenuItemX], a
xor a
ld [wCurrentMenuItem], a
ld [wLastMenuItem], a
ld a, 1
ldh [hAutoBGTransferEnabled], a
ret
SomeonesPCText: db "SOMEONE's PC@"
BillsPCText: db "BILL's PC@"
PlayersPCText: db "'s PC@"
OaksPCText: db "PROF.OAK's PC@"
PKMNLeaguePCText: db "<PKMN>LEAGUE@"
LogOffPCText: db "LOG OFF@"
BillsPC_::
ld hl, wd730
set 6, [hl]
xor a
ld [wParentMenuItem], a
inc a ; MONSTER_NAME
ld [wNameListType], a
call LoadHpBarAndStatusTilePatterns
ld a, [wListScrollOffset]
push af
ld a, [wFlags_0xcd60]
bit 3, a ; accessing Bill's PC through another PC?
jr nz, BillsPCMenu
; accessing it directly
ld a, SFX_TURN_ON_PC
call PlaySound
ld hl, SwitchOnText
call PrintText
BillsPCMenu:
ld a, [wParentMenuItem]
ld [wCurrentMenuItem], a
ld hl, vChars2 tile $78
ld de, PokeballTileGraphics
lb bc, BANK(PokeballTileGraphics), 1
call CopyVideoData
call LoadScreenTilesFromBuffer2DisableBGTransfer
hlcoord 0, 0
ld b, 10
ld c, 12
call TextBoxBorder
hlcoord 2, 2
ld de, BillsPCMenuText
call PlaceString
ld hl, wTopMenuItemY
ld a, 2
ld [hli], a ; wTopMenuItemY
dec a
ld [hli], a ; wTopMenuItemX
inc hl
inc hl
ld a, 4
ld [hli], a ; wMaxMenuItem
ld a, A_BUTTON | B_BUTTON
ld [hli], a ; wMenuWatchedKeys
xor a
ld [hli], a ; wLastMenuItem
ld [hli], a ; wPartyAndBillsPCSavedMenuItem
ld hl, wListScrollOffset
ld [hli], a ; wListScrollOffset
ld [hl], a ; wMenuWatchMovingOutOfBounds
ld [wPlayerMonNumber], a
ld hl, WhatText
call PrintText
hlcoord 9, 14
ld b, 2
ld c, 9
call TextBoxBorder
ld a, [wCurrentBoxNum]
and $7f
cp 9
jr c, .singleDigitBoxNum
; two digit box num
sub 9
hlcoord 17, 16
ld [hl], "1"
add "0"
jr .next
.singleDigitBoxNum
add "1"
.next
ldcoord_a 18, 16
hlcoord 10, 16
ld de, BoxNoPCText
call PlaceString
ld a, 1
ldh [hAutoBGTransferEnabled], a
call Delay3
call HandleMenuInput
bit 1, a
jp nz, ExitBillsPC ; b button
call PlaceUnfilledArrowMenuCursor
ld a, [wCurrentMenuItem]
ld [wParentMenuItem], a
and a
jp z, BillsPCWithdraw ; withdraw
cp $1
jp z, BillsPCDeposit ; deposit
cp $2
jp z, BillsPCRelease ; release
cp $3
jp z, BillsPCChangeBox ; change box
ExitBillsPC:
ld a, [wFlags_0xcd60]
bit 3, a ; accessing Bill's PC through another PC?
jr nz, .next
; accessing it directly
call LoadTextBoxTilePatterns
ld a, SFX_TURN_OFF_PC
call PlaySound
call WaitForSoundToFinish
.next
ld hl, wFlags_0xcd60
res 5, [hl]
call LoadScreenTilesFromBuffer2
pop af
ld [wListScrollOffset], a
ld hl, wd730
res 6, [hl]
ret
BillsPCDeposit:
ld a, [wPartyCount]
dec a
jr nz, .partyLargeEnough
ld hl, CantDepositLastMonText
call PrintText
jp BillsPCMenu
.partyLargeEnough
ld a, [wNumInBox]
cp MONS_PER_BOX
jr nz, .boxNotFull
ld hl, BoxFullText
call PrintText
jp BillsPCMenu
.boxNotFull
ld hl, wPartyCount
call DisplayMonListMenu
jp c, BillsPCMenu
call DisplayDepositWithdrawMenu
jp nc, BillsPCMenu
ld a, [wcf91]
call GetCryData
call PlaySoundWaitForCurrent
ld a, PARTY_TO_BOX
ld [wMoveMonType], a
call MoveMon
xor a
ld [wRemoveMonFromBox], a
call RemovePokemon
call WaitForSoundToFinish
ld hl, wBoxNumString
ld a, [wCurrentBoxNum]
and $7f
cp 9
jr c, .singleDigitBoxNum
sub 9
ld [hl], "1"
inc hl
add "0"
jr .next
.singleDigitBoxNum
add "1"
.next
ld [hli], a
ld [hl], "@"
ld hl, MonWasStoredText
call PrintText
jp BillsPCMenu
BillsPCWithdraw:
ld a, [wNumInBox]
and a
jr nz, .boxNotEmpty
ld hl, NoMonText
call PrintText
jp BillsPCMenu
.boxNotEmpty
ld a, [wPartyCount]
cp PARTY_LENGTH
jr nz, .partyNotFull
ld hl, CantTakeMonText
call PrintText
jp BillsPCMenu
.partyNotFull
ld hl, wNumInBox
call DisplayMonListMenu
jp c, BillsPCMenu
call DisplayDepositWithdrawMenu
jp nc, BillsPCMenu
ld a, [wWhichPokemon]
ld hl, wBoxMonNicks
call GetPartyMonName
ld a, [wcf91]
call GetCryData
call PlaySoundWaitForCurrent
xor a ; BOX_TO_PARTY
ld [wMoveMonType], a
call MoveMon
ld a, 1
ld [wRemoveMonFromBox], a
call RemovePokemon
call WaitForSoundToFinish
ld hl, MonIsTakenOutText
call PrintText
jp BillsPCMenu
BillsPCRelease:
ld a, [wNumInBox]
and a
jr nz, .loop
ld hl, NoMonText
call PrintText
jp BillsPCMenu
.loop
ld hl, wNumInBox
call DisplayMonListMenu
jp c, BillsPCMenu
ld hl, OnceReleasedText
call PrintText
call YesNoChoice
ld a, [wCurrentMenuItem]
and a
jr nz, .loop
inc a
ld [wRemoveMonFromBox], a
call RemovePokemon
call WaitForSoundToFinish
ld a, [wcf91]
call PlayCry
ld hl, MonWasReleasedText
call PrintText
jp BillsPCMenu
BillsPCChangeBox:
farcall ChangeBox
jp BillsPCMenu
DisplayMonListMenu:
ld a, l
ld [wListPointer], a
ld a, h
ld [wListPointer + 1], a
xor a
ld [wPrintItemPrices], a
ld [wListMenuID], a
inc a ; MONSTER_NAME
ld [wNameListType], a
ld a, [wPartyAndBillsPCSavedMenuItem]
ld [wCurrentMenuItem], a
call DisplayListMenuID
ld a, [wCurrentMenuItem]
ld [wPartyAndBillsPCSavedMenuItem], a
ret
BillsPCMenuText:
db "WITHDRAW <PKMN>"
next "DEPOSIT <PKMN>"
next "RELEASE <PKMN>"
next "CHANGE BOX"
next "SEE YA!"
db "@"
BoxNoPCText:
db "BOX No.@"
KnowsHMMove::
; returns whether mon with party index [wWhichPokemon] knows an HM move
ld hl, wPartyMon1Moves
ld bc, wPartyMon2 - wPartyMon1
jr .next
; unreachable
ld hl, wBoxMon1Moves
ld bc, wBoxMon2 - wBoxMon1
.next
ld a, [wWhichPokemon]
call AddNTimes
ld b, NUM_MOVES
.loop
ld a, [hli]
push hl
push bc
ld hl, HMMoveArray
ld de, 1
call IsInArray
pop bc
pop hl
ret c
dec b
jr nz, .loop
and a
ret
HMMoveArray:
INCLUDE "data/moves/hm_moves.asm"
DisplayDepositWithdrawMenu:
hlcoord 9, 10
ld b, 6
ld c, 9
call TextBoxBorder
ld a, [wParentMenuItem]
and a ; was the Deposit or Withdraw item selected in the parent menu?
ld de, DepositPCText
jr nz, .next
ld de, WithdrawPCText
.next
hlcoord 11, 12
call PlaceString
hlcoord 11, 14
ld de, StatsCancelPCText
call PlaceString
ld hl, wTopMenuItemY
ld a, 12
ld [hli], a ; wTopMenuItemY
ld a, 10
ld [hli], a ; wTopMenuItemX
xor a
ld [hli], a ; wCurrentMenuItem
inc hl
ld a, 2
ld [hli], a ; wMaxMenuItem
ld a, A_BUTTON | B_BUTTON
ld [hli], a ; wMenuWatchedKeys
xor a
ld [hl], a ; wLastMenuItem
ld hl, wListScrollOffset
ld [hli], a ; wListScrollOffset
ld [hl], a ; wMenuWatchMovingOutOfBounds
ld [wPlayerMonNumber], a
ld [wPartyAndBillsPCSavedMenuItem], a
.loop
call HandleMenuInput
bit 1, a ; pressed B?
jr nz, .exit
ld a, [wCurrentMenuItem]
and a
jr z, .choseDepositWithdraw
dec a
jr z, .viewStats
.exit
and a
ret
.choseDepositWithdraw
scf
ret
.viewStats
call SaveScreenTilesToBuffer1
ld a, [wParentMenuItem]
and a
ld a, PLAYER_PARTY_DATA
jr nz, .next2
ld a, BOX_DATA
.next2
ld [wMonDataLocation], a
predef StatusScreen
predef StatusScreen2
call LoadScreenTilesFromBuffer1
call ReloadTilesetTilePatterns
call RunDefaultPaletteCommand
call LoadGBPal
jr .loop
DepositPCText: db "DEPOSIT@"
WithdrawPCText: db "WITHDRAW@"
StatsCancelPCText:
db "STATS"
next "CANCEL@"
SwitchOnText:
text_far _SwitchOnText
text_end
WhatText:
text_far _WhatText
text_end
DepositWhichMonText:
text_far _DepositWhichMonText
text_end
MonWasStoredText:
text_far _MonWasStoredText
text_end
CantDepositLastMonText:
text_far _CantDepositLastMonText
text_end
BoxFullText:
text_far _BoxFullText
text_end
MonIsTakenOutText:
text_far _MonIsTakenOutText
text_end
NoMonText:
text_far _NoMonText
text_end
CantTakeMonText:
text_far _CantTakeMonText
text_end
ReleaseWhichMonText:
text_far _ReleaseWhichMonText
text_end
OnceReleasedText:
text_far _OnceReleasedText
text_end
MonWasReleasedText:
text_far _MonWasReleasedText
text_end
CableClubLeftGameboy::
ldh a, [hSerialConnectionStatus]
cp USING_EXTERNAL_CLOCK
ret z
ld a, [wSpritePlayerStateData1FacingDirection]
cp SPRITE_FACING_RIGHT
ret nz
ld a, [wCurMap]
cp TRADE_CENTER
ld a, LINK_STATE_START_TRADE
jr z, .next
inc a ; LINK_STATE_START_BATTLE
.next
ld [wLinkState], a
call EnableAutoTextBoxDrawing
tx_pre_jump JustAMomentText
CableClubRightGameboy::
ldh a, [hSerialConnectionStatus]
cp USING_INTERNAL_CLOCK
ret z
ld a, [wSpritePlayerStateData1FacingDirection]
cp SPRITE_FACING_LEFT
ret nz
ld a, [wCurMap]
cp TRADE_CENTER
ld a, LINK_STATE_START_TRADE
jr z, .next
inc a ; LINK_STATE_START_BATTLE
.next
ld [wLinkState], a
call EnableAutoTextBoxDrawing
tx_pre_jump JustAMomentText
JustAMomentText::
text_far _JustAMomentText
text_end
ld a, [wSpritePlayerStateData1FacingDirection]
cp SPRITE_FACING_UP
ret nz
call EnableAutoTextBoxDrawing
tx_pre_jump OpenBillsPCText
OpenBillsPCText::
script_bills_pc