summaryrefslogtreecommitdiff
path: root/src/engine/menus/card_album.asm
blob: 797bc60da6b9d8c6c8a7f49bffd7d38cafe73d7d (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
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
; fills wFilteredCardList and wOwnedCardsCountList
; with cards IDs and counts, respectively,
; from given Card Set in register a
; a = CARD_SET_* constant
CreateCardSetList:
	push af
	ld a, DECK_SIZE
	ld hl, wFilteredCardList
	call ClearNBytesFromHL
	ld a, DECK_SIZE
	ld hl, wOwnedCardsCountList
	call ClearNBytesFromHL
	xor a
	ld [wOwnedPhantomCardFlags], a
	pop af

	ld hl, 0
	lb de, 0, 0
	ld b, a
.loop_all_cards
	inc e
	call LoadCardDataToBuffer1_FromCardID
	jr c, .done_pkmn_cards
	ld a, [wLoadedCard1Set]
	and $f0 ; set 1
	swap a
	cp b
	jr nz, .loop_all_cards

; it's same set as input
	ld a, e
	cp VENUSAUR1
	jp z, .SetVenusaur1OwnedFlag
	cp MEW2
	jp z, .SetMew2OwnedFlag

	push bc
	push hl
	ld bc, wFilteredCardList
	add hl, bc
	ld [hl], e ; card ID

	ld hl, wTempCardCollection
	add hl, de
	ld a, [hl]
	pop hl
	push hl
	ld bc, wOwnedCardsCountList
	add hl, bc
	ld [hl], a ; card count in collection
	pop hl

	inc l
	pop bc
	jr .loop_all_cards

.done_pkmn_cards
; for the energy cards, put all basic energy cards in Colosseum
; and Double Colorless energy in Mystery
	ld a, b
	cp CARD_SET_MYSTERY
	jr z, .mystery
	or a
	jr nz, .skip_energy_cards

; colosseum
; places all basic energy cards in wFilteredCardList
	lb de, 0, 0
.loop_basic_energy_cards
	inc e
	ld a, e
	cp DOUBLE_COLORLESS_ENERGY
	jr z, .skip_energy_cards
	push bc
	push hl
	ld bc, wFilteredCardList
	add hl, bc
	ld [hl], e
	ld hl, wTempCardCollection
	add hl, de
	ld a, [hl]
	pop hl
	push hl
	ld bc, wOwnedCardsCountList
	add hl, bc
	ld [hl], a
	pop hl
	inc l
	pop bc
	jr .loop_basic_energy_cards

.mystery
; places double colorless energy card in wFilteredCardList
	lb de, 0, 0
.loop_find_double_colorless
	inc e
	ld a, e
	cp BULBASAUR
	jr z, .skip_energy_cards
	cp DOUBLE_COLORLESS_ENERGY
	jr nz, .loop_find_double_colorless
	; double colorless energy
	push bc
	push hl
	ld bc, wFilteredCardList
	add hl, bc
	ld [hl], e
	ld hl, wTempCardCollection
	add hl, de
	ld a, [hl]
	pop hl
	push hl
	ld bc, wOwnedCardsCountList
	add hl, bc
	ld [hl], a
	pop hl
	inc l
	pop bc
	jr .loop_find_double_colorless

.skip_energy_cards
	ld a, [wOwnedPhantomCardFlags]
	bit VENUSAUR_OWNED_PHANTOM_F, a
	jr z, .check_mew
	call .PlaceVenusaur1InList
.check_mew
	bit MEW_OWNED_PHANTOM_F, a
	jr z, .find_first_owned
	call .PlaceMew2InList

.find_first_owned
	dec l
	ld c, l
	ld b, h
.loop_owned_cards
	ld hl, wOwnedCardsCountList
	add hl, bc
	ld a, [hl]
	cp CARD_NOT_OWNED
	jr nz, .found_owned
	dec c
	jr .loop_owned_cards

.found_owned
	inc c
	ld a, c
	ld [wNumEntriesInCurFilter], a
	xor a
	ld hl, wFilteredCardList
	add hl, bc
	ld [hl], a
	ld a, $ff ; terminator byte
	ld hl, wOwnedCardsCountList
	add hl, bc
	ld [hl], a
	ret

.SetMew2OwnedFlag
	ld a, (1 << MEW_OWNED_PHANTOM_F)
;	fallthrough

.SetPhantomOwnedFlag
	push hl
	push bc
	ld b, a
	ld hl, wTempCardCollection
	add hl, de
	ld a, [hl]
	cp CARD_NOT_OWNED
	jr z, .skip_set_flag
	ld a, [wOwnedPhantomCardFlags]
	or b
	ld [wOwnedPhantomCardFlags], a
.skip_set_flag
	pop bc
	pop hl
	jp .loop_all_cards

.SetVenusaur1OwnedFlag
	ld a, (1 << VENUSAUR_OWNED_PHANTOM_F)
	jr .SetPhantomOwnedFlag

.PlaceVenusaur1InList
	push af
	push hl
	ld e, VENUSAUR1
;	fallthrough

; places card in register e directly in the list
.PlaceCardInList
	ld bc, wFilteredCardList
	add hl, bc
	ld [hl], e
	pop hl
	push hl
	ld bc, wOwnedCardsCountList
	add hl, bc
	ld [hl], $01
	pop hl
	inc l
	pop af
	ret

.PlaceMew2InList
	push af
	push hl
	ld e, MEW2
	jr .PlaceCardInList

; a = CARD_SET_* constant
CreateCardSetListAndInitListCoords:
	push af
	ld hl, sCardCollection
	ld de, wTempCardCollection
	ld b, CARD_COLLECTION_SIZE - 1
	call EnableSRAM
	call CopyNBytesFromHLToDE
	call DisableSRAM
	pop af

	push af
	call .GetEntryPrefix
	call CreateCardSetList
	ld a, NUM_CARD_ALBUM_VISIBLE_CARDS
	ld [wNumVisibleCardListEntries], a
	lb de, 2, 4
	ld hl, wCardListCoords
	ld [hl], e
	inc hl
	ld [hl], d
	pop af
	ret

; places in entry name the prefix associated with the selected Card Set
; a = CARD_SET_* constant
.GetEntryPrefix
	push af
	cp CARD_SET_PROMOTIONAL
	jr nz, .laboratory
	lb de, 3, "FW3_P"
	jr .got_prefix
.laboratory
	cp CARD_SET_LABORATORY
	jr nz, .mystery
	lb de, 3, "FW3_D"
	jr .got_prefix
.mystery
	cp CARD_SET_MYSTERY
	jr nz, .evolution
	lb de, 3, "FW3_C"
	jr .got_prefix
.evolution
	cp CARD_SET_EVOLUTION
	jr nz, .colosseum
	lb de, 3, "FW3_B"
	jr .got_prefix
.colosseum
	lb de, 3, "FW3_A"

.got_prefix
	ld hl, wCurDeckName
	ld [hl], d
	inc hl
	ld [hl], e
	pop af
	ret

; prints the cards being shown in the Card Album screen
; for the corresponding Card Set
PrintCardSetListEntries:
	push bc
	ld hl, wCardListCoords
	ld e, [hl]
	inc hl
	ld d, [hl]
	ld b, $13
	ld c, e
	dec c
	dec c

; draw up cursor on top right
	ld a, [wCardListVisibleOffset]
	or a
	jr z, .no_up_cursor
	ld a, SYM_CURSOR_U
	jr .got_up_cursor_tile
.no_up_cursor
	ld a, SYM_BOX_TOP_R
.got_up_cursor_tile
	call WriteByteToBGMap0

	ld a, [wCardListVisibleOffset]
	ld l, a
	ld h, $00
	ld a, [wNumVisibleCardListEntries]
.loop_visible_cards
	push de
	or a
	jr z, .handle_down_cursor
	ld b, a
	ld de, wFilteredCardList
	push hl
	add hl, de
	ld a, [hl]
	pop hl
	inc l
	or a
	jr z, .no_down_cursor
	ld e, a
	call AddCardIDToVisibleList
	call LoadCardDataToBuffer1_FromCardID
	push bc
	push hl
	ld de, wOwnedCardsCountList
	add hl, de
	dec hl
	ld a, [hl]
	cp CARD_NOT_OWNED
	jr nz, .owned
	ld hl, .EmptySlotText
	ld de, wDefaultText
	call CopyListFromHLToDE
	jr .print_text
.owned
	ld a, 13
	call CopyCardNameAndLevel
.print_text
	pop hl
	pop bc
	pop de
	push hl
	call InitTextPrinting
	pop hl
	push hl
	call .AppendCardListIndex
	call ProcessText
	ld hl, wDefaultText
	jr .asm_a76d

	; this code is never reached
	pop de
	push hl
	call InitTextPrinting
	ld hl, Text_9a36

.asm_a76d
	call ProcessText
	pop hl
	ld a, b
	dec a
	inc e
	inc e
	jr .loop_visible_cards

.handle_down_cursor
	ld de, wFilteredCardList
	add hl, de
	ld a, [hl]
	or a
	jr z, .no_down_cursor
	pop de
	xor a ; FALSE
	ld [wUnableToScrollDown], a
	ld a, SYM_CURSOR_D
	jr .got_down_cursor_tile
.no_down_cursor
	pop de
	ld a, TRUE
	ld [wUnableToScrollDown], a
	ld a, SYM_BOX_BTM_R
.got_down_cursor_tile
	ld b, 19
	ld c, 17
	call WriteByteToBGMap0
	pop bc
	ret

.EmptySlotText
	textfw0 "-------------"
	done

; gets the index in the card list and adds it to wCurDeckName
.AppendCardListIndex
	push bc
	push de
	ld de, wFilteredCardList
	add hl, de
	dec hl
	ld a, [hl]
	cp DOUBLE_COLORLESS_ENERGY + 1
	jr c, .energy_card
	cp VENUSAUR1
	jr z, .phantom_card
	cp MEW2
	jr z, .phantom_card

	ld a, [wNumVisibleCardListEntries]
	sub b
	ld hl, wCardListVisibleOffset
	add [hl]
	inc a
	call CalculateOnesAndTensDigits
	ld hl, wOnesAndTensPlace
	ld a, [hli]
	ld b, a
	ld a, [hl]
	or a
	jr nz, .got_index
	ld a, SYM_0
.got_index
	ld hl, wCurDeckName + 2 ; skip prefix
	ld [hl], TX_SYMBOL
	inc hl
	ld [hli], a ; tens place
	ld [hl], TX_SYMBOL
	inc hl
	ld a, b
	ld [hli], a ; ones place
	ld [hl], TX_SYMBOL
	inc hl
	xor a ; SYM_SPACE
	ld [hli], a
	ld [hl], a
	ld hl, wCurDeckName
	pop de
	pop bc
	ret

.energy_card
	call CalculateOnesAndTensDigits
	ld hl, wOnesAndTensPlace
	ld a, [hli]
	ld b, a
	ld hl, wCurDeckName + 2
	lb de, 3, "FW3_E"
	ld [hl], d
	inc hl
	ld [hl], e
	inc hl
	ld [hl], TX_SYMBOL
	inc hl
	ld a, SYM_0
	ld [hli], a
	ld [hl], TX_SYMBOL
	inc hl
	ld a, b
	ld [hli], a
	ld [hl], TX_SYMBOL
	inc hl
	xor a ; SYM_SPACE
	ld [hli], a
	ld [hl], a
	ld hl, wCurDeckName + 2
	pop de
	pop bc
	ret

.phantom_card
; phantom cards get only "××" in their index number
	ld hl, wCurDeckName + 2
	ld [hl], "FW0_×"
	inc hl
	ld [hl], "FW0_×"
	inc hl
	ld [hl], TX_SYMBOL
	inc hl
	xor a ; SYM_SPACE
	ld [hli], a
	ld [hl], a
	ld hl, wCurDeckName
	pop de
	pop bc
	ret

; handles opening card page, and inputs when inside Card Album
HandleCardAlbumCardPage:
	ld a, [wCardListCursorPos]
	ld b, a
	ld a, [wCardListVisibleOffset]
	add b
	ld c, a
	ld b, $00
	ld hl, wOwnedCardsCountList
	add hl, bc
	ld a, [hl]
	cp CARD_NOT_OWNED
	jr z, .handle_input

	ld hl, wCurCardListPtr
	ld a, [hli]
	ld h, [hl]
	ld l, a
	add hl, bc
	ld e, [hl]
	ld d, $00
	push de
	call LoadCardDataToBuffer1_FromCardID
	lb de, $38, $9f
	call SetupText
	bank1call OpenCardPage_FromCheckHandOrDiscardPile
	pop de

.handle_input
	ldh a, [hDPadHeld]
	ld b, a
	and A_BUTTON | B_BUTTON | SELECT | START
	jp nz, .exit
	xor a ; FALSE
	ld [wPlaysSfx], a
	ld a, [wCardListNumCursorPositions]
	ld c, a
	ld a, [wCardListCursorPos]
	bit D_UP_F, b
	jr z, .check_d_down

	push af
	ld a, TRUE
	ld [wPlaysSfx], a
	ld a, [wCardListCursorPos]
	ld hl, wCardListVisibleOffset
	add [hl]
	ld hl, wFirstOwnedCardIndex
	cp [hl]
	jr z, .open_card_page_pop_af_2
	pop af

	dec a
	bit 7, a
	jr z, .got_new_pos
	ld a, [wCardListVisibleOffset]
	or a
	jr z, .open_card_page
	dec a
	ld [wCardListVisibleOffset], a
	xor a
	jr .got_new_pos

.check_d_down
	bit D_DOWN_F, b
	jr z, .asm_a8d6

	push af
	ld a, TRUE
	ld [wPlaysSfx], a
	pop af

	inc a
	cp c
	jr c, .got_new_pos
	push af
	ld hl, wCurCardListPtr
	ld a, [hli]
	ld h, [hl]
	ld l, a
	ld a, [wCardListCursorPos]
	ld c, a
	ld b, $00
	add hl, bc
	ld a, [wCardListVisibleOffset]
	inc a
	ld c, a
	ld b, $00
	add hl, bc
	ld a, [hl]
	or a
	jr z, .open_card_page_pop_af_1
	ld a, [wCardListVisibleOffset]
	inc a
	ld [wCardListVisibleOffset], a
	pop af
	dec a
.got_new_pos
	; loop back to the start
	ld [wCardListCursorPos], a
	ld a, [wPlaysSfx]
	or a
	jp z, HandleCardAlbumCardPage
	call PlaySFX
	jp HandleCardAlbumCardPage
.open_card_page_pop_af_1
	pop af
	jr .open_card_page

.asm_a8d6
	ld a, [wced2]
	or a
	jr z, .open_card_page
	bit D_LEFT_F, b
	jr z, .check_d_right
	call RemoveCardFromDeck
	jr .open_card_page
.check_d_right
	bit D_RIGHT_F, b
	jr z, .open_card_page
	call TryAddCardToDeck

.open_card_page_pop_af_2
	pop af
.open_card_page
	push de
	bank1call OpenCardPage.input_loop
	pop de
	jp .handle_input

.exit
	ld a, $01
	ld [wVBlankOAMCopyToggle], a
	ld a, [wCardListCursorPos]
	ld [wTempCardListCursorPos], a
	ret

GetFirstOwnedCardIndex:
	ld hl, wOwnedCardsCountList
	ld b, 0
.loop_cards
	ld a, [hli]
	cp CARD_NOT_OWNED
	jr nz, .owned
	inc b
	jr .loop_cards
.owned
	ld a, b
	ld [wFirstOwnedCardIndex], a
	ret

HandleCardAlbumScreen:
	ld a, $01
	ld [hffb4], a ; should be ldh

	xor a
.album_card_list
	ld hl, .MenuParameters
	call InitializeMenuParameters
	call .DrawCardAlbumScreen
.loop_input_1
	call DoFrame
	call HandleMenuInput
	jp nc, .loop_input_1 ; can be jr
	ldh a, [hCurMenuItem]
	cp $ff
	ret z

	; ignore input if this Card Set is unavailable
	ld c, a
	ld b, $0
	ld hl, wUnavailableAlbumCardSets
	add hl, bc
	ld a, [hl]
	or a
	jr nz, .loop_input_1

	ld a, c
	ld [wSelectedCardSet], a
	call CreateCardSetListAndInitListCoords
	call .PrintCardCount
	xor a
	ld [wCardListVisibleOffset], a
	call PrintCardSetListEntries
	call EnableLCD
	ld a, [wNumEntriesInCurFilter]
	or a
	jr nz, .asm_a968

.loop_input_2
	call DoFrame
	ldh a, [hKeysPressed]
	and B_BUTTON
	jr z, .loop_input_2
	ld a, $ff
	call PlaySFXConfirmOrCancel
	ldh a, [hCurMenuItem]
	jp .album_card_list

.asm_a968
	call .GetNumCardEntries
	xor a
	ld hl, .CardSelectionParams
	call InitCardSelectionParams
	ld a, [wNumEntriesInCurFilter]
	ld hl, wNumVisibleCardListEntries
	cp [hl]
	jr nc, .asm_a97e
	ld [wCardListNumCursorPositions], a
.asm_a97e
	ld hl, PrintCardSetListEntries
	ld d, h
	ld a, l
	ld hl, wCardListUpdateFunction
	ld [hli], a
	ld [hl], d

	xor a
	ld [wced2], a
.loop_input_3
	call DoFrame
	call HandleDeckCardSelectionList
	jr c, .selection_made
	call HandleLeftRightInCardList
	jr c, .loop_input_3
	ldh a, [hDPadHeld]
	and START
	jr z, .loop_input_3
.open_card_page
	ld a, $01
	call PlaySFXConfirmOrCancel
	ld a, [wCardListNumCursorPositions]
	ld [wTempCardListNumCursorPositions], a
	ld a, [wCardListCursorPos]
	ld [wTempCardListCursorPos], a
	ld c, a
	ld a, [wCardListVisibleOffset]
	add c
	ld hl, wOwnedCardsCountList
	ld c, a
	ld b, $00
	add hl, bc
	ld a, [hl]
	cp CARD_NOT_OWNED
	jr z, .loop_input_3

	; set wFilteredCardList as current card list
	ld de, wFilteredCardList
	ld hl, wCurCardListPtr
	ld [hl], e
	inc hl
	ld [hl], d

	call GetFirstOwnedCardIndex
	call HandleCardAlbumCardPage
	call .PrintCardCount
	call PrintCardSetListEntries
	call EnableLCD
	ld hl, .CardSelectionParams
	call InitCardSelectionParams
	ld a, [wTempCardListNumCursorPositions]
	ld [wCardListNumCursorPositions], a
	ld a, [wTempCardListCursorPos]
	ld [wCardListCursorPos], a
	jr .loop_input_3

.selection_made
	call DrawListCursor_Invisible
	ld a, [wCardListCursorPos]
	ld [wTempCardListCursorPos], a
	ld a, [hffb3]
	cp $ff
	jr nz, .open_card_page
	ldh a, [hCurMenuItem]
	jp .album_card_list

.MenuParameters
	db 3, 3 ; cursor x, cursor y
	db 2 ; y displacement between items
	db 5 ; number of items
	db SYM_CURSOR_R ; cursor tile number
	db SYM_SPACE ; tile behind cursor
	dw NULL ; function pointer if non-0

.CardSelectionParams
	db 1 ; x pos
	db 4 ; y pos
	db 2 ; y spacing
	db 0 ; x spacing
	db NUM_CARD_ALBUM_VISIBLE_CARDS ; num entries
	db SYM_CURSOR_R ; visible cursor tile
	db SYM_SPACE ; invisible cursor tile
	dw NULL ; wCardListHandlerFunction

.GetNumCardEntries
	ld hl, wFilteredCardList
	ld b, $00
.loop_card_ids
	ld a, [hli]
	or a
	jr z, .asm_aa1f
	inc b
	jr .loop_card_ids
.asm_aa1f
	ld a, b
	ld [wNumCardListEntries], a
	ret

; prints "X/Y" where X is number of cards owned in the set
; and Y is the total card count of the Card Set
.PrintCardCount
	call Set_OBJ_8x8
	xor a
	ld [wTileMapFill], a
	call ZeroObjectPositions
	call EmptyScreen
	ld a, $01
	ld [wVBlankOAMCopyToggle], a
	call LoadCursorTile
	call LoadSymbolsFont
	call LoadDuelCardSymbolTiles
	bank1call SetDefaultConsolePalettes
	lb de, $3c, $ff
	call SetupText
	lb de, 1, 1
	call InitTextPrinting

; print the total number of cards that are in the Card Set
	ld a, [wSelectedCardSet]
	cp CARD_SET_PROMOTIONAL
	jr nz, .check_laboratory
; promotional
	ldtx hl, Item5PromotionalCardText
	ld e, NUM_CARDS_PROMOTIONAL - 2 ; minus the phantom cards
	ld a, [wOwnedPhantomCardFlags]
	bit VENUSAUR_OWNED_PHANTOM_F, a
	jr z, .check_owns_mew
	inc e
.check_owns_mew
	bit MEW_OWNED_PHANTOM_F, a
	jr z, .has_card_set_count
	inc e
	jr .has_card_set_count
.check_laboratory
	cp CARD_SET_LABORATORY
	jr nz, .check_mystery
	ldtx hl, Item4LaboratoryText
	ld e, NUM_CARDS_LABORATORY
	jr .has_card_set_count
.check_mystery
	cp CARD_SET_MYSTERY
	jr nz, .check_evolution
	ldtx hl, Item3MysteryText
	ld e, NUM_CARDS_MYSTERY
	jr .has_card_set_count
.check_evolution
	cp CARD_SET_EVOLUTION
	jr nz, .colosseum
	ldtx hl, Item2EvolutionText
	ld e, NUM_CARDS_EVOLUTION
	jr .has_card_set_count
.colosseum
	ldtx hl, Item1ColosseumText
	ld e, NUM_CARDS_COLOSSEUM

.has_card_set_count
	push de
	call ProcessTextFromID
	call .CountOwnedCardsInSet
	lb de, 14, 1
	call InitTextPrinting

	ld a, [wNumOwnedCardsInSet]
	ld hl, wDefaultText
	call ConvertToNumericalDigits
	call CalculateOnesAndTensDigits
	ld [hl], TX_SYMBOL
	inc hl
	ld [hl], SYM_SLASH
	inc hl
	pop de

	ld a, e
	call ConvertToNumericalDigits
	ld [hl], TX_END
	ld hl, wDefaultText
	call ProcessText
	lb de, 0, 2
	lb bc, 20, 16
	call DrawRegularTextBox
	call EnableLCD
	ret

; counts number of cards in wOwnedCardsCountList
; that is not set as CARD_NOT_OWNED
.CountOwnedCardsInSet
	ld hl, wOwnedCardsCountList
	ld b, 0
.loop_card_count
	ld a, [hli]
	cp $ff
	jr z, .got_num_owned_cards
	cp CARD_NOT_OWNED
	jr z, .loop_card_count
	inc b
	jr .loop_card_count
.got_num_owned_cards
	ld a, b
	ld [wNumOwnedCardsInSet], a
	ret

.DrawCardAlbumScreen
	xor a
	ld [wTileMapFill], a
	call EmptyScreen
	ld a, [hffb4]
	dec a
	jr nz, .skip_clear_screen
	ld [hffb4], a
	call Set_OBJ_8x8
	call ZeroObjectPositions
	ld a, $01
	ld [wVBlankOAMCopyToggle], a
	call LoadCursorTile
	call LoadSymbolsFont
	call LoadDuelCardSymbolTiles
	bank1call SetDefaultConsolePalettes
	lb de, $3c, $ff
	call SetupText

.skip_clear_screen
	lb de, 0, 0
	lb bc, 20, 13
	call DrawRegularTextBox
	ld hl, .BoosterPacksMenuData
	call PlaceTextItems

	; set all Card Sets as available
	ld a, NUM_CARD_SETS
	ld hl, wUnavailableAlbumCardSets
	call ClearNBytesFromHL

	; check whether player has had promotional cards
	call EnableSRAM
	ld a, [sHasPromotionalCards]
	call DisableSRAM
	or a
	jr nz, .has_promotional

	; doesn't have promotional, check if
	; this is still the case by checking the collection
	ld a, CARD_SET_PROMOTIONAL
	call CreateCardSetListAndInitListCoords
	ld a, [wFilteredCardList]
	or a
	jr nz, .set_has_promotional
	; still has no promotional, print empty Card Set name
	ld a, TRUE
	ld [wUnavailableAlbumCardSets + CARD_SET_PROMOTIONAL], a
	ld e, 11
	ld d, 5
	call InitTextPrinting
	ldtx hl, EmptyPromotionalCardText
	call ProcessTextFromID
	jr .has_promotional

.set_has_promotional
	call EnableSRAM
	ld a, TRUE
	ld [sHasPromotionalCards], a
	call DisableSRAM
.has_promotional
	ldtx hl, ViewWhichCardFileText
	call DrawWideTextBox_PrintText
	call EnableLCD
	ret

.BoosterPacksMenuData
	textitem 7,  1, BoosterPackTitleText
	textitem 5,  3, Item1ColosseumText
	textitem 5,  5, Item2EvolutionText
	textitem 5,  7, Item3MysteryText
	textitem 5,  9, Item4LaboratoryText
	textitem 5, 11, Item5PromotionalCardText
	db $ff