summaryrefslogtreecommitdiff
path: root/engine/menu/link_menu.asm
blob: 4d0beb7ef1eddc49fd11af28573416a9e720a0c0 (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
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
Func_f531b:: ; f531b (3d:531b)
	ld c,$14
	call DelayFrames
	ld a,$1
	ld [wBuffer],a
	xor a
	ld [wUnknownSerialFlag_d499],a
	coord hl, 0,0
	lb bc, 4, 5
	call TextBoxBorder
	ld de,Text_f5791
	coord hl, 1,2
	call PlaceString
	coord hl, 8,0
	lb bc, 8, 10
	call TextBoxBorder
	coord hl, 10,2
	ld de,Text_f579c
	call PlaceString
	coord hl, 0,10
	lb bc, 6, 18
	call TextBoxBorder
	call UpdateSprites
	xor a
	ld [wUnusedCD37],a
	ld [wd72d],a
	ld [wd11e],a
	ld hl,wTopMenuItemY
	ld a,$2
	ld [hli],a
	ld a,$9
	ld [hli],a
	xor a
	ld [hli],a
	inc hl
	ld a,$3
	ld [hli],a
	ld a,$3
	ld [hli],a
	xor a
	ld [hl],a
.asm_f5377
	call Func_f56bd
	call HandleMenuInput
	and $3
	add a
	add a
	ld b,a
	ld a,[wCurrentMenuItem]
	cp $3
	jr nz,.asm_f5390
	bit 2,b
	jr z,.asm_f5390
	dec a
	ld b,$8
.asm_f5390
	add b
	add $c0
	ld [wLinkMenuSelectionSendBuffer],a
	ld [wLinkMenuSelectionSendBuffer+1],a
.asm_f5399
	ld hl,wLinkMenuSelectionSendBuffer
	ld a,[hl]
	ld [hSerialSendData],a
	call Serial_ExchangeByte
	push af
	ld hl,wLinkMenuSelectionSendBuffer
	ld a,[hl]
	ld [hSerialSendData],a
	call Serial_ExchangeByte
	pop bc
	cp b
	jr nz,.asm_f5399
	and $f0
	cp $c0
	jr nz,.asm_f5399
	ld a,b
	and $c
	jr nz,.asm_f53c4
	ld a,[wLinkMenuSelectionSendBuffer]
	and $c
	jr z,.asm_f5377
	jr .asm_f53df
.asm_f53c4
	ld a,[wLinkMenuSelectionSendBuffer]
	and $c
	jr z,.asm_f53d1
	ld a,[hSerialConnectionStatus]
	cp $2
	jr z,.asm_f53df
.asm_f53d1
	ld a,$1
	ld [wd11e],a
	ld a,b
	ld [wLinkMenuSelectionSendBuffer],a
	and $3
	ld [wCurrentMenuItem],a
.asm_f53df
	call DelayFrame
	call DelayFrame
	ld hl,wLinkMenuSelectionSendBuffer
	ld a,[hl]
	ld [hSerialSendData],a
	call Serial_ExchangeByte
	call Serial_ExchangeByte
	ld b,$14
.loop
	call DelayFrame
	call Serial_SendZeroByte
	dec b
	jr nz,.loop
	ld b,$7f
	ld c,$7f
	ld d,$7f
	ld e,$ec
	ld a,[wLinkMenuSelectionSendBuffer]
	bit 3,a
	jr nz,.asm_f541a
	ld b,e
	ld e,c
	ld a,[wCurrentMenuItem]
	and a
	jr z,.asm_f541a
	ld c,b
	ld b,d
	dec a
	jr z,.asm_f541a
	ld d,c
	ld c,b
.asm_f541a
	ld a,b
	Coorda 9,2
	ld a,c
	Coorda 9,4
	ld a,d
	Coorda 9,6
	ld a,e
	Coorda 9,8
	ld c,40
	call DelayFrames
	ld a,[wLinkMenuSelectionSendBuffer]
	bit 3,a
	jr nz,asm_f547f
	ld a,[wCurrentMenuItem]
	cp $3
	jr z,asm_f547f
	inc a
	ld [wUnknownSerialFlag_d499],a
	ld a,[wCurrentMenuItem]
	ld hl,PointerTable_f5488
	ld c,a
	ld b,$0
	add hl,bc
	add hl,bc
	ld a,[hli]
	ld h,[hl]
	ld l,a
	ld de,.returnaddress
	push de
	jp hl
.returnaddress
	ld [wLinkMenuSelectionSendBuffer],a
	xor a
	ld [wUnknownSerialCounter],a
	ld [wUnknownSerialCounter+1],a
	call Serial_SyncAndExchangeNybble
	ld a,[wLinkMenuSelectionSendBuffer]
	and a
	jr nz,asm_f547c
	ld a, [wLinkMenuSelectionReceiveBuffer]
	and a
	jr nz, Func_f5476
	xor a
	ld [wUnknownSerialCounter],a
	ld [wUnknownSerialCounter+1],a
	and a
	ret

Func_f5476:: ; f5476 (3d:5476)
	ld hl,ColosseumIneligibleText
	call PrintText
asm_f547c:: ; f547c (3d:574c)
	jp Func_f531b

asm_f547f:: ; f547f (3d:547f)
	xor a
	ld [wUnknownSerialCounter],a
	ld [wUnknownSerialCounter+1],a
	scf
	ret

PointerTable_f5488:: ; f5488 (3d:5488)
	dw PokeCup
	dw PikaCup
	dw PetitCup

PokeCup:: ; f548e (3d:548e)
	ld hl,wPartyCount
	ld a,[hli]
	cp $3
	jp nz,NotThreeMonsInParty
	ld b,$3
.loop
	ld a,[hli]
	cp MEW
	jp z,MewInParty
	dec b
	jr nz,.loop
	dec hl
	dec hl
	cp [hl] ; is third mon second mon?
	jp z,DuplicateSpecies
	dec hl ; wPartySpecies
	cp [hl] ; is third mon first mon?
	jp z,DuplicateSpecies
	ld a,[hli]
	cp [hl] ; is first mon second mon?
	jp z,DuplicateSpecies
	ld a,[wPartyMon1Level]
	cp 56
	jp nc,LevelAbove55
	cp 50
	jp c,LevelUnder50
	ld b,a
	ld a,[wPartyMon2Level]
	cp 56
	jp nc,LevelAbove55
	cp 50
	jp c,LevelUnder50
	ld c,a
	ld a,[wPartyMon3Level]
	cp 56
	jp nc,LevelAbove55
	cp 50
	jp c,LevelUnder50
	add b
	add c
	cp 156
	jp nc,CombinedLevelsGreaterThan155
	xor a
	ret

PikaCup:: ; f54e4 (3d:54e4)
	ld hl,wPartyCount
	ld a,[hli]
	cp $3
	jp nz,NotThreeMonsInParty
	ld b,$3
.loop
	ld a,[hli] ; wPartySpecies
	cp MEW
	jp z,MewInParty
	dec b
	jr nz,.loop
	dec hl
	dec hl
	cp [hl] ; is third mon second mon?
	jp z,DuplicateSpecies
	dec hl ; wPartySpecies
	cp [hl] ; is third mon first mon?
	jp z,DuplicateSpecies
	ld a,[hli]
	cp [hl] ; is first mon second mon?
	jp z,DuplicateSpecies
	ld a,[wPartyMon1Level]
	cp 21
	jp nc,LevelAbove20
	cp 15
	jp c,LevelUnder15
	ld b,a
	ld a,[wPartyMon2Level]
	cp 21
	jp nc,LevelAbove20
	cp 15
	jp c,LevelUnder15
	ld c,a
	ld a,[wPartyMon3Level]
	cp 21
	jp nc,LevelAbove20
	cp 15
	jp c,LevelUnder15
	add b
	add c
	cp 51
	jp nc,CombinedLevelsAbove50
	xor a
	ret

PetitCup:: ; f553a (3d:553a)
	ld hl,wPartyCount
	ld a,[hli]
	cp $3
	jp nz,NotThreeMonsInParty
	ld b,$3
.loop
	ld a,[hli]
	cp MEW
	jp z,MewInParty
	dec b
	jr nz,.loop
	dec hl
	dec hl
	cp [hl] ; is third mon second mon?
	jp z,DuplicateSpecies
	dec hl ; wPartySpecies
	cp [hl] ; is third mon first mon?
	jp z,DuplicateSpecies
	ld a,[hli]
	cp [hl] ; is first mon second mon?
	jp z,DuplicateSpecies
	dec hl
	ld a,[hl]
	ld [wcf91],a
	push hl
	callab Func_3b10f
	pop hl
	jp c,asm_f56ad
	inc hl
	ld a,[hl]
	ld [wcf91],a
	push hl
	callab Func_3b10f
	pop hl
	jp c,asm_f56ad
	inc hl
	ld a,[hl]
	ld [wcf91],a
	push hl
	callab Func_3b10f
	pop hl
	jp c,asm_f56ad
	dec hl
	dec hl
	ld b,$3
.bigloop
	ld a,[hli]
	push hl
	push bc
	push af
	dec a
	ld c,a
	ld b,$0
	ld hl,PokedexEntryPointers
	add hl,bc
	add hl,bc
	ld de,wcd6d
	ld bc,$2
	ld a,BANK(PokedexEntryPointers)
	call FarCopyData
	ld hl,wcd6d
	ld a,[hli]
	ld h,[hl]
	ld l,a
	ld de,wcd6d
	ld bc,$14
	ld a,BANK(PokedexEntryPointers)
	call FarCopyData
	ld hl,wcd6d
.loop2
	ld a,[hli]
	cp "@"
	jr nz,.loop2
	ld a,[hli]
	cp $7
	jp nc,asm_f5689
	add a
	add a
	ld b,a
	add a
	add b
	ld b,a
	ld a,[hli]
	add b
	cp $51
	jp nc,asm_f5689
	ld a,[hli]
	sub $b9
	ld a,[hl]
	sbc $1
	jp nc,asm_f569b
	pop af
	pop bc
	pop hl
	dec b
	jr nz,.bigloop
	ld a,[wPartyMon1Level]
	cp 31
	jp nc,LevelAbove30
	cp 25
	jp c,LevelUnder25
	ld b,a
	ld a,[wPartyMon2Level]
	cp 31
	jp nc,LevelAbove30
	cp 25
	jp c,LevelUnder25
	ld c,a
	ld a,[wPartyMon3Level]
	cp 31
	jp nc,LevelAbove30
	cp 25
	jp c,LevelUnder25
	add b
	add c
	cp 81
	jp nc,CombinedLevelsAbove80
	xor a
	ret

NotThreeMonsInParty:: ; f561d (3d:516d)
	ld hl,Colosseum3MonsText
	call PrintText
	ld a,$1
	ret

MewInParty:: ; f5626 (3d:f5626)
	ld hl,ColosseumMewText
	call PrintText
	ld a,$2
	ret

DuplicateSpecies:: ; f562f (3d:f562f)
	ld hl,ColosseumDifferentMonsText
	call PrintText
	ld a,$3
	ret

LevelAbove55:: ; f5638 (3d:5638)
	ld hl,ColosseumMaxL55Text
	call PrintText
	ld a,$4
	ret

LevelUnder50:: ; f5641 (3d:5641)
	ld hl,ColosseumMinL50Text
	call PrintText
	ld a,$5
	ret

CombinedLevelsGreaterThan155:: ; f5641 (3d:564a)
	ld hl,ColosseumTotalL155Text
	call PrintText
	ld a,$6
	ret

LevelAbove30:: ; f5653 (3d:5653)
	ld hl,ColosseumMaxL30Text
	call PrintText
	ld a,$7
	ret

LevelUnder25:: ; f565c (3d:565c)
	ld hl,ColosseumMinL25Text
	call PrintText
	ld a,$8
	ret

CombinedLevelsAbove80:: ; f5665 (3d:5665)
	ld hl,ColosseumTotalL80Text
	call PrintText
	ld a,$9
	ret

LevelAbove20:: ; f566e (3d:566e)
	ld hl,ColosseumMaxL20Text
	call PrintText
	ld a,$a
	ret

LevelUnder15:: ; f5677 (3d:5677)
	ld hl,ColosseumMinL15Text
	call PrintText
	ld a,$b
	ret

CombinedLevelsAbove50:: ; f5680 (3d:5680)
	ld hl,ColosseumTotalL50Text
	call PrintText
	ld a,$c
	ret

asm_f5689:: ; f5689 (3d:5689)
	pop af
	pop bc
	pop hl
	ld [wd11e],a
	call GetMonName
	ld hl,ColosseumHeightText
	call PrintText
	ld a,$d
	ret

asm_f569b:: ; f569b (3d:569b)
	pop af
	pop bc
	pop hl
	ld [wd11e],a
	call GetMonName
	ld hl,ColosseumWeightText
	call PrintText
	ld a,$e
	ret

asm_f56ad:: ; f56ad (3d:56ad)
	ld a,[hl]
	ld [wd11e],a
	call GetMonName
	ld hl,ColosseumEvolvedText
	call PrintText
	ld a,$f
	ret

Func_f56bd:: ; f56bd (3d:56bd)
	xor a
	ld [H_AUTOBGTRANSFERENABLED],a
	coord hl, 1,11
	lb bc, 6, 18
	call ClearScreenArea
	ld a,[wCurrentMenuItem]
	cp $3
	jr nc,.asm_f56e6
	ld hl,PointerTable_f56ee
	ld a,[wCurrentMenuItem]
	ld c,a
	ld b,$0
	add hl,bc
	add hl,bc
	ld a,[hli]
	ld h,[hl]
	ld l,a
	ld d,h
	ld e,l
	coord hl, 1,12
	call PlaceString
.asm_f56e6
	call Delay3
	ld a,$1
	ld [H_AUTOBGTRANSFERENABLED],a
	ret

PointerTable_f56ee:: ; f56ee (3d:56ee)
	dw Text_f56f4
	dw Text_f5728
	dw Text_f575b

Text_f56f4:: ; f56f4 (3d:56f4)
	db "LVs of 3<pkmn>:50-55"
	next "Sum of LVs:155 MAX"
	next "MEW can't attend.@"

Text_f5728:: ; f5728 (3d:5728)
	db "LVs of 3<pkmn>:15-20"
	next "Sum of LVs:50 MAX"
	next "MEW can't attend.@"

Text_f575b:: ; f575b (3d:575b)
	db "3 Basic <pkmn>.LV25-30"
	next "Sum of LVs:80 MAX"
	next "6′8″ and 44lb MAX@"

Text_f5791:: ; f5791 (3d:5791)
	db "View"
	next "Rules@"

Text_f579c:: ; f579c (3d:579c)
	db "# Cup"
	next "Pika Cup"
	next "Petit Cup"
	next "CANCEL@"

Colosseum3MonsText:: ; f57bc (3d:57bc)
	TX_FAR _Colosseum3MonsText ; a0a2b
	db "@"

ColosseumMewText:: ; f57c1 (3d:57c1)
	TX_FAR _ColosseumMewText ; a0a46
	db "@"

ColosseumDifferentMonsText:: ; f57c6 (3d:57c6)
	TX_FAR _ColosseumDifferentMonsText ; a0a5f
	db "@"

ColosseumMaxL55Text:: ; f57cb (3d:57cb)
    TX_FAR _ColosseumMaxL55Text ; a0a81
    db "@"

ColosseumMinL50Text:: ; f57d0 (3d:57d0)
	TX_FAR _ColosseumMinL50Text ; a0a9a
	db "@"

ColosseumTotalL155Text:: ; f57d5 (3d:57d5)
	TX_FAR _ColosseumTotalL155Text ; a0aba
	db "@"

ColosseumMaxL30Text:: ; f57da (3d:57da)
	TX_FAR _ColosseumMaxL30Text ; a0ad9
	db "@"

ColosseumMinL25Text:: ; f57df (3d:57df)
	TX_FAR _ColosseumMinL25Text ; a0af2
	db "@"

ColosseumTotalL80Text:: ; f57e4 (3d:57e4)
	TX_FAR _ColosseumTotalL80Text ; a0b12
	db "@"

ColosseumMaxL20Text:: ; f57e9 (3d:57e9)
	TX_FAR _ColosseumMaxL20Text ; a0b30
	db "@"

ColosseumMinL15Text:: ; f57ee (3d:57ee)
	TX_FAR _ColosseumMinL15Text ; a0b49
	db "@"

ColosseumTotalL50Text:: ; f57f3 (3d:57f3)
	TX_FAR _ColosseumTotalL50Text ; a0b69
	db "@"

ColosseumHeightText:: ; f57f8 (3d:57f8)
	TX_FAR _ColosseumHeightText ; a0b87
	db "@"

ColosseumWeightText:: ; f57fd (3d:57fd)
	TX_FAR _ColosseumWeightText ; a0b9f
	db "@"

ColosseumEvolvedText:: ; f5802 (3d:5802)
	TX_FAR _ColosseumEvolvedText ; a0bbb
	db "@"

ColosseumIneligibleText:: ; f5807 (3d:5807)
	TX_FAR _ColosseumIneligibleText ; a0bd4
	db "@"

LinkMenu: ; f580c (3d:580c)
	xor a
	ld [wLetterPrintingDelayFlags], a
	ld hl, wd72e
	set 6, [hl]
	ld hl, TextTerminator_f5a16
	call PrintText
	call SaveScreenTilesToBuffer1
	ld hl, ColosseumWhereToText
	call PrintText
	coord hl, 5, 3
	lb bc, 8, 13
	call TextBoxBorder
	call UpdateSprites
	coord hl, 7, 5
	ld de, TradeCenterText
	call PlaceString
	xor a
	ld [wUnusedCD37], a
	ld [wd72d], a
	ld [wd11e], a
	ld hl, wTopMenuItemY
	ld a, $5
	ld [hli], a
	ld a, $6
	ld [hli], a
	xor a
	ld [hli], a
	inc hl
	ld a, $3
	ld [hli], a
	ld [hli], a
	xor a
	ld [hl], a
.waitForInputLoop
	call HandleMenuInput
	and A_BUTTON | B_BUTTON
	add a
	add a
	ld b, a
	ld a, [wCurrentMenuItem]
	cp $3
	jr nz,.asm_f586b
	bit 2,b
	jr z,.asm_f586b
	dec a
	ld b,$8
.asm_f586b
	add b
	add $d0
	ld [wLinkMenuSelectionSendBuffer], a
	ld [wLinkMenuSelectionSendBuffer + 1], a
.exchangeMenuSelectionLoop
	call Serial_ExchangeLinkMenuSelection
	ld a, [wLinkMenuSelectionReceiveBuffer]
	ld b, a
	and $f0
	cp $d0
	jr z, .asm_f5c7d
	ld a, [wLinkMenuSelectionReceiveBuffer + 1]
	ld b, a
	and $f0
	cp $d0
	jr nz, .exchangeMenuSelectionLoop
.asm_f5c7d
	ld a, b
	and $c ; did the enemy press A or B?
	jr nz, .enemyPressedAOrB
; the enemy didn't press A or B
	ld a, [wLinkMenuSelectionSendBuffer]
	and $c ; did the player press A or B?
	jr z, .waitForInputLoop ; if neither the player nor the enemy pressed A or B, try again
	jr .doneChoosingMenuSelection ; if the player pressed A or B but the enemy didn't, use the player's selection
.enemyPressedAOrB
	ld a, [wLinkMenuSelectionSendBuffer]
	and $c ; did the player press A or B?
	jr z, .useEnemyMenuSelection ; if the enemy pressed A or B but the player didn't, use the enemy's selection
; the enemy and the player both pressed A or B
; The gameboy that is clocking the connection wins.
	ld a, [hSerialConnectionStatus]
	cp USING_INTERNAL_CLOCK
	jr z, .doneChoosingMenuSelection
.useEnemyMenuSelection
	ld a, $1
	ld [wd11e], a
	ld a, b
	ld [wLinkMenuSelectionSendBuffer], a
	and $3
	ld [wCurrentMenuItem], a ; wCurrentMenuItem
.doneChoosingMenuSelection
	ld a, [hSerialConnectionStatus]
	cp USING_INTERNAL_CLOCK
	jr nz, .skipStartingTransfer
	call DelayFrame
	call DelayFrame
	ld a, START_TRANSFER_INTERNAL_CLOCK
	ld [rSC], a
.skipStartingTransfer
	ld b, " "
	ld c, " "
	ld d, " "
	ld e, "▷"
	ld a, [wLinkMenuSelectionSendBuffer]
	and (B_BUTTON << 2) ; was B button pressed?
	jr nz, .updateCursorPosition
; A button was pressed
	ld a, [wCurrentMenuItem]
	cp $2
	jp z, .asm_f5963
	ld b, e
	ld e, c
	ld a, [wCurrentMenuItem]
	and a
	jr z, .updateCursorPosition
	ld c, b
	ld b, d
	dec a
	jr z, .updateCursorPosition
	ld d, c
	ld c, b
.updateCursorPosition
	call Func_f59ec
	call LoadScreenTilesFromBuffer1
	ld a, [wLinkMenuSelectionSendBuffer]
	and (B_BUTTON << 2) ; was B button pressed?
	jr nz, .choseCancel ; cancel if B pressed
	ld a, [wCurrentMenuItem]
	cp $2
	jr z, .choseCancel
	xor a
	ld [wWalkBikeSurfState], a ; start walking
	ld a, [wCurrentMenuItem]
	and a
	ld a, COLOSSEUM
	jr nz, .next
	ld a, TRADE_CENTER
.next
	ld [wd72d], a
	ld hl, ColosseumPleaseWaitText
	call PrintText
	ld c, 50
	call DelayFrames
	ld hl, wd732
	res 1, [hl]
	ld a, [wDefaultMap]
	ld [wDestinationMap], a
	callab SpecialWarpIn
	ld c, 20
	call DelayFrames
	xor a
	ld [wMenuJoypadPollCount], a
	ld [wSerialExchangeNybbleSendData], a
	inc a ; LINK_STATE_IN_CABLE_CLUB
	ld [wLinkState], a
	ld [wEnteringCableClub], a
	jpab SpecialEnterMap
.choseCancel
	xor a
	ld [wMenuJoypadPollCount], a
	call Delay3
	callab CloseLinkConnection
	ld hl, ColosseumCanceledText
	call PrintText
	ld hl, wd72e
	res 6, [hl]
	ret

.asm_f5963
	ld a,[wd11e]
	and a
	jr nz,.asm_f5974
	ld b," "
	ld c," "
	ld d,"▷"
	ld e," "
	call Func_f59ec
.asm_f5974
	xor a
	ld [wBuffer], a
	ld a,$ff
	ld [wSerialExchangeNybbleReceiveData],a
	ld a, $b
	ld [wLinkMenuSelectionSendBuffer], a
	ld b,$78
.loop
	ld a,[hSerialConnectionStatus]
	cp $2
	call z,DelayFrame
	dec b
	jr z,.asm_f59b2
	call Serial_ExchangeNybble
	call DelayFrame
	ld a,[wSerialExchangeNybbleReceiveData]
	inc a
	jr z,.loop
	ld b,$f
.loop2
	call DelayFrame
	call Serial_ExchangeNybble
	dec b
	jr nz,.loop2
	ld b,$f
.loop3
	call DelayFrame
	call Serial_SendZeroByte
	dec b
	jr nz,.loop3
	jr .asm_f59d6

.asm_f59b2
	xor a
	ld [wUnknownSerialCounter],a
	ld [wUnknownSerialCounter+1],a
	ld a,[wd11e]
	and a
	jr z,.asm_f59cd
	ld b," "
	ld c," "
	ld d," "
	ld e,"▷"
	call Func_f59ec
	jp .choseCancel

.asm_f59cd
	ld hl,ColosseumVersionText
	call PrintText
	jp .choseCancel

.asm_f59d6
	ld b," "
	ld c," "
	ld d,"▷"
	ld e," "
	call Func_f59ec
	call Func_f531b
	jp c,.choseCancel
	ld a,$f0
	jp .next

Func_f59ec:: ; f59ec (3d:59ec)
	ld a, b
	Coorda 6, 5
	ld a, c
	Coorda 6, 7
	ld a, d
	Coorda 6, 9
	ld a, e
	Coorda 6, 11
	ld c, 40
	call DelayFrames
	ret

ColosseumWhereToText: ; f5a02 (3d:5a02)
	TX_FAR _ColosseumWhereToText
	db "@"

ColosseumPleaseWaitText: ; f5a07 (3d:5a07)
	TX_FAR _ColosseumPleaseWaitText
	db "@"

ColosseumCanceledText: ; f5a0c (3d:5a0c)
	TX_FAR _ColosseumCanceledText
	db "@"

ColosseumVersionText: ; f5a11 (3d:5a11)
	TX_FAR _ColosseumVersionText ; 28:4c47
	db "@"

TextTerminator_f5a16: ; f5a16 (3d:5a16)
	db "@"

TradeCenterText: ; f5a17 (3d:5a17)
	db "TRADE CENTER"
	next "COLOSSEUM"
	next "COLOSSEUM2"
	next "CANCEL@"