summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
Diffstat (limited to 'src')
-rw-r--r--src/constants.asm1
-rw-r--r--src/constants/card_data_constants.asm33
-rw-r--r--src/constants/duel_constants.asm12
-rw-r--r--src/constants/menu_constants.asm48
-rw-r--r--src/data/auto_deck_card_lists.asm1159
-rw-r--r--src/data/auto_deck_machines.asm82
-rw-r--r--src/engine/bank01.asm19
-rw-r--r--src/engine/bank02.asm6426
-rw-r--r--src/engine/bank03.asm14
-rw-r--r--src/engine/bank06.asm245
-rw-r--r--src/engine/bank1c.asm4
-rw-r--r--src/engine/effect_functions.asm4
-rw-r--r--src/engine/home.asm27
-rw-r--r--src/hram.asm1
-rw-r--r--src/macros/wram.asm5
-rw-r--r--src/sram.asm139
-rw-r--r--src/text/text2.asm50
-rw-r--r--src/text/text3.asm226
-rw-r--r--src/text/text_offsets.asm276
-rw-r--r--src/wram.asm288
20 files changed, 7372 insertions, 1687 deletions
diff --git a/src/constants.asm b/src/constants.asm
index 96361c9..1a04af4 100644
--- a/src/constants.asm
+++ b/src/constants.asm
@@ -8,6 +8,7 @@ INCLUDE "constants/duel_interface_constants.asm"
INCLUDE "constants/gfx_constants.asm"
INCLUDE "constants/hardware_constants.asm"
INCLUDE "constants/map_constants.asm"
+INCLUDE "constants/menu_constants.asm"
INCLUDE "constants/misc_constants.asm"
INCLUDE "constants/music_constants.asm"
INCLUDE "constants/name_constants.asm"
diff --git a/src/constants/card_data_constants.asm b/src/constants/card_data_constants.asm
index 3b775b0..2fc0bfc 100644
--- a/src/constants/card_data_constants.asm
+++ b/src/constants/card_data_constants.asm
@@ -8,9 +8,14 @@ CARD_NOT_OWNED EQU 1 << CARD_NOT_OWNED_F
CARD_COUNT_MASK EQU $7f
; sDeck* and generic deck constants
-NUM_DECKS EQU 4
-DECK_NAME_SIZE EQU 24
-DECK_SIZE EQU 60
+NUM_DECKS EQU 4
+DECK_NAME_SIZE EQU 24
+DECK_NAME_SIZE_WO_SUFFIX EQU 21 ; name part before "deck"
+DECK_SIZE EQU 60
+DECK_STRUCT_SIZE EQU DECK_NAME_SIZE + DECK_SIZE
+DECK_CONFIG_BUFFER_SIZE EQU 80
+MAX_NUM_SAME_NAME_CARDS EQU 4
+MAX_UNNAMED_DECK_NUM EQU 999
; card data offsets (data/cards.asm and card_data_struct)
@@ -128,13 +133,23 @@ DIAMOND EQU $1
STAR EQU $2
PROMOSTAR EQU $ff
+; card set constants (set 1)
+ const_def
+ const CARD_SET_COLOSSEUM ; $0
+ const CARD_SET_EVOLUTION ; $1
+ const CARD_SET_MYSTERY ; $2
+ const CARD_SET_LABORATORY ; $3
+ const CARD_SET_PROMOTIONAL ; $4
+ const CARD_SET_ENERGY ; $5
+NUM_CARD_SETS EQU const_value - 1
+
; CARD_DATA_SET constants (set 1)
-COLOSSEUM EQU $0 << 4
-EVOLUTION EQU $1 << 4
-MYSTERY EQU $2 << 4
-LABORATORY EQU $3 << 4
-PROMOTIONAL EQU $4 << 4
-ENERGY EQU $5 << 4
+COLOSSEUM EQU CARD_SET_COLOSSEUM << 4
+EVOLUTION EQU CARD_SET_EVOLUTION << 4
+MYSTERY EQU CARD_SET_MYSTERY << 4
+LABORATORY EQU CARD_SET_LABORATORY << 4
+PROMOTIONAL EQU CARD_SET_PROMOTIONAL << 4
+ENERGY EQU CARD_SET_ENERGY << 4
; CARD_DATA_SET constants (set 2)
JUNGLE EQU $1
diff --git a/src/constants/duel_constants.asm b/src/constants/duel_constants.asm
index fe21753..89377dc 100644
--- a/src/constants/duel_constants.asm
+++ b/src/constants/duel_constants.asm
@@ -257,12 +257,12 @@ EFFECT_FAILED_UNSUCCESSFUL EQU $02
; wAnimationQueue length
ANIMATION_QUEUE_LENGTH EQU 7
-PRIZES_1 EQU $01
-PRIZES_2 EQU $02
-PRIZES_3 EQU $03
-PRIZES_4 EQU $04
-PRIZES_5 EQU $05
-PRIZES_6 EQU $06
+PRIZES_1 EQU $01
+PRIZES_2 EQU $02
+PRIZES_3 EQU $03
+PRIZES_4 EQU $04
+PRIZES_5 EQU $05
+PRIZES_6 EQU $06
; constants to use as input to LookForCardInDeck
SEARCHEFFECT_CARD_ID EQU $0
diff --git a/src/constants/menu_constants.asm b/src/constants/menu_constants.asm
new file mode 100644
index 0000000..86df8bf
--- /dev/null
+++ b/src/constants/menu_constants.asm
@@ -0,0 +1,48 @@
+; filter types for CardTypeFilters
+; used to categorise the different cards
+; i.e. in the deck building screen
+FILTER_FIRE EQUS "TYPE_PKMN_FIRE"
+FILTER_GRASS EQUS "TYPE_PKMN_GRASS"
+FILTER_LIGHTNING EQUS "TYPE_PKMN_LIGHTNING"
+FILTER_WATER EQUS "TYPE_PKMN_WATER"
+FILTER_FIGHTING EQUS "TYPE_PKMN_FIGHTING"
+FILTER_PSYCHIC EQUS "TYPE_PKMN_PSYCHIC"
+FILTER_COLORLESS EQUS "TYPE_PKMN_COLORLESS"
+FILTER_TRAINER EQUS "TYPE_TRAINER"
+FILTER_ENERGY EQU $20
+
+NUM_FILTERS EQU 9
+
+NUM_DECK_CONFIRMATION_VISIBLE_CARDS EQU 7
+NUM_CARD_ALBUM_VISIBLE_CARDS EQU 7
+NUM_FILTERED_LIST_VISIBLE_CARDS EQU 6
+NUM_DECK_MACHINE_VISIBLE_DECKS EQU 5
+
+; deck flags
+ const_def
+ const DECK_1_F ; $0
+ const DECK_2_F ; $1
+ const DECK_3_F ; $2
+ const DECK_4_F ; $3
+
+DECK_1 EQU 1 << DECK_1_F ; $1
+DECK_2 EQU 1 << DECK_2_F ; $2
+DECK_3 EQU 1 << DECK_3_F ; $4
+DECK_4 EQU 1 << DECK_4_F ; $8
+
+ALL_DECKS EQU $ff
+
+NUM_DECK_SAVE_MACHINE_SLOTS EQU 60
+NUM_DECK_MACHINE_SLOTS EQU 5
+
+; TODO find a way to not have these hardcoded?
+NUM_CARDS_COLOSSEUM EQU 56
+NUM_CARDS_EVOLUTION EQU 50
+NUM_CARDS_MYSTERY EQU 51
+NUM_CARDS_LABORATORY EQU 51
+NUM_CARDS_PROMOTIONAL EQU 20
+
+; wOwnedPhantomCardFlags flags
+ const_def
+ const VENUSAUR_OWNED_PHANTOM_F ; $0
+ const MEW_OWNED_PHANTOM_F ; $1
diff --git a/src/data/auto_deck_card_lists.asm b/src/data/auto_deck_card_lists.asm
new file mode 100644
index 0000000..8dbf6e5
--- /dev/null
+++ b/src/data/auto_deck_card_lists.asm
@@ -0,0 +1,1159 @@
+; card lists read by AutoDeckMachineEntries
+; each list entry is a card count and card ID pair
+
+AllFightingPokemonCardList: ; 1b0da (6:70da)
+ db 26, FIGHTING_ENERGY
+ db 2, SANDSHREW
+ db 1, SANDSLASH
+ db 2, DIGLETT
+ db 1, DUGTRIO
+ db 2, MANKEY
+ db 1, PRIMEAPE
+ db 3, MACHOP
+ db 2, MACHOKE
+ db 1, MACHAMP
+ db 2, GEODUDE
+ db 1, GRAVELER
+ db 1, GOLEM
+ db 1, ONIX
+ db 2, CUBONE
+ db 1, MAROWAK1
+ db 1, HITMONLEE
+ db 1, HITMONCHAN
+ db 2, RHYHORN
+ db 1, RHYDON
+ db 1, PROFESSOR_OAK
+ db 2, BILL
+ db 1, SWITCH
+ db 2, POTION
+ db 0 ; end of list
+
+BenchAttackCardList: ; 1b10b (6:710b)
+ db 12, LIGHTNING_ENERGY
+ db 14, FIGHTING_ENERGY
+ db 4, VOLTORB
+ db 2, ELECTRODE2
+ db 2, ZAPDOS1
+ db 4, HITMONLEE
+ db 2, HITMONCHAN
+ db 4, MEOWTH1
+ db 1, PROFESSOR_OAK
+ db 2, BILL
+ db 1, MR_FUJI
+ db 2, ENERGY_RETRIEVAL
+ db 2, SWITCH
+ db 1, SCOOP_UP
+ db 2, PLUSPOWER
+ db 2, DEFENDER
+ db 1, ITEM_FINDER
+ db 1, GUST_OF_WIND
+ db 1, MAINTENANCE
+ db 0 ; end of list
+
+BattleContestCardList: ; 1b132 (6:7132)
+ db 24, FIGHTING_ENERGY
+ db 2, DOUBLE_COLORLESS_ENERGY
+ db 3, MANKEY
+ db 4, MACHOP
+ db 3, MACHOKE
+ db 2, HITMONLEE
+ db 2, HITMONCHAN
+ db 3, MEOWTH1
+ db 2, PERSIAN
+ db 3, DRATINI
+ db 2, DRAGONAIR
+ db 1, DRAGONITE2
+ db 1, PROFESSOR_OAK
+ db 3, PLUSPOWER
+ db 3, DEFENDER
+ db 2, POTION
+ db 0 ; end of list
+
+HeatedBattleCardList: ; 1b153 (6:7153)
+ db 8, FIRE_ENERGY
+ db 4, LIGHTNING_ENERGY
+ db 15, FIGHTING_ENERGY
+ db 4, MAGMAR1
+ db 2, ELECTABUZZ2
+ db 3, MANKEY
+ db 2, PRIMEAPE
+ db 3, HITMONLEE
+ db 3, HITMONCHAN
+ db 2, KANGASKHAN
+ db 2, ENERGY_SEARCH
+ db 2, SCOOP_UP
+ db 3, PLUSPOWER
+ db 2, DEFENDER
+ db 3, POTION
+ db 2, FULL_HEAL
+ db 0 ; end of list
+
+FirstStrikeCardList: ; 1b174 (6:7174)
+ db 25, FIGHTING_ENERGY
+ db 4, MACHOP
+ db 3, MACHOKE
+ db 2, MACHAMP
+ db 2, HITMONCHAN
+ db 4, HITMONLEE
+ db 4, MANKEY
+ db 1, PRIMEAPE
+ db 2, POTION
+ db 2, DEFENDER
+ db 2, PLUSPOWER
+ db 2, SWITCH
+ db 3, GUST_OF_WIND
+ db 4, BILL
+ db 0 ; end of list
+
+SqueakingMouseCardList: ; 1b191 (6:7191)
+ db 8, LIGHTNING_ENERGY
+ db 15, FIGHTING_ENERGY
+ db 2, DOUBLE_COLORLESS_ENERGY
+ db 2, PIKACHU1
+ db 2, PIKACHU2
+ db 1, RAICHU1
+ db 1, RAICHU2
+ db 4, SANDSHREW
+ db 3, SANDSLASH
+ db 4, RATTATA
+ db 3, RATICATE
+ db 1, PROFESSOR_OAK
+ db 2, BILL
+ db 1, POKEMON_TRADER
+ db 2, ENERGY_RETRIEVAL
+ db 1, COMPUTER_SEARCH
+ db 3, PLUSPOWER
+ db 2, DEFENDER
+ db 2, POTION
+ db 1, SUPER_POTION
+ db 0 ; end of list
+
+GreatQuakeCardList: ; 1b1ba (6:71ba)
+ db 25, FIGHTING_ENERGY
+ db 4, DIGLETT
+ db 3, DUGTRIO
+ db 4, ONIX
+ db 3, RHYHORN
+ db 2, RHYDON
+ db 2, KANGASKHAN
+ db 1, TAUROS
+ db 1, SNORLAX
+ db 1, PROFESSOR_OAK
+ db 2, BILL
+ db 2, POKEMON_TRADER
+ db 3, SWITCH
+ db 4, DEFENDER
+ db 3, POTION
+ db 0 ; end of list
+
+BoneAttackCardList: ; 1b1d9 (6:71d9)
+ db 24, FIGHTING_ENERGY
+ db 3, SANDSHREW
+ db 2, SANDSLASH
+ db 3, GEODUDE
+ db 2, GRAVELER
+ db 1, GOLEM
+ db 4, ONIX
+ db 4, CUBONE
+ db 1, MAROWAK1
+ db 2, MAROWAK2
+ db 2, RHYHORN
+ db 1, RHYDON
+ db 2, BILL
+ db 1, MR_FUJI
+ db 2, POKE_BALL
+ db 1, POKEDEX
+ db 3, DEFENDER
+ db 2, POKEMON_FLUTE
+ db 0 ; end of list
+
+ExcavationCardList: ; 1b1fe (6:71fe)
+ db 15, FIGHTING_ENERGY
+ db 8, WATER_ENERGY
+ db 3, SHELLDER
+ db 1, CLOYSTER
+ db 3, OMANYTE
+ db 2, OMASTAR
+ db 4, SANDSHREW
+ db 2, SANDSLASH
+ db 3, CUBONE
+ db 1, MAROWAK2
+ db 3, HITMONCHAN
+ db 2, KABUTO
+ db 1, KABUTOPS
+ db 2, AERODACTYL
+ db 2, PROFESSOR_OAK
+ db 2, BILL
+ db 2, POKEMON_BREEDER
+ db 4, MYSTERIOUS_FOSSIL
+ db 0 ; end of list
+
+RockCrusherCardList: ; 1b223 (6:7223)
+ db 24, FIGHTING_ENERGY
+ db 2, DOUBLE_COLORLESS_ENERGY
+ db 4, DIGLETT
+ db 2, DUGTRIO
+ db 4, GEODUDE
+ db 3, GRAVELER
+ db 2, GOLEM
+ db 3, ONIX
+ db 3, RHYHORN
+ db 2, PROFESSOR_OAK
+ db 1, POKEMON_BREEDER
+ db 2, ENERGY_REMOVAL
+ db 2, SWITCH
+ db 1, COMPUTER_SEARCH
+ db 2, DEFENDER
+ db 1, SUPER_POTION
+ db 2, POTION
+ db 0 ; end of list
+
+BlueWaterCardList: ; 1b246 (6:7246)
+ db 25, WATER_ENERGY
+ db 2, PSYDUCK
+ db 1, GOLDUCK
+ db 2, POLIWAG
+ db 1, POLIWHIRL
+ db 1, POLIWRATH
+ db 2, SEEL
+ db 1, DEWGONG
+ db 2, SHELLDER
+ db 1, CLOYSTER
+ db 2, KRABBY
+ db 1, KINGLER
+ db 2, HORSEA
+ db 1, SEADRA
+ db 1, MAGIKARP
+ db 1, GYARADOS
+ db 1, LAPRAS
+ db 1, OMANYTE
+ db 1, OMASTAR
+ db 1, ARTICUNO1
+ db 1, PROFESSOR_OAK
+ db 2, BILL
+ db 1, POKEMON_TRADER
+ db 2, MYSTERIOUS_FOSSIL
+ db 1, ENERGY_SEARCH
+ db 1, POKE_BALL
+ db 1, POTION
+ db 1, SUPER_POTION
+ db 0 ; end of list
+
+OnTheBeachCardList: ; 1b27f (6:727f)
+ db 16, WATER_ENERGY
+ db 10, FIGHTING_ENERGY
+ db 2, SEEL
+ db 1, DEWGONG
+ db 3, SHELLDER
+ db 2, CLOYSTER
+ db 3, KRABBY
+ db 2, KINGLER
+ db 3, STARYU
+ db 2, STARMIE
+ db 3, SANDSHREW
+ db 2, SANDSLASH
+ db 2, BILL
+ db 2, ENERGY_RETRIEVAL
+ db 2, ENERGY_REMOVAL
+ db 2, GUST_OF_WIND
+ db 3, POTION
+ db 0 ; end of list
+
+ParalyzeCardList: ; 1b2a2 (6:72a2)
+ db 8, GRASS_ENERGY
+ db 14, WATER_ENERGY
+ db 4, DOUBLE_COLORLESS_ENERGY
+ db 3, CATERPIE
+ db 2, METAPOD
+ db 3, SQUIRTLE
+ db 2, WARTORTLE
+ db 3, SHELLDER
+ db 2, CLOYSTER
+ db 4, STARYU
+ db 3, STARMIE
+ db 2, PROFESSOR_OAK
+ db 2, BILL
+ db 2, PLUSPOWER
+ db 2, DEFENDER
+ db 4, POTION
+ db 0 ; end of list
+
+EnergyRemovalCardList: ; 1b2c3 (6:72c3)
+ db 15, WATER_ENERGY
+ db 8, PSYCHIC_ENERGY
+ db 3, DOUBLE_COLORLESS_ENERGY
+ db 3, PSYDUCK
+ db 2, GOLDUCK
+ db 4, POLIWAG
+ db 3, POLIWHIRL
+ db 2, POLIWRATH
+ db 4, GASTLY2
+ db 3, HAUNTER1
+ db 3, DRATINI
+ db 2, DRAGONAIR
+ db 1, PROFESSOR_OAK
+ db 1, BILL
+ db 1, LASS
+ db 2, ENERGY_SEARCH
+ db 2, ENERGY_REMOVAL
+ db 1, SUPER_ENERGY_REMOVAL
+ db 0 ; end of list
+
+RainDancerCardList: ; 1b2e8 (6:72e8)
+ db 24, WATER_ENERGY
+ db 4, SQUIRTLE
+ db 3, WARTORTLE
+ db 2, BLASTOISE
+ db 4, GOLDEEN
+ db 3, SEAKING
+ db 3, HORSEA
+ db 2, SEADRA
+ db 2, LAPRAS
+ db 2, PROFESSOR_OAK
+ db 1, POKEMON_BREEDER
+ db 1, ENERGY_RETRIEVAL
+ db 1, SUPER_ENERGY_RETRIEVAL
+ db 2, ENERGY_REMOVAL
+ db 1, SUPER_ENERGY_REMOVAL
+ db 2, SWITCH
+ db 2, POTION
+ db 1, GAMBLER
+ db 0 ; end of list
+
+CutePokemonCardList: ; 1b30d (6:730d)
+ db 4, FIRE_ENERGY
+ db 6, WATER_ENERGY
+ db 8, LIGHTNING_ENERGY
+ db 2, DOUBLE_COLORLESS_ENERGY
+ db 1, FLAREON2
+ db 1, VAPOREON2
+ db 1, PIKACHU1
+ db 1, PIKACHU2
+ db 1, PIKACHU3
+ db 1, PIKACHU4
+ db 1, FLYING_PIKACHU
+ db 1, SURFING_PIKACHU1
+ db 1, SURFING_PIKACHU2
+ db 1, RAICHU1
+ db 1, RAICHU2
+ db 1, JOLTEON2
+ db 2, CLEFAIRY
+ db 1, CLEFABLE
+ db 1, JIGGLYPUFF1
+ db 2, JIGGLYPUFF2
+ db 1, JIGGLYPUFF3
+ db 2, WIGGLYTUFF
+ db 4, EEVEE
+ db 2, PROFESSOR_OAK
+ db 3, BILL
+ db 2, CLEFAIRY_DOLL
+ db 2, SCOOP_UP
+ db 1, COMPUTER_SEARCH
+ db 1, PLUSPOWER
+ db 1, DEFENDER
+ db 3, POTION
+ db 0 ; end of list
+
+PokemonFluteCardList: ; 1b34c (6:734c)
+ db 9, WATER_ENERGY
+ db 12, LIGHTNING_ENERGY
+ db 2, STARYU
+ db 2, LAPRAS
+ db 3, PIKACHU1
+ db 1, RAICHU1
+ db 2, MAGNEMITE1
+ db 3, ELECTABUZZ2
+ db 2, RATTATA
+ db 1, RATICATE
+ db 2, PROFESSOR_OAK
+ db 4, BILL
+ db 3, ENERGY_REMOVAL
+ db 1, COMPUTER_SEARCH
+ db 3, PLUSPOWER
+ db 2, ITEM_FINDER
+ db 4, GUST_OF_WIND
+ db 4, POKEMON_FLUTE
+ db 0 ; end of list
+
+YellowFlashCardList: ; 1b371 (6:7371)
+ db 26, LIGHTNING_ENERGY
+ db 2, PIKACHU1
+ db 1, PIKACHU2
+ db 1, RAICHU1
+ db 1, RAICHU2
+ db 2, MAGNEMITE1
+ db 1, MAGNEMITE2
+ db 1, MAGNETON1
+ db 1, MAGNETON2
+ db 3, VOLTORB
+ db 1, ELECTRODE1
+ db 1, ELECTRODE2
+ db 1, ELECTABUZZ1
+ db 1, ELECTABUZZ2
+ db 1, JOLTEON1
+ db 1, JOLTEON2
+ db 1, ZAPDOS1
+ db 1, ZAPDOS2
+ db 3, EEVEE
+ db 1, ENERGY_RETRIEVAL
+ db 2, ENERGY_REMOVAL
+ db 2, POKE_BALL
+ db 2, PLUSPOWER
+ db 2, DEFENDER
+ db 1, GUST_OF_WIND
+ db 0 ; end of list
+
+ElectricShockCardList: ; 1b3a4 (6:73a4)
+ db 24, LIGHTNING_ENERGY
+ db 1, DOUBLE_COLORLESS_ENERGY
+ db 2, PIKACHU2
+ db 1, PIKACHU3
+ db 1, PIKACHU4
+ db 2, RAICHU1
+ db 2, MAGNEMITE1
+ db 2, MAGNEMITE2
+ db 2, MAGNETON1
+ db 4, VOLTORB
+ db 3, ELECTRODE2
+ db 1, ZAPDOS2
+ db 3, PORYGON
+ db 2, ENERGY_RETRIEVAL
+ db 2, PLUSPOWER
+ db 3, DEFENDER
+ db 2, ITEM_FINDER
+ db 3, GUST_OF_WIND
+ db 0 ; end of list
+
+ZappingSelfdestructCardList: ; 1b3c9 (6:73c9)
+ db 24, LIGHTNING_ENERGY
+ db 2, DOUBLE_COLORLESS_ENERGY
+ db 4, MAGNEMITE1
+ db 3, MAGNETON1
+ db 4, VOLTORB
+ db 2, ELECTRODE1
+ db 4, ELECTABUZZ2
+ db 2, KANGASKHAN
+ db 1, TAUROS
+ db 1, PROFESSOR_OAK
+ db 2, BILL
+ db 2, SWITCH
+ db 4, DEFENDER
+ db 1, GUST_OF_WIND
+ db 4, POTION
+ db 0 ; end of list
+
+InsectCollectionCardList: ; 1b3e8 (6:73e8)
+ db 24, GRASS_ENERGY
+ db 3, CATERPIE
+ db 2, METAPOD
+ db 1, BUTTERFREE
+ db 3, WEEDLE
+ db 2, KAKUNA
+ db 1, BEEDRILL
+ db 4, PARAS
+ db 3, PARASECT
+ db 2, VENONAT
+ db 1, VENOMOTH
+ db 1, SCYTHER
+ db 1, PINSIR
+ db 2, BILL
+ db 2, POKEMON_BREEDER
+ db 2, SWITCH
+ db 2, POKE_BALL
+ db 2, POKEDEX
+ db 2, POTION
+ db 0 ; end of list
+
+JungleCardList: ; 1b40f (6:740f)
+ db 25, GRASS_ENERGY
+ db 1, DOUBLE_COLORLESS_ENERGY
+ db 2, EKANS
+ db 1, ARBOK
+ db 2, ZUBAT
+ db 1, GOLBAT
+ db 2, ODDISH
+ db 1, GLOOM
+ db 1, VILEPLUME
+ db 2, PARAS
+ db 1, PARASECT
+ db 2, VENONAT
+ db 1, VENOMOTH
+ db 2, BELLSPROUT
+ db 1, WEEPINBELL
+ db 1, VICTREEBEL
+ db 1, PINSIR
+ db 1, LICKITUNG
+ db 1, KANGASKHAN
+ db 2, BILL
+ db 1, SWITCH
+ db 1, POKE_BALL
+ db 2, PLUSPOWER
+ db 2, DEFENDER
+ db 2, POTION
+ db 1, FULL_HEAL
+ db 0 ; end of list
+
+FlowerGardenCardList: ; 1b444 (6:7444)
+ db 24, GRASS_ENERGY
+ db 2, DOUBLE_COLORLESS_ENERGY
+ db 3, BULBASAUR
+ db 2, IVYSAUR
+ db 2, VENUSAUR2
+ db 3, ODDISH
+ db 2, GLOOM
+ db 2, VILEPLUME
+ db 2, BELLSPROUT
+ db 1, WEEPINBELL
+ db 1, VICTREEBEL
+ db 2, TANGELA1
+ db 1, TANGELA2
+ db 2, LICKITUNG
+ db 2, POKEMON_TRADER
+ db 3, POKEMON_BREEDER
+ db 1, ENERGY_SEARCH
+ db 2, SWITCH
+ db 2, POTION
+ db 1, FULL_HEAL
+ db 0 ; end of list
+
+KaleidoscopeCardList: ; 1b46d (6:746d)
+ db 10, GRASS_ENERGY
+ db 4, FIRE_ENERGY
+ db 4, WATER_ENERGY
+ db 4, LIGHTNING_ENERGY
+ db 3, DOUBLE_COLORLESS_ENERGY
+ db 3, VENONAT
+ db 2, VENOMOTH
+ db 1, FLAREON1
+ db 1, FLAREON2
+ db 1, VAPOREON1
+ db 1, VAPOREON2
+ db 1, JOLTEON1
+ db 1, JOLTEON2
+ db 4, DITTO
+ db 4, EEVEE
+ db 4, PORYGON
+ db 2, BILL
+ db 2, MR_FUJI
+ db 2, ENERGY_SEARCH
+ db 4, SWITCH
+ db 2, GUST_OF_WIND
+ db 0 ; end of list
+
+FlowerPowerCardList: ; 1b498 (6:7498)
+ db 18, GRASS_ENERGY
+ db 4, PSYCHIC_ENERGY
+ db 4, BULBASAUR
+ db 3, IVYSAUR
+ db 2, VENUSAUR2
+ db 4, ODDISH
+ db 3, GLOOM
+ db 2, VILEPLUME
+ db 4, EXEGGCUTE
+ db 3, EXEGGUTOR
+ db 2, PROFESSOR_OAK
+ db 3, BILL
+ db 2, POKEMON_BREEDER
+ db 2, ENERGY_RETRIEVAL
+ db 2, SWITCH
+ db 2, POTION
+ db 0 ; end of list
+
+PsychicPowerCardList: ; 1b4b9 (6:74b9)
+ db 25, PSYCHIC_ENERGY
+ db 3, ABRA
+ db 2, KADABRA
+ db 1, ALAKAZAM
+ db 2, SLOWPOKE2
+ db 1, SLOWBRO
+ db 1, GASTLY1
+ db 2, GASTLY2
+ db 1, HAUNTER1
+ db 1, HAUNTER2
+ db 1, GENGAR
+ db 2, DROWZEE
+ db 1, HYPNO
+ db 1, MR_MIME
+ db 1, JYNX
+ db 1, MEWTWO1
+ db 1, MEW3
+ db 1, CLEFAIRY
+ db 1, CLEFABLE
+ db 1, SNORLAX
+ db 2, PROFESSOR_OAK
+ db 1, POKEMON_TRADER
+ db 1, POKEMON_BREEDER
+ db 2, SWITCH
+ db 1, POKEMON_CENTER
+ db 2, PLUSPOWER
+ db 1, DEVOLUTION_SPRAY
+ db 0 ; end of list
+
+DreamEaterHaunterCardList: ; 1b40f (6:740f)
+ db 7, GRASS_ENERGY
+ db 17, PSYCHIC_ENERGY
+ db 3, ZUBAT
+ db 2, GOLBAT
+ db 4, GASTLY1
+ db 1, HAUNTER1
+ db 2, HAUNTER2
+ db 2, GENGAR
+ db 3, DROWZEE
+ db 2, HYPNO
+ db 2, JIGGLYPUFF3
+ db 2, MEOWTH2
+ db 2, PROFESSOR_OAK
+ db 2, BILL
+ db 2, ENERGY_RETRIEVAL
+ db 1, SUPER_ENERGY_RETRIEVAL
+ db 2, SWITCH
+ db 1, COMPUTER_SEARCH
+ db 3, REVIVE
+ db 0 ; end of list
+
+ScavengingSlowbroCardList: ; 1b517 (6:7517)
+ db 23, PSYCHIC_ENERGY
+ db 4, SLOWPOKE2
+ db 3, SLOWBRO
+ db 3, JYNX
+ db 2, MEWTWO1
+ db 2, MEW3
+ db 2, JIGGLYPUFF2
+ db 2, JIGGLYPUFF3
+ db 2, EEVEE
+ db 2, ENERGY_RETRIEVAL
+ db 3, ENERGY_REMOVAL
+ db 2, PLUSPOWER
+ db 3, DEFENDER
+ db 3, POTION
+ db 4, RECYCLE
+ db 0 ; end of list
+
+StrangePowerCardList: ; 1b536 (6:7536)
+ db 25, PSYCHIC_ENERGY
+ db 1, DOUBLE_COLORLESS_ENERGY
+ db 3, SLOWPOKE1
+ db 2, SLOWBRO
+ db 4, DROWZEE
+ db 3, HYPNO
+ db 2, MR_MIME
+ db 2, JYNX
+ db 1, MEW1
+ db 2, MEW3
+ db 2, LICKITUNG
+ db 1, SNORLAX
+ db 2, POKEMON_TRADER
+ db 2, ENERGY_RETRIEVAL
+ db 2, ENERGY_REMOVAL
+ db 1, SUPER_ENERGY_REMOVAL
+ db 2, PLUSPOWER
+ db 1, ITEM_FINDER
+ db 1, GUST_OF_WIND
+ db 1, FULL_HEAL
+ db 0 ; end of list
+
+StrangePsyshockCardList: ; 1b55f (6:755f)
+ db 22, PSYCHIC_ENERGY
+ db 4, ABRA
+ db 3, KADABRA
+ db 2, ALAKAZAM
+ db 2, MR_MIME
+ db 3, CHANSEY
+ db 3, KANGASKHAN
+ db 2, SNORLAX
+ db 2, PROFESSOR_OAK
+ db 2, POKEMON_CENTER
+ db 3, ENERGY_REMOVAL
+ db 3, GUST_OF_WIND
+ db 4, SCOOP_UP
+ db 4, SWITCH
+ db 1, GAMBLER
+ db 0 ; end of list
+
+LovelyNidoranCardList: ; 1b57e (6:757e)
+ db 20, GRASS_ENERGY
+ db 4, NIDORANF
+ db 3, NIDORINA
+ db 2, NIDOQUEEN
+ db 4, NIDORANM
+ db 4, NIDORINO
+ db 4, NIDOKING
+ db 3, LICKITUNG
+ db 2, PROFESSOR_OAK
+ db 3, POKEMON_TRADER
+ db 3, POKEMON_BREEDER
+ db 2, ENERGY_RETRIEVAL
+ db 3, SWITCH
+ db 1, COMPUTER_SEARCH
+ db 2, ITEM_FINDER
+ db 0 ; end of list
+
+ScienceCorpsCardList: ; 1b59d (6:759d)
+ db 26, GRASS_ENERGY
+ db 2, EKANS
+ db 1, ARBOK
+ db 2, NIDORANF
+ db 1, NIDORINA
+ db 1, NIDOQUEEN
+ db 3, NIDORANM
+ db 2, NIDORINO
+ db 1, NIDOKING
+ db 2, ZUBAT
+ db 1, GOLBAT
+ db 2, GRIMER
+ db 1, MUK
+ db 2, KOFFING
+ db 1, WEEZING
+ db 2, MEOWTH2
+ db 1, PERSIAN
+ db 1, PROFESSOR_OAK
+ db 1, BILL
+ db 1, POKEMON_TRADER
+ db 1, POKEMON_BREEDER
+ db 1, POTION
+ db 1, FULL_HEAL
+ db 1, MAINTENANCE
+ db 1, GAMBLER
+ db 1, RECYCLE
+ db 0 ; end of list
+
+FlyinPokemonCardList: ; 1b5d2 (6:75d2)
+ db 13, GRASS_ENERGY
+ db 10, LIGHTNING_ENERGY
+ db 2, DOUBLE_COLORLESS_ENERGY
+ db 4, ZUBAT
+ db 3, GOLBAT
+ db 2, FLYING_PIKACHU
+ db 4, PIDGEY
+ db 3, PIDGEOTTO
+ db 1, PIDGEOT1
+ db 1, PIDGEOT2
+ db 4, SPEAROW
+ db 3, FEAROW
+ db 2, IMPOSTER_PROFESSOR_OAK
+ db 2, LASS
+ db 2, BILL
+ db 4, POTION
+ db 0 ; end of list
+
+PoisonCardList: ; 1b5f3 (6:75f3)
+ db 24, GRASS_ENERGY
+ db 3, WEEDLE
+ db 2, KAKUNA
+ db 1, BEEDRILL
+ db 4, EKANS
+ db 3, ARBOK
+ db 4, NIDORANM
+ db 3, NIDORINO
+ db 2, NIDOKING
+ db 3, KOFFING
+ db 2, WEEZING
+ db 1, PROFESSOR_OAK
+ db 2, IMPOSTER_PROFESSOR_OAK
+ db 1, POKEMON_BREEDER
+ db 2, POTION
+ db 2, FULL_HEAL
+ db 1, GAMBLER
+ db 0 ; end of list
+
+WondersOfScienceCardList: ; 1b616 (6:7616)
+ db 15, GRASS_ENERGY
+ db 8, PSYCHIC_ENERGY
+ db 4, GRIMER
+ db 3, MUK
+ db 4, KOFFING
+ db 3, WEEZING
+ db 2, MEWTWO1
+ db 1, MEWTWO3
+ db 1, MEWTWO2
+ db 2, PORYGON
+ db 1, IMPOSTER_PROFESSOR_OAK
+ db 2, PROFESSOR_OAK
+ db 2, BILL
+ db 2, ENERGY_SEARCH
+ db 2, SWITCH
+ db 2, COMPUTER_SEARCH
+ db 2, POKEDEX
+ db 2, MAINTENANCE
+ db 2, FULL_HEAL
+ db 0 ; end of list
+
+ReplaceEmAllCardList: ; 1b63d (6:763d)
+ db 24, FIRE_ENERGY
+ db 4, VULPIX
+ db 2, NINETAILS1
+ db 1, NINETAILS2
+ db 4, GROWLITHE
+ db 1, ARCANINE1
+ db 1, ARCANINE2
+ db 4, PIDGEY
+ db 3, PIDGEOTTO
+ db 1, PIDGEOT1
+ db 1, PIDGEOT2
+ db 3, DODUO
+ db 2, DODRIO
+ db 2, PROFESSOR_OAK
+ db 2, IMPOSTER_PROFESSOR_OAK
+ db 2, LASS
+ db 3, GUST_OF_WIND
+ db 0 ; end of list
+
+ChariSaurCardList: ; 1b660 (6:7660)
+ db 12, GRASS_ENERGY
+ db 10, FIRE_ENERGY
+ db 4, BULBASAUR
+ db 3, IVYSAUR
+ db 2, VENUSAUR2
+ db 4, CHARMANDER
+ db 3, CHARMELEON
+ db 2, CHARIZARD
+ db 3, FLAREON1
+ db 4, EEVEE
+ db 2, BILL
+ db 3, POKEMON_TRADER
+ db 3, POKEMON_BREEDER
+ db 2, ENERGY_RETRIEVAL
+ db 1, ENERGY_REMOVAL
+ db 2, POTION
+ db 0 ; end of list
+
+TrafficLightCardList: ; 1b681 (6:7681)
+ db 10, FIRE_ENERGY
+ db 8, WATER_ENERGY
+ db 8, LIGHTNING_ENERGY
+ db 3, CHARMANDER
+ db 2, CHARMELEON
+ db 3, PONYTA
+ db 2, RAPIDASH
+ db 2, FLAREON1
+ db 2, VAPOREON1
+ db 2, PIKACHU1
+ db 3, VOLTORB
+ db 2, ELECTRODE2
+ db 2, JOLTEON1
+ db 4, EEVEE
+ db 2, ENERGY_SEARCH
+ db 2, SWITCH
+ db 3, PLUSPOWER
+ db 0 ; end of list
+
+FirePokemonCardList: ; 1b6a4 (6:76a4)
+ db 24, FIRE_ENERGY
+ db 2, DOUBLE_COLORLESS_ENERGY
+ db 3, CHARMANDER
+ db 2, CHARMELEON
+ db 1, CHARIZARD
+ db 3, VULPIX
+ db 1, NINETAILS1
+ db 1, NINETAILS2
+ db 2, GROWLITHE
+ db 1, ARCANINE2
+ db 2, PONYTA
+ db 1, RAPIDASH
+ db 1, MAGMAR1
+ db 1, MAGMAR2
+ db 1, FLAREON1
+ db 1, FLAREON2
+ db 1, MOLTRES1
+ db 3, EEVEE
+ db 1, PROFESSOR_OAK
+ db 2, BILL
+ db 1, POKEMON_TRADER
+ db 1, POKEMON_BREEDER
+ db 1, ENERGY_RETRIEVAL
+ db 1, SUPER_ENERGY_RETRIEVAL
+ db 1, SWITCH
+ db 1, GUST_OF_WIND
+ db 0 ; end of list
+
+FireChargeCardList: ; 1b6d9 (6:76d9)
+ db 21, FIRE_ENERGY
+ db 4, DOUBLE_COLORLESS_ENERGY
+ db 4, GROWLITHE
+ db 3, ARCANINE2
+ db 2, MAGMAR1
+ db 3, JIGGLYPUFF1
+ db 1, JIGGLYPUFF3
+ db 1, WIGGLYTUFF
+ db 2, CHANSEY
+ db 2, TAUROS
+ db 1, PROFESSOR_OAK
+ db 2, BILL
+ db 2, ENERGY_RETRIEVAL
+ db 1, POKE_BALL
+ db 1, COMPUTER_SEARCH
+ db 2, DEFENDER
+ db 3, POTION
+ db 1, FULL_HEAL
+ db 3, RECYCLE
+ db 1, GAMBLER
+ db 0 ; end of list
+
+CharmanderAndFriendsCardList: ; 1b702 (6:7702)
+ db 8, GRASS_ENERGY
+ db 10, FIRE_ENERGY
+ db 6, WATER_ENERGY
+ db 2, CATERPIE
+ db 1, METAPOD
+ db 2, NIDORANF
+ db 1, NIDORANM
+ db 1, PINSIR
+ db 2, CHARMANDER
+ db 1, CHARMELEON
+ db 1, CHARIZARD
+ db 2, GROWLITHE
+ db 1, ARCANINE2
+ db 2, PONYTA
+ db 1, MAGMAR1
+ db 2, SEEL
+ db 1, DEWGONG
+ db 2, GOLDEEN
+ db 1, SEAKING
+ db 2, RATTATA
+ db 1, RATICATE
+ db 1, MEOWTH1
+ db 1, PROFESSOR_OAK
+ db 2, BILL
+ db 1, SWITCH
+ db 1, COMPUTER_SEARCH
+ db 1, PLUSPOWER
+ db 2, POTION
+ db 2, FULL_HEAL
+ db 0 ; end of list
+
+SquirtleAndFriendsCardList: ; 1b73d (6:773d)
+ db 8, FIRE_ENERGY
+ db 11, WATER_ENERGY
+ db 6, LIGHTNING_ENERGY
+ db 2, CHARMANDER
+ db 1, CHARMELEON
+ db 1, GROWLITHE
+ db 1, ARCANINE2
+ db 1, MAGMAR1
+ db 2, SQUIRTLE
+ db 1, WARTORTLE
+ db 1, BLASTOISE
+ db 2, SEEL
+ db 1, DEWGONG
+ db 1, GOLDEEN
+ db 1, SEAKING
+ db 1, STARYU
+ db 1, STARMIE
+ db 1, LAPRAS
+ db 2, PIKACHU1
+ db 1, MAGNEMITE1
+ db 1, MAGNETON1
+ db 1, ELECTABUZZ2
+ db 2, RATTATA
+ db 1, RATICATE
+ db 1, MEOWTH1
+ db 1, PROFESSOR_OAK
+ db 1, BILL
+ db 1, SWITCH
+ db 1, POKE_BALL
+ db 1, SCOOP_UP
+ db 1, ITEM_FINDER
+ db 1, POTION
+ db 1, FULL_HEAL
+ db 0 ; end of list
+
+BulbasaurAndFriendsCardList: ; 1b780 (6:7780)
+ db 9, GRASS_ENERGY
+ db 8, LIGHTNING_ENERGY
+ db 6, PSYCHIC_ENERGY
+ db 2, BULBASAUR
+ db 1, IVYSAUR
+ db 1, VENUSAUR2
+ db 2, NIDORANF
+ db 2, NIDORANM
+ db 1, NIDORINO
+ db 1, TANGELA2
+ db 2, PIKACHU1
+ db 1, RAICHU1
+ db 1, MAGNEMITE1
+ db 1, ELECTABUZZ2
+ db 2, ABRA
+ db 1, KADABRA
+ db 2, GASTLY1
+ db 1, HAUNTER2
+ db 1, JYNX
+ db 1, JIGGLYPUFF3
+ db 1, MEOWTH1
+ db 1, KANGASKHAN
+ db 1, PROFESSOR_OAK
+ db 1, BILL
+ db 1, SWITCH
+ db 1, POKE_BALL
+ db 2, PLUSPOWER
+ db 1, DEFENDER
+ db 1, GUST_OF_WIND
+ db 2, POTION
+ db 2, FULL_HEAL
+ db 0 ; end of list
+
+PsychicMachampCardList: ; 1b7b (6:77b)
+ db 12, FIGHTING_ENERGY
+ db 12, PSYCHIC_ENERGY
+ db 2, DIGLETT
+ db 1, DUGTRIO
+ db 2, MACHOP
+ db 1, MACHOKE
+ db 1, MACHAMP
+ db 1, ONIX
+ db 1, HITMONLEE
+ db 1, HITMONCHAN
+ db 2, ABRA
+ db 1, KADABRA
+ db 1, ALAKAZAM
+ db 2, GASTLY1
+ db 1, HAUNTER2
+ db 1, GENGAR
+ db 1, MR_MIME
+ db 1, JYNX
+ db 1, MEW3
+ db 2, PIDGEY
+ db 1, PIDGEOTTO
+ db 1, PIDGEOT2
+ db 2, RATTATA
+ db 1, RATICATE
+ db 1, PROFESSOR_OAK
+ db 2, BILL
+ db 1, SWITCH
+ db 1, GUST_OF_WIND
+ db 2, POTION
+ db 1, FULL_HEAL
+ db 0 ; end of list
+
+WaterBeetleCardList: ; 1b7fc (6:77fc)
+ db 14, GRASS_ENERGY
+ db 10, WATER_ENERGY
+ db 2, WEEDLE
+ db 1, KAKUNA
+ db 1, BEEDRILL
+ db 2, NIDORANM
+ db 1, NIDORINO
+ db 1, NIDOKING
+ db 2, BELLSPROUT
+ db 1, WEEPINBELL
+ db 1, VICTREEBEL
+ db 1, SCYTHER
+ db 2, POLIWAG
+ db 1, POLIWHIRL
+ db 1, POLIWRATH
+ db 2, KRABBY
+ db 1, KINGLER
+ db 2, MAGIKARP
+ db 1, GYARADOS
+ db 1, LAPRAS
+ db 1, ARTICUNO1
+ db 1, LICKITUNG
+ db 1, KANGASKHAN
+ db 1, TAUROS
+ db 1, PROFESSOR_OAK
+ db 2, BILL
+ db 1, ENERGY_RETRIEVAL
+ db 1, ENERGY_SEARCH
+ db 1, SWITCH
+ db 1, PLUSPOWER
+ db 1, FULL_HEAL
+ db 0 ; end of list
+
+LegendaryMoltresCardList: ; 1b83b (6:783b)
+ db 25, FIRE_ENERGY
+ db 4, VULPIX
+ db 3, NINETAILS2
+ db 4, GROWLITHE
+ db 2, ARCANINE2
+ db 2, MAGMAR1
+ db 2, MAGMAR2
+ db 2, MOLTRES1
+ db 2, MOLTRES2
+ db 3, BILL
+ db 2, LASS
+ db 1, POKEMON_TRADER
+ db 1, ENERGY_RETRIEVAL
+ db 1, SUPER_ENERGY_RETRIEVAL
+ db 2, ENERGY_REMOVAL
+ db 2, SWITCH
+ db 1, POTION
+ db 1, SUPER_POTION
+ db 0 ; end of list
+
+LegendaryZapdosCardList: ; 1b860 (6:7860)
+ db 25, LIGHTNING_ENERGY
+ db 4, VOLTORB
+ db 3, ELECTRODE1
+ db 4, ELECTABUZZ2
+ db 2, JOLTEON2
+ db 1, ZAPDOS1
+ db 1, ZAPDOS2
+ db 2, ZAPDOS3
+ db 3, EEVEE
+ db 4, BILL
+ db 2, ENERGY_RETRIEVAL
+ db 2, SWITCH
+ db 3, PLUSPOWER
+ db 3, POTION
+ db 1, GAMBLER
+ db 0 ; end of list
+
+LegendaryArticunoCardList: ; 1b87f (6:787f)
+ db 25, WATER_ENERGY
+ db 4, SEEL
+ db 3, DEWGONG
+ db 4, LAPRAS
+ db 2, ARTICUNO2
+ db 2, ARTICUNO1
+ db 3, CHANSEY
+ db 2, DITTO
+ db 2, PROFESSOR_OAK
+ db 2, POKEMON_TRADER
+ db 3, ENERGY_RETRIEVAL
+ db 3, SWITCH
+ db 4, SCOOP_UP
+ db 1, GAMBLER
+ db 0 ; end of list
+
+LegendaryDragoniteCardList: ; 1b89c (6:789c)
+ db 20, WATER_ENERGY
+ db 4, DOUBLE_COLORLESS_ENERGY
+ db 3, CHARMANDER
+ db 2, CHARMELEON
+ db 2, CHARIZARD
+ db 3, MAGIKARP
+ db 2, GYARADOS
+ db 2, LAPRAS
+ db 2, KANGASKHAN
+ db 4, DRATINI
+ db 3, DRAGONAIR
+ db 2, DRAGONITE1
+ db 2, PROFESSOR_OAK
+ db 2, POKEMON_TRADER
+ db 2, POKEMON_BREEDER
+ db 1, ENERGY_RETRIEVAL
+ db 1, SUPER_ENERGY_RETRIEVAL
+ db 2, SWITCH
+ db 1, GAMBLER
+ db 0 ; end of list
+
+MysteriousPokemonCardList: ; 1b8c3 (6:78c3)
+ db 12, GRASS_ENERGY
+ db 14, PSYCHIC_ENERGY
+ db 4, BULBASAUR
+ db 3, IVYSAUR
+ db 2, VENUSAUR1
+ db 2, SCYTHER
+ db 4, ABRA
+ db 3, KADABRA
+ db 2, ALAKAZAM
+ db 2, MR_MIME
+ db 1, MEW1
+ db 2, MEW2
+ db 1, PROFESSOR_OAK
+ db 2, BILL
+ db 2, POKEMON_BREEDER
+ db 1, ENERGY_REMOVAL
+ db 2, SWITCH
+ db 1, POKEMON_CENTER
+ db 0 ; end of list
+; 0x1b8e8
diff --git a/src/data/auto_deck_machines.asm b/src/data/auto_deck_machines.asm
new file mode 100644
index 0000000..17ca823
--- /dev/null
+++ b/src/data/auto_deck_machines.asm
@@ -0,0 +1,82 @@
+; each Auto Deck Machine has 5 slots for deck configurations
+; each entry in an Auto Deck Machine consists of a card list
+; (see data/auto_deck_card_lists.asm) and two text IDs
+; for the corresponding deck name and description/flavor text
+
+auto_deck: MACRO
+ dw \1 ; deck card list
+ tx \2 ; deck name text ID
+ tx \3 ; deck description text ID
+ENDM
+
+AutoDeckMachineEntries: ; 1b8e8 (6:78e8)
+; Fighting Auto Deck Machine
+ auto_deck AllFightingPokemonCardList, AllFightingPokemonText, AllFightingPokemonDescriptionText
+ auto_deck BenchAttackCardList, BenchAttackText, BenchAttackDescriptionText
+ auto_deck BattleContestCardList, BattleContestText, BattleContestDescriptionText
+ auto_deck HeatedBattleCardList, HeatedBattleText, HeatedBattleDescriptionText
+ auto_deck FirstStrikeCardList, FirstStrikeText, FirstStrikeDescriptionText
+
+; Rock Auto Deck Machine
+ auto_deck SqueakingMouseCardList, SqueakingMouseText, SqueakingMouseDescriptionText
+ auto_deck GreatQuakeCardList, GreatQuakeText, GreatQuakeDescriptionText
+ auto_deck BoneAttackCardList, BoneAttackText, BoneAttackDescriptionText
+ auto_deck ExcavationCardList, ExcavationText, ExcavationDescriptionText
+ auto_deck RockCrusherCardList, RockCrusherText, RockCrusherDescriptionText
+
+; Water Auto Deck Machine
+ auto_deck BlueWaterCardList, BlueWaterText, BlueWaterDescriptionText
+ auto_deck OnTheBeachCardList, OnTheBeachText, OnTheBeachDescriptionText
+ auto_deck ParalyzeCardList, ParalyzeText, ParalyzeDescriptionText
+ auto_deck EnergyRemovalCardList, EnergyRemovalText, EnergyRemovalDescriptionText
+ auto_deck RainDancerCardList, RainDancerText, RainDancerDescriptionText
+
+; Lightning Auto Deck Machine
+ auto_deck CutePokemonCardList, CutePokemonText, CutePokemonDescriptionText
+ auto_deck PokemonFluteCardList, PokemonFluteText, PokemonFluteDescriptionText
+ auto_deck YellowFlashCardList, YellowFlashText, YellowFlashDescriptionText
+ auto_deck ElectricShockCardList, ElectricShockText, ElectricShockDescriptionText
+ auto_deck ZappingSelfdestructCardList, ZappingSelfdestructText, ZappingSelfdestructDescriptionText
+
+; Grass Auto Deck Machine
+ auto_deck InsectCollectionCardList, InsectCollectionText, InsectCollectionDescriptionText
+ auto_deck JungleCardList, JungleText, JungleDescriptionText
+ auto_deck FlowerGardenCardList, FlowerGardenText, FlowerGardenDescriptionText
+ auto_deck KaleidoscopeCardList, KaleidoscopeText, KaleidoscopeDescriptionText
+ auto_deck FlowerPowerCardList, FlowerPowerText, FlowerPowerDescriptionText
+
+; Psychic Auto Deck Machine
+ auto_deck PsychicPowerCardList, PsychicPowerText, PsychicPowerDescriptionText
+ auto_deck DreamEaterHaunterCardList, DreamEaterHaunterText, DreamEaterHaunterDescriptionText
+ auto_deck ScavengingSlowbroCardList, ScavengingSlowbroText, ScavengingSlowbroDescriptionText
+ auto_deck StrangePowerCardList, StrangePowerText, StrangePowerDescriptionText
+ auto_deck StrangePsyshockCardList, StrangePsyshockText, StrangePsyshockDescriptionText
+
+; Science Auto Deck Machine
+ auto_deck LovelyNidoranCardList, LovelyNidoranText, LovelyNidoranDescriptionText
+ auto_deck ScienceCorpsCardList, ScienceCorpsText, ScienceCorpsDescriptionText
+ auto_deck FlyinPokemonCardList, FlyinPokemonText, FlyinPokemonDescriptionText
+ auto_deck PoisonCardList, PoisonText, PoisonDescriptionText
+ auto_deck WondersOfScienceCardList, WondersOfScienceText, WondersOfScienceDescriptionText
+
+; Fire Auto Deck Machine
+ auto_deck ReplaceEmAllCardList, ReplaceEmAllText, ReplaceEmAllDescriptionText
+ auto_deck ChariSaurCardList, ChariSaurText, ChariSaurDescriptionText
+ auto_deck TrafficLightCardList, TrafficLightText, TrafficLightDescriptionText
+ auto_deck FirePokemonCardList, FirePokemonDeckText, FirePokemonDescriptionText
+ auto_deck FireChargeCardList, FireChargeText, FireChargeDescriptionText
+
+; Auto Deck Machine
+ auto_deck CharmanderAndFriendsCardList, CharmanderAndFriendsText, CharmanderAndFriendsDescriptionText
+ auto_deck SquirtleAndFriendsCardList, SquirtleAndFriendsText, SquirtleAndFriendsDescriptionText
+ auto_deck BulbasaurAndFriendsCardList, BulbasaurAndFriendsText, BulbasaurAndFriendsDescriptionText
+ auto_deck PsychicMachampCardList, PsychicMachampText, PsychicMachampDescriptionText
+ auto_deck WaterBeetleCardList, WaterBeetleText, WaterBeetleDescriptionText
+
+; Legendary Auto Deck Machine
+ auto_deck LegendaryMoltresCardList, LegendaryMoltresText, LegendaryMoltresDescriptionText
+ auto_deck LegendaryZapdosCardList, LegendaryZapdosText, LegendaryZapdosDescriptionText
+ auto_deck LegendaryArticunoCardList, LegendaryArticunoText, LegendaryArticunoDescriptionText
+ auto_deck LegendaryDragoniteCardList, LegendaryDragoniteText, LegendaryDragoniteDescriptionText
+ auto_deck MysteriousPokemonCardList, MysteriousPokemonText, MysteriousPokemonDescriptionText
+; 0x1ba14
diff --git a/src/engine/bank01.asm b/src/engine/bank01.asm
index c706842..449cd75 100644
--- a/src/engine/bank01.asm
+++ b/src/engine/bank01.asm
@@ -1813,7 +1813,7 @@ Func_4b60: ; 4b60 (1:4b60)
call ChooseInitialArenaAndBenchPokemon
call SwapTurn
jp c, .asm_4c77
- call Func_311d
+ call DrawPlayAreaToPlacePrizeCards
ldtx hl, PlacingThePrizesText
call DrawWideTextBox_WaitForInput
call ExchangeRNG
@@ -3684,7 +3684,7 @@ Func_5805: ; 5805 (1:5805)
ldtx hl, WillDrawNPrizesText
call DrawWideTextBox_WaitForInput
ld a, [wNumberPrizeCardsToTake]
- call Func_310a
+ call SelectPrizeCards
ld hl, hTemp_ffa0
ld d, [hl]
inc hl
@@ -8523,7 +8523,20 @@ Func_7576: ; 7576 (1:7576)
ret
; 0x757b
- INCROM $757b, $758a
+Func_757b: ; 757b (1:757b)
+ farcall Func_19e42
+ ret
+; 0x7580
+
+Func_7580: ; 7580 (1:7580)
+ farcall Func_1a162
+ ret
+; 0x7585
+
+Func_7585: ; 7585 (1:7585)
+ farcall Func_1a270
+ ret
+; 0x758a
Func_758a: ; 758a (1:758a)
farcall Func_19eb4
diff --git a/src/engine/bank02.asm b/src/engine/bank02.asm
index 3483af2..9afbaed 100644
--- a/src/engine/bank02.asm
+++ b/src/engine/bank02.asm
@@ -434,7 +434,7 @@ _DrawYourOrOppPlayAreaScreen: ; 8211 (2:4211)
; a = (6 - name text in tiles) / 2 + 4
ld d, a ; text horizontal alignment
- ld e, $00
+ ld e, 0
call InitTextPrinting
ldtx hl, DuelistsPlayAreaText
ldh a, [hWhoseTurn]
@@ -512,7 +512,7 @@ DrawInPlayAreaScreen: ; 82ce (2:42ce)
call DoFrame
call EmptyScreen
- ld a, $0a
+ ld a, CHECK_PLAY_AREA
ld [wDuelDisplayedScreen], a
call Set_OBJ_8x8
call LoadCursorTile
@@ -1281,7 +1281,7 @@ HandleCheckMenuInput_YourOrOppPlayArea: ; 86ac (2:46ac)
ld e, a
.erase
- ld a, $01
+ ld a, TRUE
ld [wPlaysSfx], a
push de
call EraseCheckMenuCursor_YourOrOppPlayArea
@@ -1367,20 +1367,20 @@ DrawCheckMenuCursor_YourOrOppPlayArea: ; 8743 (2:4743)
call WriteByteToBGMap0
or a
ret
+; 0x8760
DisplayCheckMenuCursor_YourOrOppPlayArea: ; 8760 (2:4760)
ld a, SYM_CURSOR_R ; load cursor byte
jr DrawCheckMenuCursor_YourOrOppPlayArea
-; seems to be function to deal with the Peek menu
-; to select a prize card to view
-Func_8764: ; 8764 (2:4764)
+; handles Peek Pkmn Power selection menus
+_HandlePeekSelection: ; 8764 (2:4764)
call Set_OBJ_8x8
call LoadCursorTile
-; reset ce5c and ce56
+; reset ce5c and wIsSwapTurnPending
xor a
ld [wce5c], a
- ld [wce56], a
+ ld [wIsSwapTurnPending], a
; draw play area screen for the turn player
ldh a, [hWhoseTurn]
@@ -1388,51 +1388,51 @@ Func_8764: ; 8764 (2:4764)
ld l, a
call DrawYourOrOppPlayAreaScreen
-.swap
- ld a, [wce56]
+.check_swap
+ ld a, [wIsSwapTurnPending]
or a
- jr z, .draw_menu
-; if ce56 != 0, swap turn
+ jr z, .draw_menu_1
+; if wIsSwapTurnPending is TRUE, swap turn
call SwapTurn
xor a
- ld [wce56], a
+ ld [wIsSwapTurnPending], a
-.draw_menu
+; prompt player to choose either own Play Area or opponent's
+.draw_menu_1
xor a
- ld hl, PlayAreaMenuParameters
+ ld hl, .PlayAreaMenuParameters
call InitializeMenuParameters
call DrawWideTextBox
-
- ld hl, YourOrOppPlayAreaData
+ ld hl, .YourOrOppPlayAreaData
call PlaceTextItems
-.loop_1
+.loop_input_1
call DoFrame
- call HandleMenuInput ; await input
- jr nc, .loop_1
- cp $ff
- jr z, .loop_1
+ call HandleMenuInput
+ jr nc, .loop_input_1
+ cp -1
+ jr z, .loop_input_1 ; can't use B btn
call EraseCursor
ldh a, [hCurMenuItem]
or a
- jp nz, Func_8883 ; jump if not first option
+ jp nz, .PrepareYourPlayAreaSelection ; jump if not Opp Play Area
-; hCurMenuItem = 0
+; own Play Area was chosen
ld a, [wCheckMenuPlayAreaWhichDuelist]
ld b, a
ldh a, [hWhoseTurn]
cp b
- jr z, .text
+ jr z, .text_1
; switch the play area to draw
ld h, a
ld l, a
call DrawYourOrOppPlayAreaScreen
xor a
- ld [wce56], a
+ ld [wIsSwapTurnPending], a
-.text
+.text_1
call DrawWideTextBox
lb de, 1, 14
call InitTextPrinting
@@ -1440,43 +1440,43 @@ Func_8764: ; 8764 (2:4764)
call ProcessTextFromID
xor a
- ld [wPrizeCardCursorPosition], a
- ld de, Func_8764_TransitionTable
- ld hl, wce53
+ ld [wYourOrOppPlayAreaCurPosition], a
+ ld de, PeekYourPlayAreaTransitionTable
+ ld hl, wTransitionTablePtr
ld [hl], e
inc hl
ld [hl], d
-.loop_2
+.loop_input_2
ld a, $01
ld [wVBlankOAMCopyToggle], a
call DoFrame
- call Func_89ae
- jr c, .asm_87e7
- jr .loop_2
-.asm_87e7
- cp $ff
- jr nz, .asm_87f0
+ call YourOrOppPlayAreaScreen_HandleInput
+ jr c, .selection_cancelled
+ jr .loop_input_2
+.selection_cancelled
+ cp -1
+ jr nz, .selection_made
call ZeroObjectPositionsWithCopyToggleOn
- jr .swap
-.asm_87f0
- ld hl, .asm_87f8
+ jr .check_swap
+.selection_made
+ ld hl, .SelectionFunctionTable
call JumpToFunctionInTable
- jr .loop_2
+ jr .loop_input_2
-.asm_87f8
+.SelectionFunctionTable
rept 6
- dw Func_8819
+ dw .SelectedPrize
endr
- dw Func_883c
- dw Func_8849
+ dw .SelectedOppsHand
+ dw .SelectedDeck
-YourOrOppPlayAreaData: ; 8808 (2:4808)
+.YourOrOppPlayAreaData ; 8808 (2:4808)
textitem 2, 14, YourPlayAreaText
textitem 2, 16, OppPlayAreaText
db $ff
-PlayAreaMenuParameters: ; 8811 (2:4811)
+.PlayAreaMenuParameters ; 8811 (2:4811)
db 1, 14 ; cursor x, cursor y
db 2 ; y displacement between items
db 2 ; number of items
@@ -1484,21 +1484,21 @@ PlayAreaMenuParameters: ; 8811 (2:4811)
db SYM_SPACE ; tile behind cursor
dw NULL ; function pointer if non-0
-Func_8819: ; 8819 (2:4819)
- ld a, [wPrizeCardCursorPosition]
+.SelectedPrize: ; 8819 (2:4819)
+ ld a, [wYourOrOppPlayAreaCurPosition]
ld c, a
- ld b, $01
+ ld b, $1
; left-shift b a number of times
; corresponding to this prize card
-.loop
+.loop_prize_bitmask
or a
- jr z, .asm_8827
+ jr z, .got_prize_bitmask
sla b
dec a
- jr .loop
+ jr .loop_prize_bitmask
-.asm_8827
+.got_prize_bitmask
ld a, DUELVARS_PRIZES
call GetTurnDuelistVariable
and b
@@ -1510,17 +1510,17 @@ Func_8819: ; 8819 (2:4819)
ld a, c
add DUELVARS_PRIZE_CARDS
call GetTurnDuelistVariable
- jr Func_8855
+ jr .ShowSelectedCard
-Func_883c: ; 883c (2:483c)
+.SelectedOppsHand ; 883c (2:483c)
call CreateHandCardList
ret c
ld hl, wDuelTempList
call ShuffleCards
ld a, [hl]
- jr Func_8855
+ jr .ShowSelectedCard
-Func_8849: ; 8849 (2:4849)
+.SelectedDeck ; 8849 (2:4849)
call CreateDeckCardList
ret c
ld a, %01111111
@@ -1533,11 +1533,12 @@ Func_8849: ; 8849 (2:4849)
; output:
; a = ce5c
; with upper bit set if turn was swapped
-Func_8855: ; 8855 (2:4855)
+.ShowSelectedCard ; 8855 (2:4855)
ld b, a
ld a, [wce5c]
or a
jr nz, .display
+ ; if wce5c is not set, set it as input deck index
ld a, b
ld [wce5c], a
.display
@@ -1549,8 +1550,8 @@ Func_8855: ; 8855 (2:4855)
ld [wVBlankOAMCopyToggle], a
pop af
-; if ce56 != 0, swap turn
- ld a, [wce56]
+; if wIsSwapTurnPending is TRUE, swap turn
+ ld a, [wIsSwapTurnPending]
or a
jr z, .dont_swap
call SwapTurn
@@ -1561,26 +1562,28 @@ Func_8855: ; 8855 (2:4855)
ld a, [wce5c]
ret
-Func_8883: ; 8883 (2:4883)
+; prepare menu parameters to handle selection
+; of player's own Play Area
+.PrepareYourPlayAreaSelection: ; 8883 (2:4883)
ld a, [wCheckMenuPlayAreaWhichDuelist]
ld b, a
ldh a, [hWhoseTurn]
cp b
- jr nz, .text
+ jr nz, .text_2
ld l, a
cp PLAYER_TURN
jr nz, .opponent
ld a, OPPONENT_TURN
- jr .draw
+ jr .draw_menu_2
.opponent
ld a, PLAYER_TURN
-.draw
+.draw_menu_2
ld h, a
call DrawYourOrOppPlayAreaScreen
-.text
+.text_2
call DrawWideTextBox
lb de, 1, 14
call InitTextPrinting
@@ -1588,19 +1591,19 @@ Func_8883: ; 8883 (2:4883)
call ProcessTextFromID
xor a
- ld [wPrizeCardCursorPosition], a
- ld de, Func_8883_TransitionTable
- ld hl, wce53
+ ld [wYourOrOppPlayAreaCurPosition], a
+ ld de, PeekOppPlayAreaTransitionTable
+ ld hl, wTransitionTablePtr
ld [hl], e
inc hl
ld [hl], d
call SwapTurn
- ld a, $01
- ld [wce56], a
- jp Func_8764.loop_2
+ ld a, TRUE
+ ld [wIsSwapTurnPending], a ; mark pending to swap turn
+ jp .loop_input_2
-Func_8764_TransitionTable: ; 88c2 (2:48c2)
+PeekYourPlayAreaTransitionTable: ; 88c2 (2:48c2)
cursor_transition $08, $28, $00, $04, $02, $01, $07
cursor_transition $30, $28, $20, $05, $03, $07, $00
cursor_transition $08, $38, $00, $00, $04, $03, $07
@@ -1610,7 +1613,7 @@ Func_8764_TransitionTable: ; 88c2 (2:48c2)
cursor_transition $78, $50, $00, $07, $07, $00, $01
cursor_transition $78, $28, $00, $07, $07, $00, $01
-Func_8883_TransitionTable: ; 88fa (2:48fa)
+PeekOppPlayAreaTransitionTable: ; 88fa (2:48fa)
cursor_transition $a0, $60, $20, $02, $04, $07, $01
cursor_transition $78, $60, $00, $03, $05, $00, $07
cursor_transition $a0, $50, $20, $04, $00, $06, $03
@@ -1620,8 +1623,68 @@ Func_8883_TransitionTable: ; 88fa (2:48fa)
cursor_transition $08, $38, $00, $07, $07, $05, $04
cursor_transition $08, $60, $00, $06, $06, $01, $00
-Func_8932: ; 8932 (2:4932)
- INCROM $8932, $8992
+_DrawAIPeekScreen: ; 8932 (2:4932)
+ push bc
+ call Set_OBJ_8x8
+ call LoadCursorTile
+ xor a
+ ld [wIsSwapTurnPending], a
+ ldh a, [hWhoseTurn]
+ ld l, a
+ ld de, PeekYourPlayAreaTransitionTable
+ pop bc
+ bit AI_PEEK_TARGET_HAND_F, b
+ jr z, .draw_play_area
+
+; AI chose the hand
+ call SwapTurn
+ ld a, TRUE
+ ld [wIsSwapTurnPending], a ; mark pending to swap turn
+ ldh a, [hWhoseTurn]
+ ld de, PeekOppPlayAreaTransitionTable
+.draw_play_area
+ ld h, a
+ push bc
+ push de
+ call DrawYourOrOppPlayAreaScreen
+ pop de
+ pop bc
+
+; get the right cursor position
+; depending on what action the AI chose
+; (prize card, hand, deck)
+ ld hl, wMenuInputTablePointer
+ ld [hl], e
+ inc hl
+ ld [hl], d
+ ld a, b
+ and $7f
+ cp $7f
+ jr nz, .prize_card
+; cursor on the deck
+ ld a, $7
+ ld [wYourOrOppPlayAreaCurPosition], a
+ jr .got_cursor_position
+.prize_card
+ bit AI_PEEK_TARGET_PRIZE_F, a
+ jr z, .hand
+ and $3f
+ ld [wYourOrOppPlayAreaCurPosition], a
+ jr .got_cursor_position
+.hand
+ ld a, $6
+ ld [wYourOrOppPlayAreaCurPosition], a
+.got_cursor_position
+ call YourOrOppPlayAreaScreen_HandleInput.draw_cursor
+
+ ld a, $1
+ ld [wVBlankOAMCopyToggle], a
+ ld a, [wIsSwapTurnPending]
+ or a
+ ret z
+ call SwapTurn
+ ret
+; 0x8992
LoadCursorTile: ; 8992 (2:4992)
ld de, v0Tiles0
@@ -1634,24 +1697,26 @@ LoadCursorTile: ; 8992 (2:4992)
db $e0, $c0, $98, $b0, $84, $8c, $83, $82
db $86, $8f, $9d, $be, $f4, $f8, $50, $60
-; similar to OpenInPlayAreaScreen_HandleInput
-Func_89ae: ; 89ae (2:49ae)
+; handles input inside the "Your Play Area" or "Opp Play Area" screens
+; returns carry if either A or B button were pressed
+; returns -1 in a if B button was pressed
+YourOrOppPlayAreaScreen_HandleInput: ; 89ae (2:49ae)
xor a
ld [wPlaysSfx], a
- ld hl, wce53
+; get the transition data for the prize card with cursor
+ ld hl, wTransitionTablePtr
ld e, [hl]
inc hl
ld d, [hl]
-
- ld a, [wPrizeCardCursorPosition]
+ ld a, [wYourOrOppPlayAreaCurPosition]
ld [wPrizeCardCursorTemporaryPosition], a
ld l, a
- ld h, 7
+ ld h, 7 ; length of each transition table item
call HtimesL
add hl, de
-; hl = [wce53] + 7 * wce52
+; get the transition index related to the directional input
ldh a, [hDPadHeld]
or a
jp z, .check_button
@@ -1692,10 +1757,10 @@ Func_89ae: ; 89ae (2:49ae)
; left
ld a, [hl]
.process_dpad
- ld [wPrizeCardCursorPosition], a
- cp $08 ; if a >= 0x8
+ ld [wYourOrOppPlayAreaCurPosition], a
+ cp $8 ; if a >= 0x8
jr nc, .next
- ld b, $01
+ ld b, $1
; this loop equals to
; b = (1 << a)
@@ -1716,7 +1781,7 @@ Func_89ae: ; 89ae (2:49ae)
; when no cards exist at the cursor,
ld a, [wPrizeCardCursorTemporaryPosition]
cp $06
- jr nz, Func_89ae
+ jr nz, YourOrOppPlayAreaScreen_HandleInput
; move once more in the direction (recursively) until it reaches an existing item.
; check if one of the dpad, left or right, is pressed.
@@ -1725,37 +1790,44 @@ Func_89ae: ; 89ae (2:49ae)
bit D_RIGHT_F, a
jr nz, .left_or_right
bit D_LEFT_F, a
- jr z, Func_89ae
+ jr z, YourOrOppPlayAreaScreen_HandleInput
.left_or_right
+ ; if started with 5 or 6 prize cards
+ ; can switch sides normally,
ld a, [wDuelInitialPrizes]
- cp $05
+ cp PRIZES_5
jr nc, .next
- ld a, [wPrizeCardCursorPosition]
- cp $05
- jr nz, .asm_8a28
- ld a, $03
- ld [wPrizeCardCursorPosition], a
- jr .asm_8a2d
+ ; else if it's last card,
+ ld a, [wYourOrOppPlayAreaCurPosition]
+ cp 5
+ jr nz, .not_last_card
+ ; place it at pos 3
+ ld a, 3
+ ld [wYourOrOppPlayAreaCurPosition], a
+ jr .ok
+.not_last_card
+ ; otherwise place at pos 2
+ ld a, 2
+ ld [wYourOrOppPlayAreaCurPosition], a
-.asm_8a28
- ld a, $02
- ld [wPrizeCardCursorPosition], a
-.asm_8a2d
+.ok
ld a, [wDuelInitialPrizes]
- cp $03
- jr nc, .asm_8a3c
- ld a, [wPrizeCardCursorPosition]
- sub $02
- ld [wPrizeCardCursorPosition], a
-.asm_8a3c
- ld a, [wPrizeCardCursorPosition]
+ cp PRIZES_3
+ jr nc, .handled_cursor_pos
+ ; in this case can just sub 2 from pos
+ ld a, [wYourOrOppPlayAreaCurPosition]
+ sub 2
+ ld [wYourOrOppPlayAreaCurPosition], a
+
+.handled_cursor_pos
+ ld a, [wYourOrOppPlayAreaCurPosition]
ld [wPrizeCardCursorTemporaryPosition], a
- ld b, $01
+ ld b, $1
jr .make_bitmask_loop
.next
- ld a, $01
+ ld a, TRUE
ld [wPlaysSfx], a
; reset cursor blink
@@ -1778,7 +1850,7 @@ Func_89ae: ; 89ae (2:49ae)
call .draw_cursor
ld a, $01
call PlaySFXConfirmOrCancel
- ld a, [wPrizeCardCursorPosition]
+ ld a, [wYourOrOppPlayAreaCurPosition]
scf
ret
@@ -1798,16 +1870,16 @@ Func_89ae: ; 89ae (2:49ae)
.draw_cursor
call ZeroObjectPositions
- ld hl, wce53
+ ld hl, wTransitionTablePtr
ld e, [hl]
inc hl
ld d, [hl]
- ld a, [wPrizeCardCursorPosition]
+ ld a, [wYourOrOppPlayAreaCurPosition]
ld l, a
ld h, 7
call HtimesL
add hl, de
-; hl = [wce53] + 7 * wce52
+; hl = [wTransitionTablePtr] + 7 * wce52
ld d, [hl]
inc hl
@@ -1826,11 +1898,293 @@ ZeroObjectPositionsWithCopyToggleOn: ; 8aa1 (2:4aa1)
ld [wVBlankOAMCopyToggle], a
ret
-Func_8aaa: ; 8aaa (2:4aaa)
- INCROM $8aaa, $8b85
+; handles the screen for Player to select prize card(s)
+_SelectPrizeCards: ; 8aaa (2:4aaa)
+ xor a
+ call GetFirstSetPrizeCard
+ ld [wYourOrOppPlayAreaCurPosition], a
+ ld de, hTempPlayAreaLocation_ffa1
+ ld hl, wSelectedPrizeCardListPtr
+ ld [hl], e
+ inc hl
+ ld [hl], d
+
+.check_prize_cards_to_select
+ ld a, [wNumberOfPrizeCardsToSelect]
+ or a
+ jr z, .done_selection
+ ld a, DUELVARS_PRIZES
+ call GetTurnDuelistVariable
+ or a
+ jr nz, .got_prizes
+
+.done_selection
+ ld a, DUELVARS_PRIZES
+ call GetTurnDuelistVariable
+ ldh [hTemp_ffa0], a
+ ld a, [wSelectedPrizeCardListPtr + 0]
+ ld l, a
+ ld a, [wSelectedPrizeCardListPtr + 1]
+ ld h, a
+ ld [hl], $ff
+ ret
+
+.got_prizes
+ ldh a, [hWhoseTurn]
+ ld h, a
+ ld l, a
+ call DrawYourOrOppPlayAreaScreen
+ call DrawWideTextBox
+ lb de, 1, 14
+ call InitTextPrinting
+ ldtx hl, PleaseChooseAPrizeText
+ call ProcessTextFromID
+ ld de, .cursor_transition_table
+ ld hl, wMenuInputTablePointer
+ ld [hl], e
+ inc hl
+ ld [hl], d
+.loop_handle_input
+ ld a, $1
+ ld [wVBlankOAMCopyToggle], a
+ call DoFrame
+ call YourOrOppPlayAreaScreen_HandleInput
+ jr nc, .loop_handle_input
+ cp $ff
+ jr z, .loop_handle_input
+
+ call ZeroObjectPositionsWithCopyToggleOn
+
+; get prize bit mask that corresponds
+; to the one pointed by the cursor
+ ld a, [wYourOrOppPlayAreaCurPosition]
+ ld c, a
+ ld b, $1
+.loop
+ or a
+ jr z, .got_prize_mask
+ sla b
+ dec a
+ jr .loop
+
+.got_prize_mask
+ ; if cursor prize is not set,
+ ; then return to input loop
+ ld a, DUELVARS_PRIZES
+ call GetTurnDuelistVariable
+ and b
+ jp z, .loop_handle_input ; can be jr
+
+ ; remove prize
+ ld a, DUELVARS_PRIZES
+ call GetTurnDuelistVariable
+ sub b
+ ld [hl], a
+
+ ; get its deck index
+ ld a, c
+ add DUELVARS_PRIZE_CARDS
+ call GetTurnDuelistVariable
+
+ ld hl, wSelectedPrizeCardListPtr
+ ld e, [hl]
+ inc hl
+ ld d, [hl]
+ ld [de], a ; store deck index
+ inc de
+ ld [hl], d
+ dec hl
+ ld [hl], e
+
+ ; add prize card to hand
+ call AddCardToHand
+ call LoadCardDataToBuffer1_FromDeckIndex
+ call Set_OBJ_8x16
+ bank1call OpenCardPage_FromHand
+ ld a, [wNumberOfPrizeCardsToSelect]
+ dec a
+ ld [wNumberOfPrizeCardsToSelect], a
+ ld a, [wYourOrOppPlayAreaCurPosition]
+ call GetFirstSetPrizeCard
+ ld [wYourOrOppPlayAreaCurPosition], a
+ jp .check_prize_cards_to_select
+
+.cursor_transition_table
+ cursor_transition $08, $28, $00, $04, $02, $01, $01
+ cursor_transition $30, $28, $20, $05, $03, $00, $00
+ cursor_transition $08, $38, $00, $00, $04, $03, $03
+ cursor_transition $30, $38, $20, $01, $05, $02, $02
+ cursor_transition $08, $48, $00, $02, $00, $05, $05
+ cursor_transition $30, $48, $20, $03, $01, $04, $04
+; 0x8b85
+
+_DrawPlayAreaToPlacePrizeCards: ; 8b85 (2:4b85)
+ xor a
+ ld [wTileMapFill], a
+ call ZeroObjectPositions
+ call EmptyScreen
+ call LoadSymbolsFont
+ call LoadPlacingThePrizesScreenTiles
+
+ ldh a, [hWhoseTurn]
+ ld [wCheckMenuPlayAreaWhichLayout], a
+ ld [wCheckMenuPlayAreaWhichDuelist], a
+
+ lb de, 0, 10
+ ld c, 3
+ call DrawPlayArea_BenchCards
+ ld hl, .player_icon_coordinates
+ call DrawYourOrOppPlayArea_Icons.draw
+ lb de, 8, 6
+ ld a, $a0
+ lb hl, 1, 4
+ lb bc, 4, 3
+ call FillRectangle
+
+ call SwapTurn
+ ld a, TRUE
+ ld [wIsSwapTurnPending], a ; mark pending to swap turn
+ ldh a, [hWhoseTurn]
+ ld [wCheckMenuPlayAreaWhichDuelist], a
+ lb de, 6, 0
+ ld c, 3
+ call DrawPlayArea_BenchCards
+ ld hl, .opp_icon_coordinates
+ call DrawYourOrOppPlayArea_Icons.draw
+ lb de, 8, 3
+ ld a, $a0
+ lb hl, 1, 4
+ lb bc, 4, 3
+ call FillRectangle
+ call SwapTurn
+ ret
+
+.player_icon_coordinates
+ db 15, 11
+ db 15, 6
+ db 15, 8
+
+.opp_icon_coordinates
+ db 0, 0
+ db 0, 4
+ db 0, 2
+; 0x8bf2
+
+; seems like a function to draw prize cards
+; given a list of coordinates in hl
+; unreferenced?
+; hl = pointer to coords
+Func_8bf2: ; 8bf2 (2:4bf2)
+ push hl
+ ld a, [wCheckMenuPlayAreaWhichDuelist]
+ ld h, a
+ ld l, DUELVARS_PRIZES
+ ld a, [hl]
+ pop hl
+
+ ld b, 0
+ push af
+.loop_prize_cards
+ inc b
+ ld a, [wDuelInitialPrizes]
+ inc a
+ cp b
+ jr z, .done
+ pop af
+ srl a
+ push af
+ jr c, .not_taken
+ ; same tile whether the prize card is taken or not
+ ld a, $ac
+ jr .got_tile
+.not_taken
+ ld a, $ac
+.got_tile
+ ld e, [hl]
+ inc hl
+ ld d, [hl]
+ inc hl
+ push hl
+ push bc
+ lb hl, 0, 0
+ lb bc, 1, 1
+ call FillRectangle
+ ld a, [wConsole]
+ cp CONSOLE_CGB
+ jr nz, .skip_pal
+ ld a, $02
+ lb bc, 1, 1
+ lb hl, 0, 0
+ call BankswitchVRAM1
+ call FillRectangle
+ call BankswitchVRAM0
+.skip_pal
+ pop bc
+ pop hl
+ jr .loop_prize_cards
+.done
+ pop af
+ ret
+; 0x8c3f
+
+; unknown data
+; unreferenced?
+Data_8c3f: ; 8c3f (6:4c3f)
+ db $06, $05, $06, $06, $07, $05, $07, $06, $08, $05, $08, $06, $05, $0e, $05, $0d, $04, $0e, $04, $0d, $03, $0e, $03, $0d
+; 0x8c57
+
+; gets the first prize card index that is set
+; beginning from index in register a
+; a = prize card index
+GetFirstSetPrizeCard: ; 8c57 (2:4c57)
+ push bc
+ push de
+ push hl
+ ld e, PRIZES_6
+ ld c, a
+ ldh a, [hWhoseTurn]
+ ld h, a
+ ld l, DUELVARS_PRIZES
+ ld d, [hl]
+.loop_prizes
+ call .GetPrizeMask
+ and d
+ jr nz, .done ; prize is set
+ dec e
+ jr nz, .next_prize
+ ld c, 0
+ jr .done
+.next_prize
+ inc c
+ ld a, PRIZES_6
+ cp c
+ jr nz, .loop_prizes
+ ld c, 0
+ jr .loop_prizes
+
+.done
+ ld a, c ; first prize index that is set
+ pop hl
+ pop de
+ pop bc
+ ret
-Func_8b85: ; 8b85 (2:4b85)
- INCROM $8b85, $8c8e
+; returns 1 shifted left by c bits
+.GetPrizeMask
+ push bc
+ ld a, c
+ ld b, $1
+.loop
+ or a
+ jr z, .got_mask
+ sla b
+ dec a
+ jr .loop
+.got_mask
+ ld a, b
+ pop bc
+ ret
+; 0x8c8e
OpenGlossaryScreen_TransitionTable:
cursor_transition $08, $28, $00, $04, $01, $05, $05
@@ -1845,7 +2199,7 @@ OpenGlossaryScreen_TransitionTable:
cursor_transition $58, $68, $00, $08, $05, $04, $04
; copies DECK_SIZE number of cards from de to hl in SRAM
-Func_8cd4: ; 8cd4 (2:4cd4)
+CopyDeckFromSRAM: ; 8cd4 (2:4cd4)
push bc
call EnableSRAM
ld b, DECK_SIZE
@@ -1862,31 +2216,35 @@ Func_8cd4: ; 8cd4 (2:4cd4)
ret
; 0x8ce7
-Func_8ce7: ; 8ce7 (2:4ce7)
+; clears some WRAM addresses to act as
+; terminator bytes to wFilteredCardList and wCurDeckCards
+WriteCardListsTerminatorBytes: ; 8ce7 (2:4ce7)
xor a
- ld hl, wceda
+ ld hl, wFilteredCardList
ld bc, DECK_SIZE
add hl, bc
ld [hl], a ; wcf16
- ld hl, wcf17
- ld bc, $50
+ ld hl, wCurDeckCards
+ ld bc, DECK_CONFIG_BUFFER_SIZE
add hl, bc
- ld [hl], a
+ ld [hl], a ; wCurDeckCardsTerminator
ret
; 0x8cf9
+; inits some SRAM addresses
Func_8cf9: ; 8cf9 (2:4cf9)
call EnableSRAM
xor a
- ld hl, sb703
+ ld hl, sHasPromotionalCards
ld [hli], a
- inc a
+ inc a ; $1
ld [hli], a
ld [hli], a
ld [hl], a
- ld [sb701], a
+ ld [sUnnamedDeckCounter], a
call DisableSRAM
-; fallthrough
+; ret missing
+; unintentional fallthrough
; loads the Hard Cards icon gfx to v0Tiles2
LoadHandCardsIcon: ; 8d0b (2:4d0b)
@@ -1899,7 +2257,7 @@ HandCardsGfx: ; 8d15 (2:4d15)
INCBIN "gfx/hand_cards.2bpp"
db $00 ; end of data
-Func_8d56: ; 8d56 (2:4d56)
+EmptyScreenAndLoadFontDuelAndHandCardsIcons: ; 8d56 (2:4d56)
xor a
ld [wTileMapFill], a
call EmptyScreen
@@ -1935,9 +2293,14 @@ Func_8d78: ; 8d78 (2:4d78)
ret
; 0x8d9d
-; copies 7 bytes from hl to wcfd1
-Func_8d9d: ; 8d9d (2:4d9d)
- ld de, wcfd1
+; inits the following deck building params from hl:
+; wMaxNumCardsAllowed
+; wSameNameCardsLimit
+; wIncludeCardsInDeck
+; wDeckConfigurationMenuHandlerFunction
+; wDeckConfigurationMenuTransitionTable
+InitDeckBuildingParams: ; 8d9d (2:4d9d)
+ ld de, wMaxNumCardsAllowed
ld b, $7
.loop
ld a, [hli]
@@ -1947,131 +2310,161 @@ Func_8d9d: ; 8d9d (2:4d9d)
jr nz, .loop
ret
-Data_8da9: ; 8da9 (2:4da9)
- db $50, $04, $01
+DeckBuildingParams: ; 8da9 (2:4da9)
+ db DECK_CONFIG_BUFFER_SIZE ; max number of cards
+ db MAX_NUM_SAME_NAME_CARDS ; max number of same name cards
+ db TRUE ; whether to include deck cards
dw HandleDeckConfigurationMenu
dw DeckConfigurationMenu_TransitionTable
+; 0x8db0
- INCROM $8db0, $8db0
-
-Func_8db0: ; 8db0 (2:4db0)
- ld hl, Data_8da9
- call Func_8d9d
- ld a, $ff
- call Func_9168
+DeckSelectionMenu: ; 8db0 (2:4db0)
+ ld hl, DeckBuildingParams
+ call InitDeckBuildingParams
+ ld a, ALL_DECKS
+ call DrawDecksScreen
xor a
-Func_8dbc: ; 8dbc (2:4dbc)
- ld hl, Unknown_8de2
+.init_menu_params
+ ld hl, .DeckSelectionMenuParameters
call InitializeMenuParameters
ldtx hl, PleaseSelectDeckText
call DrawWideTextBox_PrintText
-.asm_8dc8
+.loop_input
call DoFrame
- jr c, Func_8dbc
- call Func_8dea
- jr c, Func_8dbc
+ jr c, .init_menu_params ; reinit menu parameters
+ call HandleStartButtonInDeckSelectionMenu
+ jr c, .init_menu_params
call HandleMenuInput
- jr nc, .asm_8dc8
+ jr nc, .loop_input
ldh a, [hCurMenuItem]
cp $ff
- ret z
- ld [wceb1], a
- jp Func_8e42
-
-Unknown_8de2: ; 8de2 (2:4de2)
- INCROM $8de2, $8dea
+ ret z ; B btn returns
+; A btn pressed on a deck
+ ld [wCurDeck], a
+ jp DeckSelectionSubMenu
+
+.DeckSelectionMenuParameters
+ db 1, 2 ; cursor x, cursor y
+ db 3 ; y displacement between items
+ db 4 ; number of items
+ db SYM_CURSOR_R ; cursor tile number
+ db SYM_SPACE ; tile behind cursor
+ dw NULL ; function pointer if non-0
-Func_8dea: ; 8dea (2:4dea)
+; handles START button press when in deck selection menu
+; does nothing if START button isn't pressed
+; if a press was handled, returns carry
+; prints "There is no deck here!" if the selected deck is empty
+HandleStartButtonInDeckSelectionMenu: ; 8dea (2:4dea)
ldh a, [hDPadHeld]
and START
- ret z
+ ret z ; skip
+
+; set menu item as current deck
ld a, [wCurMenuItem]
- ld [wceb1], a
- call Func_8ff2
- jp nc, Func_8e05
+ ld [wCurDeck], a
+ call CheckIfCurDeckIsValid
+ jp nc, .valid_deck ; can be jr
+
+; not a valid deck, cancel
ld a, $ff ; cancel
call PlaySFXConfirmOrCancel
- call Func_8fe8
+ call PrintThereIsNoDeckHereText
scf
ret
-Func_8e05: ; 8e05 (2:4e05)
+.valid_deck
ld a, $1
call PlaySFXConfirmOrCancel
call GetPointerToDeckCards
push hl
call GetPointerToDeckName
pop de
- call Func_8e1f
- ld a, $ff
- call Func_9168
- ld a, [wceb1]
+ call OpenDeckConfirmationMenu
+ ld a, ALL_DECKS
+ call DrawDecksScreen
+ ld a, [wCurDeck]
scf
ret
+; 0x8e1f
-; copies deck in hl to wcfb9
-; copies deck in de to wcf17
-Func_8e1f: ; 8e1f (2:4e1f)
+OpenDeckConfirmationMenu: ; 8e1f (2:4e1f)
+; copy deck name
push de
- ld de, wcfb9
+ ld de, wCurDeckName
call CopyListFromHLToDEInSRAM
pop de
- ld hl, wcf17
- call Func_8cd4
- ld a, 9
- ld hl, wcebb
+
+; copy deck cards
+ ld hl, wCurDeckCards
+ call CopyDeckFromSRAM
+
+ ld a, NUM_FILTERS
+ ld hl, wCardFilterCounts
call ClearNBytesFromHL
ld a, DECK_SIZE
- ld [wcecc], a
- ld hl, wcebb
+ ld [wTotalCardCount], a
+ ld hl, wCardFilterCounts
ld [hl], a
- call Func_9e41
+ call HandleDeckConfirmationMenu
ret
+; 0x8e42
-Func_8e42: ; 8e42 (2:4e42)
+; handles the submenu when selecting a deck
+; (Modify Deck, Select Deck, Change Name and Cancel)
+DeckSelectionSubMenu: ; 8e42 (2:4e42)
call DrawWideTextBox
- ld hl, Unknown_9027
+ ld hl, DeckSelectionData
call PlaceTextItems
call ResetCheckMenuCursorPositionAndBlink
-.asm_8e4e
+.loop_input
call DoFrame
call HandleCheckMenuInput
- jp nc, .asm_8e4e
+ jp nc, .loop_input
cp $ff
- jr nz, .asm_8e64
+ jr nz, .option_selected
+; B btn pressed
+; erase cursor and go back
+; to deck selection handling
call EraseCheckMenuCursor
- ld a, [wceb1]
- jp Func_8dbc
-.asm_8e64
+ ld a, [wCurDeck]
+ jp DeckSelectionMenu.init_menu_params
+
+.option_selected
ld a, [wCheckMenuCursorXPosition]
or a
- jp nz, Func_8f8a
+ jp nz, DeckSelectionSubMenu_SelectOrCancel
ld a, [wCheckMenuCursorYPosition]
or a
- jp nz, .asm_8ecf
+ jp nz, .ChangeName
+
+; Modify Deck
+; read deck from SRAM
+; TODO
call GetPointerToDeckCards
ld e, l
ld d, h
- ld hl, wcf17
- call Func_8cd4
+ ld hl, wCurDeckCards
+ call CopyDeckFromSRAM
ld a, 20
- ld hl, wcfb9
+ ld hl, wCurDeckName
call ClearNBytesFromHL
- ld de, wcfb9
+ ld de, wCurDeckName
call GetPointerToDeckName
call CopyListFromHLToDEInSRAM
- call Func_9345
+
+ call HandleDeckBuildScreen
jr nc, .asm_8ec4
call EnableSRAM
- ld hl, wcf17
- call Func_910a
+ ld hl, wCurDeckCards
+ call DecrementDeckCardsInCollection
call GetPointerToDeckCards
- call Func_9152
+ call AddDeckToCollection
ld e, l
ld d, h
- ld hl, wcf17
- ld b, $3c
+ ld hl, wCurDeckCards
+ ld b, DECK_SIZE
.asm_8ea9
ld a, [hli]
ld [de], a
@@ -2081,73 +2474,80 @@ Func_8e42: ; 8e42 (2:4e42)
call GetPointerToDeckName
ld d, h
ld e, l
- ld hl, wcfb9
+ ld hl, wCurDeckName
call CopyListFromHLToDE
call GetPointerToDeckName
ld a, [hl]
call DisableSRAM
or a
- jr z, .asm_8edb
+ jr z, .get_input_deck_name
.asm_8ec4
- ld a, $ff
- call Func_9168
- ld a, [wceb1]
- jp Func_8dbc
-.asm_8ecf
- call Func_8ff2
- jp nc, .asm_8edb
- call Func_8fe8
- jp Func_8dbc
-.asm_8edb
+ ld a, ALL_DECKS
+ call DrawDecksScreen
+ ld a, [wCurDeck]
+ jp DeckSelectionMenu.init_menu_params
+
+.ChangeName
+ call CheckIfCurDeckIsValid
+ jp nc, .get_input_deck_name
+ call PrintThereIsNoDeckHereText
+ jp DeckSelectionMenu.init_menu_params
+.get_input_deck_name
ld a, 20
- ld hl, wcfb9
+ ld hl, wCurDeckName
call ClearNBytesFromHL
- ld de, wcfb9
+ ld de, wCurDeckName
call GetPointerToDeckName
call CopyListFromHLToDEInSRAM
- call Func_8f05
+ call InputCurDeckName
call GetPointerToDeckName
ld d, h
ld e, l
- ld hl, wcfb9
+ ld hl, wCurDeckName
call CopyListFromHLToDEInSRAM
- ld a, $ff
- call Func_9168
- ld a, [wceb1]
- jp Func_8dbc
-
-Func_8f05: ; 8f05 (2:4f05)
- ld a, [wceb1]
+ ld a, ALL_DECKS
+ call DrawDecksScreen
+ ld a, [wCurDeck]
+ jp DeckSelectionMenu.init_menu_params
+
+; gets current deck's name from user input
+InputCurDeckName: ; 8f05 (2:4f05)
+ ld a, [wCurDeck]
or a
- jr nz, .asm_8f10
- ; it refers to a data in the other bank without any bank desc.
+ jr nz, .deck_2
ld hl, Deck1Data
- jr .asm_8f23
-.asm_8f10
+ jr .got_deck_ptr
+.deck_2
dec a
- jr nz, .asm_8f18
+ jr nz, .deck_3
ld hl, Deck2Data
- jr .asm_8f23
-.asm_8f18
+ jr .got_deck_ptr
+.deck_3
dec a
- jr nz, .asm_8f20
+ jr nz, .deck_4
ld hl, Deck3Data
- jr .asm_8f23
-.asm_8f20
+ jr .got_deck_ptr
+.deck_4
ld hl, Deck4Data
-.asm_8f23
+.got_deck_ptr
ld a, MAX_DECK_NAME_LENGTH
lb bc, 4, 1
- ld de, wcfb9
+ ld de, wCurDeckName
farcall InputDeckName
- ld a, [wcfb9]
+ ld a, [wCurDeckName]
or a
ret nz
- call Func_8f38
+ ; empty name
+ call .UnnamedDeck
ret
-Func_8f38: ; 8f38 (2:4f38)
- ld hl, sb701
+; handles the naming of unnamed decks
+; inputs as the deck name "DECK XXX"
+; where XXX is the current unnamed deck counter
+.UnnamedDeck
+; read the current unnamed deck number
+; and convert it to text
+ ld hl, sUnnamedDeckCounter
call EnableSRAM
ld a, [hli]
ld h, [hl]
@@ -2155,20 +2555,21 @@ Func_8f38: ; 8f38 (2:4f38)
ld l, a
ld de, wDefaultText
call TwoByteNumberToText
- ld hl, wcfb9
+
+ ld hl, wCurDeckName
ld [hl], $6
inc hl
- ld [hl], $44
+ ld [hl], "D"
inc hl
- ld [hl], $65
+ ld [hl], "e"
inc hl
- ld [hl], $63
+ ld [hl], "c"
inc hl
- ld [hl], $6b
+ ld [hl], "k"
inc hl
- ld [hl], $20
+ ld [hl], " "
inc hl
- ld de, wc592
+ ld de, wDefaultText + 2
ld a, [de]
inc de
ld [hli], a
@@ -2179,39 +2580,53 @@ Func_8f38: ; 8f38 (2:4f38)
ld [hli], a
xor a
ld [hl], a
- ld hl, sb701
+
+; increment the unnamed deck counter
+ ld hl, sUnnamedDeckCounter
call EnableSRAM
ld e, [hl]
inc hl
ld d, [hl]
- ld a, $3
+; capped at 999
+ ld a, HIGH(MAX_UNNAMED_DECK_NUM)
cp d
- jr nz, .asm_8f82
- ld a, $e7
+ jr nz, .incr_counter
+ ld a, LOW(MAX_UNNAMED_DECK_NUM)
cp e
- jr nz, .asm_8f82
- ld de, $0000
-.asm_8f82
+ jr nz, .incr_counter
+ ; reset counter
+ ld de, 0
+.incr_counter
inc de
ld [hl], d
dec hl
ld [hl], e
call DisableSRAM
ret
+; 0x8f8a
-Func_8f8a: ; 8f8a (2:4f8a)
+; handle deck selection sub-menu
+; the option is either "Select Deck" or "Cancel"
+; depending on the cursor Y pos
+DeckSelectionSubMenu_SelectOrCancel: ; 8f8a (2:4f8a)
ld a, [wCheckMenuCursorYPosition]
or a
- jp nz, Func_9026
- call Func_8ff2
- jp nc, Func_8f9d
- call Func_8fe8
- jp Func_8dbc
+ jp nz, CancelDeckSelectionSubMenu
+
+; select deck
+ call CheckIfCurDeckIsValid
+ jp nc, .SelectDeck
+ ; invalid deck
+ call PrintThereIsNoDeckHereText
+ jp DeckSelectionMenu.init_menu_params
-Func_8f9d: ; 8f9d (2:4f9d)
+.SelectDeck
call EnableSRAM
ld a, [sCurrentlySelectedDeck]
call DisableSRAM
+
+; draw empty rectangle on currently selected deck
+; i.e. erase the Hand Cards Gfx icon
ld h, $3
ld l, a
call HtimesL
@@ -2222,55 +2637,96 @@ Func_8f9d: ; 8f9d (2:4f9d)
lb hl, 0, 0
lb bc, 2, 2
call FillRectangle
- ld a, [wceb1]
+
+; set current deck as the selected deck
+; and draw the Hand Cards Gfx icon
+ ld a, [wCurDeck]
call EnableSRAM
ld [sCurrentlySelectedDeck], a
call DisableSRAM
- call DrawHandCardsTileOnSelectedDeck
+ call DrawHandCardsTileOnCurDeck
+
+; print "<DECK> was chosen as the dueling deck!"
call GetPointerToDeckName
call EnableSRAM
- call Func_9253
+ call CopyDeckName
call DisableSRAM
xor a
ld [wTxRam2], a
ld [wTxRam2 + 1], a
ldtx hl, ChosenAsDuelingDeckText
call DrawWideTextBox_WaitForInput
- ld a, [wceb1]
- jp Func_8dbc
+ ld a, [wCurDeck]
+ jp DeckSelectionMenu.init_menu_params
+; 0x8fe8
-Func_8fe8: ; 8fe8 (2:4fe8)
+PrintThereIsNoDeckHereText: ; 8fe8 (2:4fe8)
ldtx hl, ThereIsNoDeckHereText
call DrawWideTextBox_WaitForInput
- ld a, [wceb1]
+ ld a, [wCurDeck]
ret
-Func_8ff2: ; 8ff2 (2:4ff2)
- ld a, [wceb1]
- ld hl, wceb2
+; returns carry if deck in wCurDeck
+; is not a valid deck
+CheckIfCurDeckIsValid: ; 8ff2 (2:4ff2)
+ ld a, [wCurDeck]
+ ld hl, wDecksValid
ld b, $0
ld c, a
add hl, bc
ld a, [hl]
or a
- ret nz
+ ret nz ; is valid
scf
- ret
+ ret ; is not valid
; 0x9001
- INCROM $9001, $9026
+; write to $d00a the decimal representation (number characters)
+; of the value in hl
+; unreferenced?
+Func_9001: ; 9001 (2:5001)
+ ld de, $d00a
+ ld bc, -100
+ call .GetNumberChar
+ ld bc, -10
+ call .GetNumberChar
+ ld bc, -1
+ call .GetNumberChar
+ ret
+
+.GetNumberChar
+ ld a, SYM_0 - 1
+.loop
+ inc a
+ add hl, bc
+ jr c, .loop
+ ld [de], a
+ inc de
+ ld a, l
+ sub c
+ ld l, a
+ ld a, h
+ sbc b
+ ld h, a
+ ret
+; 0x9026
-Func_9026: ; 9026 (2:5026)
+CancelDeckSelectionSubMenu: ; 9026 (2:5026)
ret
-Unknown_9027: ; 9027 (2:5027)
- INCROM $9027, $9038
+DeckSelectionData: ; 9027 (2:5027)
+ textitem 2, 14, ModifyDeckText
+ textitem 12, 14, SelectDeckText
+ textitem 2, 16, ChangeNameText
+ textitem 12, 16, CancelText
+ db $ff
+; 0x9038
-; return, in hl, the pointer to sDeckXName where X is [wceb1] + 1
+; return, in hl, the pointer to sDeckXName where X is [wCurDeck] + 1
GetPointerToDeckName: ; 9038 (2:5038)
- ld a, [wceb1]
+ ld a, [wCurDeck]
ld h, a
- ld l, sDeck2Name - sDeck1Name
+ ld l, DECK_STRUCT_SIZE
call HtimesL
push de
ld de, sDeck1Name
@@ -2278,10 +2734,10 @@ GetPointerToDeckName: ; 9038 (2:5038)
pop de
ret
-; return, in hl, the pointer to sDeckXCards where X is [wceb1] + 1
+; return, in hl, the pointer to sDeckXCards where X is [wCurDeck] + 1
GetPointerToDeckCards: ; 9048 (2:5048)
push af
- ld a, [wceb1]
+ ld a, [wCurDeck]
ld h, a
ld l, sDeck2Cards - sDeck1Cards
call HtimesL
@@ -2342,7 +2798,7 @@ HandleCheckMenuInput: ; 9065 (2:5065)
ld e, a
.okay
- ld a, $01
+ ld a, TRUE
ld [wPlaysSfx], a
push de
call EraseCheckMenuCursor
@@ -2442,14 +2898,17 @@ PlaySFXConfirmOrCancel: ; 90fb (2:50fb)
pop af
ret
-Func_910a: ; 910a (2:510a)
+; goes through whole deck in hl
+; for each card ID, goes to its corresponding
+; entry in sCardCollection and decrements its count
+DecrementDeckCardsInCollection: ; 910a (2:510a)
push hl
ld b, $0
- ld d, $3c
-.asm_910f
+ ld d, DECK_SIZE
+.loop_deck
ld a, [hli]
or a
- jr z, .asm_911e
+ jr z, .done
ld c, a
push hl
ld hl, sCardCollection
@@ -2457,17 +2916,24 @@ Func_910a: ; 910a (2:510a)
dec [hl]
pop hl
dec d
- jr nz, .asm_910f
-.asm_911e
+ jr nz, .loop_deck
+.done
pop hl
ret
; 0x9120
-Func_9120: ; 9120 (2:5120)
+; like AddDeckToCollection, but takes care to
+; check if increasing the collection count would
+; go over MAX_AMOUNT_OF_CARD and caps it
+; this is because it's used within Gift Center,
+; so we cannot assume that the deck configuration
+; won't make it go over MAX_AMOUNT_OF_CARD
+; hl = deck configuration, with cards to add
+AddGiftCenterDeckCardsToCollection: ; 9120 (2:5120)
push hl
- ld b, $00
+ ld b, $0
ld d, DECK_SIZE
-.asm_9125
+.loop_deck
ld a, [hli]
or a
jr z, .done
@@ -2475,42 +2941,46 @@ Func_9120: ; 9120 (2:5120)
push hl
push de
push bc
- ld a, $ff
- call Func_a3ca
+ ld a, ALL_DECKS
+ call CreateCardCollectionListWithDeckCards
pop bc
pop de
ld hl, wTempCardCollection
add hl, bc
ld a, [hl]
- cp $63
- jr z, .asm_914c
- call EnableSRAM
+ cp MAX_AMOUNT_OF_CARD
+ jr z, .next_card ; capped
+ call EnableSRAM ; no DisableSRAM
ld hl, sCardCollection
add hl, bc
ld a, [hl]
- cp $80
- jr nz, .asm_914b
+ cp CARD_NOT_OWNED
+ jr nz, .incr
+ ; not owned
xor a
ld [hl], a
-.asm_914b
+.incr
inc [hl]
-.asm_914c
+.next_card
pop hl
dec d
- jr nz, .asm_9125
+ jr nz, .loop_deck
.done
pop hl
ret
; 0x9152
-Func_9152: ; 9152 (2:5152)
+; adds all cards in deck in hl to player's collection
+; assumes SRAM is enabled
+; hl = pointer to deck cards
+AddDeckToCollection: ; 9152 (2:5152)
push hl
ld b, $0
ld d, DECK_SIZE
-.asm_9157
+.loop_deck
ld a, [hli]
or a
- jr z, .asm_9166
+ jr z, .done
ld c, a
push hl
ld hl, sCardCollection
@@ -2518,14 +2988,17 @@ Func_9152: ; 9152 (2:5152)
inc [hl]
pop hl
dec d
- jr nz, .asm_9157
-.asm_9166
+ jr nz, .loop_deck
+.done
pop hl
ret
-Func_9168: ; 9168 (2:5168)
+; draws the screen which shows the player's current
+; deck configurations
+; a = DECK_* flags to pick which deck names to show
+DrawDecksScreen: ; 9168 (2:5168)
ld [hffb5], a
- call Func_8d56
+ call EmptyScreenAndLoadFontDuelAndHandCardsIcons
lb de, 0, 0
lb bc, 20, 4
call DrawRegularTextBox
@@ -2538,94 +3011,118 @@ Func_9168: ; 9168 (2:5168)
lb de, 0, 9
lb bc, 20, 4
call DrawRegularTextBox
- ld hl, Unknown_9242
+ ld hl, DeckNameMenuData
call PlaceTextItems
- ld a, 4
- ld hl, wceb2
+
+; mark all decks as invalid
+ ld a, NUM_DECKS
+ ld hl, wDecksValid
call ClearNBytesFromHL
+
+; for each deck, check if it has cards and if so
+; mark is as valid in wDecksValid
+
+; deck 1
ld a, [hffb5] ; should be ldh
bit 0, a
- jr z, .asm_91b0
+ jr z, .skip_name_1
ld hl, sDeck1Name
lb de, 6, 2
- call Func_926e
-.asm_91b0
+ call PrintDeckName
+.skip_name_1
ld hl, sDeck1Cards
- call Func_9314
- jr c, .asm_91bd
- ld a, $1
- ld [wceb2], a
-.asm_91bd
+ call CheckIfDeckHasCards
+ jr c, .deck_2
+ ld a, TRUE
+ ld [wDeck1Valid], a
+
+.deck_2
ld a, [hffb5] ; should be ldh
bit 1, a
- jr z, .asm_91cd
+ jr z, .skip_name_2
ld hl, sDeck2Name
lb de, 6, 5
- call Func_926e
-.asm_91cd
+ call PrintDeckName
+.skip_name_2
ld hl, sDeck2Cards
- call Func_9314
- jr c, .asm_91da
- ld a, $1
- ld [wceb3], a
-.asm_91da
+ call CheckIfDeckHasCards
+ jr c, .deck_3
+ ld a, TRUE
+ ld [wDeck2Valid], a
+
+.deck_3
ld a, [hffb5] ; should be ldh
bit 2, a
- jr z, .asm_91ea
+ jr z, .skip_name_3
ld hl, sDeck3Name
lb de, 6, 8
- call Func_926e
-.asm_91ea
+ call PrintDeckName
+.skip_name_3
ld hl, sDeck3Cards
- call Func_9314
- jr c, .asm_91f7
- ld a, $1
- ld [wceb4], a
-.asm_91f7
+ call CheckIfDeckHasCards
+ jr c, .deck_4
+ ld a, TRUE
+ ld [wDeck3Valid], a
+
+.deck_4
ld a, [hffb5] ; should be ldh
bit 3, a
- jr z, .asm_9207
+ jr z, .skip_name_4
ld hl, sDeck4Name
lb de, 6, 11
- call Func_926e
-.asm_9207
+ call PrintDeckName
+.skip_name_4
ld hl, sDeck4Cards
- call Func_9314
- jr c, .asm_9214
- ld a, $1
- ld [wceb5], a
-.asm_9214
+ call CheckIfDeckHasCards
+ jr c, .place_cursor
+ ld a, TRUE
+ ld [wDeck4Valid], a
+
+.place_cursor
+; places cursor on sCurrentlySelectedDeck
+; if it's an empty deck, then advance the cursor
+; until it's selecting a valid deck
call EnableSRAM
ld a, [sCurrentlySelectedDeck]
ld c, a
ld b, $0
- ld d, $2
-.asm_921f
- ld hl, wceb2
+ ld d, 2
+.check_valid_deck
+ ld hl, wDecksValid
add hl, bc
ld a, [hl]
or a
- jr nz, .asm_9234
+ jr nz, .valid_selected_deck
inc c
- ld a, $4
+ ld a, NUM_DECKS
cp c
- jr nz, .asm_921f
- ld c, $0
+ jr nz, .check_valid_deck
+ ld c, 0 ; roll back to deck 1
dec d
- jr z, .asm_9234
- jr .asm_921f
-.asm_9234
+ jr z, .valid_selected_deck
+ jr .check_valid_deck
+
+.valid_selected_deck
ld a, c
ld [sCurrentlySelectedDeck], a
call DisableSRAM
- call DrawHandCardsTileOnSelectedDeck
+ call DrawHandCardsTileOnCurDeck
call EnableLCD
ret
+; 0x9242
-Unknown_9242: ; 9242 (2:5242)
- INCROM $9242, $9253
+DeckNameMenuData: ; 9242 (2:5242)
+ textitem 4, 2, Deck1Text
+ textitem 4, 5, Deck2Text
+ textitem 4, 8, Deck3Text
+ textitem 4, 11, Deck4Text
+ db $ff
+; 0x9253
-Func_9253: ; 9253 (2:5253)
+; copies text from hl to wDefaultText
+; with " deck" appended to the end
+; hl = ptr to deck name
+CopyDeckName: ; 9253 (2:5253)
ld de, wDefaultText
call CopyListFromHLToDE
ld hl, wDefaultText
@@ -2635,16 +3132,22 @@ Func_9253: ; 9253 (2:5253)
add hl, bc
ld d, h
ld e, l
- ld hl, Data_92a7
+ ld hl, DeckNameSuffix
call CopyListFromHLToDE
ret
+; prints deck name given in hl in position de
+; if it's an empty deck, print "NEW DECK" instead
+; returns carry if it's an empty deck
+; hl = deck name (sDeck1Name ~ sDeck4Name)
; de = coordinates to print text
-Func_926e: ; 926e (2:526e)
+PrintDeckName: ; 926e (2:526e)
push hl
- call Func_9314
+ call CheckIfDeckHasCards
pop hl
- jr c, .asm_929c
+ jr c, .new_deck
+
+; print "<deck name> deck"
push de
ld de, wDefaultText
call CopyListFromHLToDEInSRAM
@@ -2655,7 +3158,7 @@ Func_926e: ; 926e (2:526e)
add hl, bc
ld d, h
ld e, l
- ld hl, Data_92a7
+ ld hl, DeckNameSuffix
call CopyListFromHLToDE
pop de
ld hl, wDefaultText
@@ -2663,16 +3166,18 @@ Func_926e: ; 926e (2:526e)
call ProcessText
or a
ret
-.asm_929c
+
+.new_deck
+; print "NEW DECK"
call InitTextPrinting
ldtx hl, NewDeckText
call ProcessTextFromID
scf
ret
-Data_92a7: ; 92a7 (2:52a7)
+DeckNameSuffix: ; 92a7 (2:52a7)
db " deck"
- db TX_END
+ done
; copies a $00-terminated list from hl to de
CopyListFromHLToDE: ; 92ad (2:52ad)
@@ -2691,31 +3196,41 @@ CopyListFromHLToDEInSRAM: ; 92b4 (2:52b4)
ret
; 0x92be
-Func_92be: ; 92be (2:52be)
+; appends text in hl to wDefaultText
+; then adds "deck" to the end
+; returns carry if deck has no cards
+; hl = text to append
+; de = input to InitTextPrinting
+AppendDeckName: ; 92be (2:52be)
push hl
- call Func_9314
+ call CheckIfDeckHasCards
pop hl
- ret c
+ ret c ; no cards
+
push de
+ ; append the text from hl
ld de, wDefaultText
call CopyListFromHLToDEInSRAM
+
+ ; get string length (up to DECK_NAME_SIZE_WO_SUFFIX)
ld hl, wDefaultText
call GetTextLengthInTiles
ld a, c
- cp 21
- jr c, .asm_92d8
- ld c, 21
-.asm_92d8
+ cp DECK_NAME_SIZE_WO_SUFFIX
+ jr c, .got_len
+ ld c, DECK_NAME_SIZE_WO_SUFFIX
+.got_len
ld b, $0
ld hl, wDefaultText
add hl, bc
ld d, h
ld e, l
+ ; append "deck" starting from the given length
ld hl, .text_start
ld b, .text_end - .text_start
call CopyNBytesFromHLToDE
- xor a
- ld [wc5aa], a
+ xor a ; TX_END
+ ld [wDefaultText + DECK_NAME_SIZE + 2], a
pop de
ld hl, wDefaultText
call InitTextPrinting
@@ -2728,23 +3243,31 @@ Func_92be: ; 92be (2:52be)
.text_end
; 0x9314
-Func_9314: ; 9314 (2:5314)
- ld bc, $0018
+; returns carry if the deck in hl
+; is not valid, that is, has no cards
+; alternatively, the direct address of the cards
+; can be used, since DECK_SIZE > DECK_NAME_SIZE
+; hl = deck name (sDeck1Name ~ sDeck4Name)
+; or deck cards (sDeck1Cards ~ sDeck4Cards)
+CheckIfDeckHasCards: ; 9314 (2:5314)
+ ld bc, DECK_NAME_SIZE
add hl, bc
call EnableSRAM
ld a, [hl]
call DisableSRAM
+ ; being max size means last char
+ ; is not TX_END, i.e. $0
or a
- jr nz, .asm_9324
+ jr nz, .max_size
scf
ret
-.asm_9324
+.max_size
or a
ret
; calculates the y coordinate of the currently selected deck
; and draws the hands card tile at that position
-DrawHandCardsTileOnSelectedDeck: ; 9326 (2:5326)
+DrawHandCardsTileOnCurDeck: ; 9326 (2:5326)
call EnableSRAM
ld a, [sCurrentlySelectedDeck]
call DisableSRAM
@@ -2763,144 +3286,168 @@ DrawHandCardsTileAtDE: ; 9339 (2:5339)
lb bc, 2, 2
call FillRectangle
ret
+; 0x9345
-Func_9345: ; 9345 (2:5345)
- call Func_8ce7
+; handles user input when selecting a card filter
+; when building a deck configuration
+; the handling of selecting cards themselves from the list
+; to add/remove to the deck is done in HandleDeckCardSelectionList
+HandleDeckBuildScreen: ; 9345 (2:5345)
+ call WriteCardListsTerminatorBytes
call CountNumberOfCardsForEachCardType
.skip_count
call DrawCardTypeIconsAndPrintCardCounts
xor a
- ld [wcea1], a
- ld [wced3], a
- call Func_993d
+ ld [wCardListVisibleOffset], a
+ ld [wCurCardTypeFilter], a ; FILTER_GRASS
+ call PrintFilteredCardList
.skip_draw
- ld hl, Data_9667
- call Func_9a6d
+ ld hl, FiltersCardSelectionParams
+ call InitCardSelectionParams
.wait_input
call DoFrame
ldh a, [hDPadHeld]
and START
- jr z, .no_start_btn
+ jr z, .no_start_btn_1
ld a, $01
call PlaySFXConfirmOrCancel
call ConfirmDeckConfiguration
- ld a, [wced3]
- ld [wNamingScreenCursorY], a
+ ld a, [wCurCardTypeFilter]
+ ld [wTempCardTypeFilter], a
jr .wait_input
-.no_start_btn
- ld a, [wced3]
+
+.no_start_btn_1
+ ld a, [wCurCardTypeFilter]
ld b, a
- ld a, [wNamingScreenCursorY]
+ ld a, [wTempCardTypeFilter]
cp b
jr z, .check_down_btn
- ld [wced3], a
- ld hl, wcea1
- ld [hl], $00
- call Func_993d
- ld a, $09
- ld [wNamingScreenKeyboardHeight], a
+ ; need to refresh the filtered card list
+ ld [wCurCardTypeFilter], a
+ ld hl, wCardListVisibleOffset
+ ld [hl], 0
+ call PrintFilteredCardList
+ ld a, NUM_FILTERS
+ ld [wCardListNumCursorPositions], a
.check_down_btn
ldh a, [hDPadHeld]
and D_DOWN
jr z, .no_down_btn
- call Func_9ad7
- jr .asm_93a9
+ call ConfirmSelectionAndReturnCarry
+ jr .jump_to_list
+
.no_down_btn
- call Func_9a83
+ call HandleCardSelectionInput
jr nc, .wait_input
ld a, [hffb3]
- cp $ff
- jp z, Func_9461
-.asm_93a9
- ld a, [wceab + 3]
+ cp $ff ; operation cancelled?
+ jp z, OpenDeckConfigurationMenu
+
+; input was made to jump to the card list
+.jump_to_list
+ ld a, [wNumEntriesInCurFilter]
or a
jr z, .wait_input
xor a
-.asm_93b0
- ld hl, Data_9670
- call Func_9a6d
- ld a, [wceab + 3]
- ld [wcfe4 + 2], a
- ld hl, wcecb
+.wait_list_input
+ ld hl, FilteredCardListSelectionParams
+ call InitCardSelectionParams
+ ld a, [wNumEntriesInCurFilter]
+ ld [wNumCardListEntries], a
+ ld hl, wNumVisibleCardListEntries
cp [hl]
- jr nc, .asm_93c5
- ld [wNamingScreenKeyboardHeight], a
-.asm_93c5
+ jr nc, .ok
+ ; if total number of entries is greater than or equal to
+ ; the number of visible entries, then set number of cursor positions
+ ; as number of visible entries
+ ld [wCardListNumCursorPositions], a
+.ok
ld hl, PrintDeckBuildingCardList
ld d, h
ld a, l
- ld hl, wcece
+ ld hl, wCardListUpdateFunction
ld [hli], a
ld [hl], d
ld a, $01
ld [wced2], a
-.asm_93d4
+.loop_input
call DoFrame
ldh a, [hDPadHeld]
and START
- jr z, .asm_93f0
+ jr z, .no_start_btn_2
ld a, $01
call PlaySFXConfirmOrCancel
- ld a, [wNamingScreenCursorY]
- ld [wced5], a
+
+ ; temporarily store current cursor position
+ ; to retrieve it later
+ ld a, [wCardListCursorPos]
+ ld [wTempFilteredCardListNumCursorPositions], a
call ConfirmDeckConfiguration
- ld a, [wced5]
- jr .asm_93b0
-.asm_93f0
- call Func_9efc
- jr c, .asm_93d4
- call Func_9b25
- jr c, .asm_9442
- jr .asm_93d4
-.asm_93fc
+ ld a, [wTempFilteredCardListNumCursorPositions]
+ jr .wait_list_input
+
+.no_start_btn_2
+ call HandleSelectUpAndDownInList
+ jr c, .loop_input
+ call HandleDeckCardSelectionList
+ jr c, .selection_made
+ jr .loop_input
+
+.open_card_page
ld a, $01
call PlaySFXConfirmOrCancel
- ld a, [wNamingScreenKeyboardHeight]
- ld [wcfdf], a
- ld a, [wNamingScreenCursorY]
- ld [wced4], a
- ld de, wceda
- ld hl, wcfd8
+ ld a, [wCardListNumCursorPositions]
+ ld [wTempCardListNumCursorPositions], a
+ ld a, [wCardListCursorPos]
+ ld [wTempCardListCursorPos], a
+
+ ; set wFilteredCardList as current card list
+ ; and show card page screen
+ ld de, wFilteredCardList
+ ld hl, wCurCardListPtr
ld [hl], e
inc hl
ld [hl], d
- call Func_9c3f
+ call OpenCardPageFromCardList
call DrawCardTypeIconsAndPrintCardCounts
- ld hl, Data_9667
- call Func_9a6d
- ld a, [wced3]
- ld [wNamingScreenCursorY], a
- call Func_9b20
+
+ ld hl, FiltersCardSelectionParams
+ call InitCardSelectionParams
+ ld a, [wCurCardTypeFilter]
+ ld [wTempCardTypeFilter], a
+ call DrawHorizontalListCursor_Visible
call PrintDeckBuildingCardList
- ld hl, Data_9670
- call Func_9a6d
- ld a, [wcfdf]
- ld [wNamingScreenKeyboardHeight], a
- ld a, [wced4]
- ld [wNamingScreenCursorY], a
- jr .asm_93d4
-.asm_9442
- call Func_9c0e
- ld a, [wNamingScreenCursorY]
- ld [wced4], a
+ ld hl, FilteredCardListSelectionParams
+ call InitCardSelectionParams
+ ld a, [wTempCardListNumCursorPositions]
+ ld [wCardListNumCursorPositions], a
+ ld a, [wTempCardListCursorPos]
+ ld [wCardListCursorPos], a
+ jr .loop_input
+
+.selection_made
+ call DrawListCursor_Invisible
+ ld a, [wCardListCursorPos]
+ ld [wTempCardListCursorPos], a
ld a, [hffb3]
cp $ff
- jr nz, .asm_93fc
- ld hl, Data_9667
- call Func_9a6d
- ld a, [wced3]
- ld [wNamingScreenCursorY], a
+ jr nz, .open_card_page
+ ; cancelled
+ ld hl, FiltersCardSelectionParams
+ call InitCardSelectionParams
+ ld a, [wCurCardTypeFilter]
+ ld [wTempCardTypeFilter], a
jp .wait_input
; 0x9461
-Func_9461: ; 9461 (2:5461)
+OpenDeckConfigurationMenu: ; 9461 (2:5461)
xor a
- ld [wPrizeCardCursorPosition], a
- ld de, wcfd1 + 5
+ ld [wYourOrOppPlayAreaCurPosition], a
+ ld de, wDeckConfigurationMenuTransitionTable
ld hl, wMenuInputTablePointer
ld a, [de]
ld [hli], a
@@ -2909,10 +3456,10 @@ Func_9461: ; 9461 (2:5461)
ld [hl], a
ld a, $ff
ld [wDuelInitialPrizesUpperBitsSet], a
-.asm_9475
+.skip_init
xor a
ld [wCheckMenuCursorBlinkCounter], a
- ld hl, wcfd1 + 3
+ ld hl, wDeckConfigurationMenuHandlerFunction
ld a, [hli]
ld h, [hl]
ld l, a
@@ -2930,28 +3477,28 @@ HandleDeckConfigurationMenu: ; 9480 (2:5480)
ld a, $1
ld [wVBlankOAMCopyToggle], a
call DoFrame
- call Func_89ae
+ call YourOrOppPlayAreaScreen_HandleInput
jr nc, .do_frame
ld [wced6], a
cp $ff
jr nz, .asm_94b5
.draw_icons
call DrawCardTypeIconsAndPrintCardCounts
- ld a, [wced4]
- ld [wNamingScreenCursorY], a
- ld a, [wced3]
- call Func_993d
- jp Func_9345.skip_draw
+ ld a, [wTempCardListCursorPos]
+ ld [wCardListCursorPos], a
+ ld a, [wCurCardTypeFilter]
+ call PrintFilteredCardList
+ jp HandleDeckBuildScreen.skip_draw
.asm_94b5
push af
- call Func_89ae.draw_cursor
+ call YourOrOppPlayAreaScreen_HandleInput.draw_cursor
ld a, $01
ld [wVBlankOAMCopyToggle], a
pop af
ld hl, .func_table
call JumpToFunctionInTable
- jr Func_9461.asm_9475
+ jr OpenDeckConfigurationMenu.skip_init
.func_table
dw ConfirmDeckConfiguration ; Confirm
@@ -2963,25 +3510,25 @@ HandleDeckConfigurationMenu: ; 9480 (2:5480)
; 0x94d3
ConfirmDeckConfiguration: ; 94d3 (2:54d3)
- ld hl, wcea1
+ ld hl, wCardListVisibleOffset
ld a, [hl]
ld hl, wced8
ld [hl], a
- call Func_9e41
+ call HandleDeckConfirmationMenu
ld hl, wced8
ld a, [hl]
- ld hl, wcea1
+ ld hl, wCardListVisibleOffset
ld [hl], a
call DrawCardTypeIconsAndPrintCardCounts
- ld hl, Data_9667
- call Func_9a6d
- ld a, [wced3]
- ld [wNamingScreenCursorY], a
- call Func_9b20
- ld a, [wced3]
- call Func_993d
+ ld hl, FiltersCardSelectionParams
+ call InitCardSelectionParams
+ ld a, [wCurCardTypeFilter]
+ ld [wTempCardTypeFilter], a
+ call DrawHorizontalListCursor_Visible
+ ld a, [wCurCardTypeFilter]
+ call PrintFilteredCardList
ld a, [wced6]
- ld [wNamingScreenCursorY], a
+ ld [wCardListCursorPos], a
ret
; 0x9505
@@ -2990,23 +3537,25 @@ ModifyDeckConfiguration: ; 9505 (2:5505)
jr HandleDeckConfigurationMenu.draw_icons
; 0x9509
-; returns carry set if player chose to save deck
+; returns carry set if player chose to go back
CancelDeckModifications: ; 9509 (2:5509)
- call Func_95c1
- jr nc, .asm_9516
+; if deck was not changed, cancel modification immediately
+ call CheckIfCurrentDeckWasChanged
+ jr nc, .cancel_modification
+; else prompt the player to confirm
ldtx hl, QuitModifyingTheDeckText
call YesOrNoMenuWithText
jr c, SaveDeckConfiguration.go_back
-.asm_9516
+.cancel_modification
add sp, $2
or a
ret
SaveDeckConfiguration: ; 951a (2:551a)
; handle deck configuration size
- ld a, [wcecc]
+ ld a, [wTotalCardCount]
cp DECK_SIZE
- jp z, .ask_to_save_deck ; should be jr
+ jp z, .ask_to_save_deck ; can be jr
ldtx hl, ThisIsntA60CardDeckText
call DrawWideTextBox_WaitForInput
ldtx hl, ReturnToOriginalConfigurationText
@@ -3025,7 +3574,7 @@ SaveDeckConfiguration: ; 951a (2:551a)
ldtx hl, SaveThisDeckText
call YesOrNoMenuWithText
jr c, .go_back
- call Func_9649
+ call CheckIfThereAreAnyBasicCardsInDeck
jr c, .set_carry
ldtx hl, ThereAreNoBasicPokemonInThisDeckText
call DrawWideTextBox_WaitForInput
@@ -3036,7 +3585,7 @@ SaveDeckConfiguration: ; 951a (2:551a)
call DrawCardTypeIconsAndPrintCardCounts
call PrintDeckBuildingCardList
ld a, [wced6]
- ld [wNamingScreenCursorY], a
+ ld [wCardListCursorPos], a
ret
.set_carry
@@ -3049,20 +3598,20 @@ DismantleDeck: ; 9566 (2:5566)
ldtx hl, DismantleThisDeckText
call YesOrNoMenuWithText
jr c, SaveDeckConfiguration.go_back
- call Func_9622
- jp nc, .Dismantle ; should be jr
+ call CheckIfHasOtherValidDecks
+ jp nc, .Dismantle ; can be jr
ldtx hl, ThereIsOnly1DeckSoCannotBeDismantledText
call DrawWideTextBox_WaitForInput
call EmptyScreen
- ld hl, Data_9667
- call Func_9a6d
- ld a, [wced3]
- ld [wNamingScreenCursorY], a
- call Func_9b20
+ ld hl, FiltersCardSelectionParams
+ call InitCardSelectionParams
+ ld a, [wCurCardTypeFilter]
+ ld [wTempCardTypeFilter], a
+ call DrawHorizontalListCursor_Visible
call PrintDeckBuildingCardList
call EnableLCD
ld a, [wced6]
- ld [wNamingScreenCursorY], a
+ ld [wCardListCursorPos], a
ret
.Dismantle
@@ -3074,7 +3623,7 @@ DismantleDeck: ; 9566 (2:5566)
ld a, NAME_BUFFER_LENGTH
call ClearNBytesFromHL
call GetPointerToDeckCards
- call Func_9152
+ call AddDeckToCollection
ld a, DECK_SIZE
call ClearNBytesFromHL
.done_dismantle
@@ -3084,40 +3633,42 @@ DismantleDeck: ; 9566 (2:5566)
; 0x95b9
ChangeDeckName: ; 95b9 (2:55b9)
- call Func_8f05
+ call InputCurDeckName
add sp, $2
- jp Func_9345.skip_count
+ jp HandleDeckBuildScreen.skip_count
; 0x95c1
-Func_95c1: ; 95c1 (2:55c1)
- ld a, [wcecc]
+; returns carry if current deck was changed
+; either through its card configuration or its name
+CheckIfCurrentDeckWasChanged: ; 95c1 (2:55c1)
+ ld a, [wTotalCardCount]
or a
jr z, .skip_size_check
cp DECK_SIZE
- jr nz, .done
+ jr nz, .set_carry
.skip_size_check
-; copy the selected deck to wc590
+; copy the selected deck to wCurDeckCardChanges
call GetPointerToDeckCards
- ld de, wc590
+ ld de, wCurDeckCardChanges
ld b, DECK_SIZE
call EnableSRAM
call CopyNBytesFromHLToDE
call DisableSRAM
-; loops through cards in wcf17
-; then if that card is found in wc590
+; loops through cards in wCurDeckCards
+; then if that card is found in wCurDeckCardChanges
; overwrite it by $0
ld a, $ff
ld [wc5cc], a
- ld de, wcf17
+ ld de, wCurDeckCards
.loop_outer
ld a, [de]
or a
jr z, .check_empty
ld b, a
inc de
- ld hl, wc590
+ ld hl, wCurDeckCardChanges
.loop_inner
ld a, [hli]
cp $ff
@@ -3131,70 +3682,81 @@ Func_95c1: ; 95c1 (2:55c1)
jr .loop_outer
.check_empty
- ld hl, wc590
+ ld hl, wCurDeckCardChanges
.loop_check_empty
ld a, [hli]
cp $ff
jr z, .is_empty
or a
- jr nz, .done
+ jr nz, .set_carry
jr .loop_check_empty
-; wc590 is empty (all $0)
.is_empty
+; wCurDeckCardChanges is empty (all $0)
+; check if name was changed
call GetPointerToDeckName
- ld de, wcfb9
+ ld de, wCurDeckName
call EnableSRAM
-.asm_9610
+.loop_name
ld a, [de]
cp [hl]
- jr nz, .done
+ jr nz, .set_carry
inc de
inc hl
or a
- jr nz, .asm_9610
+ jr nz, .loop_name
call DisableSRAM
ret
-.done
+
+.set_carry
call DisableSRAM
scf
ret
; 0x9622
-Func_9622: ; 9622 (2:5622)
- ld hl, wceb2
- ld bc, $0
+; returns carry if doesn't have a valid deck
+; aside from the current deck
+CheckIfHasOtherValidDecks: ; 9622 (2:5622)
+ ld hl, wDecksValid
+ lb bc, 0, 0
.loop
inc b
- ld a, $04
+ ld a, NUM_DECKS
cp b
- jr c, .asm_963a
+ jr c, .check_has_cards
ld a, [hli]
or a
jr z, .loop
+ ; is valid
inc c
- ld a, $01
+ ld a, 1
cp c
- jr nc, .loop
+ jr nc, .loop ; just 1 valid
+ ; at least 2 decks are valid
.no_carry
or a
ret
-.asm_963a
+
+.check_has_cards
+; doesn't have at least 2 valid decks
+; check if current deck is the only one
+; that is valid (i.e. has cards)
call GetPointerToDeckCards
call EnableSRAM
ld a, [hl]
call DisableSRAM
or a
- jr z, .no_carry
+ jr z, .no_carry ; no cards
+ ; has cards, is the only valid deck!
scf
ret
; 0x9649
-; checks if wcf17 has any basics
+; checks if wCurDeckCards has any basics
; returns carry set if there is at least
; 1 Basic Pokemon card
-Func_9649: ; 9649 (2:5649)
- ld hl, wcf17
+CheckIfThereAreAnyBasicCardsInDeck: ; 9649 (2:5649)
+ ld hl, wCurDeckCards
.loop_cards
ld a, [hli]
ld e, a
@@ -3216,11 +3778,25 @@ Func_9649: ; 9649 (2:5649)
ret
; 0x9667
-Data_9667: ; 9667 (2:5667)
- db $01, $01, $00, $02, $09, $2f, $00, $00, $00
-
-Data_9670: ; 9670 (2:5670)
- db $00, $07, $02, $00, $06, $0f, $00, $00, $00
+FiltersCardSelectionParams: ; 9667 (2:5667)
+ db 1 ; x pos
+ db 1 ; y pos
+ db 0 ; y spacing
+ db 2 ; x spacing
+ db NUM_FILTERS ; num entries
+ db SYM_CURSOR_D ; visible cusor tile
+ db SYM_SPACE ; invisible cusor tile
+ dw NULL ; wCardListHandlerFunction
+
+FilteredCardListSelectionParams: ; 9670 (2:5670)
+ db 0 ; x pos
+ db 7 ; y pos
+ db 2 ; y spacing
+ db 0 ; x spacing
+ db NUM_FILTERED_LIST_VISIBLE_CARDS ; num entries
+ db SYM_CURSOR_R ; visible cursor tile
+ db SYM_SPACE ; invisible cursor tile
+ dw NULL ; wCardListHandlerFunction
DeckConfigurationMenu_TransitionTable: ; 9679 (2:5679)
cursor_transition $10, $20, $00, $03, $03, $01, $02
@@ -3269,10 +3845,10 @@ FillBGMapLineWithA: ; 96c7 (2:56c7)
ret
; 0x96e3
-; saves the count of each type of card that is in wcf17
-; stores these values in wcebb
+; saves the count of each type of card that is in wCurDeckCards
+; stores these values in wCardFilterCounts
CountNumberOfCardsForEachCardType: ; 96e3 (2:56e3)
- ld hl, wcebb
+ ld hl, wCardFilterCounts
ld de, CardTypeFilters
.loop
ld a, [de]
@@ -3411,13 +3987,13 @@ CreateFilteredCardList: ; 978b (2:578b)
.loop_card_ids
inc e
call GetCardType
- jr c, .add_terminator_byte
+ jr c, .store_count
ld c, a
ld a, b
cp $ff
jr z, .add_card
- and $20
- cp $20
+ and FILTER_ENERGY
+ cp FILTER_ENERGY
jr z, .check_energy
ld a, c
cp b
@@ -3456,9 +4032,9 @@ CreateFilteredCardList: ; 978b (2:578b)
pop bc
jr .loop_card_ids
-.add_terminator_byte
+.store_count
ld a, l
- ld [wceab + 3], a
+ ld [wNumEntriesInCurFilter], a
; add terminator bytes in both lists
xor a
ld c, l
@@ -3544,13 +4120,12 @@ ClearNBytesFromHL: ; 9843 (2:5843)
ret
; 0x9850
-; finds instance of e in list wcf17
-; returns the position in the list that it was found
-; if not found, returns last position + 1
-Func_9850: ; 9850 (2:5850)
+; returns the number of times that card e
+; appears in wCurDeckCards
+GetCountOfCardInCurDeck: ; 9850 (2:5850)
push hl
- ld hl, wcf17
- ld d, $00
+ ld hl, wCurDeckCards
+ ld d, 0
.loop
ld a, [hli]
or a
@@ -3613,7 +4188,7 @@ AppendOwnedCardCountAndStorageCountNumbers: ; 9880 (2:5880)
jr .loop
.print
push de
- call Func_9850
+ call GetCountOfCardInCurDeck
call ConvertToNumericalDigits
ld [hl], TX_SYMBOL
inc hl
@@ -3689,7 +4264,7 @@ ConvertToNumericalDigits: ; 98c7 (2:58c7)
ret
; 0x98dc
-; counts the number of cards in wcf17
+; counts the number of cards in wCurDeckCards
; that are the same type as input in register a
; if input is $20, counts all energy cards instead
; input:
@@ -3705,7 +4280,7 @@ CountNumberOfCardsOfType: ; 98dc (2:58dc)
.loop_cards
push hl
push bc
- ld bc, wcf17
+ ld bc, wCurDeckCards
add hl, bc
ld a, [hl]
pop bc
@@ -3715,7 +4290,7 @@ CountNumberOfCardsOfType: ; 98dc (2:58dc)
jr z, .done ; end of card list
; get card type and compare it with input type
-; if input is $20, run a separate comparison
+; if input is FILTER_ENERGY, run a separate comparison
; if it's the same type, increase the count
ld e, a
call GetCardType
@@ -3723,8 +4298,8 @@ CountNumberOfCardsOfType: ; 98dc (2:58dc)
push hl
ld l, a
ld a, b
- and $20
- cp $20
+ and FILTER_ENERGY
+ cp FILTER_ENERGY
jr z, .check_energy
ld a, l
pop hl
@@ -3758,7 +4333,7 @@ PrintCardTypeCounts: ; 9916 (2:5916)
ld hl, wDefaultText
.loop
push hl
- ld hl, wcebb
+ ld hl, wCardFilterCounts
add hl, bc
ld a, [hl]
pop hl
@@ -3766,7 +4341,7 @@ PrintCardTypeCounts: ; 9916 (2:5916)
call ConvertToNumericalDigits
pop bc
inc c
- ld a, $9
+ ld a, NUM_FILTERS
cp c
jr nz, .loop
ld [hl], TX_END
@@ -3777,7 +4352,10 @@ PrintCardTypeCounts: ; 9916 (2:5916)
ret
; 0x993d
-Func_993d: ; 993d (2:593d)
+; prints the list of cards, applying the filter from register a
+; the counts of each card displayed is taken from wCurDeck
+; a = card type filter
+PrintFilteredCardList: ; 993d (2:593d)
push af
ld hl, CardTypeFilters
ld b, $00
@@ -3790,24 +4368,25 @@ Func_993d: ; 993d (2:593d)
call EnableSRAM
ld hl, sCardCollection
ld de, wTempCardCollection
- ld b, $ff
+ ld b, CARD_COLLECTION_SIZE - 1
call CopyNBytesFromHLToDE
call DisableSRAM
- ld a, [wcfd1 + 2]
+ ld a, [wIncludeCardsInDeck]
or a
jr z, .ok
call GetPointerToDeckCards
ld d, h
ld e, l
- call GetDeckCardCounts
+ call IncrementDeckCardsInTempCollection
.ok
pop af
+
call CreateFilteredCardList
- ld a, $06
- ld [wcecb], a
- lb de, 1 ,7
- ld hl, wced0
+ ld a, NUM_FILTERED_LIST_VISIBLE_CARDS
+ ld [wNumVisibleCardListEntries], a
+ lb de, 1, 7
+ ld hl, wCardListCoords
ld [hl], e
inc hl
ld [hl], d
@@ -3818,36 +4397,36 @@ Func_993d: ; 993d (2:593d)
; used to filter the cards in the deck building/card selection screen
CardTypeFilters: ; 997d (2:597d)
- db TYPE_PKMN_GRASS
- db TYPE_PKMN_FIRE
- db TYPE_PKMN_WATER
- db TYPE_PKMN_LIGHTNING
- db TYPE_PKMN_FIGHTING
- db TYPE_PKMN_PSYCHIC
- db TYPE_PKMN_COLORLESS
- db TYPE_TRAINER
- db $20
+ db FILTER_GRASS
+ db FILTER_FIRE
+ db FILTER_WATER
+ db FILTER_LIGHTNING
+ db FILTER_FIGHTING
+ db FILTER_PSYCHIC
+ db FILTER_COLORLESS
+ db FILTER_TRAINER
+ db FILTER_ENERGY
db -1 ; end of list
; 0x9987
; counts all the cards from each card type
-; (stored in wcebb) and store it in wcecc
+; (stored in wCardFilterCounts) and store it in wTotalCardCount
; also prints it in coordinates de
PrintTotalCardCount: ; 9987 (2:5987)
push de
ld bc, $0
- ld hl, wcebb
+ ld hl, wCardFilterCounts
.loop
ld a, [hli]
add b
ld b, a
inc c
- ld a, $9
+ ld a, NUM_FILTERS
cp c
jr nz, .loop
ld hl, wDefaultText
ld a, b
- ld [wcecc], a
+ ld [wTotalCardCount], a
push bc
call ConvertToNumericalDigits
pop bc
@@ -3867,14 +4446,14 @@ PrintTotalCardCount: ; 9987 (2:5987)
; and Y is the storage count of that card
PrintDeckBuildingCardList: ; 99b0 (2:59b0)
push bc
- ld hl, wced0
+ ld hl, wCardListCoords
ld e, [hl]
inc hl
ld d, [hl]
ld b, 19 ; x coord
ld c, e
dec c
- ld a, [wcea1]
+ ld a, [wCardListVisibleOffset]
or a
jr z, .no_cursor
ld a, SYM_CURSOR_U
@@ -3884,14 +4463,14 @@ PrintDeckBuildingCardList: ; 99b0 (2:59b0)
.got_cursor_tile
call WriteByteToBGMap0
-; iterates by decreasing value in wcecb
+; iterates by decreasing value in wNumVisibleCardListEntries
; by 1 until it reaches 0
- ld a, [wcea1]
+ ld a, [wCardListVisibleOffset]
ld c, a
ld b, $0
ld hl, wFilteredCardList
add hl, bc
- ld a, [wcecb]
+ ld a, [wNumVisibleCardListEntries]
.loop_filtered_cards
push de
or a
@@ -3901,7 +4480,7 @@ PrintDeckBuildingCardList: ; 99b0 (2:59b0)
or a
jr z, .invalid_card ; card ID of 0
ld e, a
- call Func_9a59
+ call AddCardIDToVisibleList
call LoadCardDataToBuffer1_FromCardID
ld a, 13
push bc
@@ -3941,14 +4520,14 @@ PrintDeckBuildingCardList: ; 99b0 (2:59b0)
; draw down cursor because
; there are still more cards
; to be scrolled down
- xor a
- ld [wcecd], a
+ xor a ; FALSE
+ ld [wUnableToScrollDown], a
ld a, SYM_CURSOR_D
jr .draw_cursor
.cannot_scroll
pop de
- ld a, $01
- ld [wcecd], a
+ ld a, TRUE
+ ld [wUnableToScrollDown], a
ld a, SYM_SPACE
.draw_cursor
ld b, 19 ; x coord
@@ -4020,22 +4599,24 @@ Text_9a56:
db TX_SYMBOL, TX_END
Text_9a58:
- db TX_END
+ done
+; writes the card ID in register e to wVisibleListCardIDs
+; given its position in the list in register b
; input:
-; b = ?
+; b = list position (starts from bottom)
; e = card ID
-Func_9a59: ; 9a59 (2:5a59)
+AddCardIDToVisibleList: ; 9a59 (2:5a59)
push af
push bc
push hl
- ld hl, wcec4
+ ld hl, wVisibleListCardIDs
ld c, b
- ld a, [wcecb]
+ ld a, [wNumVisibleCardListEntries]
sub c
- ld c, a
- ld b, $00
- add hl, bc ; = wcec4 + (wcecb - b)
+ ld c, a ; wNumVisibleCardListEntries - b
+ ld b, $0
+ add hl, bc
ld [hl], e
pop hl
pop bc
@@ -4043,11 +4624,19 @@ Func_9a59: ; 9a59 (2:5a59)
ret
; 0x9a6d
-; copies 9 bytes from hl to wcea5
-Func_9a6d: ; 9a6d (2:5a6d)
- ld [wNamingScreenCursorY], a
+; copies data from hl to:
+; wCardListCursorXPos
+; wCardListCursorYPos
+; wCardListYSpacing
+; wCardListXSpacing
+; wCardListNumCursorPositions
+; wVisibleCursorTile
+; wInvisibleCursorTile
+; wCardListHandlerFunction
+InitCardSelectionParams: ; 9a6d (2:5a6d)
+ ld [wCardListCursorPos], a
ld [hffb3], a
- ld de, wcea5
+ ld de, wCardListCursorXPos
ld b, $9
.loop
ld a, [hli]
@@ -4060,163 +4649,792 @@ Func_9a6d: ; 9a6d (2:5a6d)
ret
; 0x9a83
-Func_9a83: ; 9a83 (2:5a83)
- INCROM $9a83, $9ad7
+HandleCardSelectionInput: ; 9a83 (2:5a83)
+ xor a ; FALSE
+ ld [wPlaysSfx], a
+ ldh a, [hDPadHeld]
+ or a
+ jr z, .handle_ab_btns
-Func_9ad7: ; 9ad7 (2:5ad7)
- call Func_9b20
+; handle d-pad
+ ld b, a
+ ld a, [wCardListNumCursorPositions]
+ ld c, a
+ ld a, [wCardListCursorPos]
+ bit D_LEFT_F, b
+ jr z, .check_d_right
+ dec a
+ bit 7, a
+ jr z, .got_cursor_pos
+ ; if underflow, set to max cursor pos
+ ld a, [wCardListNumCursorPositions]
+ dec a
+ jr .got_cursor_pos
+.check_d_right
+ bit D_RIGHT_F, b
+ jr z, .handle_ab_btns
+ inc a
+ cp c
+ jr c, .got_cursor_pos
+ ; if over max pos, set to pos 0
+ xor a
+.got_cursor_pos
+ push af
+ ld a, TRUE
+ ld [wPlaysSfx], a
+ call DrawHorizontalListCursor_Invisible
+ pop af
+ ld [wCardListCursorPos], a
+ xor a
+ ld [wCheckMenuCursorBlinkCounter], a
+
+.handle_ab_btns
+ ld a, [wCardListCursorPos]
+ ld [hffb3], a
+ ldh a, [hKeysPressed]
+ and A_BUTTON | B_BUTTON
+ jr z, HandleCardSelectionCursorBlink
+ and A_BUTTON
+ jr nz, ConfirmSelectionAndReturnCarry
+ ; b button
+ ld a, $ff
+ ld [hffb3], a
+ call PlaySFXConfirmOrCancel
+ scf
+ ret
+; 0x9ad7
+
+; outputs cursor position in e and selection in a
+ConfirmSelectionAndReturnCarry: ; 9ad7 (2:5ad7)
+ call DrawHorizontalListCursor_Visible
ld a, $01
call PlaySFXConfirmOrCancel
- ld a, [wNamingScreenCursorY]
+ ld a, [wCardListCursorPos]
ld e, a
ld a, [hffb3]
scf
ret
; 0x9ae8
- INCROM $9ae8, $9b03
+HandleCardSelectionCursorBlink: ; 9ae8 (2:5ae8)
+ ld a, [wPlaysSfx]
+ or a
+ jr z, .skip_sfx
+ call PlaySFX
+.skip_sfx
+ ld hl, wCheckMenuCursorBlinkCounter
+ ld a, [hl]
+ inc [hl]
+ and $0f
+ ret nz
+ ld a, [wVisibleCursorTile]
+ bit 4, [hl]
+ jr z, DrawHorizontalListCursor
+; 0x9b00
+
+DrawHorizontalListCursor_Invisible: ; 9b00 (2:5b00)
+ ld a, [wInvisibleCursorTile]
+; fallthrough
-Func_9b03: ; 9b03 (2:5b03)
+; like DrawListCursor but only
+; for lists with one line, and each entry
+; being laid horizontally
+; a = tile to write
+DrawHorizontalListCursor: ; 9b03 (2:5b03)
ld e, a
- ld a, [wcea5 + 3]
+ ld a, [wCardListXSpacing]
ld l, a
- ld a, [wNamingScreenCursorY]
+ ld a, [wCardListCursorPos]
ld h, a
call HtimesL
ld a, l
- ld hl, wcea5
+ ld hl, wCardListCursorXPos
add [hl]
- ld b, a
- ld hl, wcea5 + 1
+ ld b, a ; x coord
+ ld hl, wCardListCursorYPos
ld a, [hl]
- ld c, a
+ ld c, a ; y coord
ld a, e
call WriteByteToBGMap0
or a
ret
; 0x9b20
-Func_9b20: ; 9b20 (2:5b20)
- ld a, [wceaa]
- jr Func_9b03
+DrawHorizontalListCursor_Visible: ; 9b20 (2:5b20)
+ ld a, [wVisibleCursorTile]
+ jr DrawHorizontalListCursor
; 0x9b25
-Func_9b25: ; 9b25 (2:5b25)
- INCROM $9b25, $9c0e
+; handles user input when selecting cards to add
+; to deck configuration
+; returns carry if a selection was made
+; (either selected card or cancelled)
+; outputs in a the list index if selection was made
+; or $ff if operation was cancelled
+HandleDeckCardSelectionList: ; 9b25 (2:5b25)
+ xor a ; FALSE
+ ld [wPlaysSfx], a
+
+ ldh a, [hDPadHeld]
+ or a
+ jp z, .asm_9bb9
-Func_9c0e: ; 9c0e (2:5c0e)
- INCROM $9c0e, $9c11
+ ld b, 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
+ pop af
+ dec a
+ bit 7, a
+ jr z, .asm_9b8f
+ ld a, [wCardListVisibleOffset]
+ or a
+ jr z, .asm_9b5a
+ dec a
+ ld [wCardListVisibleOffset], a
+ ld hl, wCardListUpdateFunction
+ call CallIndirect
+ xor a
+ jr .asm_9b8f
+.asm_9b5a
+ xor a
+ ld [wPlaysSfx], a
+ jr .asm_9b8f
+.check_d_down
+ bit D_DOWN_F, b
+ jr z, .asm_9b9d
+ push af
+ ld a, TRUE
+ ld [wPlaysSfx], a
+ pop af
+ inc a
+ cp c
+ jr c, .asm_9b8f
+ push af
+ ld a, [wUnableToScrollDown]
+ or a
+ jr nz, .cannot_scroll_down
+ ld a, [wCardListVisibleOffset]
+ inc a
+ ld [wCardListVisibleOffset], a
+ ld hl, wCardListUpdateFunction
+ call CallIndirect
+ pop af
+ dec a
+ jr .asm_9b8f
+
+.cannot_scroll_down
+ pop af
+ dec a
+ push af
+ xor a ; FALSE
+ ld [wPlaysSfx], a
+ pop af
+
+.asm_9b8f
+ push af
+ call DrawListCursor_Invisible
+ pop af
+ ld [wCardListCursorPos], a
+ xor a
+ ld [wCheckMenuCursorBlinkCounter], a
+ jr .asm_9bb9
+.asm_9b9d
+ ld a, [wced2]
+ or a
+ jr z, .asm_9bb9
+
+ bit D_LEFT_F, b
+ jr z, .check_d_right
+ call GetSelectedVisibleCardID
+ call RemoveCardFromDeckAndUpdateCount
+ jr .asm_9bb9
+.check_d_right
+ bit D_RIGHT_F, b
+ jr z, .asm_9bb9
+ call GetSelectedVisibleCardID
+ call AddCardToDeckAndUpdateCount
+
+.asm_9bb9
+ ld a, [wCardListCursorPos]
+ ld [hffb3], a
+ ld hl, wCardListHandlerFunction
+ ld a, [hli]
+ or [hl]
+ jr z, .handle_ab_btns
+
+ ; this code seemingly never runs
+ ; because wCardListHandlerFunction is always NULL
+ ld a, [hld]
+ ld l, [hl]
+ ld h, a
+ ld a, [hffb3]
+ call CallHL
+ jr nc, .handle_blink
+
+.select_card
+ call DrawListCursor_Visible
+ ld a, $01
+ call PlaySFXConfirmOrCancel
+ ld a, [wCardListCursorPos]
+ ld e, a
+ ld a, [hffb3]
+ scf
+ ret
+
+.handle_ab_btns
+ ldh a, [hKeysPressed]
+ and A_BUTTON | B_BUTTON
+ jr z, .check_sfx
+ and A_BUTTON
+ jr nz, .select_card
+ ld a, $ff
+ ld [hffb3], a
+ call PlaySFXConfirmOrCancel
+ scf
+ ret
+
+.check_sfx
+ ld a, [wPlaysSfx]
+ or a
+ jr z, .handle_blink
+ call PlaySFX
+.handle_blink
+ ld hl, wCheckMenuCursorBlinkCounter
+ ld a, [hl]
+ inc [hl]
+ and $0f
+ ret nz
+ ld a, [wVisibleCursorTile]
+ bit 4, [hl]
+ jr z, DrawListCursor
+; fallthrough
+
+DrawListCursor_Invisible: ; 9c0e (2:5c0e)
+ ld a, [wInvisibleCursorTile]
+; fallthrough
+
+; draws cursor considering wCardListCursorPos
+; spaces each entry horizontally by wCardListXSpacing
+; and vertically by wCardListYSpacing
; a = tile to write
-Func_9c11: ; 9c11 (2:5c11)
+DrawListCursor: ; 9c11 (2:5c11)
ld e, a
- ld a, [wcea5 + 3]
+ ld a, [wCardListXSpacing]
ld l, a
- ld a, [wNamingScreenCursorY]
+ ld a, [wCardListCursorPos]
ld h, a
call HtimesL
ld a, l
- ld hl, wcea5
+ ld hl, wCardListCursorXPos
add [hl]
- ld b, a
- ld a, [wcea5 + 2]
+ ld b, a ; x coord
+ ld a, [wCardListYSpacing]
ld l, a
- ld a, [wNamingScreenCursorY]
+ ld a, [wCardListCursorPos]
ld h, a
call HtimesL
ld a, l
- ld hl, wcea5 + 1
+ ld hl, wCardListCursorYPos
add [hl]
- ld c, a
+ ld c, a ; y coord
ld a, e
call WriteByteToBGMap0
or a
ret
; 0x9c3a
-Func_9c3a: ; 9c3a (2:5c3a)
- ld a, [wceaa]
- jr Func_9c11
+DrawListCursor_Visible: ; 9c3a (2:5c3a)
+ ld a, [wVisibleCursorTile]
+ jr DrawListCursor
; 0x9c3f
-Func_9c3f: ; 9c3f (2:5c3f)
- INCROM $9c3f, $9e31
+OpenCardPageFromCardList: ; 9c3f (2:5c3f)
+; get the card index that is selected
+; and open its card page
+ ld hl, wCurCardListPtr
+ ld a, [hli]
+ ld h, [hl]
+ ld l, a
+ ld a, [wCardListCursorPos]
+ ld c, a
+ ld b, $0
+ add hl, bc
+ ld a, [wCardListVisibleOffset]
+ ld c, a
+ ld b, $0
+ add hl, bc
+ ld e, [hl]
+ ld d, $0
+ push de
+ call LoadCardDataToBuffer1_FromCardID
+ lb de, $38, $9f
+ call SetupText
+ bank1call OpenCardPage_FromCheckHandOrDiscardPile
+ pop de
-Func_9e31: ; 9e31 (2:5e31)
+.handle_input
+ ldh a, [hDPadHeld]
+ ld b, a
+ and A_BUTTON | B_BUTTON | SELECT | START
+ jp nz, .exit
+
+; check d-pad
+; if UP or DOWN is pressed, change the
+; card that is being shown, given the
+; order in the current card list
+ 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
+ pop af
+ dec a
+ bit 7, a
+ jr z, .reopen_card_page
+ ld a, [wCardListVisibleOffset]
+ or a
+ jr z, .handle_regular_card_page_input
+ dec a
+ ld [wCardListVisibleOffset], a
+ xor a
+ jr .reopen_card_page
+
+.check_d_down
+ bit D_DOWN_F, b
+ jr z, .handle_regular_card_page_input
+ push af
+ ld a, TRUE
+ ld [wPlaysSfx], a
+ pop af
+ inc a
+ cp c
+ jr c, .reopen_card_page
+ push af
+ ld hl, wCurCardListPtr
+ ld a, [hli]
+ ld h, [hl]
+ ld l, a
+ ld a, [wCardListCursorPos]
+ ld c, a
+ ld b, $0
+ add hl, bc
+ ld a, [wCardListVisibleOffset]
+ inc a
+ ld c, a
+ ld b, $0
+ add hl, bc
+ ld a, [hl]
+ or a
+ jr z, .skip_change_card
+ ld a, [wCardListVisibleOffset]
+ inc a
+ ld [wCardListVisibleOffset], a
+ pop af
+ dec a
+.reopen_card_page
+ ld [wCardListCursorPos], a
+ ld a, [wPlaysSfx]
+ or a
+ jp z, OpenCardPageFromCardList
+ call PlaySFX
+ jp OpenCardPageFromCardList
+
+.skip_change_card
+ pop af
+ jr .handle_regular_card_page_input ; unnecessary jr
+.handle_regular_card_page_input
+ push de
+ bank1call OpenCardPage.input_loop
+ pop de
+ jp .handle_input
+
+.exit
+ ld a, $1
+ ld [wVBlankOAMCopyToggle], a
+ ld a, [wCardListCursorPos]
+ ld [wTempCardListCursorPos], a
+ ret
+; 0x9ced
+
+; opens card page from the card list
+; unreferenced?
+Func_9ced: ; 9ced (2:5ced)
+ ld hl, wVisibleListCardIDs
+ ld a, [wCardListCursorPos]
+ ld c, a
+ ld b, $00
+ add hl, bc
+ ld e, [hl]
+ inc hl
+ ld d, [hl]
+ call LoadCardDataToBuffer1_FromCardID
+ ld de, $389f
+ call SetupText
+ bank1call OpenCardPage_FromHand
+ ld a, $01
+ ld [wVBlankOAMCopyToggle], a
+ ret
+; 0x9d0c
+
+; adds card in register e to deck configuration
+; and updates the values shown for its count
+; in the card selection list
+; input:
+; e = card ID
+AddCardToDeckAndUpdateCount: ; 9d0c (2:5d0c)
+ call TryAddCardToDeck
+ ret c ; failed to add card
+ push de
+ call PrintCardTypeCounts
+ lb de, 15, 0
+ call PrintTotalCardCount
+ pop de
+ call GetCountOfCardInCurDeck
+ call PrintNumberValueInCursorYPos
+ ret
+; 0x9d22
+
+; tries to add card ID in register e to wCurDeckCards
+; fails to add card if one of the following conditions are met:
+; - total cards are equal to wMaxNumCardsAllowed
+; - cards with the same name as it reached the allowed limit
+; - player doesn't own more copies in the collection
+; returns carry if fails
+; otherwise, writes card ID to first empty slot in wCurDeckCards
+; input:
+; e = card ID
+TryAddCardToDeck: ; 9d22 (2:5d22)
+ ld a, [wMaxNumCardsAllowed]
+ ld d, a
+ ld a, [wTotalCardCount]
+ cp d
+ jr nz, .not_equal
+ ; wMaxNumCardsAllowed == wTotalCardCount
+ scf
+ ret
+
+.not_equal
+ push de
+ call .CheckIfCanAddCardWithSameName
+ pop de
+ ret c ; cannot add more cards with this name
+
+ push de
+ call GetCountOfCardInCurDeck
+ ld b, a
+ ld hl, wOwnedCardsCountList
+ ld d, $0
+ ld a, [wCardListVisibleOffset]
+ ld e, a
+ add hl, de
+ ld a, [wCardListCursorPos]
+ ld e, a
+ add hl, de
+ ld d, [hl]
+ ld a, b
+ cp d
+ pop de
+ scf
+ ret z ; cannot add because player doesn't own more copies
+
+ ld a, SFX_01
+ call PlaySFX
+ push de
+ call .AddCardToCurDeck
+ ld a, [wCurCardTypeFilter]
+ ld c, a
+ ld b, $0
+ ld hl, wCardFilterCounts
+ add hl, bc
+ inc [hl]
+ pop de
+ or a
+ ret
+
+; finds first empty slot in wCurDeckCards
+; then writes the value in e to it
+.AddCardToCurDeck
+ ld hl, wCurDeckCards
+.loop
+ ld a, [hl]
+ or a
+ jr z, .empty
+ inc hl
+ jr .loop
+.empty
+ ld [hl], e
+ inc hl
+ xor a
+ ld [hl], a
+ ret
+
+; returns carry if card ID in e cannot be
+; added to the current deck configuration
+; due to having reached the maximum number
+; of cards allowed with that same name
+; e = card id
+.CheckIfCanAddCardWithSameName
+ call LoadCardDataToBuffer1_FromCardID
+ ld a, [wLoadedCard1Type]
+ cp TYPE_ENERGY_DOUBLE_COLORLESS
+ jr z, .double_colorless
+ ; basic energy cards have no limit
+ and TYPE_ENERGY
+ cp TYPE_ENERGY
+ jr z, .exit ; return if basic energy card
+.double_colorless
+
+; compare this card's name to
+; the names of cards in list wCurDeckCards
+ ld a, [wLoadedCard1Name + 0]
+ ld c, a
+ ld a, [wLoadedCard1Name + 1]
+ ld b, a
+ ld hl, wCurDeckCards
+ ld d, 0
+ push de
+.loop_cards
+ ld a, [hli]
+ or a
+ jr z, .exit_pop_de
+ ld e, a
+ ld d, $0
+ call GetCardName
+ ld a, e
+ cp c
+ jr nz, .loop_cards
+ ld a, d
+ cp b
+ jr nz, .loop_cards
+ ; has same name
+ pop de
+ inc d ; increment counter of cards with this name
+ ld a, [wSameNameCardsLimit]
+ cp d
+ push de
+ jr nz, .loop_cards
+ ; reached the maximum number
+ ; of cards with same name allowed
+ pop de
+ scf
+ ret
+
+.exit_pop_de
+ pop de
+.exit
+ or a
+ ret
+; 0x9db3
+
+; gets the element in wVisibleListCardIDs
+; corresponding to index wCardListCursorPos
+GetSelectedVisibleCardID: ; 9db3 (2:5db3)
+ ld hl, wVisibleListCardIDs
+ ld a, [wCardListCursorPos]
+ ld e, a
+ ld d, $00
+ add hl, de
+ ld e, [hl]
+ ret
+; 0x9dbf
+
+; appends the digits of value in register a to wDefaultText
+; then prints it in cursor Y position
+; a = value to convert to numerical digits
+PrintNumberValueInCursorYPos: ; 9dbf (2:5dbf)
+ ld hl, wDefaultText
+ call ConvertToNumericalDigits
+ ld [hl], TX_END
+ ld a, [wCardListYSpacing]
+ ld l, a
+ ld a, [wCardListCursorPos]
+ ld h, a
+ call HtimesL
+ ld a, l
+ ld hl, wCardListCursorYPos
+ add [hl]
+ ld e, a
+ ld d, 14
+ call InitTextPrinting
+ ld hl, wDefaultText
+ call ProcessText
+ ret
+; 0x9de4
+
+; removes card in register e from deck configuration
+; and updates the values shown for its count
+; in the card selection list
+; input:
+; e = card ID
+RemoveCardFromDeckAndUpdateCount: ; 9de4 (2:5de4)
+ call RemoveCardFromDeck
+ ret nc
+ push de
+ call PrintCardTypeCounts
+ lb de, 15, 0
+ call PrintTotalCardCount
+ pop de
+ call GetCountOfCardInCurDeck
+ call PrintNumberValueInCursorYPos
+ ret
+; 0x9dfa
+
+; removes card ID in e from wCurDeckCards
+RemoveCardFromDeck: ; 9dfa (2:5dfa)
+ push de
+ call GetCountOfCardInCurDeck
+ pop de
+ or a
+ ret z ; card is not in deck
+ ld a, SFX_01
+ call PlaySFX
+ push de
+ call .RemoveCard
+ ld a, [wCurCardTypeFilter]
+ ld c, a
+ ld b, $0
+ ld hl, wCardFilterCounts
+ add hl, bc
+ dec [hl]
+ pop de
+ scf
+ ret
+
+; remove first card instance of card ID in e
+; and shift all elements up by one
+.RemoveCard
+ ld hl, wCurDeckCards
+ ld d, 0 ; unnecessary
+.loop_1
+ inc d ; unnecessary
+ ld a, [hli]
+ cp e
+ jr nz, .loop_1
+ ld c, l
+ ld b, h
+ dec bc
+
+.loop_2
+ inc d ; unnecessary
+ ld a, [hli]
+ or a
+ jr z, .done
+ ld [bc], a
+ inc bc
+ jr .loop_2
+
+.done
+ xor a
+ ld [bc], a
+ ret
+; 0x9e31
+
+UpdateConfirmationCardScreen: ; 9e31 (2:5e31)
ld hl, hffb0
ld [hl], $01
- call Func_9fc0
+ call PrintCurDeckNumberAndName
ld hl, hffb0
ld [hl], $00
jp PrintConfirmationCardList
; 0x9e41
-Func_9e41: ; 9e41 (2:5e41)
- ld a, [wcecc]
+HandleDeckConfirmationMenu: ; 9e41 (2:5e41)
+; if deck is empty, just show deck info header with empty card list
+ ld a, [wTotalCardCount]
or a
- jp z, Func_9f40
- call Func_a028
- call Func_a06e
+ jp z, ShowDeckInfoHeaderAndWaitForBButton
+
+; create list of all unique cards
+ call SortCurDeckCardsByID
+ call CreateCurDeckUniqueCardList
xor a
- ld [wcea1], a
-.asm_9e52
- ld hl, Data_9eaf
- call Func_9a6d
- ld a, [wced9]
- ld [wcfe4+ 2], a
- cp $07
- jr c, .asm_9e64
- ld a, $07
-.asm_9e64
- ld [wNamingScreenKeyboardHeight], a
- ld [wcecb], a
- call Func_9f52
- ld hl, Func_9e31
+ ld [wCardListVisibleOffset], a
+.init_params
+ ld hl, .CardSelectionParams
+ call InitCardSelectionParams
+ ld a, [wNumUniqueCards]
+ ld [wNumCardListEntries], a
+ cp NUM_DECK_CONFIRMATION_VISIBLE_CARDS
+ jr c, .no_cap
+ ld a, NUM_DECK_CONFIRMATION_VISIBLE_CARDS
+.no_cap
+ ld [wCardListNumCursorPositions], a
+ ld [wNumVisibleCardListEntries], a
+ call ShowConfirmationCardScreen
+
+ ld hl, UpdateConfirmationCardScreen
ld d, h
ld a, l
- ld hl, wcece
+ ld hl, wCardListUpdateFunction
ld [hli], a
ld [hl], d
+
xor a
ld [wced2], a
-.asm_9e7b
+.loop_input
call DoFrame
- call Func_9b25
- jr c, .asm_9ea7
- call Func_9eb8
- jr c, .asm_9e7b
+ call HandleDeckCardSelectionList
+ jr c, .selection_made
+ call HandleLeftRightInCardList
+ jr c, .loop_input
ldh a, [hDPadHeld]
and START
- jr z, .asm_9e7b
+ jr z, .loop_input
-.asm_9e8e
+.selected_card
ld a, $01
call PlaySFXConfirmOrCancel
- ld a, [wNamingScreenCursorY]
+ ld a, [wCardListCursorPos]
ld [wced7], a
+
+ ; set wOwnedCardsCountList as current card list
+ ; and show card page screen
ld de, wOwnedCardsCountList
- ld hl, wcfd8
+ ld hl, wCurCardListPtr
ld [hl], e
inc hl
ld [hl], d
- call Func_9c3f
- jr .asm_9e52
+ call OpenCardPageFromCardList
+ jr .init_params
-.asm_9ea7
+.selection_made
ld a, [hffb3]
cp $ff
- ret z
- jr .asm_9e8e
-; 0x9eaf
-
-Data_9eaf:
- db $00, $05, $02, $00, $07, $0f, $00, $00, $00
-
-Func_9eb8: ; 9eb8 (2:5eb8)
- ld a, [wNamingScreenKeyboardHeight]
+ ret z ; operation cancelled
+ jr .selected_card
+
+.CardSelectionParams
+ db 0 ; x pos
+ db 5 ; y pos
+ db 2 ; y spacing
+ db 0 ; x spacing
+ db 7 ; num entries
+ db SYM_CURSOR_R ; visible cursor tile
+ db SYM_SPACE ; invisible cursor tile
+ dw NULL ; wCardListHandlerFunction
+; 0x9eb8
+
+; handles pressing left/right in card lists
+; scrolls up/down a number of wCardListNumCursorPositions
+; entries respectively
+; returns carry if scrolling happened
+HandleLeftRightInCardList: ; 9eb8 (2:5eb8)
+ ld a, [wCardListNumCursorPositions]
ld d, a
- ld a, [wcea1]
+ ld a, [wCardListVisibleOffset]
ld c, a
ldh a, [hDPadHeld]
cp D_RIGHT
@@ -4227,43 +5445,92 @@ Func_9eb8: ; 9eb8 (2:5eb8)
ret
.right
- ld a, [wcea1]
+ ld a, [wCardListVisibleOffset]
add d
ld b, a
add d
- ld hl, wcfe4 + 2
+ ld hl, wNumCardListEntries
cp [hl]
- jr c, .asm_9ee8
- ld a, [wcfe4 + 2]
+ jr c, .got_new_pos
+ ld a, [wNumCardListEntries]
sub d
ld b, a
- jr .asm_9ee8
+ jr .got_new_pos
.left
- ld a, [wcea1]
+ ld a, [wCardListVisibleOffset]
sub d
ld b, a
- jr nc, .asm_9ee8
- ld b, $00
-.asm_9ee8
+ jr nc, .got_new_pos
+ ld b, 0 ; first index
+.got_new_pos
ld a, b
- ld [wcea1], a
+ ld [wCardListVisibleOffset], a
cp c
jr z, .asm_9efa
ld a, SFX_01
call PlaySFX
- ld hl, wcece
+ ld hl, wCardListUpdateFunction
call CallIndirect
.asm_9efa
scf
ret
; 0x9efc
-Func_9efc: ; 9efc (2:5efc)
- INCROM $9efc, $9f40
+; handles scrolling up and down with Select button
+; in this case, the cursor position goes up/down
+; by wCardListNumCursorPositions entries respectively
+; return carry if scrolling happened, otherwise no carry
+HandleSelectUpAndDownInList: ; 9efc (2:5efc)
+ ld a, [wCardListNumCursorPositions]
+ ld d, a
+ ld a, [wCardListVisibleOffset]
+ ld c, a
+ ldh a, [hDPadHeld]
+ cp SELECT | D_DOWN
+ jr z, .sel_down
+ cp SELECT | D_UP
+ jr z, .sel_up
+ or a
+ ret
+
+.sel_down
+ ld a, [wCardListVisibleOffset]
+ add d
+ ld b, a ; wCardListVisibleOffset + wCardListNumCursorPositions
+ add d
+ ld hl, wNumCardListEntries
+ cp [hl]
+ jr c, .got_new_pos
+ ld a, [wNumCardListEntries]
+ sub d
+ ld b, a ; wNumCardListEntries - wCardListNumCursorPositions
+ jr .got_new_pos
+.sel_up
+ ld a, [wCardListVisibleOffset]
+ sub d
+ ld b, a ; wCardListVisibleOffset - wCardListNumCursorPositions
+ jr nc, .got_new_pos
+ ld b, 0 ; go to first position
-Func_9f40: ; 9f40 (2:5f40)
- call Func_9f81
+.got_new_pos
+ ld a, b
+ ld [wCardListVisibleOffset], a
+ cp c
+ jr z, .set_carry
+ ld a, SFX_01
+ call PlaySFX
+ ld hl, wCardListUpdateFunction
+ call CallIndirect
+.set_carry
+ scf
+ ret
+; 0x9f40
+
+; simply draws the deck info header
+; then awaits a b button press to exit
+ShowDeckInfoHeaderAndWaitForBButton: ; 9f40 (2:5f40)
+ call ShowDeckInfoHeader
.wait_input
call DoFrame
ldh a, [hKeysPressed]
@@ -4274,10 +5541,10 @@ Func_9f40: ; 9f40 (2:5f40)
ret
; 0x9f52
-Func_9f52: ; 9f52 (2:5f52)
- call Func_9f81
+ShowConfirmationCardScreen: ; 9f52 (2:5f52)
+ call ShowDeckInfoHeader
lb de, 3, 5
- ld hl, wced0
+ ld hl, wCardListCoords
ld [hl], e
inc hl
ld [hl], d
@@ -4285,18 +5552,18 @@ Func_9f52: ; 9f52 (2:5f52)
ret
; 0x9f62
-; counts all values stored in wcebb
+; counts all values stored in wCardFilterCounts
; if the total count is 0, then
; prints "No cards chosen."
-Func_9f62: ; 9f62 (2:5f62)
+TallyCardsInCardFilterLists: ; 9f62 (2:5f62)
lb bc, 0, 0
- ld hl, wcebb
+ ld hl, wCardFilterCounts
.loop
ld a, [hli]
add b
ld b, a
inc c
- ld a, $9
+ ld a, NUM_FILTERS
cp c
jr nz, .loop
ld a, b
@@ -4309,16 +5576,22 @@ Func_9f62: ; 9f62 (2:5f62)
ret
; 0x9f81
-Func_9f81: ; 9f81 (2:5f81)
- call Func_8d56
+; draws a box on the top of the screen
+; with wCurDeck's number, name and card count
+; and draws the Hand Cards icon if it's
+; the current dueling deck
+ShowDeckInfoHeader: ; 9f81 (2:5f81)
+ call EmptyScreenAndLoadFontDuelAndHandCardsIcons
lb de, 0, 0
lb bc, 20, 4
call DrawRegularTextBox
- ld a, [wcfb9]
+ ld a, [wCurDeckName]
or a
- jp z, .print_card_count ; should be jr
- call Func_9fc0
- ld a, [wceb1]
+ jp z, .print_card_count ; can be jr
+
+; draw hand cards icon if it's the current dueling deck
+ call PrintCurDeckNumberAndName
+ ld a, [wCurDeck]
ld b, a
call EnableSRAM
ld a, [sCurrentlySelectedDeck]
@@ -4333,40 +5606,49 @@ Func_9f81: ; 9f81 (2:5f81)
call PrintTotalCardCount
lb de, 16, 1
call PrintSlashSixty
- call Func_9f62
+ call TallyCardsInCardFilterLists
call EnableLCD
ret
; 0x9fc0
-Func_9fc0: ; 9fc0 (2:5fc0)
- ld a, [wceb1]
+; prints the name of wCurDeck in the form
+; "X· <deck name> deck", where X is the number
+; of the deck in the given menu
+; if no current deck, print blank line
+PrintCurDeckNumberAndName: ; 9fc0 (2:5fc0)
+ ld a, [wCurDeck]
cp $ff
- jr z, .asm_9fea
+ jr z, .skip_deck_numeral
+
+; print the deck number in the menu
+; in the form "X·"
lb de, 3, 2
call InitTextPrinting
- ld a, [wceb1]
+ ld a, [wCurDeck]
bit 7, a
- jr z, .asm_9fd8
+ jr z, .incr_by_one
and $7f
- jr .asm_9fd9
-.asm_9fd8
+ jr .got_deck_numeral
+.incr_by_one
inc a
-.asm_9fd9
+.got_deck_numeral
ld hl, wDefaultText
call ConvertToNumericalDigits
- ld [hl], $77
+ ld [hl], "FW0_·"
inc hl
ld [hl], TX_END
ld hl, wDefaultText
call ProcessText
-.asm_9fea
- ld hl, wcfb9
+.skip_deck_numeral
+ ld hl, wCurDeckName
ld de, wDefaultText
call CopyListFromHLToDE
- ld a, [wceb1]
+ ld a, [wCurDeck]
cp $ff
- jr z, .asm_a01b
+ jr z, .blank_deck_name
+
+; print "<deck name> deck"
ld hl, wDefaultText
call GetTextLengthInTiles
ld b, $0
@@ -4374,7 +5656,7 @@ Func_9fc0: ; 9fc0 (2:5fc0)
add hl, bc
ld d, h
ld e, l
- ld hl, Data_92a7
+ ld hl, DeckNameSuffix
call CopyListFromHLToDE
lb de, 6, 2
ld hl, wDefaultText
@@ -4382,7 +5664,7 @@ Func_9fc0: ; 9fc0 (2:5fc0)
call ProcessText
ret
-.asm_a01b
+.blank_deck_name
lb de, 2, 2
ld hl, wDefaultText
call InitTextPrinting
@@ -4390,14 +5672,17 @@ Func_9fc0: ; 9fc0 (2:5fc0)
ret
; 0xa028
-Func_a028: ; a028 (2:6028)
- ld hl, wcf17
+; sorts wCurDeckCards by ID
+SortCurDeckCardsByID: ; a028 (2:6028)
+; wOpponentDeck is used to temporarily store deck's cards
+; so that it can be later sorted by ID
+ ld hl, wCurDeckCards
ld de, wOpponentDeck
ld bc, wDuelTempList
ld a, -1
ld [bc], a
.loop_copy
- inc a
+ inc a ; incr deck index
push af
ld a, [hli]
ld [de], a
@@ -4405,14 +5690,16 @@ Func_a028: ; a028 (2:6028)
or a
jr z, .sort_cards
pop af
- ld [bc], a
+ ld [bc], a ; store deck index
inc bc
jr .loop_copy
.sort_cards
pop af
- ld a, $ff
+ ld a, $ff ; terminator byte for wDuelTempList
ld [bc], a
+
+; force Opp Turn so that SortCardsInDuelTempListByID can be used
ldh a, [hWhoseTurn]
push af
ld a, OPPONENT_TURN
@@ -4421,9 +5708,13 @@ Func_a028: ; a028 (2:6028)
pop af
ldh [hWhoseTurn], a
- ld hl, wcf17
+; given the ordered cards in wOpponentDeck,
+; each entry in it corresponds to its deck index
+; (first ordered card is deck index 0, second is deck index 1, etc)
+; place these in this order in wCurDeckCards
+ ld hl, wCurDeckCards
ld de, wDuelTempList
-.asm_a058
+.loop_order_by_deck_index
ld a, [de]
cp $ff
jr z, .done
@@ -4436,7 +5727,7 @@ Func_a028: ; a028 (2:6028)
pop hl
ld [hli], a
inc de
- jr .asm_a058
+ jr .loop_order_by_deck_index
.done
xor a
@@ -4444,15 +5735,15 @@ Func_a028: ; a028 (2:6028)
ret
; 0xa06e
-; goes through list in wcf17, and for each card in it
-; creates list in wTempHandCardList of all unique cards
-; it finds (assuming wcf17 is sorted by ID)
-; also counts the number of the different cards
-Func_a06e: ; a06e (2:606e)
+; goes through list in wCurDeckCards, and for each card in it
+; creates list in wUniqueDeckCardList of all unique cards
+; it finds (assuming wCurDeckCards is sorted by ID)
+; also counts the total number of the different cards
+CreateCurDeckUniqueCardList: ; a06e (2:606e)
ld b, 0
ld c, $0
- ld hl, wcf17
- ld de, wTempHandCardList
+ ld hl, wCurDeckCards
+ ld de, wUniqueDeckCardList
.loop
ld a, [hli]
cp c
@@ -4466,7 +5757,7 @@ Func_a06e: ; a06e (2:606e)
jr .loop
.done
ld a, b
- ld [wced9], a
+ ld [wNumUniqueCards], a
ret
; 0xa08a
@@ -4476,14 +5767,14 @@ Func_a06e: ; a06e (2:606e)
; its count preceded by "x"
PrintConfirmationCardList: ; a08a (2:608a)
push bc
- ld hl, wced0
+ ld hl, wCardListCoords
ld e, [hl]
inc hl
ld d, [hl]
ld b, 19 ; x coord
ld c, e
dec c
- ld a, [wcea1]
+ ld a, [wCardListVisibleOffset]
or a
jr z, .no_cursor
ld a, SYM_CURSOR_U
@@ -4493,14 +5784,14 @@ PrintConfirmationCardList: ; a08a (2:608a)
.got_cursor_tile_1
call WriteByteToBGMap0
-; iterates by decreasing value in wcecb
+; iterates by decreasing value in wNumVisibleCardListEntries
; by 1 until it reaches 0
- ld a, [wcea1]
+ ld a, [wCardListVisibleOffset]
ld c, a
ld b, $0
- ld hl, wTempHandCardList
+ ld hl, wOwnedCardsCountList
add hl, bc
- ld a, [wcecb]
+ ld a, [wNumVisibleCardListEntries]
.loop_cards
push de
or a
@@ -4510,7 +5801,7 @@ PrintConfirmationCardList: ; a08a (2:608a)
or a
jr z, .no_more_cards
ld e, a
- call Func_9a59
+ call AddCardIDToVisibleList
call LoadCardDataToBuffer1_FromCardID
; places in wDefaultText the card's name and level
; then appends at the end "x" with the count of that card
@@ -4542,15 +5833,15 @@ PrintConfirmationCardList: ; a08a (2:608a)
or a
jr z, .no_more_cards
pop de
- xor a
- ld [wcecd], a
+ xor a ; FALSE
+ ld [wUnableToScrollDown], a
ld a, SYM_CURSOR_D
jr .got_cursor_tile_2
.no_more_cards
pop de
- ld a, $01
- ld [wcecd], a
+ ld a, TRUE
+ ld [wUnableToScrollDown], a
ld a, SYM_SPACE
.got_cursor_tile_2
ld b, 19 ; x coord
@@ -4575,7 +5866,7 @@ PrintConfirmationCardList: ; a08a (2:608a)
inc hl
jr .loop_search
.found_card_id
- call Func_9850
+ call GetCountOfCardInCurDeck
ld [hl], TX_SYMBOL
inc hl
ld [hl], SYM_CROSS
@@ -4668,7 +5959,7 @@ GetCardTypeIconPalette: ; a173 (2:6173)
cp b
jr z, .done
inc hl
- jp .loop ; should be jr
+ jp .loop ; can be jr
.done
ld a, [hl]
pop hl
@@ -4692,26 +5983,29 @@ GetCardTypeIconPalette: ; a173 (2:6173)
db $00, $ff
; 0xa1a2
-Func_a1a2: ; a1a2 (2:61a2)
- ld hl, wcf17
- ld a, DECK_SIZE + $15
+; inits WRAM vars to start creating deck configuration to send
+PrepareToBuildDeckConfigurationToSend: ; a1a2 (2:61a2)
+ ld hl, wCurDeckCards
+ ld a, wCurDeckCardsEnd - wCurDeckCards
call ClearNBytesFromHL
ld a, $ff
- ld [wceb1], a
+ ld [wCurDeck], a
ld hl, .text
- ld de, wcfb9
+ ld de, wCurDeckName
call CopyListFromHLToDE
- ld hl, .unknown_a1d8
- call Func_8d9d
- call Func_9345
+ ld hl, .DeckConfigurationParams
+ call InitDeckBuildingParams
+ call HandleDeckBuildScreen
ret
.text
text "Cards chosen to send"
- db TX_END
+ done
-.unknown_a1d8
- db $3c, $3c, $00
+.DeckConfigurationParams
+ db DECK_SIZE ; max number of cards
+ db 60 ; max number of same name cards
+ db FALSE ; whether to include deck cards
dw HandleSendDeckConfigurationMenu
dw SendDeckConfigurationMenu_TransitionTable
; 0xa1df
@@ -4739,21 +6033,21 @@ HandleSendDeckConfigurationMenu: ; a201 (2:6201)
ld a, $01
ld [wVBlankOAMCopyToggle], a
call DoFrame
- call Func_89ae
+ call YourOrOppPlayAreaScreen_HandleInput
jr nc, .loop_input
ld [wced6], a
cp $ff
jr nz, .asm_a23b
call DrawCardTypeIconsAndPrintCardCounts
- ld a, [wced4]
- ld [wNamingScreenCursorY], a
- ld a, [wced3]
- call Func_993d
- jp Func_9345.skip_draw
+ ld a, [wTempCardListCursorPos]
+ ld [wCardListCursorPos], a
+ ld a, [wCurCardTypeFilter]
+ call PrintFilteredCardList
+ jp HandleDeckBuildScreen.skip_draw
.asm_a23b
ld hl, .func_table
call JumpToFunctionInTable
- jp Func_9461.asm_9475
+ jp OpenDeckConfigurationMenu.skip_init
.func_table
dw ConfirmDeckConfiguration ; Confirm
@@ -4762,24 +6056,24 @@ HandleSendDeckConfigurationMenu: ; a201 (2:6201)
; 0xa24a
SendDeckConfiguration: ; a24a (2:624a)
- ld a, [wcf17]
+ ld a, [wCurDeckCards]
or a
jr z, CancelSendDeckConfiguration
xor a
- ld [wcea1], a
+ ld [wCardListVisibleOffset], a
ld hl, Data_b04a
- call Func_9a6d
- ld hl, wcf17
+ call InitCardSelectionParams
+ ld hl, wCurDeckCards
ld de, wDuelTempList
call CopyListFromHLToDE
- call Func_b131
+ call PrintCardToSendText
call Func_b088
call EnableLCD
ldtx hl, SendTheseCardsText
call YesOrNoMenuWithText
jr nc, .asm_a279
add sp, $2
- jp Func_9345.skip_count
+ jp HandleDeckBuildScreen.skip_count
.asm_a279
add sp, $2
scf
@@ -4801,48 +6095,223 @@ CopyNBytesFromHLToDE: ; a281 (2:6281)
ret
; 0xa288
-Func_a288: ; a288 (2:6288)
- INCROM $a288, $a3ca
+; handles the screen showing all the player's cards
+HandlePlayersCardsScreen: ; a288 (2:6288)
+ call WriteCardListsTerminatorBytes
+ call PrintPlayersCardsHeaderInfo
+ xor a
+ ld [wCardListVisibleOffset], a
+ ld [wCurCardTypeFilter], a
+ call PrintFilteredCardSelectionList
+ call EnableLCD
+ xor a
+ ld hl, FiltersCardSelectionParams
+ call InitCardSelectionParams
+.wait_input
+ call DoFrame
+ ld a, [wCurCardTypeFilter]
+ ld b, a
+ ld a, [wTempCardTypeFilter]
+ cp b
+ jr z, .check_d_down
+ ld [wCurCardTypeFilter], a
+ ld hl, wCardListVisibleOffset
+ ld [hl], $00
+ call PrintFilteredCardSelectionList
+
+ ld hl, hffb0
+ ld [hl], $01
+ call PrintPlayersCardsText
+ ld hl, hffb0
+ ld [hl], $00
+
+ ld a, NUM_FILTERS
+ ld [wCardListNumCursorPositions], a
+.check_d_down
+ ldh a, [hDPadHeld]
+ and D_DOWN
+ jr z, .no_d_down
+ call ConfirmSelectionAndReturnCarry
+ jr .jump_to_list
+
+.no_d_down
+ call HandleCardSelectionInput
+ jr nc, .wait_input
+ ld a, [hffb3]
+ cp $ff ; operation cancelled
+ jr nz, .jump_to_list
+ ret
-Func_a3ca: ; a3ca (2:63ca)
+.jump_to_list
+ ld a, [wNumEntriesInCurFilter]
+ or a
+ jr z, .wait_input
+
+ xor a
+ ld hl, Data_a396
+ call InitCardSelectionParams
+ ld a, [wNumEntriesInCurFilter]
+ ld [wNumCardListEntries], a
+ ld hl, wNumVisibleCardListEntries
+ cp [hl]
+ jr nc, .asm_a300
+ ld [wCardListNumCursorPositions], a
+.asm_a300
+ ld hl, PrintCardSelectionList
+ ld d, h
+ ld a, l
+ ld hl, wCardListUpdateFunction
+ ld [hli], a
+ ld [hl], d
+ xor a
+ ld [wced2], a
+
+.loop_input
+ call DoFrame
+ call HandleSelectUpAndDownInList
+ jr c, .loop_input
+ call HandleDeckCardSelectionList
+ jr c, .asm_a36a
+ ldh a, [hDPadHeld]
+ and START
+ jr z, .loop_input
+ ; start btn pressed
+
+.open_card_page
+ ld a, $01
+ call PlaySFXConfirmOrCancel
+ ld a, [wCardListNumCursorPositions]
+ ld [wTempCardListNumCursorPositions], a
+ ld a, [wCardListCursorPos]
+ ld [wTempCardListCursorPos], a
+
+ ; set wFilteredCardList as current card list
+ ; and show card page screen
+ ld de, wFilteredCardList
+ ld hl, wCurCardListPtr
+ ld [hl], e
+ inc hl
+ ld [hl], d
+ call OpenCardPageFromCardList
+ call PrintPlayersCardsHeaderInfo
+
+ ld hl, FiltersCardSelectionParams
+ call InitCardSelectionParams
+ ld a, [wCurCardTypeFilter]
+ ld [wTempCardTypeFilter], a
+ call DrawHorizontalListCursor_Visible
+ call PrintCardSelectionList
+ call EnableLCD
+ ld hl, Data_a396
+ call InitCardSelectionParams
+ ld a, [wTempCardListNumCursorPositions]
+ ld [wCardListNumCursorPositions], a
+ ld a, [wTempCardListCursorPos]
+ ld [wCardListCursorPos], a
+ jr .loop_input
+
+.asm_a36a
+ call DrawListCursor_Invisible
+ ld a, [wCardListCursorPos]
+ ld [wTempCardListCursorPos], a
+ ld a, [hffb3]
+ cp $ff
+ jr nz, .open_card_page
+ ld hl, FiltersCardSelectionParams
+ call InitCardSelectionParams
+ ld a, [wCurCardTypeFilter]
+ ld [wTempCardTypeFilter], a
+ ld hl, hffb0
+ ld [hl], $01
+ call PrintPlayersCardsText
+ ld hl, hffb0
+ ld [hl], $00
+ jp .wait_input
+; 0xa396
+
+Data_a396: ; a396 (2:6396)
+ db 1 ; x pos
+ db 5 ; y pos
+ db 2 ; y spacing
+ db 0 ; x spacing
+ db 7 ; num entries
+ db SYM_CURSOR_R ; visible cursor tile
+ db SYM_SPACE ; invisible cursor tile
+ dw NULL ; wCardListHandlerFunction
+; 0xa39f
+
+; a = which card type filter
+PrintFilteredCardSelectionList: ; a39f (2:639f)
+ push af
+ ld hl, CardTypeFilters
+ ld b, $00
+ ld c, a
+ add hl, bc
+ ld a, [hl]
+ push af
+ ld a, ALL_DECKS
+ call CreateCardCollectionListWithDeckCards
+ pop af
+ call CreateFilteredCardList
+
+ ld a, NUM_DECK_CONFIRMATION_VISIBLE_CARDS
+ ld [wNumVisibleCardListEntries], a
+ lb de, 2, 5
+ ld hl, wCardListCoords
+ ld [hl], e
+ inc hl
+ ld [hl], d
+ ld a, SYM_SPACE
+ ld [wCursorAlternateTile], a
+ call PrintCardSelectionList
+ pop af
+ ret
+; 0xa3ca
+
+; outputs in wTempCardCollection all the cards in sCardCollection
+; plus the cards that are being used in built decks
+; a = DECK_* flags for which decks to include in the collection
+CreateCardCollectionListWithDeckCards: ; a3ca (2:63ca)
ld [hffb5], a
+; copies sCardCollection to wTempCardCollection
ld hl, sCardCollection
ld de, wTempCardCollection
- ld b, $ff
+ ld b, CARD_COLLECTION_SIZE - 1
call EnableSRAM
call CopyNBytesFromHLToDE
call DisableSRAM
+
; deck_1
ld a, [hffb5] ; should be ldh
- bit 0, a
+ bit DECK_1_F, a
jr z, .deck_2
ld de, sDeck1Cards
- call GetDeckCardCounts
+ call IncrementDeckCardsInTempCollection
.deck_2
ld a, [hffb5] ; should be ldh
- bit 1, a
+ bit DECK_2_F, a
jr z, .deck_3
ld de, sDeck2Cards
- call GetDeckCardCounts
+ call IncrementDeckCardsInTempCollection
.deck_3
ld a, [hffb5] ; should be ldh
- bit 2, a
+ bit DECK_3_F, a
jr z, .deck_4
ld de, sDeck3Cards
- call GetDeckCardCounts
+ call IncrementDeckCardsInTempCollection
.deck_4
ld a, [hffb5] ; should be ldh
- bit 3, a
+ bit DECK_4_F, a
ret z
ld de, sDeck4Cards
- call GetDeckCardCounts
+ call IncrementDeckCardsInTempCollection
ret
; 0xa412
-; goes through deck cards in de
-; and gets the count of each card ID
-; in wTempCardCollection in card collection order
-GetDeckCardCounts: ; a412 (2:6412)
+; goes through cards in deck in de
+; and for each card ID, increments its corresponding
+; entry in wTempCardCollection
+IncrementDeckCardsInTempCollection: ; a412 (2:6412)
call EnableSRAM
ld bc, wTempCardCollection
ld h, DECK_SIZE
@@ -4871,13 +6340,13 @@ GetDeckCardCounts: ; a412 (2:6412)
; where X is the current count of that card
PrintCardSelectionList: ; a42d (2:642d)
push bc
- ld hl, wced0
+ ld hl, wCardListCoords
ld e, [hl]
inc hl
ld d, [hl]
ld b, 19 ; x coord
ld c, e
- ld a, [wcea1]
+ ld a, [wCardListVisibleOffset]
or a
jr z, .alternate_cursor_tile
ld a, SYM_CURSOR_U
@@ -4887,14 +6356,14 @@ PrintCardSelectionList: ; a42d (2:642d)
.got_cursor_tile_1
call WriteByteToBGMap0
-; iterates by decreasing value in wcecb
+; iterates by decreasing value in wNumVisibleCardListEntries
; by 1 until it reaches 0
- ld a, [wcea1]
+ ld a, [wCardListVisibleOffset]
ld c, a
ld b, $0
ld hl, wFilteredCardList
add hl, bc
- ld a, [wcecb]
+ ld a, [wNumVisibleCardListEntries]
.loop_filtered_cards
push de
or a
@@ -4904,7 +6373,7 @@ PrintCardSelectionList: ; a42d (2:642d)
or a
jr z, .invalid_card ; card ID of 0
ld e, a
- call Func_9a59
+ call AddCardIDToVisibleList
call LoadCardDataToBuffer1_FromCardID
; places in wDefaultText the card's name and level
; then appends at the end the count of that card
@@ -4946,14 +6415,14 @@ PrintCardSelectionList: ; a42d (2:642d)
; draw down cursor because
; there are still more cards
; to be scrolled down
- xor a
- ld [wcecd], a
+ xor a ; FALSE
+ ld [wUnableToScrollDown], a
ld a, SYM_CURSOR_D
jr .got_cursor_tile_2
.cannot_scroll
pop de
- ld a, $01
- ld [wcecd], a
+ ld a, TRUE
+ ld [wUnableToScrollDown], a
ld a, [wCursorAlternateTile]
.got_cursor_tile_2
ld b, 19 ; x coord
@@ -4991,16 +6460,1602 @@ AppendOwnedCardCountNumber: ; a4ae (2:64ae)
ret
; 0xa4c6
- INCROM $a4c6, $a913
+; print header info (card count and player name)
+PrintPlayersCardsHeaderInfo: ; a4c6 (2:64c6)
+ call Set_OBJ_8x8
+ call Func_8d78
+.skip_empty_screen
+ lb bc, 0, 4
+ ld a, SYM_BOX_TOP
+ call FillBGMapLineWithA
+ call PrintTotalNumberOfCardsInCollection
+ call PrintPlayersCardsText
+ call DrawCardTypeIcons
+ ret
+; 0xa4de
+
+; prints "<PLAYER>'s cards"
+PrintPlayersCardsText: ; a4de (2:64de)
+ lb de, 1, 0
+ call InitTextPrinting
+ ld de, wDefaultText
+ call CopyPlayerName
+ ld hl, wDefaultText
+ call ProcessText
+ ld hl, wDefaultText
+ call GetTextLengthInTiles
+ inc b
+ ld d, b
+ ld e, 0
+ call InitTextPrinting
+ ldtx hl, SCardsText
+ call ProcessTextFromID
+ ret
+; 0xa504
+
+PrintTotalNumberOfCardsInCollection: ; a504 (2:6504)
+ ld a, ALL_DECKS
+ call CreateCardCollectionListWithDeckCards
+
+; count all the cards in collection
+ ld de, wTempCardCollection + 1
+ ld b, 0
+ ld hl, 0
+.loop_all_cards
+ ld a, [de]
+ inc de
+ and $7f
+ push bc
+ ld b, $00
+ ld c, a
+ add hl, bc
+ pop bc
+ inc b
+ ld a, NUM_CARDS
+ cp b
+ jr nz, .loop_all_cards
+
+; hl = total number of cards in collection
+ call .GetTotalCountDigits
+ ld hl, wTempCardCollection
+ ld de, wOnesAndTensPlace
+ ld b, $00
+ call .PlaceNumericalChar
+ call .PlaceNumericalChar
+ call .PlaceNumericalChar
+ call .PlaceNumericalChar
+ call .PlaceNumericalChar
+ ld a, $07
+ ld [hli], a
+ ld [hl], TX_END
+ lb de, 13, 0
+ call InitTextPrinting
+ ld hl, wTempCardCollection
+ call ProcessText
+ ret
+
+; places a numerical character in hl from de
+; doesn't place a 0 if no non-0
+; numerical character has been placed before
+; this makes it so that there are no
+; 0s in more significant digits
+.PlaceNumericalChar
+ ld [hl], TX_SYMBOL
+ inc hl
+ ld a, b
+ or a
+ jr z, .leading_num
+ ld a, [de]
+ inc de
+ ld [hli], a
+ ret
+.leading_num
+; don't place a 0 as a leading number
+ ld a, [de]
+ inc de
+ cp SYM_0
+ jr z, .space_char
+ ld [hli], a
+ ld b, $01 ; at least one non-0 char was placed
+ ret
+.space_char
+ xor a ; SYM_SPACE
+ ld [hli], a
+ ret
+
+; gets the digits in decimal form
+; of value stored in hl
+; stores the result in wOnesAndTensPlace
+.GetTotalCountDigits
+ ld de, wOnesAndTensPlace
+ ld bc, -10000
+ call .GetDigit
+ ld bc, -1000
+ call .GetDigit
+ ld bc, -100
+ call .GetDigit
+ ld bc, -10
+ call .GetDigit
+ ld bc, -1
+ call .GetDigit
+ ret
+
+.GetDigit
+ ld a, SYM_0 - 1
+.loop
+ inc a
+ add hl, bc
+ jr c, .loop
+ ld [de], a
+ inc de
+ ld a, l
+ sub c
+ ld l, a
+ ld a, h
+ sbc b
+ ld h, a
+ ret
+; 0xa596
+
+; fills wFilteredCardList and wOwnedCardsCountList
+; with cards IDs and counts, respectively,
+; from given Card Set in register a
+; a = CARD_SET_* constant
+CreateCardSetList: ; a596 (2:6596)
+ 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
-Func_a913: ; a913 (2:6913)
- INCROM $a913, $ad51
+ inc l
+ pop bc
+ jr .loop_all_cards
-Func_ad51: ; ad51 (2:6d51)
- INCROM $ad51, $adfe
+.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
-Func_adfe: ; adfe (2:6dfe)
- INCROM $adfe, $af1d
+; 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
+; 0xa6a0
+
+; a = CARD_SET_* constant
+CreateCardSetListAndInitListCoords: ; a6a0 (2:66a0)
+ 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
+; 0xa6fa
+
+; prints the cards being shown in the Card Album screen
+; for the corresponding Card Set
+PrintCardSetListEntries: ; a6fa (2:66fa)
+ 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
+; 0xa828
+
+; handles opening card page, and inputs when inside Card Album
+HandleCardAlbumCardPage: ; a828 (2:6828)
+ 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
+; 0xa901
+
+GetFirstOwnedCardIndex: ; a901 (2:6901)
+ 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
+; 0xa913
+
+HandleCardAlbumScreen: ; a913 (2:6913)
+ 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 SetDefaultPalettes
+ 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 SetDefaultPalettes
+ 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
+; 0xab7b
+
+PrinterMenu_PokemonCards: ; ab7b (2:6b7b)
+ call WriteCardListsTerminatorBytes
+ call PrintPlayersCardsHeaderInfo
+ xor a
+ ld [wCardListVisibleOffset], a
+ ld [wCurCardTypeFilter], a
+ call PrintFilteredCardSelectionList
+ call EnableLCD
+ xor a
+ ld hl, FiltersCardSelectionParams
+ call InitCardSelectionParams
+
+.loop_frame_1
+ call DoFrame
+ ld a, [wCurCardTypeFilter]
+ ld b, a
+ ld a, [wTempCardTypeFilter]
+ cp b
+ jr z, .handle_input
+ ld [wCurCardTypeFilter], a
+ ld hl, wCardListVisibleOffset
+ ld [hl], $00
+ call PrintFilteredCardSelectionList
+ ld hl, hffb0
+ ld [hl], $01
+ call PrintPlayersCardsText
+ ld hl, hffb0
+ ld [hl], $00
+ ld a, NUM_FILTERS
+ ld [wCardListNumCursorPositions], a
+.handle_input
+ ldh a, [hDPadHeld]
+ and D_DOWN
+ jr z, .asm_abca
+; d_down
+ call ConfirmSelectionAndReturnCarry
+ jr .asm_abd7
+.asm_abca
+ call HandleCardSelectionInput
+ jr nc, .loop_frame_1
+ ld a, [hffb3]
+ cp $ff
+ jr nz, .asm_abd7
+ ret
+
+.asm_abd7
+ ld a, [wNumEntriesInCurFilter]
+ or a
+ jr z, .loop_frame_1
+
+ xor a
+ ld hl, Data_a396
+ call InitCardSelectionParams
+ ld a, [wNumEntriesInCurFilter]
+ ld [wNumCardListEntries], a
+ ld hl, wNumVisibleCardListEntries
+ cp [hl]
+ jr nc, .asm_abf6
+ ld [wCardListNumCursorPositions], a
+ ld [wTempCardListNumCursorPositions], a
+.asm_abf6
+ ld hl, PrintCardSelectionList
+ ld d, h
+ ld a, l
+ ld hl, wCardListUpdateFunction
+ ld [hli], a
+ ld [hl], d
+ xor a
+ ld [wced2], a
+
+.loop_frame_2
+ call DoFrame
+ call HandleSelectUpAndDownInList
+ jr c, .loop_frame_2
+ call HandleDeckCardSelectionList
+ jr c, .asm_ac60
+ ldh a, [hDPadHeld]
+ and START
+ jr z, .loop_frame_2
+; start btn
+ ld a, $01
+ call PlaySFXConfirmOrCancel
+ ld a, [wCardListNumCursorPositions]
+ ld [wTempCardListNumCursorPositions], a
+ ld a, [wCardListCursorPos]
+ ld [wTempCardListCursorPos], a
+
+ ; set wFilteredCardList as current card list
+ ; and show card page screen
+ ld de, wFilteredCardList
+ ld hl, wCurCardListPtr
+ ld [hl], e
+ inc hl
+ ld [hl], d
+ call OpenCardPageFromCardList
+ call PrintPlayersCardsHeaderInfo
+
+.asm_ac37
+ ld hl, FiltersCardSelectionParams
+ call InitCardSelectionParams
+ ld a, [wCurCardTypeFilter]
+ ld [wTempCardTypeFilter], a
+ call DrawHorizontalListCursor_Visible
+ call PrintCardSelectionList
+ call EnableLCD
+ ld hl, Data_a396
+ call InitCardSelectionParams
+ ld a, [wTempCardListNumCursorPositions]
+ ld [wCardListNumCursorPositions], a
+ ld a, [wTempCardListCursorPos]
+ ld [wCardListCursorPos], a
+ jr .loop_frame_2
+
+.asm_ac60
+ call DrawListCursor_Invisible
+ ld a, [wCardListNumCursorPositions]
+ ld [wTempCardListNumCursorPositions], a
+ ld a, [wCardListCursorPos]
+ ld [wTempCardListCursorPos], a
+ ld a, [hffb3]
+ cp $ff
+ jr nz, .asm_ac92
+
+ ld hl, FiltersCardSelectionParams
+ call InitCardSelectionParams
+ ld a, [wCurCardTypeFilter]
+ ld [wTempCardTypeFilter], a
+ ld hl, hffb0
+ ld [hl], $01
+ call PrintPlayersCardsText
+ ld hl, hffb0
+ ld [hl], $00
+ jp .loop_frame_1
+
+.asm_ac92
+ call DrawListCursor_Visible
+ call .Func_acde
+ lb de, 1, 1
+ call InitTextPrinting
+ ldtx hl, PrintThisCardYesNoText
+ call ProcessTextFromID
+ ld a, $01
+ ld hl, Data_ad05
+ call InitCardSelectionParams
+.loop_frame
+ call DoFrame
+ call HandleCardSelectionInput
+ jr nc, .loop_frame
+ ld a, [hffb3]
+ or a
+ jr nz, .asm_acd5
+ ld hl, wFilteredCardList
+ ld a, [wTempCardListCursorPos]
+ ld c, a
+ ld b, $00
+ add hl, bc
+ ld a, [wCardListVisibleOffset]
+ ld c, a
+ ld b, $00
+ add hl, bc
+ ld a, [hl]
+ bank1call Func_758a
+ call PrintPlayersCardsHeaderInfo
+ jp .asm_ac37
+
+.asm_acd5
+ call .Func_acde
+ call PrintPlayersCardsHeaderInfo.skip_empty_screen
+ jp .asm_ac37
+
+.Func_acde
+ xor a
+ lb hl, 0, 0
+ lb de, 0, 0
+ lb bc, 20, 4
+ call FillRectangle
+ ld a, [wConsole]
+ cp CONSOLE_CGB
+ ret nz ; exit if not CGB
+
+ xor a
+ lb hl, 0, 0
+ lb de, 0, 0
+ lb bc, 20, 4
+ call BankswitchVRAM1
+ call FillRectangle
+ call BankswitchVRAM0
+ ret
+; 0xad0e
+
+Data_ad05: ; ad05 (2:6d05)
+ db 3 ; x pos
+ db 3 ; y pos
+ db 0 ; y spacing
+ db 4 ; x spacing
+ db 2 ; num entries
+ db SYM_CURSOR_R ; visible cursor tile
+ db SYM_SPACE ; invisible cursor tile
+ dw NULL ; wCardListHandlerFunction
+; 0xad0e
+
+PrinterMenu_CardList: ; ad0e (2:6d0e)
+ call WriteCardListsTerminatorBytes
+ call Set_OBJ_8x8
+ call Func_8d78
+ lb bc, 0, 4
+ ld a, SYM_BOX_TOP
+ call FillBGMapLineWithA
+
+ xor a
+ ld [wCardListVisibleOffset], a
+ ld [wCurCardTypeFilter], a
+ call PrintFilteredCardSelectionList
+ call EnableLCD
+ lb de, 1, 1
+ call InitTextPrinting
+ ld hl, EnableLCD
+ call ProcessTextFromID
+ ld a, $01
+ ld hl, Data_ad05
+ call InitCardSelectionParams
+.loop_frame
+ call DoFrame
+ call HandleCardSelectionInput
+ jr nc, .loop_frame
+ ld a, [hffb3]
+ or a
+ ret nz
+ bank1call Func_7585
+ ret
+; 0xad51
+
+HandlePrinterMenu: ; ad51 (2:6d51)
+ bank1call Func_757b
+ ret c
+ xor a
+.loop
+ ld hl, PrinterMenuParameters
+ call InitializeMenuParameters
+ call EmptyScreenAndLoadFontDuelAndHandCardsIcons
+ lb de, 4, 0
+ lb bc, 12, 12
+ call DrawRegularTextBox
+ lb de, 6, 2
+ call InitTextPrinting
+ ldtx hl, PrintMenuItemsText
+ call ProcessTextFromID
+ ldtx hl, WhatWouldYouLikeToPrintText
+ call DrawWideTextBox_PrintText
+ call EnableLCD
+.loop_input
+ call DoFrame
+ call HandleMenuInput
+ jr nc, .loop_input
+ ldh a, [hCurMenuItem]
+ cp $ff
+ call z, PrinterMenu_QuitPrint
+ ld [wcfe4], a
+ ld hl, PrinterMenuFunctionTable
+ call JumpToFunctionInTable
+ ld a, [wcfe4]
+ jr .loop
+; 0xad9a
+
+PrinterMenu_QuitPrint: ; ad9a (2:6d9a)
+ add sp, $2 ; exit menu
+ ldtx hl, PleaseMakeSureToTurnGameBoyPrinterOffText
+ call DrawWideTextBox_WaitForInput
+ ret
+; 0xada3
+
+PrinterMenuFunctionTable: ; ada3 (2:6da3)
+ dw PrinterMenu_PokemonCards
+ dw PrinterMenu_DeckConfiguration
+ dw PrinterMenu_CardList
+ dw PrinterMenu_PrintQuality
+ dw PrinterMenu_QuitPrint
+; 0xadad
+
+PrinterMenuParameters: ; adad (2:6dad)
+ db 5, 2 ; 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
+; 0xadb5
+
+PrinterMenu_PrintQuality: ; adb5 (2:6db5)
+ ldtx hl, PleaseSetTheContrastText
+ call DrawWideTextBox_PrintText
+ call EnableSRAM
+ ld a, [sPrinterContrastLevel]
+ call DisableSRAM
+ ld hl, Data_adf5
+ call InitCardSelectionParams
+.loop_frame
+ call DoFrame
+ call HandleCardSelectionInput
+ jr nc, .loop_frame
+ ld a, [hffb3]
+ cp $ff
+ jr z, .asm_ade2
+ call EnableSRAM
+ ld [sPrinterContrastLevel], a
+ call DisableSRAM
+.asm_ade2
+ add sp, $2 ; exit menu
+ ld a, [wcfe4]
+ ld hl, PrinterMenuParameters
+ call InitializeMenuParameters
+ ldtx hl, WhatWouldYouLikeToPrintText
+ call DrawWideTextBox_PrintText
+ jr HandlePrinterMenu.loop_input
+; 0xadf5
+
+Data_adf5: ; adf5 (2:6df5)
+ db 5 ; x pos
+ db 16 ; y pos
+ db 0 ; y spacing
+ db 2 ; x spacing
+ db 5 ; num entries
+ db SYM_CURSOR_R ; visible cursor tile
+ db SYM_SPACE ; invisible cursor tile
+ dw NULL ; wCardListHandlerFunction
+; 0xadfe
+
+; handles printing and player input
+; in the card confirmation list shown
+; when cards are missing for some deck configuration
+; hl = deck name
+; de = deck cards
+HandleDeckMissingCardsList: ; adfe (2:6dfe)
+; read deck name from hl and cards from de
+ push de
+ ld de, wCurDeckName
+ call CopyListFromHLToDEInSRAM
+ pop de
+ ld hl, wCurDeckCards
+ call CopyDeckFromSRAM
+
+ ld a, NUM_FILTERS
+ ld hl, wCardFilterCounts
+ call ClearNBytesFromHL
+ ld a, DECK_SIZE
+ ld [wTotalCardCount], a
+ ld hl, wCardFilterCounts
+ ld [hl], a
+ call .HandleList ; can skip call and fallthrough instead
+ ret
+
+.HandleList
+ call SortCurDeckCardsByID
+ call CreateCurDeckUniqueCardList
+ xor a
+ ld [wCardListVisibleOffset], a
+.loop
+ ld hl, .DeckConfirmationCardSelectionParams
+ call InitCardSelectionParams
+ ld a, [wNumUniqueCards]
+ ld [wNumCardListEntries], a
+ cp $05
+ jr c, .got_num_positions
+ ld a, $05
+.got_num_positions
+ ld [wCardListNumCursorPositions], a
+ ld [wNumVisibleCardListEntries], a
+ call .PrintTitleAndList
+ ld hl, wCardConfirmationText
+ ld a, [hli]
+ ld h, [hl]
+ ld l, a
+ call DrawWideTextBox_PrintText
+
+; set card update function
+ ld hl, .CardListUpdateFunction
+ ld d, h
+ ld a, l
+ ld hl, wCardListUpdateFunction
+ ld [hli], a
+ ld [hl], d
+ xor a
+ ld [wced2], a
+
+.loop_input
+ call DoFrame
+ call HandleDeckCardSelectionList
+ jr c, .selection_made
+ call HandleLeftRightInCardList
+ jr c, .loop_input
+ ldh a, [hDPadHeld]
+ and START
+ jr z, .loop_input
+
+.open_card_pge
+ ld a, $01
+ call PlaySFXConfirmOrCancel
+ ld a, [wCardListCursorPos]
+ ld [wced7], a
+
+ ; set wOwnedCardsCountList as current card list
+ ; and show card page screen
+ ld de, wOwnedCardsCountList
+ ld hl, wCurCardListPtr
+ ld [hl], e
+ inc hl
+ ld [hl], d
+ call OpenCardPageFromCardList
+ jr .loop
+
+.selection_made
+ ld a, [hffb3]
+ cp $ff
+ ret z
+ jr .open_card_pge
+
+.DeckConfirmationCardSelectionParams
+ db 0 ; x pos
+ db 3 ; y pos
+ db 2 ; y spacing
+ db 0 ; x spacing
+ db 5 ; num entries
+ db SYM_CURSOR_R ; visible cursor tile
+ db SYM_SPACE ; invisible cursor tile
+ dw NULL ; wCardListHandlerFunction
+
+.CardListUpdateFunction
+ ld hl, hffb0
+ ld [hl], $01
+ call .PrintDeckIndexAndName
+ lb de, 1, 14
+ call InitTextPrinting
+ ld hl, wCardConfirmationText
+ ld a, [hli]
+ ld h, [hl]
+ ld l, a
+ call ProcessTextFromID
+ ld hl, hffb0
+ ld [hl], $00
+ jp PrintConfirmationCardList
+
+.PrintTitleAndList
+ call .ClearScreenAndPrintDeckTitle
+ lb de, 3, 3
+ ld hl, wCardListCoords
+ ld [hl], e
+ inc hl
+ ld [hl], d
+ call PrintConfirmationCardList
+ ret
+
+.ClearScreenAndPrintDeckTitle
+ call EmptyScreenAndLoadFontDuelAndHandCardsIcons
+ call .PrintDeckIndexAndName
+ call EnableLCD
+ ret
+
+; prints text in the form "X.<DECK NAME> deck"
+; where X is the deck index in the list
+.PrintDeckIndexAndName
+ ld a, [wCurDeckName]
+ or a
+ ret z ; not a valid deck
+ lb de, 0, 1
+ call InitTextPrinting
+ ld a, [wCurDeck]
+ inc a
+ ld hl, wDefaultText
+ call ConvertToNumericalDigits
+ ld [hl], "FW0_·"
+ inc hl
+ ld [hl], TX_END
+ ld hl, wDefaultText
+ call ProcessText
+
+ ld hl, wCurDeckName
+ ld de, wDefaultText
+ call CopyListFromHLToDE
+ ld hl, wDefaultText
+ call GetTextLengthInTiles
+ ld b, $0
+ ld hl, wDefaultText
+ add hl, bc
+ ld d, h
+ ld e, l
+ ld hl, DeckNameSuffix
+ call CopyListFromHLToDE
+ lb de, 3, 1
+ ld hl, wDefaultText
+ call InitTextPrinting
+ call ProcessText
+ ret
+; 0xaf1d
Func_af1d: ; af1d (2:6f1d)
xor a
@@ -5030,14 +8085,14 @@ Func_af1d: ; af1d (2:6f1d)
call DrawWideTextBox_WaitForInput
call EnableLCD
- call Func_a1a2
+ call PrepareToBuildDeckConfigurationToSend
jr c, .asm_af6b
ld a, $01
or a
ret
.asm_af6b
- ld hl, wcf17
+ ld hl, wCurDeckCards
ld de, wDuelTempList
call CopyListFromHLToDE
xor a
@@ -5045,8 +8100,8 @@ Func_af1d: ; af1d (2:6f1d)
bank1call Func_756c
ret c
call EnableSRAM
- ld hl, wcf17
- call Func_910a
+ ld hl, wCurDeckCards
+ call DecrementDeckCardsInCollection
call DisableSRAM
call SaveGame
ld hl, wNameBuffer
@@ -5069,27 +8124,27 @@ Func_af98: ; af98 (2:6f98)
call EnableSRAM
ld hl, wDuelTempList
- call Func_9120
+ call AddGiftCenterDeckCardsToCollection
call DisableSRAM
call SaveGame
xor a
- ld [wcea1], a
+ ld [wCardListVisibleOffset], a
ld hl, Data_b04a
- call Func_9a6d
- call Func_b141
+ call InitCardSelectionParams
+ call PrintReceivedTheseCardsText
call Func_b088
call EnableLCD
- ld a, [wceab + 3]
- ld [wcfe4 + 2], a
- ld hl, wcecb
+ ld a, [wNumEntriesInCurFilter]
+ ld [wNumCardListEntries], a
+ ld hl, wNumVisibleCardListEntries
cp [hl]
jr nc, .asm_afd4
- ld [wNamingScreenKeyboardHeight], a
+ ld [wCardListNumCursorPositions], a
.asm_afd4
- ld hl, Func_b053
+ ld hl, ShowReceivedCardsList
ld d, h
ld a, l
- ld hl, wcece
+ ld hl, wCardListUpdateFunction
ld [hli], a
ld [hl], d
@@ -5097,9 +8152,9 @@ Func_af98: ; af98 (2:6f98)
ld [wced2], a
.asm_afe2
call DoFrame
- call Func_9b25
+ call HandleDeckCardSelectionList
jr c, .asm_b02f
- call Func_9eb8
+ call HandleLeftRightInCardList
jr c, .asm_afe2
ldh a, [hDPadHeld]
and START
@@ -5107,32 +8162,36 @@ Func_af98: ; af98 (2:6f98)
.asm_aff5
ld a, $01
call PlaySFXConfirmOrCancel
- ld a, [wNamingScreenCursorY]
- ld [wced4], a
+ ld a, [wCardListCursorPos]
+ ld [wTempCardListCursorPos], a
+
+ ; set wFilteredCardList as current card list
+ ; and show card page screen
ld de, wFilteredCardList
- ld hl, wcfd8
+ ld hl, wCurCardListPtr
ld [hl], e
inc hl
ld [hl], d
- call Func_9c3f
- call Func_b141
+ call OpenCardPageFromCardList
+ call PrintReceivedTheseCardsText
+
call PrintCardSelectionList
call EnableLCD
ld hl, Data_b04a
- call Func_9a6d
- ld a, [wceab + 3]
- ld hl, wcecb
+ call InitCardSelectionParams
+ ld a, [wNumEntriesInCurFilter]
+ ld hl, wNumVisibleCardListEntries
cp [hl]
jr nc, .asm_b027
- ld [wNamingScreenKeyboardHeight], a
+ ld [wCardListNumCursorPositions], a
.asm_b027
- ld a, [wced4]
- ld [wNamingScreenCursorY], a
+ ld a, [wTempCardListCursorPos]
+ ld [wCardListCursorPos], a
jr .asm_afe2
.asm_b02f
- call Func_9c0e
- ld a, [wNamingScreenCursorY]
- ld [wced4], a
+ call DrawListCursor_Invisible
+ ld a, [wCardListCursorPos]
+ ld [wTempCardListCursorPos], a
ld a, [hffb3]
cp $ff
jr nz, .asm_aff5
@@ -5143,9 +8202,16 @@ Func_af98: ; af98 (2:6f98)
ret
Data_b04a: ; b04a (2:704a)
- db $01, $03, $02, $00, $05, $0f, $00, $00, $00
-
-Func_b053: ; b053 (2:7053)
+ db 1 ; x pos
+ db 3 ; y pos
+ db 2 ; y spacing
+ db 0 ; x spacing
+ db 5 ; num entries
+ db SYM_CURSOR_R ; visible cursor tile
+ db SYM_SPACE ; invisible cursor tile
+ dw NULL ; wCardListHandlerFunction
+
+ShowReceivedCardsList: ; b053 (2:7053)
ld hl, hffb0
ld [hl], $01
lb de, 1, 1
@@ -5168,7 +8234,7 @@ Func_b053: ; b053 (2:7053)
; 0xb088
Func_b088: ; b088 (2:7088)
- ld a, $ff
+ ld a, CARD_COLLECTION_SIZE - 1
ld hl, wTempCardCollection
call ClearNBytesFromHL
ld de, wDuelTempList
@@ -5176,9 +8242,9 @@ Func_b088: ; b088 (2:7088)
ld a, $ff
call .Func_b0c0
ld a, $05
- ld [wcecb], a
+ ld [wNumVisibleCardListEntries], a
lb de, 2, 3
- ld hl, wced0
+ ld hl, wCardListCoords
ld [hl], e
inc hl
ld [hl], d
@@ -5224,8 +8290,8 @@ Func_b088: ; b088 (2:7088)
ld a, b
cp $ff
jr z, .asm_b0fc
- and $20
- cp $20
+ and FILTER_ENERGY
+ cp FILTER_ENERGY
jr z, .asm_b0f5
ld a, c
cp b
@@ -5261,7 +8327,7 @@ Func_b088: ; b088 (2:7088)
.asm_b119
ld a, l
- ld [wceab + 3], a
+ ld [wNumEntriesInCurFilter], a
xor a
ld c, l
ld b, h
@@ -5279,8 +8345,8 @@ Func_b088: ; b088 (2:7088)
ret
; 0xb131
-Func_b131: ; b131 (2:7131)
- call Func_b141.Func_b167
+PrintCardToSendText: ; b131 (2:7131)
+ call EmptyScreenAndDrawTextBox
lb de, 1, 1
call InitTextPrinting
ldtx hl, CardToSendText
@@ -5288,8 +8354,8 @@ Func_b131: ; b131 (2:7131)
ret
; 0xb141
-Func_b141: ; b141 (2:7141)
- call .Func_b167
+PrintReceivedTheseCardsText: ; b141 (2:7141)
+ call EmptyScreenAndDrawTextBox
lb de, 1, 1
call InitTextPrinting
ldtx hl, CardReceivedText
@@ -5303,11 +8369,12 @@ Func_b141: ; b141 (2:7141)
ldtx hl, ReceivedTheseCardsFromText
call DrawWideTextBox_PrintText
ret
+; 0xb167
-.Func_b167
+EmptyScreenAndDrawTextBox: ; b167 (2:7167)
call Set_OBJ_8x8
call Func_8d78
- ld de, $0
+ lb de, 0, 0
lb bc, 20, 13
call DrawRegularTextBox
ret
@@ -5337,123 +8404,141 @@ Func_b177: ; b177 (2:7177)
dw Func_bc7a
; 0xb19d
-Func_b19d: ; b19d (2:719d)
+HandleDeckSaveMachineMenu: ; b19d (2:719d)
xor a
- ld [wcea1], a
+ ld [wCardListVisibleOffset], a
ldtx de, DeckSaveMachineText
- ld hl, wd0a2
+ ld hl, wDeckMachineTitleText
ld [hl], e
inc hl
ld [hl], d
- call Func_b379
- ld a, $3c
- ld [wd0a5], a
+ call ClearScreenAndDrawDeckMachineScreen
+ ld a, NUM_DECK_SAVE_MACHINE_SLOTS
+ ld [wNumDeckMachineEntries], a
+
xor a
-.asm_b1b3
- ld hl, Data_b6fb
- call Func_9a6d
- call Func_b704
- call Func_b545
+.wait_input
+ ld hl, DeckMachineSelectionParams
+ call InitCardSelectionParams
+ call DrawListScrollArrows
+ call PrintNumSavedDecks
ldtx hl, PleaseSelectDeckText
call DrawWideTextBox_PrintText
ldtx de, PleaseSelectDeckText
- call Func_b285
- call Func_b29f
- jr c, .asm_b1b3
+ call InitDeckMachineDrawingParams
+ call HandleDeckMachineSelection
+ jr c, .wait_input
cp $ff
- ret z
+ ret z ; operation cancelled
+ ; get the index of selected deck
ld b, a
- ld a, [wcea1]
+ ld a, [wCardListVisibleOffset]
add b
- ld [wd088], a
+ ld [wSelectedDeckMachineEntry], a
+
call ResetCheckMenuCursorPositionAndBlink
call DrawWideTextBox
- ld hl, Unknown_b274
+ ld hl, .DeckMachineMenuData
call PlaceTextItems
-.asm_b1e7
+.wait_input_submenu
call DoFrame
call HandleCheckMenuInput
- jp nc, .asm_b1e7
+ jp nc, .wait_input_submenu
cp $ff
- jr nz, .asm_b1fa
- ld a, [wd086]
- jp .asm_b1b3
+ jr nz, .submenu_option_selected
+ ; return from submenu
+ ld a, [wTempDeckMachineCursorPos]
+ jp .wait_input
-.asm_b1fa
+.submenu_option_selected
ld a, [wCheckMenuCursorYPosition]
sla a
ld hl, wCheckMenuCursorXPosition
add [hl]
or a
- jr nz, .asm_b22c
- call Func_b35b
- jr nc, .asm_b216
- call Func_b592
- ld a, [wd086]
- jp c, .asm_b1b3
- jr .asm_b25e
-
-.asm_b216
+ jr nz, .ok_1
+
+; Save a Deck
+ call CheckIfSelectedDeckMachineEntryIsEmpty
+ jr nc, .prompt_ok_if_deleted
+ call SaveDeckInDeckSaveMachine
+ ld a, [wTempDeckMachineCursorPos]
+ jp c, .wait_input
+ jr .return_to_list
+.prompt_ok_if_deleted
ldtx hl, OKIfFileDeletedText
call YesOrNoMenuWithText
- ld a, [wd086]
- jr c, .asm_b1b3
- call Func_b592
- ld a, [wd086]
- jp c, .asm_b1b3
- jr .asm_b25e
-
-.asm_b22c
+ ld a, [wTempDeckMachineCursorPos]
+ jr c, .wait_input
+ call SaveDeckInDeckSaveMachine
+ ld a, [wTempDeckMachineCursorPos]
+ jp c, .wait_input
+ jr .return_to_list
+
+.ok_1
cp $1
- jr nz, .asm_b24c
- call Func_b35b
- jr c, .asm_b240
- call Func_b6ca
- ld a, [wd086]
- jp c, .asm_b1b3
- jr .asm_b25e
-
-.asm_b240
+ jr nz, .ok_2
+
+; Delete a Deck
+ call CheckIfSelectedDeckMachineEntryIsEmpty
+ jr c, .is_empty
+ call TryDeleteSavedDeck
+ ld a, [wTempDeckMachineCursorPos]
+ jp c, .wait_input
+ jr .return_to_list
+
+.is_empty
ld hl, WaitForVBlank
call DrawWideTextBox_WaitForInput
- ld a, [wd086]
- jp .asm_b1b3
+ ld a, [wTempDeckMachineCursorPos]
+ jp .wait_input
-.asm_b24c
+.ok_2
cp $2
- jr nz, .asm_b273
- call Func_b35b
- jr c, .asm_b240
- call Func_b7c6
- ld a, [wd086]
- jp nc, .asm_b1b3
-
-.asm_b25e
- ld a, [wd087]
- ld [wcea1], a
- call Func_b379
- call Func_b704
- call Func_b545
- ld a, [wd086]
- jp .asm_b1b3
+ jr nz, .cancel
+
+; Build a Deck
+ call CheckIfSelectedDeckMachineEntryIsEmpty
+ jr c, .is_empty
+ call TryBuildDeckMachineDeck
+ ld a, [wTempDeckMachineCursorPos]
+ jp nc, .wait_input
+
+.return_to_list
+ ld a, [wTempCardListVisibleOffset]
+ ld [wCardListVisibleOffset], a
+ call ClearScreenAndDrawDeckMachineScreen
+ call DrawListScrollArrows
+ call PrintNumSavedDecks
+ ld a, [wTempDeckMachineCursorPos]
+ jp .wait_input
-.asm_b273
+.cancel
ret
-Unknown_b274: ; b274 (2:7274)
- INCROM $b274, $b285
-
-Func_b285: ; b285 (2:7285)
- ld a, $05
- ld [wNamingScreenKeyboardHeight], a
- ld hl, wd0a7
+.DeckMachineMenuData
+ textitem 2, 14, SaveADeckText
+ textitem 12, 14, DeleteADeckText
+ textitem 2, 16, BuildADeckText
+ textitem 12, 16, CancelText
+ db $ff
+; 0xb285
+
+; sets the number of cursor positions for deck machine menu,
+; sets the text ID to show given by de
+; and sets DrawDeckMachineScreen as the update function
+; de = text ID
+InitDeckMachineDrawingParams: ; b285 (2:7285)
+ ld a, NUM_DECK_MACHINE_SLOTS
+ ld [wCardListNumCursorPositions], a
+ ld hl, wDeckMachineText
ld [hl], e
inc hl
ld [hl], d
- ld hl, Func_b403
+ ld hl, DrawDeckMachineScreen
ld d, h
ld a, l
- ld hl, wcece
+ ld hl, wCardListUpdateFunction
ld [hli], a
ld [hl], d
xor a
@@ -5461,19 +8546,180 @@ Func_b285: ; b285 (2:7285)
ret
; 0xb29f
-Func_b29f: ; b29f (2:729f)
- INCROM $b29f, $b35b
+; handles player input inside the Deck Machine screen
+; the Start button opens up the deck confirmation menu
+; and returns carry
+; otherwise, returns no carry and selection made in a
+HandleDeckMachineSelection: ; b29f (2:729f)
+ call DoFrame
+ call HandleDeckCardSelectionList
+ jr c, .selection_made
+
+ call .HandleListJumps
+ jr c, HandleDeckMachineSelection ; jump back to start
+ ldh a, [hDPadHeld]
+ and START
+ jr z, HandleDeckMachineSelection ; jump back to start
+
+; start btn
+ ld a, [wCardListVisibleOffset]
+ ld [wTempCardListVisibleOffset], a
+ ld b, a
+ ld a, [wCardListCursorPos]
+ ld [wTempDeckMachineCursorPos], a
+ add b
+ ld c, a
+ inc a
+ or $80
+ ld [wCurDeck], a
-Func_b35b: ; b35b (2:735b)
- INCROM $b35b, $b379
+ ; get pointer to selected deck cards
+ ; and if it's an empty deck, jump to start
+ sla c
+ ld b, $0
+ ld hl, wMachineDeckPtrs
+ add hl, bc
+ ld a, [hli]
+ ld h, [hl]
+ ld l, a
+ push hl
+ ld bc, DECK_NAME_SIZE
+ add hl, bc
+ ld d, h
+ ld e, l
+ call EnableSRAM
+ ld a, [hl]
+ call DisableSRAM
+ pop hl
+ or a
+ jr z, HandleDeckMachineSelection ; jump back to start
+
+; show deck confirmation screen with deck cards
+; and return carry set
+ ld a, $01
+ call PlaySFXConfirmOrCancel
+ call OpenDeckConfirmationMenu
+ ld a, [wTempCardListVisibleOffset]
+ ld [wCardListVisibleOffset], a
+ call ClearScreenAndDrawDeckMachineScreen
+ call DrawListScrollArrows
+ call PrintNumSavedDecks
+ ld a, [wTempDeckMachineCursorPos]
+ ld [wCardListCursorPos], a
+ scf
+ ret
+
+.selection_made
+ call DrawListCursor_Visible
+ ld a, [wCardListVisibleOffset]
+ ld [wTempCardListVisibleOffset], a
+ ld a, [wCardListCursorPos]
+ ld [wTempDeckMachineCursorPos], a
+ ld a, [hffb3]
+ or a
+ ret
+
+; handles right and left input for jumping several entries at once
+; returns carry if jump was made
+.HandleListJumps
+ ld a, [wCardListVisibleOffset]
+ ld c, a
+ ldh a, [hDPadHeld]
+ cp D_RIGHT
+ jr z, .d_right
+ cp D_LEFT
+ jr z, .d_left
+ or a
+ ret
+
+.d_right
+ ld a, [wCardListVisibleOffset]
+ add NUM_DECK_MACHINE_SLOTS
+ ld b, a
+ add NUM_DECK_MACHINE_SLOTS
+ ld hl, wNumDeckMachineEntries
+ cp [hl]
+ jr c, .got_new_pos
+ ld a, [wNumDeckMachineEntries]
+ sub NUM_DECK_MACHINE_SLOTS
+ ld b, a
+ jr .got_new_pos
+
+.d_left
+ ld a, [wCardListVisibleOffset]
+ sub NUM_DECK_MACHINE_SLOTS
+ ld b, a
+ jr nc, .got_new_pos
+ ld b, 0 ; first entry
+
+.got_new_pos
+ ld a, b
+ ld [wCardListVisibleOffset], a
+ cp c
+ jr z, .set_carry
+ ; play SFX if jump was made
+ ; and update UI
+ ld a, SFX_01
+ call PlaySFX
+ call DrawDeckMachineScreen
+ call PrintNumSavedDecks
+.set_carry
+ scf
+ ret
+; 0xb35b
+
+; returns carry if deck corresponding to the
+; entry selected in the Deck Machine menu is empty
+CheckIfSelectedDeckMachineEntryIsEmpty: ; b35b (2:735b)
+ ld a, [wSelectedDeckMachineEntry]
+ sla a
+ ld l, a
+ ld h, $0
+ ld bc, wMachineDeckPtrs
+ add hl, bc
+ ld a, [hli]
+ ld h, [hl]
+ ld l, a
+ ld bc, DECK_NAME_SIZE
+ add hl, bc
+ call EnableSRAM
+ ld a, [hl]
+ call DisableSRAM
+ or a
+ ret nz ; is valid
+ scf
+ ret; is empty
+; 0xb379
-Func_b379: ; b379 (2:7379)
- INCROM $b379, $b3b3
+ClearScreenAndDrawDeckMachineScreen: ; b379 (2:7379)
+ call Set_OBJ_8x8
+ xor a
+ ld [wTileMapFill], a
+ call ZeroObjectPositions
+ call EmptyScreen
+ ld a, $01
+ ld [wVBlankOAMCopyToggle], a
+ call LoadSymbolsFont
+ call LoadDuelCardSymbolTiles
+ bank1call SetDefaultPalettes
+ lb de, $3c, $ff
+ call SetupText
+ lb de, 0, 0
+ lb bc, 20, 13
+ call DrawRegularTextBox
+ call SetDeckMachineTitleText
+ call GetSavedDeckPointers
+ call PrintVisibleDeckMachineEntries
+ call GetSavedDeckCount
+ call EnableLCD
+ ret
+; 0xb3b3
-Func_b3b3: ; b3b3 (2:73b3)
+; prints wDeckMachineTitleText as title text
+SetDeckMachineTitleText: ; b3b3 (2:73b3)
lb de, 1, 0
call InitTextPrinting
- ld hl, wd0a2
+ ld hl, wDeckMachineTitleText
ld a, [hli]
ld h, [hl]
ld l, a
@@ -5481,67 +8727,102 @@ Func_b3b3: ; b3b3 (2:73b3)
ret
; 0xb3c3
- INCROM $b3c3, $b3e5
+; save all sSavedDecks pointers in wMachineDeckPtrs
+GetSavedDeckPointers: ; b3c3 (2:73c3)
+ ld a, NUM_DECK_SAVE_MACHINE_SLOTS
+ add NUM_DECK_SAVE_MACHINE_SLOTS ; add a is better
+ ld hl, wMachineDeckPtrs
+ call ClearNBytesFromHL
+ ld de, wMachineDeckPtrs
+ ld hl, sSavedDecks
+ ld bc, DECK_STRUCT_SIZE
+ ld a, NUM_DECK_SAVE_MACHINE_SLOTS
+.loop_saved_decks
+ push af
+ ld a, l
+ ld [de], a
+ inc de
+ ld a, h
+ ld [de], a
+ inc de
+ add hl, bc
+ pop af
+ dec a
+ jr nz, .loop_saved_decks
+ ret
+; 0xb3e5
-Func_b3e5: ; b3e5 (2:73e5)
- ld a, [wcea1]
- ld de, $202
- ld b, $05
-.asm_b3ed
+; given the cursor position in the deck machine menu
+; prints the deck names of all entries that are visible
+PrintVisibleDeckMachineEntries: ; b3e5 (2:73e5)
+ ld a, [wCardListVisibleOffset]
+ lb de, 2, 2
+ ld b, NUM_DECK_MACHINE_VISIBLE_DECKS
+.loop
push af
push bc
push de
- call Func_b424
+ call PrintDeckMachineEntry
pop de
pop bc
pop af
- ret c
+ ret c ; jump never made?
dec b
- ret z
+ ret z ; no more entries
inc a
inc e
inc e
- jr .asm_b3ed
+ jr .loop
; 0xb3fe
-Unknown_b3fe: ; b3fe (2:73fe)
- INCROM $b3fe, $b403
+UpdateDeckMachineScrollArrowsAndEntries: ; b3fe (2:73fe)
+ call DrawListScrollArrows
+ jr PrintVisibleDeckMachineEntries
+; 0xb403
-Func_b403: ; b403 (2:7403)
- call Func_b704
+DrawDeckMachineScreen: ; b403 (2:7403)
+ call DrawListScrollArrows
ld hl, hffb0
ld [hl], $01
- call Func_b3b3
+ call SetDeckMachineTitleText
lb de, 1, 14
call InitTextPrinting
- ld hl, wd0a7
+ ld hl, wDeckMachineText
ld a, [hli]
ld h, [hl]
ld l, a
call ProcessTextFromID
ld hl, hffb0
ld [hl], $00
- jr Func_b3e5
+ jr PrintVisibleDeckMachineEntries
; 0xb424
-Func_b424: ; b424 (2:7424)
+; prints the deck name of the deck corresponding
+; to index in register a, from wMachineDeckPtrs
+; also checks whether the deck can be built
+; either by dismantling other decks or not,
+; and places the corresponding symbol next to the name
+PrintDeckMachineEntry: ; b424 (2:7424)
ld b, a
push bc
ld hl, wDefaultText
inc a
call ConvertToNumericalDigits
- ld [hl], $77
+ ld [hl], "FW0_·"
inc hl
- ld [hl], $00
+ ld [hl], TX_END
call InitTextPrinting
ld hl, wDefaultText
call ProcessText
pop af
+
+; get the deck corresponding to input index
+; and append its name to wDefaultText
push af
sla a
ld l, a
- ld h, $00
- ld bc, wd00d
+ ld h, $0
+ ld bc, wMachineDeckPtrs
add hl, bc
ld a, [hli]
ld h, [hl]
@@ -5550,54 +8831,62 @@ Func_b424: ; b424 (2:7424)
inc d
inc d
push de
- call Func_92be
+ call AppendDeckName
pop de
pop bc
- jr nc, .asm_b46b
+ jr nc, .valid_deck
+
+; invalid deck, give it the default
+; empty deck name ("--------------")
call InitTextPrinting
- ldtx hl, Text025b
+ ldtx hl, EmptyDeckNameText
call ProcessTextFromID
ld d, 13
inc e
call InitTextPrinting
- ld hl, Text_b4d4
+ ld hl, .text
call ProcessText
scf
ret
-.asm_b46b
+.valid_deck
push de
push bc
ld d, 18
call InitTextPrinting
- ld a, $00
- call Func_b625
+
+; print the symbol that symbolizes whether the deck can
+; be built, or if another deck has to be dismantled to build it
+ ld a, $0 ; no decks dismantled
+ call CheckIfCanBuildSavedDeck
pop bc
ld hl, wDefaultText
- jr c, .asm_b482
- ld de, $35f
+ jr c, .cannot_build
+ lb de, 3, "FW3_○" ; can build
jr .asm_b4c2
-
-.asm_b482
+.cannot_build
push bc
- ld a, $ff
- call Func_b625
- jr c, .asm_b490
+ ld a, ALL_DECKS
+ call CheckIfCanBuildSavedDeck
+ jr c, .cannot_build_at_all
pop bc
- ld de, $360
+ lb de, 3, "FW3_❄" ; can build by dismantling
jr .asm_b4c2
-.asm_b490
- ld de, $6c
+.cannot_build_at_all
+ lb de, 0, "FW0_✕" ; cannot build even by dismantling
call Func_22ca
pop bc
pop de
+
+; place in wDefaultText the number of cards
+; that are needed in order to build the deck
push bc
ld d, 17
inc e
call InitTextPrinting
pop bc
- call Func_b4e1
+ call .GetNumCardsMissingToBuildDeck
call CalculateOnesAndTensDigits
ld hl, wOnesAndTensPlace
ld a, [hli]
@@ -5623,85 +8912,223 @@ Func_b424: ; b424 (2:7424)
ld d, 13
inc e
call InitTextPrinting
- ld hl, Text_b4d4
+ ld hl, .text
call ProcessText
or a
ret
-; 0xb4d4
-Text_b4d4: ; b4d4 (2:74d4)
+.text
db TX_SYMBOL, TX_END
db TX_SYMBOL, TX_END
db TX_SYMBOL, TX_END
db TX_SYMBOL, TX_END
db TX_SYMBOL, TX_END
db TX_SYMBOL, TX_END
- db TX_END
-; 0xb4e1
+ done
-Func_b4e1: ; b4e1 (2:74e1)
+; outputs in a the number of cards that the player does not own
+; in order to build the deck entry from wMachineDeckPtrs
+; given in register b
+.GetNumCardsMissingToBuildDeck
push bc
- call Func_b644
- call Func_a3ca
- call Func_b664
+ call SafelySwitchToSRAM0
+ call CreateCardCollectionListWithDeckCards
+ call SafelySwitchToTempSRAMBank
pop bc
+
+; get address to cards for the corresponding deck entry
sla b
ld c, b
ld b, $00
- ld hl, wd00d
+ ld hl, wMachineDeckPtrs
add hl, bc
ld a, [hli]
ld h, [hl]
ld l, a
- ld bc, $18
+ ld bc, DECK_NAME_SIZE
add hl, bc
+
call EnableSRAM
ld de, wTempCardCollection
- ld bc, $0
-.asm_b505
+ lb bc, 0, 0
+.loop
inc b
ld a, DECK_SIZE
cp b
- jr c, .asm_b520
+ jr c, .done
ld a, [hli]
push hl
ld l, a
ld h, $00
add hl, de
ld a, [hl]
- and $7f
+ and CARD_COUNT_MASK
or a
- jr z, .asm_b51c
+ jr z, .none
dec a
ld [hl], a
pop hl
- jr .asm_b505
-.asm_b51c
+ jr .loop
+.none
inc c
pop hl
- jr .asm_b505
-.asm_b520
+ jr .loop
+.done
ld a, c
call DisableSRAM
ret
; 0xb525
- INCROM $b525, $b545
+; counts how many decks in sSavedDecks are not empty
+; stores value in wNumSavedDecks
+GetSavedDeckCount: ; b525 (2:7525)
+ call EnableSRAM
+ ld hl, sSavedDecks
+ ld bc, DECK_STRUCT_SIZE
+ ld d, NUM_DECK_SAVE_MACHINE_SLOTS
+ ld e, 0
+.loop
+ ld a, [hl]
+ or a
+ jr z, .empty_slot
+ inc e
+.empty_slot
+ dec d
+ jr z, .got_count
+ add hl, bc
+ jr .loop
+.got_count
+ ld a, e
+ ld [wNumSavedDecks], a
+ call DisableSRAM
+ ret
+; 0xb545
-Func_b545: ; b545 (2:7545)
- INCROM $b545, $b592
+; prints "[wNumSavedDecks]/60"
+PrintNumSavedDecks: ; b545 (2:7545)
+ ld a, [wNumSavedDecks]
+ ld hl, wDefaultText
+ call ConvertToNumericalDigits
+ ld a, TX_SYMBOL
+ ld [hli], a
+ ld a, SYM_SLASH
+ ld [hli], a
+ ld a, NUM_DECK_SAVE_MACHINE_SLOTS
+ call ConvertToNumericalDigits
+ ld [hl], TX_END
+ lb de, 14, 1
+ call InitTextPrinting
+ ld hl, wDefaultText
+ call ProcessText
+ ret
+; 0xb568
-Func_b592: ; b592 (2:7592)
- INCROM $b592, $b611
+; prints "X/Y" where X is the current list index
+; and Y is the total number of saved decks
+; unreferenced?
+Func_b568: ; b568 (2:7568)
+ ld a, [wCardListCursorPos]
+ ld b, a
+ ld a, [wCardListVisibleOffset]
+ add b
+ inc a
+ ld hl, wDefaultText
+ call ConvertToNumericalDigits
+ ld a, TX_SYMBOL
+ ld [hli], a
+ ld a, SYM_SLASH
+ ld [hli], a
+ ld a, [wNumSavedDecks]
+ call ConvertToNumericalDigits
+ ld [hl], TX_END
+ lb de, 14, 1
+ call InitTextPrinting
+ ld hl, wDefaultText
+ call ProcessText
+ ret
+; 0xb592
-Func_b611: ; b611 (2:7611)
+; handles player choice in what deck to save
+; in the Deck Save Machine
+; assumes the slot to save was selected and
+; is stored in wSelectedDeckMachineEntry
+; if operation was successful, return carry
+SaveDeckInDeckSaveMachine: ; b592 (2:7592)
+ ld a, ALL_DECKS
+ call DrawDecksScreen
+ xor a
+.wait_input
+ ld hl, DeckMachineMenuParameters
+ call InitializeMenuParameters
+ ldtx hl, ChooseADeckToSaveText
+ call DrawWideTextBox_PrintText
+.wait_submenu_input
+ call DoFrame
+ call HandleStartButtonInDeckSelectionMenu
+ jr c, .wait_input
+ call HandleMenuInput
+ jp nc, .wait_submenu_input ; can be jr
+ ldh a, [hCurMenuItem]
+ cp $ff
+ ret z ; operation cancelled
+ ld [wCurDeck], a
+ call CheckIfCurDeckIsValid
+ jp nc, .SaveDeckInSelectedEntry ; can be jr
+ ; is an empty deck
+ call PrintThereIsNoDeckHereText
+ ld a, [wCurDeck]
+ jr .wait_input
+
+; overwrites data in the selected deck in SRAM
+; with the deck that was chosen, in wCurDeck
+; then returns carry
+.SaveDeckInSelectedEntry
+ call GetPointerToDeckName
+ call GetSelectedSavedDeckPtr
+ ld b, DECK_STRUCT_SIZE
+ call EnableSRAM
+ call CopyNBytesFromHLToDE
+ call DisableSRAM
+
+ call ClearScreenAndDrawDeckMachineScreen
+ call DrawListScrollArrows
+ call PrintNumSavedDecks
+ ld a, [wTempDeckMachineCursorPos]
+ ld hl, DeckMachineSelectionParams
+ call InitCardSelectionParams
+ call DrawListCursor_Visible
+ call GetPointerToDeckName
+ call EnableSRAM
+ call CopyDeckName
+ call DisableSRAM
+ xor a
+ ld [wTxRam2 + 0], a
+ ld [wTxRam2 + 1], a
+ ldtx hl, SavedTheConfigurationForText
+ call DrawWideTextBox_WaitForInput
+ scf
+ ret
+; 0xb609
+
+DeckMachineMenuParameters: ; b609 (2:7609)
+ db 1, 2 ; cursor x, cursor y
+ db 3 ; y displacement between items
+ db 4 ; number of items
+ db SYM_CURSOR_R ; cursor tile number
+ db SYM_SPACE ; tile behind cursor
+ dw NULL ; function pointer if non-0
+; 0xb611
+
+; outputs in de pointer of saved deck
+; corresponding to index in wSelectedDeckMachineEntry
+GetSelectedSavedDeckPtr: ; b611 (2:7611)
push af
push hl
- ld a, [wd088]
+ ld a, [wSelectedDeckMachineEntry]
sla a
ld e, a
ld d, $00
- ld hl, wd00d
+ ld hl, wMachineDeckPtrs
add hl, de
ld e, [hl]
inc hl
@@ -5711,236 +9138,881 @@ Func_b611: ; b611 (2:7611)
ret
; 0xb625
-Func_b625: ; b625 (2:7625)
- INCROM $b625, $b644
+; checks if it's possible to build saved deck with index b
+; includes cards from already built decks from flags in a
+; returns carry if cannot build the deck with the given criteria
+; a = DECK_* flags for which decks to include in the collection
+; b = saved deck index
+CheckIfCanBuildSavedDeck: ; b625 (2:7625)
+ push bc
+ call SafelySwitchToSRAM0
+ call CreateCardCollectionListWithDeckCards
+ call SafelySwitchToTempSRAMBank
+ pop bc
+ sla b
+ ld c, b
+ ld b, $0
+ ld hl, wMachineDeckPtrs
+ add hl, bc
+ ld a, [hli]
+ ld h, [hl]
+ ld l, a
+ ld bc, DECK_NAME_SIZE
+ add hl, bc
+ call CheckIfHasEnoughCardsToBuildDeck
+ ret
+; 0xb644
-Func_b644: ; b644 (2:7644)
- INCROM $b644, $b653
+; switches to SRAM bank 0 and stores current SRAM bank in wTempBankSRAM
+; skips if current SRAM bank is already 0
+SafelySwitchToSRAM0: ; b644 (2:7644)
+ push af
+ ldh a, [hBankSRAM]
+ or a
+ jr z, .skip
+ ld [wTempBankSRAM], a
+ xor a
+ call BankswitchSRAM
+.skip
+ pop af
+ ret
+; 0xb653
-Func_b653: ; b653 (2:7653)
- INCROM $b653, $b664
+; switches to SRAM bank 1 and stores current SRAM bank in wTempBankSRAM
+; skips if current SRAM bank is already 1
+SafelySwitchToSRAM1: ; b653 (2:7653)
+ push af
+ ldh a, [hBankSRAM]
+ cp BANK("SRAM1")
+ jr z, .skip
+ ld [wTempBankSRAM], a
+ ld a, BANK("SRAM1")
+ call BankswitchSRAM
+.skip
+ pop af
+ ret
+; 0xb664
-Func_b664: ; b664 (2:7664)
+SafelySwitchToTempSRAMBank: ; b664 (2:7664)
push af
push bc
ldh a, [hBankSRAM]
ld b, a
- ld a, [wd0a4]
+ ld a, [wTempBankSRAM]
cp b
- jr z, .asm_b672
+ jr z, .skip
call BankswitchSRAM
-.asm_b672
+.skip
pop bc
pop af
ret
; 0xb675
- INCROM $b675, $b6ca
+; returns carry if wTempCardCollection does not
+; have enough cards to build deck pointed by hl
+; hl = pointer to cards of deck to check
+CheckIfHasEnoughCardsToBuildDeck: ; b675 (2:7675)
+ call EnableSRAM
+ ld de, wTempCardCollection
+ ld b, 0
+.loop
+ inc b
+ ld a, DECK_SIZE
+ cp b
+ jr c, .no_carry
+ ld a, [hli]
+ push hl
+ ld l, a
+ ld h, $00
+ add hl, de
+ ld a, [hl]
+ or a
+ jr z, .set_carry
+ cp CARD_NOT_OWNED
+ jr z, .set_carry
+ dec a
+ ld [hl], a
+ pop hl
+ jr .loop
+
+.set_carry
+ pop hl
+ call DisableSRAM
+ scf
+ ret
+
+.no_carry
+ call DisableSRAM
+ or a
+ ret
+; 0xb6a1
+
+; outputs in a the first slot that is empty to build a deck
+; if no empty slot is found, return carry
+FindFirstEmptyDeckSlot: ; b6a1 (2:76a1)
+ ld hl, sDeck1Cards
+ ld a, [hl]
+ or a
+ jr nz, .check_deck_2
+ xor a
+ ret
+
+.check_deck_2
+ ld hl, sDeck2Cards
+ ld a, [hl]
+ or a
+ jr nz, .check_deck_3
+ ld a, 1
+ ret
+
+.check_deck_3
+ ld hl, sDeck3Cards
+ ld a, [hl]
+ or a
+ jr nz, .check_deck_4
+ ld a, 2
+ ret
+
+.check_deck_4
+ ld hl, sDeck4Cards
+ ld a, [hl]
+ or a
+ jr nz, .set_carry
+ ld a, 3
+ ret
+
+.set_carry
+ scf
+ ret
+; 0xb6ca
+
+; prompts the player whether to delete selected saved deck
+; if player selects yes, clears memory in SRAM
+; corresponding to that saved deck slot
+; if player selects no, return carry
+TryDeleteSavedDeck: ; b6ca (2:76ca)
+ ldtx hl, DoYouReallyWishToDeleteText
+ call YesOrNoMenuWithText
+ jr c, .no
+ call GetSelectedSavedDeckPtr
+ ld l, e
+ ld h, d
+ push hl
+ call EnableSRAM
+ call CopyDeckName
+ pop hl
+ ld a, DECK_STRUCT_SIZE
+ call ClearNBytesFromHL
+ call DisableSRAM
+ xor a
+ ld [wTxRam2 + 0], a
+ ld [wTxRam2 + 1], a
+ ldtx hl, DeletedTheConfigurationForText
+ call DrawWideTextBox_WaitForInput
+ or a
+ ret
+
+.no
+ ld a, [wCardListCursorPos]
+ scf
+ ret
+; 0xb6fb
+
+DeckMachineSelectionParams: ; b6fb (2:76fb)
+ db 1 ; x pos
+ db 2 ; y pos
+ db 2 ; y spacing
+ db 0 ; x spacing
+ db 5 ; num entries
+ db SYM_CURSOR_R ; visible cursor tile
+ db SYM_SPACE ; invisible cursor tile
+ dw NULL ; wCardListHandlerFunction
+
+DrawListScrollArrows: ; b704 (2:7704)
+ ld a, [wCardListVisibleOffset]
+ or a
+ jr z, .no_up_cursor
+ ld a, SYM_CURSOR_U
+ jr .got_tile_1
+.no_up_cursor
+ ld a, SYM_BOX_RIGHT
+.got_tile_1
+ lb bc, 19, 1
+ call WriteByteToBGMap0
+
+ ld a, [wCardListVisibleOffset]
+ add NUM_DECK_MACHINE_VISIBLE_DECKS + 1
+ ld b, a
+ ld a, [wNumDeckMachineEntries]
+ cp b
+ jr c, .no_down_cursor
+ xor a ; FALSE
+ ld [wUnableToScrollDown], a
+ ld a, SYM_CURSOR_D
+ jr .got_tile_2
+.no_down_cursor
+ ld a, TRUE
+ ld [wUnableToScrollDown], a
+ ld a, SYM_BOX_RIGHT
+.got_tile_2
+ lb bc, 19, 11
+ call WriteByteToBGMap0
+ ret
+; 0xb738
+
+; handles the deck menu for when the player
+; needs to make space for new deck to build
+HandleDismantleDeckToMakeSpace: ; b738 (2:7738)
+ ldtx hl, YouMayOnlyCarry4DecksText
+ call DrawWideTextBox_WaitForInput
+ call SafelySwitchToSRAM0
+ ld a, ALL_DECKS
+ call DrawDecksScreen
+ xor a
+.init_menu_params
+ ld hl, DeckMachineMenuParameters
+ call InitializeMenuParameters
+ ldtx hl, ChooseADeckToDismantleText
+ call DrawWideTextBox_PrintText
+.loop_input
+ call DoFrame
+ call HandleStartButtonInDeckSelectionMenu
+ jr c, .init_menu_params
+ call HandleMenuInput
+ jp nc, .loop_input ; can be jr
+ ldh a, [hCurMenuItem]
+ cp $ff
+ jr nz, .selected_deck
+ ; operation was cancelled
+ call SafelySwitchToTempSRAMBank
+ scf
+ ret
+
+.selected_deck
+ ld [wCurDeck], a
+ ldtx hl, DismantleThisDeckText
+ call YesOrNoMenuWithText
+ jr nc, .dismantle
+ ld a, [wCurDeck]
+ jr .init_menu_params
+
+.dismantle
+ call GetPointerToDeckName
+ push hl
+ ld de, wDismantledDeckName
+ call EnableSRAM
+ call CopyListFromHLToDE
+ pop hl
+ push hl
+ ld bc, DECK_NAME_SIZE
+ add hl, bc
+ call AddDeckToCollection
+ pop hl
+ ld a, DECK_STRUCT_SIZE
+ call ClearNBytesFromHL
+ call DisableSRAM
+
+ ; redraw deck screen
+ ld a, ALL_DECKS
+ call DrawDecksScreen
+ ld a, [wCurDeck]
+ ld hl, DeckMachineMenuParameters
+ call InitializeMenuParameters
+ call DrawCursor2
+ call SafelySwitchToTempSRAMBank
+ ld hl, wDismantledDeckName
+ call CopyDeckName
+ xor a
+ ld [wTxRam2 + 0], a
+ ld [wTxRam2 + 1], a
+ ldtx hl, DismantledDeckText
+ call DrawWideTextBox_WaitForInput
+ ld a, [wCurDeck]
+ ret
+; 0xb7c6
+
+; tries to build the deck in wSelectedDeckMachineEntry
+; will check if can be built with or without dismantling
+; prompts the player in case a deck has to be dismantled
+; or, if it's impossible to build deck, shows missing cards list
+TryBuildDeckMachineDeck: ; b7c6 (2:77c6)
+ ld a, [wSelectedDeckMachineEntry]
+ ld b, a
+ push bc
+ ld a, $0
+ call CheckIfCanBuildSavedDeck
+ pop bc
+ jr nc, .build_deck
+ ld a, ALL_DECKS
+ call CheckIfCanBuildSavedDeck
+ jr c, .do_not_own_all_cards_needed
+ ; can only be built by dismantling some deck
+ ldtx hl, ThisDeckCanOnlyBeBuiltIfYouDismantleText
+ call DrawWideTextBox_WaitForInput
+ call .DismantleDecksNeededToBuild
+ jr nc, .build_deck
+ ; player chose not to dismantle
-Func_b6ca: ; b6ca (2:76ca)
- INCROM $b6ca, $b6fb
+.set_carry_and_return
+ ld a, [wCardListCursorPos]
+ scf
+ ret
-Data_b6fb: ; b6fb (2:76fb)
- db $01, $02, $02, $00, $05, $0f, $00, $00, $00
+.do_not_own_all_cards_needed
+ ldtx hl, YouDoNotOwnAllCardsNeededToBuildThisDeckText
+ call DrawWideTextBox_WaitForInput
+ jp .ShowMissingCardList
-Func_b704: ; b704 (2:7704)
- INCROM $b704, $b7c6
+.build_deck
+ call EnableSRAM
+ call SafelySwitchToSRAM0
+ call FindFirstEmptyDeckSlot
+ call SafelySwitchToTempSRAMBank
+ call DisableSRAM
+ jr nc, .got_deck_slot
+ call HandleDismantleDeckToMakeSpace
+ jr nc, .got_deck_slot
+ scf
+ ret
-Func_b7c6: ; b7c6 (2:77c6)
- INCROM $b7c6, $ba04
+.got_deck_slot
+ ld [wDeckSlotForNewDeck], a
+ ld a, [wSelectedDeckMachineEntry]
+ ld c, a
+ ld b, $0
+ sla c
+ ld hl, wMachineDeckPtrs
+ add hl, bc
+ ld a, [hli]
+ ld h, [hl]
+ ld l, a
+
+ ; copy deck to buffer
+ ld de, wDeckToBuild
+ ld b, DECK_STRUCT_SIZE
+ call EnableSRAM
+ call CopyNBytesFromHLToDE
+
+ ; remove the needed cards from collection
+ ld hl, wDeckToBuild + DECK_NAME_SIZE
+ call SafelySwitchToSRAM0
+ call DecrementDeckCardsInCollection
+
+ ; copy the deck cards from the buffer
+ ; to the deck slot that was chosen
+ ld a, [wDeckSlotForNewDeck]
+ ld l, a
+ ld h, DECK_STRUCT_SIZE
+ call HtimesL
+ ld bc, sBuiltDecks
+ add hl, bc
+ ld d, h
+ ld e, l
+ ld hl, wDeckToBuild
+ ld b, DECK_STRUCT_SIZE
+ call CopyNBytesFromHLToDE
+ call DisableSRAM
-Func_ba04: ; ba04 (2:7a04)
- ld a, [wd0a9]
- ld hl, Data_bb83
+ ; draw Decks screen
+ ld a, ALL_DECKS
+ call DrawDecksScreen
+ ld a, [wDeckSlotForNewDeck]
+ ld [wCurDeck], a
+ ld hl, DeckMachineMenuParameters
+ call InitializeMenuParameters
+ call DrawCursor2
+ call GetPointerToDeckName
+ call EnableSRAM
+ call CopyDeckName
+ call DisableSRAM
+ call SafelySwitchToTempSRAMBank
+ xor a
+ ld [wTxRam2 + 0], a
+ ld [wTxRam2 + 1], a
+ ldtx hl, BuiltDeckText
+ call DrawWideTextBox_WaitForInput
+ scf
+ ret
+
+; asks the player for confirmation to dismantle decks
+; needed to build the selected deck from the Deck Save Machine
+; returns carry set if player selected "no"
+; if player selected "yes", dismantle decks
+.DismantleDecksNeededToBuild
+; shows Decks screen with the names
+; of the decks to be dismantled
+ farcall CheckWhichDecksToDismantleToBuildSavedDeck
+ call SafelySwitchToSRAM0
+ call DrawDecksScreen
+ ldtx hl, DismantleTheseDecksText
+ call YesOrNoMenuWithText
+ jr nc, .yes
+; no
+ call SafelySwitchToTempSRAMBank
+ scf
+ ret
+
+.yes
+ call EnableSRAM
+ ld a, [wDecksToBeDismantled]
+ bit DECK_1_F, a
+ jr z, .deck_2
+ ld a, DECK_1_F
+ call .DismantleDeck
+.deck_2
+ ld a, [wDecksToBeDismantled]
+ bit DECK_2_F, a
+ jr z, .deck_3
+ ld a, DECK_2_F
+ call .DismantleDeck
+.deck_3
+ ld a, [wDecksToBeDismantled]
+ bit DECK_3_F, a
+ jr z, .deck_4
+ ld a, DECK_3_F
+ call .DismantleDeck
+.deck_4
+ ld a, [wDecksToBeDismantled]
+ bit DECK_4_F, a
+ jr z, .done_dismantling
+ ld a, DECK_4_F
+ call .DismantleDeck
+
+.done_dismantling
+ call DisableSRAM
+ ld a, [wDecksToBeDismantled]
+ call DrawDecksScreen
+ call SafelySwitchToTempSRAMBank
+ ldtx hl, DismantledTheDeckText
+ call DrawWideTextBox_WaitForInput
+ or a
+ ret
+
+; dismantles built deck given by a
+; and adds its cards to the collection
+; a = DECK_*_F to dismantle
+.DismantleDeck
+ ld l, a
+ ld h, DECK_STRUCT_SIZE
+ call HtimesL
+ ld bc, sBuiltDecks
+ add hl, bc
+ push hl
+ ld bc, DECK_NAME_SIZE
+ add hl, bc
+ call AddDeckToCollection
+ pop hl
+ ld a, DECK_STRUCT_SIZE
+ call ClearNBytesFromHL
+ ret
+
+; collects cards missing from player's collection
+; and shows its confirmation list
+.ShowMissingCardList
+; copy saved deck card from SRAM to wCurDeckCards
+; and make unique card list sorted by ID
+ ld a, [wSelectedDeckMachineEntry]
+ ld [wCurDeck], a
+ call GetSelectedSavedDeckPtr
+ ld hl, DECK_NAME_SIZE
+ add hl, de
+ ld de, wCurDeckCards
+ ld b, DECK_SIZE
+ call EnableSRAM
+ call CopyNBytesFromHLToDE
+ call DisableSRAM
+ xor a ; terminator byte for deck
+ ld [wCurDeckCards + DECK_SIZE], a
+ call SortCurDeckCardsByID
+ call CreateCurDeckUniqueCardList
+
+; create collection card list, including
+; the cards from all built decks
+ ld a, ALL_DECKS
+ call SafelySwitchToSRAM0
+ call CreateCardCollectionListWithDeckCards
+ call SafelySwitchToTempSRAMBank
+
+; creates list in wFilteredCardList with
+; cards that are missing to build this deck
+ ld hl, wUniqueDeckCardList
+ ld de, wFilteredCardList
+.loop_deck_configuration
+ ld a, [hli]
+ or a
+ jr z, .finish_missing_card_list
+ ld b, a
+ push bc
+ push de
+ push hl
+ ld hl, wCurDeckCards
+ call .CheckIfCardIsMissing
+ pop hl
+ pop de
+ pop bc
+ jr nc, .loop_deck_configuration
+ ; this card is missing
+ ; store in wFilteredCardList this card ID
+ ; a number of times equal to the amount still needed
+ ld c, a
+ ld a, b
+.loop_number_missing
+ ld [de], a
+ inc de
+ dec c
+ jr nz, .loop_number_missing
+ jr .loop_deck_configuration
+
+.finish_missing_card_list
+ xor a ; terminator byte
+ ld [de], a
+
+ ldtx bc, TheseCardsAreNeededToBuildThisDeckText
+ ld hl, wCardConfirmationText
+ ld a, c
+ ld [hli], a
+ ld a, b
+ ld [hl], a
+
+ call GetSelectedSavedDeckPtr
+ ld h, d
+ ld l, e
+ ld de, wFilteredCardList
+ call HandleDeckMissingCardsList
+ jp .set_carry_and_return
+
+; checks if player has enough cards with ID given in register a
+; in the collection to build the deck and, if not, returns
+; carry set and outputs in a the difference
+; a = card ID
+; hl = deck cards
+.CheckIfCardIsMissing
+ call .GetCardCountFromDeck
+ ld hl, wTempCardCollection
+ push de
+ call .GetCardCountFromCollection
+ ld a, e
+ pop de
+
+ ; d = card count in deck
+ ; a = card count in collection
+ cp d
+ jr c, .not_enough
+ or a
+ ret
+
+.not_enough
+; needs more cards than player owns in collection
+; return carry set and the number of cards needed
+ ld e, a
+ ld a, d
+ sub e
+ scf
+ ret z
+
+; returns in d the card count of card ID given in register a
+; that is found in the card list in hl
+; a = card ID
+; hl = deck cards
+.GetCardCountFromDeck
+ push af
+ ld e, a
+ ld d, 0
+.loop_deck_cards
+ ld a, [hli]
+ or a
+ jr z, .done_deck_cards
+ cp e
+ jr nz, .loop_deck_cards
+ inc d
+ jr .loop_deck_cards
+.done_deck_cards
+ pop af
+ ret
+
+; returns in e the card count of card ID given in register a
+; that is found in the card collection
+; a = card ID
+; hl = card collection
+.GetCardCountFromCollection
+ push af
+ ld e, a
+ ld d, $0
+ add hl, de
+ ld a, [hl]
+ and CARD_COUNT_MASK
+ ld e, a
+ pop af
+ ret
+; 0xb991
+
+PrinterMenu_DeckConfiguration: ; b991 (2:7991)
+ xor a
+ ld [wCardListVisibleOffset], a
+ call ClearScreenAndDrawDeckMachineScreen
+ ld a, DECK_SIZE
+ ld [wNumDeckMachineEntries], a
+
+ xor a
+.asm_b99e
+ ld hl, DeckMachineSelectionParams
+ call InitCardSelectionParams
+ call DrawListScrollArrows
+ call PrintNumSavedDecks
+ ldtx hl, PleaseChooseDeckConfigurationToPrintText
+ call DrawWideTextBox_PrintText
+ ldtx de, PleaseChooseDeckConfigurationToPrintText
+ call InitDeckMachineDrawingParams
+.asm_b9b6
+ call HandleDeckMachineSelection
+ jr c, .asm_b99e
+ cp $ff
+ ret z
+
+ ld b, a
+ ld a, [wCardListVisibleOffset]
+ add b
+ ld [wSelectedDeckMachineEntry], a
+ call CheckIfSelectedDeckMachineEntryIsEmpty
+ jr c, .asm_b9b6
+ call DrawWideTextBox
+ ldtx hl, PrintThisDeckText
+ call YesOrNoMenuWithText
+ jr c, .no
+ call GetSelectedSavedDeckPtr
+ ld hl, $18
+ add hl, de
+ ld de, wCurDeckCards
+ ld b, DECK_SIZE
+ call EnableSRAM
+ call CopyNBytesFromHLToDE
+ call DisableSRAM
+ xor a ; terminator byte for deck
+ ld [wCurDeckCards + DECK_SIZE], a
+ call SortCurDeckCardsByID
+ ld a, [wSelectedDeckMachineEntry]
+ bank1call Func_7580
+ call ClearScreenAndDrawDeckMachineScreen
+
+.no
+ ld a, [wTempDeckMachineCursorPos]
+ ld [wCardListCursorPos], a
+ jp .asm_b99e
+; 0xba04
+
+HandleAutoDeckMenu: ; ba04 (2:7a04)
+ ld a, [wCurAutoDeckMachine]
+ ld hl, .DeckMachineTitleTextList
sla a
ld c, a
ld b, $0
add hl, bc
- ld de, wd0a2
+ ld de, wDeckMachineTitleText
ld a, [hli]
ld [de], a
inc de
ld a, [hl]
ld [de], a
xor a
- ld [wcea1], a
- call Func_bb97
- ld a, $5
- ld [wd0a5], a
+ ld [wCardListVisibleOffset], a
+ call .InitAutoDeckMenu
+ ld a, NUM_DECK_MACHINE_SLOTS
+ ld [wNumDeckMachineEntries], a
xor a
- ; fallthrough
-Func_ba25: ; ba25 (2:7a25)
- ld hl, Func_bb6e
+.please_select_deck
+ ld hl, .MenuParameters
call InitializeMenuParameters
ldtx hl, PleaseSelectDeckText
call DrawWideTextBox_PrintText
- ld a, $5
- ld [wNamingScreenKeyboardHeight], a
- ld hl, Unknown_b3fe
+ ld a, NUM_DECK_MACHINE_SLOTS
+ ld [wCardListNumCursorPositions], a
+ ld hl, UpdateDeckMachineScrollArrowsAndEntries
ld d, h
ld a, l
- ld hl, wcece
+ ld hl, wCardListUpdateFunction
ld [hli], a
ld [hl], d
-.asm_ba40
+.wait_input
call DoFrame
call HandleMenuInput
- jr c, .asm_baa3
+ jr c, .deck_selection_made
+
+; the following lines do nothing
ldh a, [hDPadHeld]
and D_UP | D_DOWN
jr z, .asm_ba4e
-
.asm_ba4e
+
+; check whether to show deck confirmation list
ldh a, [hDPadHeld]
and START
- jr z, .asm_ba40
- ld a, [wcea1]
- ld [wd087], a
+ jr z, .wait_input
+
+ ld a, [wCardListVisibleOffset]
+ ld [wTempCardListVisibleOffset], a
ld b, a
ld a, [wCurMenuItem]
- ld [wd086], a
+ ld [wTempDeckMachineCursorPos], a
add b
ld c, a
inc a
or $80
- ld [wceb1], a
+ ld [wCurDeck], a
sla c
ld b, $0
- ld hl, wd00d
+ ld hl, wMachineDeckPtrs
add hl, bc
- call Func_b653
+ call SafelySwitchToSRAM1
ld a, [hli]
ld h, [hl]
ld l, a
push hl
- ld bc, $0018
+ ld bc, DECK_NAME_SIZE
add hl, bc
ld d, h
ld e, l
ld a, [hl]
pop hl
- call Func_b644
+ call SafelySwitchToSRAM0
or a
- jr z, .asm_ba40
+ jr z, .wait_input ; invalid deck
+
+ ; show confirmation list
ld a, $1
call PlaySFXConfirmOrCancel
- call Func_b653
- call Func_8e1f
- call Func_b644
- ld a, [wd087]
- ld [wcea1], a
- call Func_bb97
- ld a, [wd086]
- jp Func_ba25
-
-.asm_baa3
+ call SafelySwitchToSRAM1
+ call OpenDeckConfirmationMenu
+ call SafelySwitchToSRAM0
+ ld a, [wTempCardListVisibleOffset]
+ ld [wCardListVisibleOffset], a
+ call .InitAutoDeckMenu
+ ld a, [wTempDeckMachineCursorPos]
+ jp .please_select_deck
+
+.deck_selection_made
call DrawCursor2
- ld a, [wcea1]
- ld [wd087], a
+ ld a, [wCardListVisibleOffset]
+ ld [wTempCardListVisibleOffset], a
ld a, [wCurMenuItem]
- ld [wd086], a
+ ld [wTempDeckMachineCursorPos], a
ldh a, [hCurMenuItem]
cp $ff
- jp z, .asm_bb0d
- ld [wd088], a
+ jp z, .exit ; operation cancelled
+ ld [wSelectedDeckMachineEntry], a
call ResetCheckMenuCursorPositionAndBlink
xor a
ld [wce5e], a
call DrawWideTextBox
- ld hl, Data_bb76
+ ld hl, .DeckMachineMenuData
call PlaceTextItems
-.asm_bacc
+.wait_submenu_input
call DoFrame
call HandleCheckMenuInput_YourOrOppPlayArea
- jp nc, .asm_bacc
+ jp nc, .wait_submenu_input
cp $ff
- jr nz, .asm_badf
- ld a, [wd086]
- jp Func_ba25
+ jr nz, .submenu_option_selected
+ ld a, [wTempDeckMachineCursorPos]
+ jp .please_select_deck
-.asm_badf
+.submenu_option_selected
ld a, [wCheckMenuCursorYPosition]
sla a
ld hl, wCheckMenuCursorXPosition
add [hl]
or a
jr nz, .asm_bb09
- call Func_b653
- call Func_b7c6
- call Func_b644
- ld a, [wd086]
- jp nc, Func_ba25
- ld a, [wd087]
- ld [wcea1], a
- call Func_bb97
- ld a, [wd086]
- jp Func_ba25
+
+; Build a Deck
+ call SafelySwitchToSRAM1
+ call TryBuildDeckMachineDeck
+ call SafelySwitchToSRAM0
+ ld a, [wTempDeckMachineCursorPos]
+ jp nc, .please_select_deck
+ ld a, [wTempCardListVisibleOffset]
+ ld [wCardListVisibleOffset], a
+ call .InitAutoDeckMenu
+ ld a, [wTempDeckMachineCursorPos]
+ jp .please_select_deck
.asm_bb09
cp $1
- jr nz, .asm_bb12
-.asm_bb0d
+ jr nz, .read_the_instructions
+.exit
xor a
- ld [wd0a4], a
+ ld [wTempBankSRAM], a
ret
-.asm_bb12
- ld a, [wcea1]
- ld [wd087], a
+.read_the_instructions
+; show card confirmation list
+ ld a, [wCardListVisibleOffset]
+ ld [wTempCardListVisibleOffset], a
ld b, a
ld a, [wCurMenuItem]
- ld [wd086], a
+ ld [wTempDeckMachineCursorPos], a
add b
ld c, a
- ld [wceb1], a
+ ld [wCurDeck], a
sla c
ld b, $0
- ld hl, wd00d
+ ld hl, wMachineDeckPtrs
add hl, bc
+
+ ; set the description text in text box
push hl
- ld hl, wd0aa
+ ld hl, wAutoDeckMachineTextDescriptions
add hl, bc
- ld bc, wcfda
+ ld bc, wCardConfirmationText
ld a, [hli]
ld [bc], a
inc bc
ld a, [hl]
ld [bc], a
pop hl
- call Func_b653
+
+ call SafelySwitchToSRAM1
ld a, [hli]
ld h, [hl]
ld l, a
push hl
- ld bc, $0018
+ ld bc, DECK_NAME_SIZE
add hl, bc
ld d, h
ld e, l
ld a, [hl]
pop hl
- call Func_b644
+ call SafelySwitchToSRAM0
or a
- jp z, .asm_ba40
+ jp z, .wait_input ; invalid deck
+
+ ; show confirmation list
ld a, $1
call PlaySFXConfirmOrCancel
- call Func_b653
+ call SafelySwitchToSRAM1
xor a
- call Func_adfe
- call Func_b644
- ld a, [wd087]
- ld [wcea1], a
- call Func_bb97
- ld a, [wd086]
- jp Func_ba25
-
-Func_bb6e: ; bb6e (2:7b6e)
- INCROM $bb6e, $bb76
+ call HandleDeckMissingCardsList
+ call SafelySwitchToSRAM0
+ ld a, [wTempCardListVisibleOffset]
+ ld [wCardListVisibleOffset], a
+ call .InitAutoDeckMenu
+ ld a, [wTempDeckMachineCursorPos]
+ jp .please_select_deck
+
+.MenuParameters
+ db 1, 2 ; 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
-Data_bb76: ; bb76 (2:7b76)
- INCROM $bb76, $bb83
+.DeckMachineMenuData
+ textitem 2, 14, BuildADeckText
+ textitem 12, 14, CancelText
+ textitem 2, 16, ReadTheInstructionsText
+ db $ff
-Data_bb83: ; bb83 (2:7b83)
+.DeckMachineTitleTextList
tx FightingMachineText
tx RockMachineText
tx WaterMachineText
@@ -5952,32 +10024,88 @@ Data_bb83: ; bb83 (2:7b83)
tx AutoMachineText
tx LegendaryMachineText
-Func_bb97: ; bb97 (2:7b97)
- INCROM $bb97, $bc04
+; clears screen, loads the proper tiles
+; prints the Auto Deck title and deck entries
+; and creates the auto deck configurations
+.InitAutoDeckMenu
+ call Set_OBJ_8x8
+ xor a
+ ld [wTileMapFill], a
+ call ZeroObjectPositions
+ call EmptyScreen
+ ld a, $01
+ ld [wVBlankOAMCopyToggle], a
+ call LoadSymbolsFont
+ call LoadDuelCardSymbolTiles
+ bank1call SetDefaultPalettes
+ lb de, $3c, $ff
+ call SetupText
+ lb de, 0, 0
+ lb bc, 20, 13
+ call DrawRegularTextBox
+ lb de, 1, 0
+ call InitTextPrinting
+ ld hl, wDeckMachineTitleText
+ ld a, [hli]
+ ld h, [hl]
+ ld l, a
+ call ProcessTextFromID
+ call SafelySwitchToSRAM1
+ farcall ReadAutoDeckConfiguration
+ call .CreateAutoDeckPointerList
+ call PrintVisibleDeckMachineEntries
+ call SafelySwitchToSRAM0
+ call EnableLCD
+ ret
+
+; writes to wMachineDeckPtrs the pointers
+; to the Auto Decks in sAutoDecks
+.CreateAutoDeckPointerList
+ ld a, 2 * NUM_DECK_MACHINE_SLOTS
+ ld hl, wMachineDeckPtrs
+ call ClearNBytesFromHL
+ ld de, wMachineDeckPtrs
+ ld hl, sAutoDecks
+ ld bc, DECK_STRUCT_SIZE
+ ld a, NUM_DECK_MACHINE_SLOTS
+.loop
+ push af
+ ld a, l
+ ld [de], a
+ inc de
+ ld a, h
+ ld [de], a
+ inc de
+ add hl, bc
+ pop af
+ dec a
+ jr nz, .loop
+ ret
+; 0xbc04
Func_bc04: ; bc04 (2:7c04)
xor a
- ld [wcea1], a
+ ld [wCardListVisibleOffset], a
ldtx de, DeckSaveMachineText
- ld hl, wd0a2
+ ld hl, wDeckMachineTitleText
ld [hl], e
inc hl
ld [hl], d
- call Func_b379
+ call ClearScreenAndDrawDeckMachineScreen
ld a, DECK_SIZE
- ld [wd0a5], a
+ ld [wNumDeckMachineEntries], a
xor a
.asm_bc1a
- ld hl, Data_b6fb
- call Func_9a6d
- call Func_b704
- call Func_b545
+ ld hl, DeckMachineSelectionParams
+ call InitCardSelectionParams
+ call DrawListScrollArrows
+ call PrintNumSavedDecks
ldtx hl, PleaseChooseADeckConfigurationToSendText
call DrawWideTextBox_PrintText
ldtx de, PleaseChooseADeckConfigurationToSendText
- call Func_b285
+ call InitDeckMachineDrawingParams
.asm_bc32
- call Func_b29f
+ call HandleDeckMachineSelection
jr c, .asm_bc1a
cp $ff
jr nz, .asm_bc3f
@@ -5986,17 +10114,17 @@ Func_bc04: ; bc04 (2:7c04)
ret
.asm_bc3f
ld b, a
- ld a, [wcea1]
+ ld a, [wCardListVisibleOffset]
add b
- ld [wd088], a
- call Func_b35b
+ ld [wSelectedDeckMachineEntry], a
+ call CheckIfSelectedDeckMachineEntryIsEmpty
jr c, .asm_bc32
- call Func_b611
+ call GetSelectedSavedDeckPtr
ld l, e
ld h, d
ld de, wDuelTempList
- ld b, $54
+ ld b, DECK_STRUCT_SIZE
call EnableSRAM
call CopyNBytesFromHLToDE
call DisableSRAM
@@ -6006,7 +10134,7 @@ Func_bc04: ; bc04 (2:7c04)
bank1call Func_7562
ret c
- call Func_b611
+ call GetSelectedSavedDeckPtr
ld l, e
ld h, d
ld de, wDefaultText
@@ -6019,26 +10147,26 @@ Func_bc04: ; bc04 (2:7c04)
Func_bc7a: ; bc7a (2:7c7a)
xor a
- ld [wcea1], a
+ ld [wCardListVisibleOffset], a
ldtx de, DeckSaveMachineText
- ld hl, wd0a2
+ ld hl, wDeckMachineTitleText
ld [hl], e
inc hl
ld [hl], d
- call Func_b379
+ call ClearScreenAndDrawDeckMachineScreen
ld a, DECK_SIZE
- ld [wd0a5], a
+ ld [wNumDeckMachineEntries], a
xor a
.asm_bc90
- ld hl, Data_b6fb
- call Func_9a6d
- call Func_b704
- call Func_b545
+ ld hl, DeckMachineSelectionParams
+ call InitCardSelectionParams
+ call DrawListScrollArrows
+ call PrintNumSavedDecks
ldtx hl, PleaseChooseASaveSlotText
call DrawWideTextBox_PrintText
ldtx de, PleaseChooseASaveSlotText
- call Func_b285
- call Func_b29f
+ call InitDeckMachineDrawingParams
+ call HandleDeckMachineSelection
jr c, .asm_bc90
cp $ff
jr nz, .asm_bcb5
@@ -6047,17 +10175,17 @@ Func_bc7a: ; bc7a (2:7c7a)
ret
.asm_bcb5
ld b, a
- ld a, [wcea1]
+ ld a, [wCardListVisibleOffset]
add b
- ld [wd088], a
- call Func_b35b
+ ld [wSelectedDeckMachineEntry], a
+ call CheckIfSelectedDeckMachineEntryIsEmpty
jr nc, .asm_bcc4
jr .asm_bcd1
.asm_bcc4
ldtx hl, OKIfFileDeletedText
call YesOrNoMenuWithText
jr nc, .asm_bcd1
- ld a, [wNamingScreenCursorY]
+ ld a, [wCardListCursorPos]
jr .asm_bc90
.asm_bcd1
xor a
@@ -6067,18 +10195,18 @@ Func_bc7a: ; bc7a (2:7c7a)
ret c
call EnableSRAM
ld hl, wDuelTempList
- call Func_b611
- ld b, $54
+ call GetSelectedSavedDeckPtr
+ ld b, DECK_STRUCT_SIZE
call CopyNBytesFromHLToDE
call DisableSRAM
call SaveGame
- call Func_b379
- ld a, [wNamingScreenCursorY]
- ld hl, Data_b6fb
- call Func_9a6d
- call Func_b704
- call Func_b545
- call Func_9c3a
+ call ClearScreenAndDrawDeckMachineScreen
+ ld a, [wCardListCursorPos]
+ ld hl, DeckMachineSelectionParams
+ call InitCardSelectionParams
+ call DrawListScrollArrows
+ call PrintNumSavedDecks
+ call DrawListCursor_Visible
ld hl, wNameBuffer
ld de, wDefaultText
call CopyListFromHLToDE
@@ -6087,7 +10215,7 @@ Func_bc7a: ; bc7a (2:7c7a)
ld [wTxRam2 + 1], a
ldtx hl, ReceivedADeckConfigurationFromText
call DrawWideTextBox_WaitForInput
- call Func_b611
+ call GetSelectedSavedDeckPtr
ld l, e
ld h, d
ld de, wDefaultText
diff --git a/src/engine/bank03.asm b/src/engine/bank03.asm
index d2065ae..75e3081 100644
--- a/src/engine/bank03.asm
+++ b/src/engine/bank03.asm
@@ -1173,7 +1173,7 @@ Func_c7b8: ; c7b8 (3:47b8)
ldh [hSCY], a
call Set_OBJ_8x16
farcall Func_1288c
- farcall Func_8db0
+ farcall DeckSelectionMenu
call Set_OBJ_8x8
ret
@@ -1183,7 +1183,7 @@ Func_c7cc: ; c7cc (3:47cc)
ldh [hSCY], a
call Set_OBJ_8x16
farcall Func_1288c
- farcall Func_a288
+ farcall HandlePlayersCardsScreen
call Set_OBJ_8x8
ret
@@ -1254,7 +1254,7 @@ Func_c859: ; c859 (3:4859)
ldh [hSCY], a
call Set_OBJ_8x16
farcall Func_1288c
- farcall Func_a913
+ farcall HandleCardAlbumScreen
call Set_OBJ_8x8
ret
@@ -1272,7 +1272,7 @@ Func_c877: ; c877 (3:4877)
ldh [hSCY], a
call Set_OBJ_8x16
farcall Func_1288c
- farcall Func_ad51
+ farcall HandlePrinterMenu
call Set_OBJ_8x8
call WhiteOutDMGPals
call DoFrameIfLCDEnabled
@@ -3124,11 +3124,11 @@ ScriptCommand_OpenDeckMachine: ; d336 (3:5336)
or a
jr z, .asm_d360
dec a
- ld [wd0a9], a
- farcall Func_ba04
+ ld [wCurAutoDeckMachine], a
+ farcall HandleAutoDeckMenu
jr .asm_d364
.asm_d360
- farcall Func_b19d
+ farcall HandleDeckSaveMachineMenu
.asm_d364
call ResumeSong
call Func_c2d4
diff --git a/src/engine/bank06.asm b/src/engine/bank06.asm
index a03f631..1e728fd 100644
--- a/src/engine/bank06.asm
+++ b/src/engine/bank06.asm
@@ -746,7 +746,7 @@ OpenGlossaryScreen: ; 184c8 (6:44c8)
and SELECT
jr nz, .on_select
- farcall Func_89ae
+ farcall YourOrOppPlayAreaScreen_HandleInput
jr nc, .next
cp -1 ; b button
@@ -2050,29 +2050,32 @@ Func_1996e: ; 1996e (6:596e)
ldh [hWhoseTurn], a
ld hl, sCardCollection
ld bc, $1607
-.asm_1997b
+.loop_clear
xor a
ld [hli], a
dec bc
ld a, c
or b
- jr nz, .asm_1997b
- ld a, $5
- ld hl, s0a350
+ jr nz, .loop_clear
+
+ ld a, CHARMANDER_AND_FRIENDS_DECK
+ ld hl, sSavedDeck1
call Func_199e0
- ld a, $7
- ld hl, s0a3a4
+ ld a, SQUIRTLE_AND_FRIENDS_DECK
+ ld hl, sSavedDeck2
call Func_199e0
- ld a, $9
- ld hl, s0a3f8
+ ld a, BULBASAUR_AND_FRIENDS_DECK
+ ld hl, sSavedDeck3
call Func_199e0
+
call EnableSRAM
ld hl, sCardCollection
ld a, CARD_NOT_OWNED
-.asm_199a2
+.loop_collection
ld [hl], a
inc l
- jr nz, .asm_199a2
+ jr nz, .loop_collection
+
ld hl, sCurrentDuel
xor a
ld [hli], a
@@ -2080,15 +2083,16 @@ Func_1996e: ; 1996e (6:596e)
ld [hl], a
ld hl, sCardPopNameList
- ld c, $10
-.asm_199b2
+ ld c, CARDPOP_NAME_LIST_MAX_ELEMS
+.loop_card_pop_names
ld [hl], $0
- ld de, $0010
+ ld de, NAME_BUFFER_LENGTH
add hl, de
dec c
- jr nz, .asm_199b2
- ld a, $2
- ld [s0a003], a
+ jr nz, .loop_card_pop_names
+
+ ld a, 2
+ ld [sPrinterContrastLevel], a
ld a, $2
ld [sTextSpeed], a
ld [wTextSpeed], a
@@ -2673,6 +2677,7 @@ CalculateNameHash: ; 19e32 (6:5e32)
ret
; 0x19e42
+Func_19e42: ; 19e42 (6:5e42)
INCROM $19e42, $19e5a
; shows message on screen depending on wPrinterStatus
@@ -2955,7 +2960,7 @@ Func_1a035: ; 1a035 (6:6035)
ld a, $10
ld [wce9b], a
call EnableSRAM
- ld a, [s0a003]
+ ld a, [sPrinterContrastLevel]
ld [wce99], a
call DisableSRAM
ldh a, [hBankSRAM]
@@ -3140,7 +3145,13 @@ Func_1a138: ; 1a138 (6:6138)
db $00, $20, $40, $60, $7f
; 0x1a14b
- INCROM $1a14b, $1a435
+ INCROM $1a14b, $1a162
+
+Func_1a162: ; 1a162 (6:6162)
+ INCROM $1a162, $1a270
+
+Func_1a270: ; 1a270 (6:6270)
+ INCROM $1a270, $1a435
; compresses $28 tiles in sGfxBuffer5
; and writes it in sGfxBuffer5 + $28 tiles.
@@ -3585,9 +3596,9 @@ InputPlayerName: ; 1a7a3 (6:67a3)
ld a, $06
ld [wNamingScreenKeyboardHeight], a
ld a, $0f
- ld [wceaa], a
+ ld [wVisibleCursorTile], a
ld a, $00
- ld [wceab], a
+ ld [wInvisibleCursorTile], a
.loop
ld a, $01
ld [wVBlankOAMCopyToggle], a
@@ -3943,12 +3954,12 @@ NamingScreen_CheckButtonState: ; 1a908 (6:6908)
inc [hl]
and $0f
ret nz
- ld a, [wceaa]
+ ld a, [wVisibleCursorTile]
bit 4, [hl]
jr z, Func_1aa07.asm_6a0a
Func_1aa07: ; 1aa07 (6:6a07)
- ld a, [wceab]
+ ld a, [wInvisibleCursorTile]
.asm_6a0a
ld e, a
ld a, [wNamingScreenCursorX]
@@ -3967,7 +3978,7 @@ Func_1aa07: ; 1aa07 (6:6a07)
ret
Func_1aa23: ; 1aa23 (6:6a23)
- ld a, [wceaa]
+ ld a, [wVisibleCursorTile]
jr Func_1aa07.asm_6a0a
Func_1aa28: ; 1aa28 (6:6a28)
@@ -3979,7 +3990,7 @@ Func_1aa28: ; 1aa28 (6:6a28)
call ZeroObjectPositions
pop af
ld b, a
- ld a, [wceab]
+ ld a, [wInvisibleCursorTile]
cp b
jr z, .asm_6a60
ld a, [wNamingScreenBufferLength]
@@ -4449,9 +4460,9 @@ InputDeckName: ; 1ad89 (6:6d89)
ld a, $07
ld [wNamingScreenKeyboardHeight], a
ld a, $0f
- ld [wceaa], a
+ ld [wVisibleCursorTile], a
ld a, $00
- ld [wceab], a
+ ld [wInvisibleCursorTile], a
.loop
ld a, $01
ld [wVBlankOAMCopyToggle], a
@@ -4741,12 +4752,12 @@ Func_1aefb: ; 1aefb (6:6efb)
inc [hl]
and $0f
ret nz
- ld a, [wceaa]
+ ld a, [wVisibleCursorTile]
bit 4, [hl]
jr z, Func_1afa1.asm_6fa4
Func_1afa1: ; 1afa1 (6:6fa1)
- ld a, [wceab]
+ ld a, [wInvisibleCursorTile]
.asm_6fa4
ld e, a
ld a, [wNamingScreenCursorX]
@@ -4765,7 +4776,7 @@ Func_1afa1: ; 1afa1 (6:6fa1)
ret
Func_1afbd: ; 1afbd (6:6fbd)
- ld a, [wceaa]
+ ld a, [wVisibleCursorTile]
jr Func_1afa1.asm_6fa4
Func_1afc2: ; 1afc2 (6:6fc2)
@@ -4777,7 +4788,7 @@ Func_1afc2: ; 1afc2 (6:6fc2)
call ZeroObjectPositions
pop af
ld b, a
- ld a, [wceab]
+ ld a, [wInvisibleCursorTile]
cp b
jr z, .asm_6ffb
ld a, [wNamingScreenBufferLength]
@@ -4914,30 +4925,32 @@ KeyboardData_Deck: ; 1b019 (6:7019)
db $0e, $12, $02
db $10, $0f, $01
-; unknown data.
-; needs analyze.
-; (6:70d6)
- INCROM $1b0d6, $1ba12
+ ds 4 ; empty
-Func_1ba12: ; 1ba12 (6:7a12)
- push af
- ld [bc], a
+INCLUDE "data/auto_deck_card_lists.asm"
+INCLUDE "data/auto_deck_machines.asm"
+
+; writes to sAutoDecks all the deck configurations
+; from the Auto Deck Machine in wCurAutoDeckMachine
+ReadAutoDeckConfiguration: ; 1ba14 (6:7a14)
call EnableSRAM
- ld a, [wd0a9]
+ ld a, [wCurAutoDeckMachine]
ld l, a
- ld h, $1e
+ ld h, 6 * NUM_DECK_MACHINE_SLOTS
call HtimesL
- ld bc, $78e8
+ ld bc, AutoDeckMachineEntries
add hl, bc
- ld b, $00
-.asm_7a26
- call Func_1ba4c
- call Func_1ba5b
- call Func_1ba7d
+ ld b, 0
+.loop_decks
+ call .GetPointerToSRAMAutoDeck
+ call .ReadDeckConfiguration
+ call .ReadDeckName
+
+ ; store deck description text ID
push hl
- ld de, wd0aa
+ ld de, wAutoDeckMachineTextDescriptions
ld h, b
- ld l, $02
+ ld l, 2
call HtimesL
add hl, de
ld d, h
@@ -4950,24 +4963,27 @@ Func_1ba12: ; 1ba12 (6:7a12)
ld [de], a
inc b
ld a, b
- cp $05
- jr nz, .asm_7a26
+ cp NUM_DECK_MACHINE_SLOTS
+ jr nz, .loop_decks
call DisableSRAM
ret
-Func_1ba4c: ; 1ba4c (6:7a4c)
+; outputs in de the saved deck with index b
+.GetPointerToSRAMAutoDeck
push hl
ld l, b
- ld h, $54
+ ld h, DECK_STRUCT_SIZE
call HtimesL
- ld de, s0a350
+ ld de, sAutoDecks
add hl, de
ld d, h
ld e, l
pop hl
ret
-Func_1ba5b: ; 1ba5b (6:7a5b)
+; writes the deck configuration in SRAM
+; by reading the given deck card list
+.ReadDeckConfiguration
push hl
push bc
push de
@@ -4976,24 +4992,24 @@ Func_1ba5b: ; 1ba5b (6:7a5b)
inc hl
ld d, [hl]
pop hl
- ld bc, $0018
+ ld bc, DECK_NAME_SIZE
add hl, bc
-.asm_7a67
+.loop_create_deck
ld a, [de]
inc de
- ld b, a
+ ld b, a ; card count
or a
- jr z, .asm_7a77
+ jr z, .done_create_deck
ld a, [de]
inc de
- ld c, a
-.asm_7a70
+ ld c, a ; card ID
+.loop_card_count
ld [hl], c
inc hl
dec b
- jr nz, .asm_7a70
- jr .asm_7a67
-.asm_7a77
+ jr nz, .loop_card_count
+ jr .loop_create_deck
+.done_create_deck
pop de
pop bc
pop hl
@@ -5001,87 +5017,104 @@ Func_1ba5b: ; 1ba5b (6:7a5b)
inc hl
ret
-Func_1ba7d: ; 1ba7d (6:7a7d)
+.ReadDeckName
push hl
push bc
push de
ld a, [hli]
ld h, [hl]
ld l, a
- ld de, wd089
+ ld de, wDismantledDeckName
call CopyText
pop hl
- ld de, wd089
-.asm_7a8d
+ ld de, wDismantledDeckName
+.loop_copy_name
ld a, [de]
ld [hli], a
or a
- jr z, .asm_7a95
+ jr z, .done_copy_name
inc de
- jr .asm_7a8d
-.asm_7a95
+ jr .loop_copy_name
+.done_copy_name
pop bc
pop hl
inc hl
inc hl
ret
-; farcall from 0xb87e(2:787d): [EF|06|9A|7A]
-Func_1ba9a: ; 1ba9a (6:7a9a)
+; tries out all combinations of dismantling the player's decks
+; in order to build the deck in wSelectedDeckMachineEntry
+; if none of the combinations work, return carry set
+; otherwise, return in a which deck flags should be dismantled
+CheckWhichDecksToDismantleToBuildSavedDeck: ; 1ba9a (6:7a9a)
xor a
- ld [wd0a6], a
- ld a, $01
-.asm_7aa0
- call Func_1bae4
+ ld [wDecksToBeDismantled], a
+
+; first check if it can be built by
+; only dismantling a single deck
+ ld a, DECK_1
+.loop_single_built_decks
+ call .CheckIfCanBuild
ret nc
- sla a
- cp $10
- jr z, .asm_7aac
- jr .asm_7aa0
-.asm_7aac
- ld a, $03
- call Func_1bae4
+ sla a ; next deck
+ cp (1 << NUM_DECKS)
+ jr z, .two_deck_combinations
+ jr .loop_single_built_decks
+
+.two_deck_combinations
+; next check all two deck combinations
+ ld a, DECK_1 | DECK_2
+ call .CheckIfCanBuild
ret nc
- ld a, $05
- call Func_1bae4
+ ld a, DECK_1 | DECK_3
+ call .CheckIfCanBuild
ret nc
- ld a, $09
- call Func_1bae4
+ ld a, DECK_1 | DECK_4
+ call .CheckIfCanBuild
ret nc
- ld a, $06
- call Func_1bae4
+ ld a, DECK_2 | DECK_3
+ call .CheckIfCanBuild
ret nc
- ld a, $0a
- call Func_1bae4
+ ld a, DECK_2 | DECK_4
+ call .CheckIfCanBuild
ret nc
- ld a, $0c
- call Func_1bae4
+ ld a, DECK_3 | DECK_4
+ call .CheckIfCanBuild
ret nc
- ld a, $f7
-.asm_7ad2
- call Func_1bae4
+
+; all but one deck combinations
+ ld a, $ff ^ DECK_4
+.loop_three_deck_combinations
+ call .CheckIfCanBuild
ret nc
sra a
cp $ff
- jr z, .asm_7ade
- jr .asm_7ad2
-.asm_7ade
- call Func_1bae4
+ jr z, .all_decks
+ jr .loop_three_deck_combinations
+
+.all_decks
+; finally check if can be built by dismantling all decks
+ call .CheckIfCanBuild
ret nc
+
+; none of the combinations work
scf
ret
-Func_1bae4: ; 1bae4 (6:7ae4)
+; returns carry if wSelectedDeckMachineEntry cannot be built
+; by dismantling the decks given by register a
+; a = DECK_* flags
+.CheckIfCanBuild
push af
- ld hl, wd088
+ ld hl, wSelectedDeckMachineEntry
ld b, [hl]
- farcall Func_b625
- jr c, .asm_7af5
+ farcall CheckIfCanBuildSavedDeck
+ jr c, .cannot_build
pop af
- ld [wd0a6], a
+ ld [wDecksToBeDismantled], a
or a
ret
-.asm_7af5
+.cannot_build
pop af
scf
ret
diff --git a/src/engine/bank1c.asm b/src/engine/bank1c.asm
index 1c68fb5..e7eb5e5 100644
--- a/src/engine/bank1c.asm
+++ b/src/engine/bank1c.asm
@@ -430,7 +430,7 @@ ENDM
border_medal_tile v0Tiles1 + $23a, $6a, $10
border_medal_tile v0Tiles1 + $23c, $6b, $10
-; FIGHTING_MEDAL
+; PSYCHIC_MEDAL
border_medal_tile v0Tiles1 + $2b8, $7e, $10
border_medal_tile v0Tiles1 + $2ba, $7f, $10
border_medal_tile v0Tiles1 + $2bc, $80, $10
@@ -452,7 +452,7 @@ ENDM
border_medal_tile v0Tiles1 + $43a, $7c, $10
border_medal_tile v0Tiles1 + $43c, $7d, $10
-; PSYCHIC_MEDAL
+; FIGHTING_MEDAL
border_medal_tile v0Tiles1 + $4b8, $6c, $10
border_medal_tile v0Tiles1 + $4ba, $6d, $10
border_medal_tile v0Tiles1 + $4bc, $6e, $10
diff --git a/src/engine/effect_functions.asm b/src/engine/effect_functions.asm
index b8b4914..f67a89b 100644
--- a/src/engine/effect_functions.asm
+++ b/src/engine/effect_functions.asm
@@ -6622,7 +6622,7 @@ Peek_SelectEffect: ; 2e2b4 (b:62b4)
; player
call Func_3b31
- call Func_30e7
+ call HandlePeekSelection
ldh [hAIPkmnPowerEffectParam], a
call SerialSend8Bytes
ret
@@ -6660,7 +6660,7 @@ Peek_SelectEffect: ; 2e2b4 (b:62b4)
call SwapTurn
ldh a, [hAIPkmnPowerEffectParam]
xor $80
- call Func_30f9
+ call DrawAIPeekScreen
call SwapTurn
ldtx hl, CardPeekWasUsedOnText
call DrawWideTextBox_WaitForInput
diff --git a/src/engine/home.asm b/src/engine/home.asm
index b848287..0b60609 100644
--- a/src/engine/home.asm
+++ b/src/engine/home.asm
@@ -9303,46 +9303,47 @@ DrawPlayersPrizeAndBenchCards: ; 30d7 (0:30d7)
call BankswitchROM
ret
-Func_30e7: ; 30e7 (0:30e7)
+HandlePeekSelection: ; 30e7 (0:30e7)
ldh a, [hBankROM]
push af
- ld a, BANK(Func_8764)
+ ld a, BANK(_HandlePeekSelection)
call BankswitchROM
- call Func_8764
+ call _HandlePeekSelection
ld b, a
pop af
call BankswitchROM
ld a, b
ret
-Func_30f9: ; 30f9 (0:30f9)
+DrawAIPeekScreen: ; 30f9 (0:30f9)
ld b, a
ldh a, [hBankROM]
push af
- ld a, BANK(Func_8932)
+ ld a, BANK(_DrawAIPeekScreen)
call BankswitchROM
- call Func_8932
+ call _DrawAIPeekScreen
pop af
call BankswitchROM
ret
-Func_310a: ; 310a (0:310a)
- ld [wce59], a
+; a = number of prize cards for player to select to take
+SelectPrizeCards: ; 310a (0:310a)
+ ld [wNumberOfPrizeCardsToSelect], a
ldh a, [hBankROM]
push af
- ld a, BANK(Func_8aaa)
+ ld a, BANK(_SelectPrizeCards)
call BankswitchROM
- call Func_8aaa
+ call _SelectPrizeCards
pop af
call BankswitchROM
ret
-Func_311d: ; 311d (0:311d)
+DrawPlayAreaToPlacePrizeCards: ; 311d (0:311d)
ldh a, [hBankROM]
push af
- ld a, BANK(Func_8b85)
+ ld a, BANK(_DrawPlayAreaToPlacePrizeCards)
call BankswitchROM
- call Func_8b85
+ call _DrawPlayAreaToPlacePrizeCards
pop af
call BankswitchROM
ret
diff --git a/src/hram.asm b/src/hram.asm
index fee69a9..6877f9c 100644
--- a/src/hram.asm
+++ b/src/hram.asm
@@ -171,6 +171,7 @@ hCurSelectionItem:: ; ffb2
hffb3:: ; ffb3
ds $1
+hffb4:: ; ffb4
ds $1
hffb5:: ; ffb5
diff --git a/src/macros/wram.asm b/src/macros/wram.asm
index 5e7eb1c..5eca96b 100644
--- a/src/macros/wram.asm
+++ b/src/macros/wram.asm
@@ -93,3 +93,8 @@ duel_anim_struct: MACRO
\1Unknown2:: ds 1
\1Bank:: ds 1
ENDM
+
+deck_struct: MACRO
+\1Name:: ds DECK_NAME_SIZE
+\1Cards:: ds DECK_SIZE
+ENDM
diff --git a/src/sram.asm b/src/sram.asm
index 481c8e4..b64d8c3 100644
--- a/src/sram.asm
+++ b/src/sram.asm
@@ -3,7 +3,9 @@ SECTION "SRAM0", SRAM
s0a000:: ; a000
ds $3
-s0a003:: ; a003
+; what was the last option selected by the player
+; for the printer contrast level (0 ~ 4)
+sPrinterContrastLevel:: ; a003
ds $1
s0a004:: ; a004
ds $1
@@ -42,47 +44,91 @@ sPlayerName:: ; a010
sCardCollection:: ; a100
ds $100
-sDeck1Name:: ; a200
- ds DECK_NAME_SIZE
-sDeck1Cards:: ; a218
- ds DECK_SIZE
-
-sDeck2Name:: ; a254
- ds DECK_NAME_SIZE
-sDeck2Cards:: ; a26c
- ds DECK_SIZE
-
-sDeck3Name:: ; a2a8
- ds DECK_NAME_SIZE
-sDeck3Cards:: ; a2c0
- ds DECK_SIZE
-
-sDeck4Name:: ; a2fc
- ds DECK_NAME_SIZE
-sDeck4Cards:: ; a314
- ds DECK_SIZE
-
-s0a350:: ; a350
- ds DECK_NAME_SIZE + DECK_SIZE
-s0a3a4:: ; a3a4
- ds DECK_NAME_SIZE + DECK_SIZE
-s0a3f8:: ; a3f8
- ds DECK_NAME_SIZE + DECK_SIZE
-
- ds $12b4
+sBuiltDecks::
+sDeck1:: deck_struct sDeck1 ; a200
+sDeck2:: deck_struct sDeck2 ; a254
+sDeck3:: deck_struct sDeck3 ; a2a8
+sDeck4:: deck_struct sDeck4 ; a2fc
+
+sSavedDecks::
+sSavedDeck1:: deck_struct sSavedDeck1 ; a350
+sSavedDeck2:: deck_struct sSavedDeck2 ; a3a4
+sSavedDeck3:: deck_struct sSavedDeck3 ; a3f8
+sSavedDeck4:: deck_struct sSavedDeck4 ; a44c
+sSavedDeck5:: deck_struct sSavedDeck5 ; a4a0
+sSavedDeck6:: deck_struct sSavedDeck6 ; a4f4
+sSavedDeck7:: deck_struct sSavedDeck7 ; a548
+sSavedDeck8:: deck_struct sSavedDeck8 ; a59c
+sSavedDeck9:: deck_struct sSavedDeck9 ; a5f0
+sSavedDeck10:: deck_struct sSavedDeck10 ; a644
+sSavedDeck11:: deck_struct sSavedDeck11 ; a698
+sSavedDeck12:: deck_struct sSavedDeck12 ; a6ec
+sSavedDeck13:: deck_struct sSavedDeck13 ; a740
+sSavedDeck14:: deck_struct sSavedDeck14 ; a794
+sSavedDeck15:: deck_struct sSavedDeck15 ; a7e8
+sSavedDeck16:: deck_struct sSavedDeck16 ; a83c
+sSavedDeck17:: deck_struct sSavedDeck17 ; a890
+sSavedDeck18:: deck_struct sSavedDeck18 ; a8e4
+sSavedDeck19:: deck_struct sSavedDeck19 ; a938
+sSavedDeck20:: deck_struct sSavedDeck20 ; a98c
+sSavedDeck21:: deck_struct sSavedDeck21 ; a9e0
+sSavedDeck22:: deck_struct sSavedDeck22 ; aa34
+sSavedDeck23:: deck_struct sSavedDeck23 ; aa88
+sSavedDeck24:: deck_struct sSavedDeck24 ; aadc
+sSavedDeck25:: deck_struct sSavedDeck25 ; ab30
+sSavedDeck26:: deck_struct sSavedDeck26 ; ab84
+sSavedDeck27:: deck_struct sSavedDeck27 ; abd8
+sSavedDeck28:: deck_struct sSavedDeck28 ; ac2c
+sSavedDeck29:: deck_struct sSavedDeck29 ; ac80
+sSavedDeck30:: deck_struct sSavedDeck30 ; acd4
+sSavedDeck31:: deck_struct sSavedDeck31 ; ad28
+sSavedDeck32:: deck_struct sSavedDeck32 ; ad7c
+sSavedDeck33:: deck_struct sSavedDeck33 ; add0
+sSavedDeck34:: deck_struct sSavedDeck34 ; ae24
+sSavedDeck35:: deck_struct sSavedDeck35 ; ae78
+sSavedDeck36:: deck_struct sSavedDeck36 ; aecc
+sSavedDeck37:: deck_struct sSavedDeck37 ; af20
+sSavedDeck38:: deck_struct sSavedDeck38 ; af74
+sSavedDeck39:: deck_struct sSavedDeck39 ; afc8
+sSavedDeck40:: deck_struct sSavedDeck40 ; b01c
+sSavedDeck41:: deck_struct sSavedDeck41 ; b070
+sSavedDeck42:: deck_struct sSavedDeck42 ; b0c4
+sSavedDeck43:: deck_struct sSavedDeck43 ; b118
+sSavedDeck44:: deck_struct sSavedDeck44 ; b16c
+sSavedDeck45:: deck_struct sSavedDeck45 ; b1c0
+sSavedDeck46:: deck_struct sSavedDeck46 ; b214
+sSavedDeck47:: deck_struct sSavedDeck47 ; b268
+sSavedDeck48:: deck_struct sSavedDeck48 ; b2bc
+sSavedDeck49:: deck_struct sSavedDeck49 ; b310
+sSavedDeck50:: deck_struct sSavedDeck50 ; b364
+sSavedDeck51:: deck_struct sSavedDeck51 ; b3b8
+sSavedDeck52:: deck_struct sSavedDeck52 ; b40c
+sSavedDeck53:: deck_struct sSavedDeck53 ; b460
+sSavedDeck54:: deck_struct sSavedDeck54 ; b4b4
+sSavedDeck55:: deck_struct sSavedDeck55 ; b508
+sSavedDeck56:: deck_struct sSavedDeck56 ; b55c
+sSavedDeck57:: deck_struct sSavedDeck57 ; b5b0
+sSavedDeck58:: deck_struct sSavedDeck58 ; b604
+sSavedDeck59:: deck_struct sSavedDeck59 ; b658
+sSavedDeck60:: deck_struct sSavedDeck60 ; b6ac
sCurrentlySelectedDeck:: ; b700
ds $1
-sb701:: ; b701
- ds $1
-
- ds $1
+; keeps track of how many unnamed decks have been built
+; this is the number that gets appended at the end of
+; an unnamed deck (i.e. DECK XXX)
+; max number is MAX_UNNAMED_DECK_NUM
+sUnnamedDeckCounter:: ; b701
+ ds $2
-sb703:: ; b703
- ds $1
+; whether player has had Promotional cards
+; to decide whether to show the option
+; in the Card Album PC menu
+sHasPromotionalCards:: ; b703
+ ds $4
- ds $fc
+ ds $f9
sb800:: ; b800
ds $8
@@ -210,6 +256,8 @@ sCardPopNameList:: ; bb00
SECTION "SRAM1", SRAM
+UNION
+
; buffers used to temporary store gfx related data
; such as tiles or BG maps
sGfxBuffer0:: ; a000
@@ -230,6 +278,25 @@ sGfxBuffer4:: ; b000
sGfxBuffer5:: ; b400
ds $400
+NEXTU
+
+ ds $350
+
+; buffer used to store the deck configuration
+; from the Auto Deck Machines
+; intentionally uses the same address as sSavedDecks
+; since TryBuildDeckMachineDeck uses the same
+; address in SRAM whether it's an auto deck or a saved deck
+; the difference is whether SRAM0 or SRAM1 are loaded
+sAutoDecks::
+sAutoDeck1:: deck_struct sAutoDeck1 ; a350
+sAutoDeck2:: deck_struct sAutoDeck2 ; a3a4
+sAutoDeck3:: deck_struct sAutoDeck3 ; a3f8
+sAutoDeck4:: deck_struct sAutoDeck4 ; a44c
+sAutoDeck5:: deck_struct sAutoDeck5 ; a4a0
+
+ENDU
+
SECTION "SRAM2", SRAM
ds $18fe
diff --git a/src/text/text2.asm b/src/text/text2.asm
index 0e0c083..8901f4e 100644
--- a/src/text/text2.asm
+++ b/src/text/text2.asm
@@ -1607,15 +1607,15 @@ PleaseSelectDeckText: ; 3ba0d (e:7a0d)
text "Please select deck."
done
-Text0225: ; 3ba22 (e:7a22)
+ModifyDeckText: ; 3ba22 (e:7a22)
text "Modify deck"
done
-Text0226: ; 3ba2f (e:7a2f)
+ChangeNameText: ; 3ba2f (e:7a2f)
text "Change name"
done
-Text0227: ; 3ba3c (e:7a3c)
+SelectDeckText: ; 3ba3c (e:7a3c)
text "Select deck"
done
@@ -1771,7 +1771,7 @@ WhichCardWouldYouLikeToSeeText: ; 3bce5 (e:7ce5)
text "Which card would you like to see?"
done
-Text024d: ; 3bd08 (e:7d08)
+PleaseChooseAPrizeText: ; 3bd08 (e:7d08)
text "Please choose a Prize."
done
@@ -1792,43 +1792,43 @@ EmptyLineText: ; 3bd42 (e:7d42)
textfw0 " ", " ", " ", " ", " ", " ", " ", " ", " "
done
-Text0252: ; 3bd55 (e:7d55)
+BoosterPackTitleText: ; 3bd55 (e:7d55)
text "Booster Pack"
done
-Text0253: ; 3bd63 (e:7d63)
+Item1ColosseumText: ; 3bd63 (e:7d63)
text "1. Colosseum"
done
-Text0254: ; 3bd71 (e:7d71)
+Item2EvolutionText: ; 3bd71 (e:7d71)
text "2. Evolution"
done
-Text0255: ; 3bd7f (e:7d7f)
+Item3MysteryText: ; 3bd7f (e:7d7f)
text "3. Mystery"
done
-Text0256: ; 3bd8b (e:7d8b)
+Item4LaboratoryText: ; 3bd8b (e:7d8b)
text "4. Laboratory"
done
-Text0257: ; 3bd9a (e:7d9a)
+Item5PromotionalCardText: ; 3bd9a (e:7d9a)
text "5. Promotional Card"
done
-Text0258: ; 3bdaf (e:7daf)
+ViewWhichCardFileText: ; 3bdaf (e:7daf)
text "View which Card File?"
done
-Text0259: ; 3bdc6 (e:7dc6)
+EmptyPromotionalCardText: ; 3bdc6 (e:7dc6)
textfw0 "-", "-", "-", "-", "-", "-", "-", "-", "-", "-"
done
-Text025a: ; 3bdd1 (e:7dd1)
+SCardsText: ; 3bdd1 (e:7dd1)
text "'s Cards"
done
-Text025b: ; 3bddb (e:7ddb)
+EmptyDeckNameText: ; 3bddb (e:7ddb)
textfw0 "-", "-", "-", "-", "-", "-", "-", "-", "-", "-", "-", "-", "-", "-"
done
@@ -1836,19 +1836,19 @@ DeckSaveMachineText: ; 3bdea (e:7dea)
text " Deck Save Machine "
done
-Text025d: ; 3be02 (e:7e02)
+SaveADeckText: ; 3be02 (e:7e02)
text "Save a Deck"
done
-Text025e: ; 3be0f (e:7e0f)
+DeleteADeckText: ; 3be0f (e:7e0f)
text "Delete a Deck"
done
-Text025f: ; 3be1e (e:7e1e)
+BuildADeckText: ; 3be1e (e:7e1e)
text "Build a Deck"
done
-Text0260: ; 3be2c (e:7e2c)
+ChooseADeckToSaveText: ; 3be2c (e:7e2c)
text "Choose a Deck to Save."
done
@@ -1861,7 +1861,7 @@ Text0262: ; 3be7d (e:7e7d)
text "for"
done
-Text0263: ; 3be82 (e:7e82)
+SavedTheConfigurationForText: ; 3be82 (e:7e82)
text "Saved the configuration for"
line ""
text "<RAMTEXT>! "
@@ -1876,25 +1876,25 @@ Text0265: ; 3beb7 (e:7eb7)
line "configuration to delete."
done
-Text0266: ; 3bee7 (e:7ee7)
+DoYouReallyWishToDeleteText: ; 3bee7 (e:7ee7)
text "Do you really wish to delete?"
done
-Text0267: ; 3bf06 (e:7f06)
+DeletedTheConfigurationForText: ; 3bf06 (e:7f06)
text "Deleted the configuration for"
line ""
text "<RAMTEXT>."
done
-Text0268: ; 3bf29 (e:7f29)
+YouMayOnlyCarry4DecksText: ; 3bf29 (e:7f29)
text "You may only carry 4 Decks!"
done
-Text0269: ; 3bf46 (e:7f46)
+ChooseADeckToDismantleText: ; 3bf46 (e:7f46)
text "Choose a deck to dismantle."
done
-Text026a: ; 3bf63 (e:7f63)
+DismantledDeckText: ; 3bf63 (e:7f63)
text "Dismantled"
line ""
text "<RAMTEXT>."
@@ -1905,7 +1905,7 @@ Text026b: ; 3bf73 (e:7f73)
line "you wish to Build."
done
-Text026c: ; 3bf9e (e:7f9e)
+ThisDeckCanOnlyBeBuiltIfYouDismantleText: ; 3bf9e (e:7f9e)
text "This Deck can only be built if"
line "you dismantle another Deck."
done
diff --git a/src/text/text3.asm b/src/text/text3.asm
index 3d32c15..ffe0f59 100644
--- a/src/text/text3.asm
+++ b/src/text/text3.asm
@@ -1,23 +1,23 @@
-Text026d: ; 3c000 (f:4000)
+YouDoNotOwnAllCardsNeededToBuildThisDeckText: ; 3c000 (f:4000)
text "You do not own all cards needed"
line "to build this Deck."
done
-Text026e: ; 3c035 (f:4035)
+BuiltDeckText: ; 3c035 (f:4035)
text "Built"
line "<RAMTEXT>"
done
-Text026f: ; 3c03e (f:403e)
+TheseCardsAreNeededToBuildThisDeckText: ; 3c03e (f:403e)
text "These cards are needed"
line "to build this Deck:"
done
-Text0270: ; 3c06a (f:406a)
+DismantleTheseDecksText: ; 3c06a (f:406a)
text "Dismantle these Decks?"
done
-Text0271: ; 3c082 (f:4082)
+DismantledTheDeckText: ; 3c082 (f:4082)
text "Dismantled the Deck."
done
@@ -25,21 +25,21 @@ OKIfFileDeletedText: ; 3c098 (f:4098)
text "OK if this file is deleted?"
done
-Text0273: ; 3c0b5 (f:40b5)
+ReadTheInstructionsText: ; 3c0b5 (f:40b5)
text "Read the Instructions"
done
-Text0274: ; 3c0cc (f:40cc)
+PrintThisCardYesNoText: ; 3c0cc (f:40cc)
text "Print this card?"
line " Yes No"
done
-Text0275: ; 3c0ef (f:40ef)
+PleaseChooseDeckConfigurationToPrintText: ; 3c0ef (f:40ef)
text "Please choose a Deck configuration"
line "to print."
done
-Text0276: ; 3c11d (f:411d)
+PrintThisDeckText: ; 3c11d (f:411d)
text "Print this Deck?"
done
@@ -48,7 +48,7 @@ Text0277: ; 3c12f (f:412f)
line " Yes No"
done
-Text0278: ; 3c156 (f:4156)
+PrintMenuItemsText: ; 3c156 (f:4156)
text "Pokémon Cards"
line "Deck Configuration"
line "Card List"
@@ -56,16 +56,16 @@ Text0278: ; 3c156 (f:4156)
line "Quit Print"
done
-Text0279: ; 3c19b (f:419b)
+WhatWouldYouLikeToPrintText: ; 3c19b (f:419b)
text "What would you like to print?"
done
-Text027a: ; 3c1ba (f:41ba)
+PleaseSetTheContrastText: ; 3c1ba (f:41ba)
text "Please set the contrast:"
line " Light 1 2 3 4 5 Dark"
done
-Text027b: ; 3c1f7 (f:41f7)
+PleaseMakeSureToTurnGameBoyPrinterOffText: ; 3c1f7 (f:41f7)
text "Please make sure to turn"
line "the Game Boy Printer OFF."
done
@@ -169,452 +169,452 @@ LegendaryMachineText: ; 3c4cb (f:44cb)
text " Legendary Machine "
done
-Text0292: ; 3c4e3 (f:44e3)
+AllFightingPokemonText: ; 3c4e3 (f:44e3)
text "All Fighting Pokémon"
done
-Text0293: ; 3c4f9 (f:44f9)
+BenchAttackText: ; 3c4f9 (f:44f9)
text "Bench Attack"
done
-Text0294: ; 3c507 (f:4507)
+BattleContestText: ; 3c507 (f:4507)
text "Battle Contest"
done
-Text0295: ; 3c517 (f:4517)
+HeatedBattleText: ; 3c517 (f:4517)
text "Heated Battle"
done
-Text0296: ; 3c526 (f:4526)
+FirstStrikeText: ; 3c526 (f:4526)
text "First-Strike"
done
-Text0297: ; 3c534 (f:4534)
+SqueakingMouseText: ; 3c534 (f:4534)
text "Squeaking Mouse"
done
-Text0298: ; 3c545 (f:4545)
+GreatQuakeText: ; 3c545 (f:4545)
text "Great Quake"
done
-Text0299: ; 3c552 (f:4552)
+BoneAttackText: ; 3c552 (f:4552)
text "Bone Attack"
done
-Text029a: ; 3c55f (f:455f)
+ExcavationText: ; 3c55f (f:455f)
text "Excavation"
done
-Text029b: ; 3c56b (f:456b)
+RockCrusherText: ; 3c56b (f:456b)
text "Rock Crusher"
done
-Text029c: ; 3c579 (f:4579)
+BlueWaterText: ; 3c579 (f:4579)
text "Blue Water"
done
-Text029d: ; 3c585 (f:4585)
+OnTheBeachText: ; 3c585 (f:4585)
text "On the Beach"
done
-Text029e: ; 3c593 (f:4593)
+ParalyzeText: ; 3c593 (f:4593)
text "Paralyze!"
done
-Text029f: ; 3c59e (f:459e)
+EnergyRemovalText: ; 3c59e (f:459e)
text "Energy Removal"
done
-Text02a0: ; 3c5ae (f:45ae)
+RainDancerText: ; 3c5ae (f:45ae)
text "Rain Dancer"
done
-Text02a1: ; 3c5bb (f:45bb)
+CutePokemonText: ; 3c5bb (f:45bb)
text "Cute Pokémon"
done
-Text02a2: ; 3c5c9 (f:45c9)
+PokemonFluteText: ; 3c5c9 (f:45c9)
text "Pokémon Flute"
done
-Text02a3: ; 3c5d8 (f:45d8)
+YellowFlashText: ; 3c5d8 (f:45d8)
text "Yellow Flash"
done
-Text02a4: ; 3c5e6 (f:45e6)
+ElectricShockText: ; 3c5e6 (f:45e6)
text "Electric Shock"
done
-Text02a5: ; 3c5f6 (f:45f6)
+ZappingSelfdestructText: ; 3c5f6 (f:45f6)
text "Zapping Selfdestruct"
done
-Text02a6: ; 3c60c (f:460c)
+InsectCollectionText: ; 3c60c (f:460c)
text "Insect Collection"
done
-Text02a7: ; 3c61f (f:461f)
+JungleText: ; 3c61f (f:461f)
text "Jungle"
done
-Text02a8: ; 3c627 (f:4627)
+FlowerGardenText: ; 3c627 (f:4627)
text "Flower Garden"
done
-Text02a9: ; 3c636 (f:4636)
+KaleidoscopeText: ; 3c636 (f:4636)
text "Kaleidoscope"
done
-Text02aa: ; 3c644 (f:4644)
+FlowerPowerText: ; 3c644 (f:4644)
text "Flower Power"
done
-Text02ab: ; 3c652 (f:4652)
+PsychicPowerText: ; 3c652 (f:4652)
text "Psychic Power"
done
-Text02ac: ; 3c661 (f:4661)
+DreamEaterHaunterText: ; 3c661 (f:4661)
text "Dream Eater Haunter"
done
-Text02ad: ; 3c676 (f:4676)
+ScavengingSlowbroText: ; 3c676 (f:4676)
text "Scavenging Slowbro"
done
-Text02ae: ; 3c68a (f:468a)
+StrangePowerText: ; 3c68a (f:468a)
text "Strange Power"
done
-Text02af: ; 3c699 (f:4699)
+StrangePsyshockText: ; 3c699 (f:4699)
text "Strange Psyshock"
done
-Text02b0: ; 3c6ab (f:46ab)
+LovelyNidoranText: ; 3c6ab (f:46ab)
text "Lovely Nidoran"
done
-Text02b1: ; 3c6bb (f:46bb)
+ScienceCorpsText: ; 3c6bb (f:46bb)
text "Science Corps"
done
-Text02b2: ; 3c6ca (f:46ca)
+FlyinPokemonText: ; 3c6ca (f:46ca)
text "Flyin' Pokémon"
done
-Text02b3: ; 3c6da (f:46da)
+PoisonText: ; 3c6da (f:46da)
text "Poison"
done
-Text02b4: ; 3c6e2 (f:46e2)
+WondersOfScienceText: ; 3c6e2 (f:46e2)
text "Wonders of Science"
done
-Text02b5: ; 3c6f6 (f:46f6)
+ReplaceEmAllText: ; 3c6f6 (f:46f6)
text "Replace 'Em All"
done
-Text02b6: ; 3c707 (f:4707)
+ChariSaurText: ; 3c707 (f:4707)
text "Chari-Saur"
done
-Text02b7: ; 3c713 (f:4713)
+TrafficLightText: ; 3c713 (f:4713)
text "Traffic Light"
done
-Text02b8: ; 3c722 (f:4722)
+FirePokemonDeckText: ; 3c722 (f:4722)
text "Fire Pokémon"
done
-Text02b9: ; 3c730 (f:4730)
+FireChargeText: ; 3c730 (f:4730)
text "Fire Charge"
done
-Text02ba: ; 3c73d (f:473d)
+CharmanderAndFriendsText: ; 3c73d (f:473d)
text "Charmander & Friends"
done
-Text02bb: ; 3c753 (f:4753)
+SquirtleAndFriendsText: ; 3c753 (f:4753)
text "Squirtle & Friends"
done
-Text02bc: ; 3c767 (f:4767)
+BulbasaurAndFriendsText: ; 3c767 (f:4767)
text "Bulbasaur & Friends"
done
-Text02bd: ; 3c77c (f:477c)
+PsychicMachampText: ; 3c77c (f:477c)
text "Psychic Machamp"
done
-Text02be: ; 3c78d (f:478d)
+WaterBeetleText: ; 3c78d (f:478d)
text "Water Beetle"
done
-Text02bf: ; 3c79b (f:479b)
+LegendaryMoltresText: ; 3c79b (f:479b)
text "Legendary Moltres"
done
-Text02c0: ; 3c7ae (f:47ae)
+LegendaryZapdosText: ; 3c7ae (f:47ae)
text "Legendary Zapdos"
done
-Text02c1: ; 3c7c0 (f:47c0)
+LegendaryArticunoText: ; 3c7c0 (f:47c0)
text "Legendary Articuno"
done
-Text02c2: ; 3c7d4 (f:47d4)
+LegendaryDragoniteText: ; 3c7d4 (f:47d4)
text "Legendary Dragonite"
done
-Text02c3: ; 3c7e9 (f:47e9)
+MysteriousPokemonText: ; 3c7e9 (f:47e9)
text "Mysterious Pokémon"
done
-Text02c4: ; 3c7fd (f:47fd)
+AllFightingPokemonDescriptionText: ; 3c7fd (f:47fd)
text "A Deck of Fighting Pokémon:"
line "Feel their Fighting power!"
done
-Text02c5: ; 3c835 (f:4835)
+BenchAttackDescriptionText: ; 3c835 (f:4835)
text "A Deck of Pokémon that can"
line "attack the Bench."
done
-Text02c6: ; 3c863 (f:4863)
+BattleContestDescriptionText: ; 3c863 (f:4863)
text "A Deck which uses Fighting Attacks"
line "such as Slash and Punch."
done
-Text02c7: ; 3c8a0 (f:48a0)
+HeatedBattleDescriptionText: ; 3c8a0 (f:48a0)
text "A powerful Deck with both Fire"
line "and Fighting Pokémon."
done
-Text02c8: ; 3c8d6 (f:48d6)
+FirstStrikeDescriptionText: ; 3c8d6 (f:48d6)
text "A Deck for fast and furious "
line "attacks."
done
-Text02c9: ; 3c8fd (f:48fd)
+SqueakingMouseDescriptionText: ; 3c8fd (f:48fd)
text "A Deck made of Mouse Pokémon."
line "Uses PlusPower to Power up!"
done
-Text02ca: ; 3c938 (f:4938)
+GreatQuakeDescriptionText: ; 3c938 (f:4938)
text "Use Dugtrio's Earthquake"
line "to cause great damage."
done
-Text02cb: ; 3c969 (f:4969)
+BoneAttackDescriptionText: ; 3c969 (f:4969)
text "A Deck of Cubone and Marowak - "
line "A call for help."
done
-Text02cc: ; 3c99b (f:499b)
+ExcavationDescriptionText: ; 3c99b (f:499b)
text "A Deck which creates Pokémon by"
line "evolving Mysterious Fossils."
done
-Text02cd: ; 3c9d9 (f:49d9)
+RockCrusherDescriptionText: ; 3c9d9 (f:49d9)
text "A Deck of Rock Pokémon. It's"
line "Strong against Lightning Pokémon."
done
-Text02ce: ; 3ca19 (f:4a19)
+BlueWaterDescriptionText: ; 3ca19 (f:4a19)
text "A Deck of Water Pokémon: Their"
line "Blue Horror washes over enemies."
done
-Text02cf: ; 3ca5a (f:4a5a)
+OnTheBeachDescriptionText: ; 3ca5a (f:4a5a)
text "A well balanced Deck"
line "of Sandshrew and Water Pokémon!"
done
-Text02d0: ; 3ca90 (f:4a90)
+ParalyzeDescriptionText: ; 3ca90 (f:4a90)
text "Paralyze the opponent's Pokémon:"
line "Stop 'em and drop 'em!"
done
-Text02d1: ; 3cac9 (f:4ac9)
+EnergyRemovalDescriptionText: ; 3cac9 (f:4ac9)
text "Uses Whirlpool and Hyper Beam to"
line "remove opponents' Energy cards."
done
-Text02d2: ; 3cb0b (f:4b0b)
+RainDancerDescriptionText: ; 3cb0b (f:4b0b)
text "Use Rain Dance to attach Water"
line "Energy for powerful Attacks!"
done
-Text02d3: ; 3cb48 (f:4b48)
+CutePokemonDescriptionText: ; 3cb48 (f:4b48)
text "A Deck of cute Pokémon such as"
line "Pikachu and Eevee."
done
-Text02d4: ; 3cb7b (f:4b7b)
+PokemonFluteDescriptionText: ; 3cb7b (f:4b7b)
text "Use the Pokémon Flute to revive"
line "opponents' Pokémon and Attack!"
done
-Text02d5: ; 3cbbb (f:4bbb)
+YellowFlashDescriptionText: ; 3cbbb (f:4bbb)
text "A deck of Pokémon that use Lightning"
line "Energy to zap opponents."
done
-Text02d6: ; 3cbfa (f:4bfa)
+ElectricShockDescriptionText: ; 3cbfa (f:4bfa)
text "A Deck which Shocks and Paralyzes"
line "opponents with its Attacks."
done
-Text02d7: ; 3cc39 (f:4c39)
+ZappingSelfdestructDescriptionText: ; 3cc39 (f:4c39)
text "Selfdestruct causes great damage "
line "- even to the opponent's Bench."
done
-Text02d8: ; 3cc7c (f:4c7c)
+InsectCollectionDescriptionText: ; 3cc7c (f:4c7c)
text "A Deck made of Insect Pokémon"
line "Go Bug Power!"
done
-Text02d9: ; 3cca9 (f:4ca9)
+JungleDescriptionText: ; 3cca9 (f:4ca9)
text "A Deck of Grass Pokémon: There "
line "are many dangers in the Jungle."
done
-Text02da: ; 3ccea (f:4cea)
+FlowerGardenDescriptionText: ; 3ccea (f:4cea)
text "A Deck of Flower Pokémon:"
line "Beautiful but Dangerous"
done
-Text02db: ; 3cd1d (f:4d1d)
+KaleidoscopeDescriptionText: ; 3cd1d (f:4d1d)
text "Uses Venomoth's Pokémon Power to"
line "change the opponent's Weakness."
done
-Text02dc: ; 3cd5f (f:4d5f)
+FlowerPowerDescriptionText: ; 3cd5f (f:4d5f)
text "A powerful Big Eggsplosion "
line "and Energy Transfer combo!"
done
-Text02dd: ; 3cd97 (f:4d97)
+PsychicPowerDescriptionText: ; 3cd97 (f:4d97)
text "Use the Psychic power of the"
line "Psychic Pokémon to Attack!"
done
-Text02de: ; 3cdd0 (f:4dd0)
+DreamEaterHaunterDescriptionText: ; 3cdd0 (f:4dd0)
text "Uses Haunter's Dream Eater"
line "to cause great damage!"
done
-Text02df: ; 3ce03 (f:4e03)
+ScavengingSlowbroDescriptionText: ; 3ce03 (f:4e03)
text "Continually draw Trainer "
line "Cards from the Discard Pile!"
done
-Text02e0: ; 3ce3b (f:4e3b)
+StrangePowerDescriptionText: ; 3ce3b (f:4e3b)
text "Confuse opponents with"
line "mysterious power!"
done
-Text02e1: ; 3ce65 (f:4e65)
+StrangePsyshockDescriptionText: ; 3ce65 (f:4e65)
text "Use Alakazam's Damage Swap"
line "to move damage counters!"
done
-Text02e2: ; 3ce9a (f:4e9a)
+LovelyNidoranDescriptionText: ; 3ce9a (f:4e9a)
text "Uses Nidoqueen's Boyfriends to cause"
line "great damage to the opponent."
done
-Text02e3: ; 3cede (f:4ede)
+ScienceCorpsDescriptionText: ; 3cede (f:4ede)
text "The march of the Science Corps!"
line "Attack with the power of science!"
done
-Text02e4: ; 3cf21 (f:4f21)
+FlyinPokemonDescriptionText: ; 3cf21 (f:4f21)
text "Pokémon with feathers flock "
line "together! Retreating is easy!"
done
-Text02e5: ; 3cf5d (f:4f5d)
+PoisonDescriptionText: ; 3cf5d (f:4f5d)
text "A Deck that uses Poison to "
line "slowly Knock Out the opponent."
done
-Text02e6: ; 3cf99 (f:4f99)
+WondersOfScienceDescriptionText: ; 3cf99 (f:4f99)
text "Block Pokémon Powers with "
line "Muk and attack with Mewtwo!"
done
-Text02e7: ; 3cfd1 (f:4fd1)
+ReplaceEmAllDescriptionText: ; 3cfd1 (f:4fd1)
text "A Deck that shuffles"
line "the opponent's cards"
done
-Text02e8: ; 3cffc (f:4ffc)
+ChariSaurDescriptionText: ; 3cffc (f:4ffc)
text "Attack with Charizard - with "
line "just a few Fire Energy cards!"
done
-Text02e9: ; 3d039 (f:5039)
+TrafficLightDescriptionText: ; 3d039 (f:5039)
text "Pokémon that can Attack with"
line "Fire, Water or Lightning Energy!"
done
-Text02ea: ; 3d078 (f:5078)
+FirePokemonDescriptionText: ; 3d078 (f:5078)
text "With Fire Pokémon like Charizard, "
line "Rapidash and Magmar, it's hot!"
done
-Text02eb: ; 3d0bb (f:50bb)
+FireChargeDescriptionText: ; 3d0bb (f:50bb)
text "Desperate attacks Damage your "
line "opponent and you!"
done
-Text02ec: ; 3d0ed (f:50ed)
+CharmanderAndFriendsDescriptionText: ; 3d0ed (f:50ed)
text "A Fire, Grass and Water Deck:"
line "Charmander, Pinsir and Seel"
done
-Text02ed: ; 3d128 (f:5128)
+SquirtleAndFriendsDescriptionText: ; 3d128 (f:5128)
text "A Water, Fire, and Lightning Deck:"
line "Squirtle, Charmander and Pikachu"
done
-Text02ee: ; 3d16d (f:516d)
+BulbasaurAndFriendsDescriptionText: ; 3d16d (f:516d)
text "A Grass, Lightning and Psychic Deck:"
line "Bulbasaur, Pikachu and Abra"
done
-Text02ef: ; 3d1af (f:51af)
+PsychicMachampDescriptionText: ; 3d1af (f:51af)
text "Machamp, Hitmonlee, Hitmonchan"
line "Gengar and Alakazam are furious!"
done
-Text02f0: ; 3d1f0 (f:51f0)
+WaterBeetleDescriptionText: ; 3d1f0 (f:51f0)
text "An Evolution Deck with Weedle, "
line "Nidoran♂ and Bellsprout."
done
-Text02f1: ; 3d22a (f:522a)
+LegendaryMoltresDescriptionText: ; 3d22a (f:522a)
text "Gather Fire Energy with the"
line "Legendary Moltres!"
done
-Text02f2: ; 3d25a (f:525a)
+LegendaryZapdosDescriptionText: ; 3d25a (f:525a)
text "Zap opponents with the"
line "Legandary Zapdos!"
done
-Text02f3: ; 3d284 (f:5284)
+LegendaryArticunoDescriptionText: ; 3d284 (f:5284)
text "Paralyze opponents with the"
line "Legendary Articuno!"
done
-Text02f4: ; 3d2b5 (f:52b5)
+LegendaryDragoniteDescriptionText: ; 3d2b5 (f:52b5)
text "Heal your Pokémon with the"
line "Legendary Dragonite!"
done
-Text02f5: ; 3d2e6 (f:52e6)
+MysteriousPokemonDescriptionText: ; 3d2e6 (f:52e6)
text "A very special Deck made of"
line "very rare Pokémon cards!"
done
diff --git a/src/text/text_offsets.asm b/src/text/text_offsets.asm
index b8a1dbf..b9d2561 100644
--- a/src/text/text_offsets.asm
+++ b/src/text/text_offsets.asm
@@ -550,9 +550,9 @@ TextOffsets:: ; 34000 (d:4000)
textpointer DeckNameKeyboardText ; 0x0222
textpointer NewDeckText ; 0x0223
textpointer PleaseSelectDeckText ; 0x0224
- textpointer Text0225 ; 0x0225
- textpointer Text0226 ; 0x0226
- textpointer Text0227 ; 0x0227
+ textpointer ModifyDeckText ; 0x0225
+ textpointer ChangeNameText ; 0x0226
+ textpointer SelectDeckText ; 0x0227
textpointer CancelText ; 0x0228
textpointer Text0229 ; 0x0229
textpointer ChosenAsDuelingDeckText ; 0x022a
@@ -590,53 +590,53 @@ TextOffsets:: ; 34000 (d:4000)
textpointer InPlayAreaText ; 0x024a
textpointer GlossaryText ; 0x024b
textpointer WhichCardWouldYouLikeToSeeText ; 0x024c
- textpointer Text024d ; 0x024d
+ textpointer PleaseChooseAPrizeText ; 0x024d
textpointer HandText_2 ; 0x024e
textpointer DuelistHandText_2 ; 0x024f
textpointer DuelistDiscardPileText ; 0x0250
textpointer EmptyLineText ; 0x0251
- textpointer Text0252 ; 0x0252
- textpointer Text0253 ; 0x0253
- textpointer Text0254 ; 0x0254
- textpointer Text0255 ; 0x0255
- textpointer Text0256 ; 0x0256
- textpointer Text0257 ; 0x0257
- textpointer Text0258 ; 0x0258
- textpointer Text0259 ; 0x0259
- textpointer Text025a ; 0x025a
- textpointer Text025b ; 0x025b
+ textpointer BoosterPackTitleText ; 0x0252
+ textpointer Item1ColosseumText ; 0x0253
+ textpointer Item2EvolutionText ; 0x0254
+ textpointer Item3MysteryText ; 0x0255
+ textpointer Item4LaboratoryText ; 0x0256
+ textpointer Item5PromotionalCardText ; 0x0257
+ textpointer ViewWhichCardFileText ; 0x0258
+ textpointer EmptyPromotionalCardText ; 0x0259
+ textpointer SCardsText ; 0x025a
+ textpointer EmptyDeckNameText ; 0x025b
textpointer DeckSaveMachineText ; 0x025c
- textpointer Text025d ; 0x025d
- textpointer Text025e ; 0x025e
- textpointer Text025f ; 0x025f
- textpointer Text0260 ; 0x0260
+ textpointer SaveADeckText ; 0x025d
+ textpointer DeleteADeckText ; 0x025e
+ textpointer BuildADeckText ; 0x025f
+ textpointer ChooseADeckToSaveText ; 0x0260
textpointer Text0261 ; 0x0261
textpointer Text0262 ; 0x0262
- textpointer Text0263 ; 0x0263
+ textpointer SavedTheConfigurationForText ; 0x0263
textpointer Text0264 ; 0x0264
textpointer Text0265 ; 0x0265
- textpointer Text0266 ; 0x0266
- textpointer Text0267 ; 0x0267
- textpointer Text0268 ; 0x0268
- textpointer Text0269 ; 0x0269
- textpointer Text026a ; 0x026a
+ textpointer DoYouReallyWishToDeleteText ; 0x0266
+ textpointer DeletedTheConfigurationForText ; 0x0267
+ textpointer YouMayOnlyCarry4DecksText ; 0x0268
+ textpointer ChooseADeckToDismantleText ; 0x0269
+ textpointer DismantledDeckText ; 0x026a
textpointer Text026b ; 0x026b
- textpointer Text026c ; 0x026c
- textpointer Text026d ; 0x026d
- textpointer Text026e ; 0x026e
- textpointer Text026f ; 0x026f
- textpointer Text0270 ; 0x0270
- textpointer Text0271 ; 0x0271
+ textpointer ThisDeckCanOnlyBeBuiltIfYouDismantleText ; 0x026c
+ textpointer YouDoNotOwnAllCardsNeededToBuildThisDeckText ; 0x026d
+ textpointer BuiltDeckText ; 0x026e
+ textpointer TheseCardsAreNeededToBuildThisDeckText ; 0x026f
+ textpointer DismantleTheseDecksText ; 0x0270
+ textpointer DismantledTheDeckText ; 0x0271
textpointer OKIfFileDeletedText ; 0x0272
- textpointer Text0273 ; 0x0273
- textpointer Text0274 ; 0x0274
- textpointer Text0275 ; 0x0275
- textpointer Text0276 ; 0x0276
+ textpointer ReadTheInstructionsText ; 0x0273
+ textpointer PrintThisCardYesNoText ; 0x0274
+ textpointer PleaseChooseDeckConfigurationToPrintText ; 0x0275
+ textpointer PrintThisDeckText ; 0x0276
textpointer Text0277 ; 0x0277
- textpointer Text0278 ; 0x0278
- textpointer Text0279 ; 0x0279
- textpointer Text027a ; 0x027a
- textpointer Text027b ; 0x027b
+ textpointer PrintMenuItemsText ; 0x0278
+ textpointer WhatWouldYouLikeToPrintText ; 0x0279
+ textpointer PleaseSetTheContrastText ; 0x027a
+ textpointer PleaseMakeSureToTurnGameBoyPrinterOffText ; 0x027b
textpointer ProceduresForSendingCardsText ; 0x027c
textpointer CardSendingProceduresText ; 0x027d
textpointer PleaseReadTheProceduresForSendingCardsText ; 0x027e
@@ -659,106 +659,106 @@ TextOffsets:: ; 34000 (d:4000)
textpointer FireMachineText ; 0x028f
textpointer AutoMachineText ; 0x0290
textpointer LegendaryMachineText ; 0x0291
- textpointer Text0292 ; 0x0292
- textpointer Text0293 ; 0x0293
- textpointer Text0294 ; 0x0294
- textpointer Text0295 ; 0x0295
- textpointer Text0296 ; 0x0296
- textpointer Text0297 ; 0x0297
- textpointer Text0298 ; 0x0298
- textpointer Text0299 ; 0x0299
- textpointer Text029a ; 0x029a
- textpointer Text029b ; 0x029b
- textpointer Text029c ; 0x029c
- textpointer Text029d ; 0x029d
- textpointer Text029e ; 0x029e
- textpointer Text029f ; 0x029f
- textpointer Text02a0 ; 0x02a0
- textpointer Text02a1 ; 0x02a1
- textpointer Text02a2 ; 0x02a2
- textpointer Text02a3 ; 0x02a3
- textpointer Text02a4 ; 0x02a4
- textpointer Text02a5 ; 0x02a5
- textpointer Text02a6 ; 0x02a6
- textpointer Text02a7 ; 0x02a7
- textpointer Text02a8 ; 0x02a8
- textpointer Text02a9 ; 0x02a9
- textpointer Text02aa ; 0x02aa
- textpointer Text02ab ; 0x02ab
- textpointer Text02ac ; 0x02ac
- textpointer Text02ad ; 0x02ad
- textpointer Text02ae ; 0x02ae
- textpointer Text02af ; 0x02af
- textpointer Text02b0 ; 0x02b0
- textpointer Text02b1 ; 0x02b1
- textpointer Text02b2 ; 0x02b2
- textpointer Text02b3 ; 0x02b3
- textpointer Text02b4 ; 0x02b4
- textpointer Text02b5 ; 0x02b5
- textpointer Text02b6 ; 0x02b6
- textpointer Text02b7 ; 0x02b7
- textpointer Text02b8 ; 0x02b8
- textpointer Text02b9 ; 0x02b9
- textpointer Text02ba ; 0x02ba
- textpointer Text02bb ; 0x02bb
- textpointer Text02bc ; 0x02bc
- textpointer Text02bd ; 0x02bd
- textpointer Text02be ; 0x02be
- textpointer Text02bf ; 0x02bf
- textpointer Text02c0 ; 0x02c0
- textpointer Text02c1 ; 0x02c1
- textpointer Text02c2 ; 0x02c2
- textpointer Text02c3 ; 0x02c3
- textpointer Text02c4 ; 0x02c4
- textpointer Text02c5 ; 0x02c5
- textpointer Text02c6 ; 0x02c6
- textpointer Text02c7 ; 0x02c7
- textpointer Text02c8 ; 0x02c8
- textpointer Text02c9 ; 0x02c9
- textpointer Text02ca ; 0x02ca
- textpointer Text02cb ; 0x02cb
- textpointer Text02cc ; 0x02cc
- textpointer Text02cd ; 0x02cd
- textpointer Text02ce ; 0x02ce
- textpointer Text02cf ; 0x02cf
- textpointer Text02d0 ; 0x02d0
- textpointer Text02d1 ; 0x02d1
- textpointer Text02d2 ; 0x02d2
- textpointer Text02d3 ; 0x02d3
- textpointer Text02d4 ; 0x02d4
- textpointer Text02d5 ; 0x02d5
- textpointer Text02d6 ; 0x02d6
- textpointer Text02d7 ; 0x02d7
- textpointer Text02d8 ; 0x02d8
- textpointer Text02d9 ; 0x02d9
- textpointer Text02da ; 0x02da
- textpointer Text02db ; 0x02db
- textpointer Text02dc ; 0x02dc
- textpointer Text02dd ; 0x02dd
- textpointer Text02de ; 0x02de
- textpointer Text02df ; 0x02df
- textpointer Text02e0 ; 0x02e0
- textpointer Text02e1 ; 0x02e1
- textpointer Text02e2 ; 0x02e2
- textpointer Text02e3 ; 0x02e3
- textpointer Text02e4 ; 0x02e4
- textpointer Text02e5 ; 0x02e5
- textpointer Text02e6 ; 0x02e6
- textpointer Text02e7 ; 0x02e7
- textpointer Text02e8 ; 0x02e8
- textpointer Text02e9 ; 0x02e9
- textpointer Text02ea ; 0x02ea
- textpointer Text02eb ; 0x02eb
- textpointer Text02ec ; 0x02ec
- textpointer Text02ed ; 0x02ed
- textpointer Text02ee ; 0x02ee
- textpointer Text02ef ; 0x02ef
- textpointer Text02f0 ; 0x02f0
- textpointer Text02f1 ; 0x02f1
- textpointer Text02f2 ; 0x02f2
- textpointer Text02f3 ; 0x02f3
- textpointer Text02f4 ; 0x02f4
- textpointer Text02f5 ; 0x02f5
+ textpointer AllFightingPokemonText ; 0x0292
+ textpointer BenchAttackText ; 0x0293
+ textpointer BattleContestText ; 0x0294
+ textpointer HeatedBattleText ; 0x0295
+ textpointer FirstStrikeText ; 0x0296
+ textpointer SqueakingMouseText ; 0x0297
+ textpointer GreatQuakeText ; 0x0298
+ textpointer BoneAttackText ; 0x0299
+ textpointer ExcavationText ; 0x029a
+ textpointer RockCrusherText ; 0x029b
+ textpointer BlueWaterText ; 0x029c
+ textpointer OnTheBeachText ; 0x029d
+ textpointer ParalyzeText ; 0x029e
+ textpointer EnergyRemovalText ; 0x029f
+ textpointer RainDancerText ; 0x02a0
+ textpointer CutePokemonText ; 0x02a1
+ textpointer PokemonFluteText ; 0x02a2
+ textpointer YellowFlashText ; 0x02a3
+ textpointer ElectricShockText ; 0x02a4
+ textpointer ZappingSelfdestructText ; 0x02a5
+ textpointer InsectCollectionText ; 0x02a6
+ textpointer JungleText ; 0x02a7
+ textpointer FlowerGardenText ; 0x02a8
+ textpointer KaleidoscopeText ; 0x02a9
+ textpointer FlowerPowerText ; 0x02aa
+ textpointer PsychicPowerText ; 0x02ab
+ textpointer DreamEaterHaunterText ; 0x02ac
+ textpointer ScavengingSlowbroText ; 0x02ad
+ textpointer StrangePowerText ; 0x02ae
+ textpointer StrangePsyshockText ; 0x02af
+ textpointer LovelyNidoranText ; 0x02b0
+ textpointer ScienceCorpsText ; 0x02b1
+ textpointer FlyinPokemonText ; 0x02b2
+ textpointer PoisonText ; 0x02b3
+ textpointer WondersOfScienceText ; 0x02b4
+ textpointer ReplaceEmAllText ; 0x02b5
+ textpointer ChariSaurText ; 0x02b6
+ textpointer TrafficLightText ; 0x02b7
+ textpointer FirePokemonDeckText ; 0x02b8
+ textpointer FireChargeText ; 0x02b9
+ textpointer CharmanderAndFriendsText ; 0x02ba
+ textpointer SquirtleAndFriendsText ; 0x02bb
+ textpointer BulbasaurAndFriendsText ; 0x02bc
+ textpointer PsychicMachampText ; 0x02bd
+ textpointer WaterBeetleText ; 0x02be
+ textpointer LegendaryMoltresText ; 0x02bf
+ textpointer LegendaryZapdosText ; 0x02c0
+ textpointer LegendaryArticunoText ; 0x02c1
+ textpointer LegendaryDragoniteText ; 0x02c2
+ textpointer MysteriousPokemonText ; 0x02c3
+ textpointer AllFightingPokemonDescriptionText ; 0x02c4
+ textpointer BenchAttackDescriptionText ; 0x02c5
+ textpointer BattleContestDescriptionText ; 0x02c6
+ textpointer HeatedBattleDescriptionText ; 0x02c7
+ textpointer FirstStrikeDescriptionText ; 0x02c8
+ textpointer SqueakingMouseDescriptionText ; 0x02c9
+ textpointer GreatQuakeDescriptionText ; 0x02ca
+ textpointer BoneAttackDescriptionText ; 0x02cb
+ textpointer ExcavationDescriptionText ; 0x02cc
+ textpointer RockCrusherDescriptionText ; 0x02cd
+ textpointer BlueWaterDescriptionText ; 0x02ce
+ textpointer OnTheBeachDescriptionText ; 0x02cf
+ textpointer ParalyzeDescriptionText ; 0x02d0
+ textpointer EnergyRemovalDescriptionText ; 0x02d1
+ textpointer RainDancerDescriptionText ; 0x02d2
+ textpointer CutePokemonDescriptionText ; 0x02d3
+ textpointer PokemonFluteDescriptionText ; 0x02d4
+ textpointer YellowFlashDescriptionText ; 0x02d5
+ textpointer ElectricShockDescriptionText ; 0x02d6
+ textpointer ZappingSelfdestructDescriptionText ; 0x02d7
+ textpointer InsectCollectionDescriptionText ; 0x02d8
+ textpointer JungleDescriptionText ; 0x02d9
+ textpointer FlowerGardenDescriptionText ; 0x02da
+ textpointer KaleidoscopeDescriptionText ; 0x02db
+ textpointer FlowerPowerDescriptionText ; 0x02dc
+ textpointer PsychicPowerDescriptionText ; 0x02dd
+ textpointer DreamEaterHaunterDescriptionText ; 0x02de
+ textpointer ScavengingSlowbroDescriptionText ; 0x02df
+ textpointer StrangePowerDescriptionText ; 0x02e0
+ textpointer StrangePsyshockDescriptionText ; 0x02e1
+ textpointer LovelyNidoranDescriptionText ; 0x02e2
+ textpointer ScienceCorpsDescriptionText ; 0x02e3
+ textpointer FlyinPokemonDescriptionText ; 0x02e4
+ textpointer PoisonDescriptionText ; 0x02e5
+ textpointer WondersOfScienceDescriptionText ; 0x02e6
+ textpointer ReplaceEmAllDescriptionText ; 0x02e7
+ textpointer ChariSaurDescriptionText ; 0x02e8
+ textpointer TrafficLightDescriptionText ; 0x02e9
+ textpointer FirePokemonDescriptionText ; 0x02ea
+ textpointer FireChargeDescriptionText ; 0x02eb
+ textpointer CharmanderAndFriendsDescriptionText ; 0x02ec
+ textpointer SquirtleAndFriendsDescriptionText ; 0x02ed
+ textpointer BulbasaurAndFriendsDescriptionText ; 0x02ee
+ textpointer PsychicMachampDescriptionText ; 0x02ef
+ textpointer WaterBeetleDescriptionText ; 0x02f0
+ textpointer LegendaryMoltresDescriptionText ; 0x02f1
+ textpointer LegendaryZapdosDescriptionText ; 0x02f2
+ textpointer LegendaryArticunoDescriptionText ; 0x02f3
+ textpointer LegendaryDragoniteDescriptionText ; 0x02f4
+ textpointer MysteriousPokemonDescriptionText ; 0x02f5
textpointer PokemonCardGlossaryText ; 0x02f6
textpointer GlossaryMenuPage1Text ; 0x02f7
textpointer GlossaryMenuPage2Text ; 0x02f8
diff --git a/src/wram.asm b/src/wram.asm
index 75e1e66..4bfbc8d 100644
--- a/src/wram.asm
+++ b/src/wram.asm
@@ -38,6 +38,12 @@ NEXTU
wCardPopNameList:: ; c000
ds CARDPOP_NAME_LIST_SIZE
+NEXTU
+
+; buffer used to store a deck that will be built
+wDeckToBuild:: ; c000
+ ds DECK_STRUCT_SIZE
+
ENDU
ds $100
@@ -448,21 +454,14 @@ UNION
; this is kept updated with some default text that is used
; when the text printing functions are called with text id $0000
wDefaultText:: ; c590
- ds $2
-
-wc592:: ; c592
- ds $3
-
- ds $15
-
-wc5aa:: ; c5aa
- ds $1
-
- ds $21
+ ds $3c
NEXTU
-wc590:: ; c590
+; used in CheckIfCurrentDeckWasChanged to determine whether
+; wCurDeckCards was changed from the original
+; deck it was based on
+wCurDeckCardChanges:: ; c590
ds DECK_SIZE
ENDU
@@ -1712,21 +1711,25 @@ wCheckMenuPlayAreaWhichLayout:: ; ce51
; the position of cursor in the "In Play Area" screen
wInPlayAreaCurPosition:: ; ce52
-; holds the position of the cursor when selecting a prize card
-wPrizeCardCursorPosition:: ; ce52
+; holds the position of the cursor when selecting
+; in the "Your Play Area" or "Opp Play Area" screens
+wYourOrOppPlayAreaCurPosition:: ; ce52
ds $1
; pointer to the table which contains information for each key-press.
wMenuInputTablePointer:: ; ce53
-wce53:: ; ce53
+; pointer to transition table data
+wTransitionTablePtr:: ; ce53
ds $2
; same as wDuelInitialPrizes but with upper 2 bits set
wDuelInitialPrizesUpperBitsSet:: ; ce55
ds $1
-wce56:: ; ce56
+; if TRUE, SwapTurn is called
+; after some operations are concluded
+wIsSwapTurnPending:: ; ce56
ds $1
; it's used for restore the position of cursor
@@ -1740,9 +1743,14 @@ wInPlayAreaPreservedPosition:: ; ce57
wInPlayAreaTemporaryPosition:: ; ce58
ds $1
-wce59:: ; ce59
+; number of prize cards still to be
+; picked by the player
+wNumberOfPrizeCardsToSelect:: ; ce59
ds $1
+; pointer to a $ff-terminated list
+; of the prize cards selected by the player
+wSelectedPrizeCardListPtr:: ; ce5a
ds $2
wce5c:: ; ce5c
@@ -1893,7 +1901,10 @@ wce9f:: ; ce9f
wCardPopCardObtainSong:: ; cea0
ds $1
-wcea1:: ; cea1
+; first index in the current card list that is visible
+; used to calculate which element to get based
+; on the cursor position
+wCardListVisibleOffset:: ; cea1
ds $1
ds $1
@@ -1904,42 +1915,69 @@ wcea1:: ; cea1
wCheckMenuCursorBlinkCounter:: ; cea3
ds $1
+; used to temporarily store wCurCardTypeFilter
+; to check whether a new filter is to be applied
+wTempCardTypeFilter:: ; cea4
+
+wCardListCursorPos:: ; cea4
+
wNamingScreenCursorY:: ; cea4
ds $1
-wcea5:: ; cea5
- ds $4
+wCardListCursorXPos:: ; cea5
+ ds $1
-wNamingScreenKeyboardHeight:: ; cea9
+wCardListCursorYPos:: ; cea6
ds $1
-wceaa:: ; ceaa
+wCardListYSpacing:: ; cea7
ds $1
-wceab:: ; ceab
- ds $4
+wCardListXSpacing:: ; cea8
+ ds $1
-wCheckMenuCursorXPosition:: ; ceaf
+wCardListNumCursorPositions:: ; cea9
+
+wNamingScreenKeyboardHeight:: ; cea9
ds $1
-wCheckMenuCursorYPosition:: ; ceb0
+; tile to draw when cursor is blinking
+wVisibleCursorTile:: ; ceaa
ds $1
-wceb1:: ; ceb1
+; tile to draw when cursor is visible
+wInvisibleCursorTile:: ; ceab
ds $1
-wceb2:: ; ceb2
+; unknown handler function run in HandleDeckCardSelectionList
+; is always NULL
+wCardListHandlerFunction:: ; ceac
+ ds $2
+
+; number of cards that are listed
+; in the current filtered list
+wNumEntriesInCurFilter:: ; ceae
ds $1
-wceb3:: ; ceb3
+wCheckMenuCursorXPosition:: ; ceaf
ds $1
-wceb4:: ; ceb4
+wCheckMenuCursorYPosition:: ; ceb0
ds $1
-wceb5:: ; ceb5
+; deck selected by the player in the Decks screen
+wCurDeck:: ; ceb1
ds $1
+; each of these are a boolean to
+; represent whether a given deck
+; that the player has is a valid deck
+wDecksValid::
+wDeck1Valid:: ds $1 ; ceb2
+wDeck2Valid:: ds $1 ; ceb3
+wDeck3Valid:: ds $1 ; ceb4
+wDeck4Valid:: ds $1 ; ceb5
+
; used to store the tens digit and
; ones digit of a value for printing
; the ones digit is added $20
@@ -1950,49 +1988,79 @@ wOnesAndTensPlace:: ; ceb6
ds $3
-wcebb:: ; cebb
- ds $9
+; each of these stores the card count
+; of each filter in the deck building screen
+; the order follows CardTypeFilters
+wCardFilterCounts:: ; cebb
+ ds NUM_FILTERS
-wcec4:: ; cec4
- ds $7
+UNION
+
+; buffer used to show which card IDs
+; are visible in a given list
+wVisibleListCardIDs:: ; cec4
+ ds NUM_DECK_CONFIRMATION_VISIBLE_CARDS
+
+NEXTU
-wcecb:: ; cecb
+; whether a given Card Set is unavailable in the Card Album screen
+; used only for CARD_SET_PROMOTIONAL, in which case
+; if it's unavailable, will print "----------" as the Card Set name
+wUnavailableAlbumCardSets:: ; cec4
+ ds NUM_CARD_SETS
+
+ENDU
+
+; number of visible entries
+; when showing a list of cards
+wNumVisibleCardListEntries:: ; cecb
ds $1
-wcecc:: ; cecc
+wTotalCardCount:: ; cecc
ds $1
-wcecd:: ; cecd
+; is TRUE if list cannot be scrolled down
+; past the last visible entry
+wUnableToScrollDown:: ; cecd
ds $1
-wcece:: ; cece
+; pointer to a function that should be called
+; to update the card list being shown
+wCardListUpdateFunction:: ; cece
ds $2
-wced0:: ; ced0
+; holds y and x coordinates (in that order)
+; of start of card list (top-left corner)
+wCardListCoords:: ; ced0
ds $2
wced2:: ; ced2
ds $1
-wced3:: ; ced3
+; the current filter being used
+; from the CardTypeFilters list
+wCurCardTypeFilter:: ; ced3
ds $1
-wced4:: ; ced4
+; temporarily stores wCardListNumCursorPositions value
+wTempCardListCursorPos:: ; ced4
ds $1
-wced5:: ; ced5
+wTempFilteredCardListNumCursorPositions:: ; ced5
ds $1
wced6:: ; ced6
ds $1
+; maybe unused, is written to but never read
wced7:: ; ced7
ds $1
wced8:: ; ced8
ds $1
-wced9:: ; ced9
+; stores how many different cards there are in a deck
+wNumUniqueCards:: ; ced9
ds $1
; stores the list of all card IDs that filtered by its card type
@@ -2005,14 +2073,21 @@ wHandTempList:: ; ceda
wceda:: ; ceda
ds DECK_SIZE
+; terminator for wceda
wcf16:: ; cf16
ds $1
-; used in bank2, probably related to wTempHandCardList (another temp list?)
-wcf17:: ; cf17
- ds DECK_SIZE
+; holds cards for the current deck
+wCurDeckCards:: ; cf17
+ ds DECK_CONFIG_BUFFER_SIZE
+
+wCurDeckCardsTerminator:: ; cf67
+ ds $1
+wCurDeckCardsEnd::
- ds $15
+
+; list of all the different cards in a deck configuration
+wUniqueDeckCardList:: ; cf68
; stores the count number of cards owned
; can be 0 in the case that a card is not available
@@ -2025,18 +2100,45 @@ wTempHandCardList:: ; cf68
ds $15
-wcfb9:: ; cfb9
- ds $14
+; name of the selected deck
+wCurDeckName:: ; cfb9
+ ds DECK_NAME_SIZE
- ds $4
+; max number of cards that are allowed
+; to include when building a deck configuration
+wMaxNumCardsAllowed:: ; cfd1
+ ds $1
-wcfd1:: ; cfd1
- ds $7
+; max number of cards with same name that are allowed
+; to be included when building a deck configuration
+wSameNameCardsLimit:: ; cfd2
+ ds $1
-wcfd8:: ; cfd8
+; whether to include the cards in the selected deck
+; to appear in the filtered lists
+; is TRUE when building a deck (since the cards should be shown for removal)
+; is FALSE when choosing a deck configuration to send through Gift Center
+; (can't select cards that are included in already built decks)
+wIncludeCardsInDeck:: ; cfd3
+ ds $1
+
+; pointer to a function that handles the menu
+; when building a deck configuration
+wDeckConfigurationMenuHandlerFunction:: ; cfd4
ds $2
-wcfda:: ; cfda
+; pointer to a transition table for the
+; function in wDeckConfigurationMenuHandlerFunction
+wDeckConfigurationMenuTransitionTable:: ; cfd6
+ ds $2
+
+; pointer to a list of cards that
+; is currently being shown/manipulated
+wCurCardListPtr:: ; cfd8
+ ds $2
+
+; text ID to print in the card confirmation screen text box
+wCardConfirmationText:: ; cfda
ds $2
ds $2
@@ -2046,17 +2148,36 @@ wcfda:: ; cfda
wCursorAlternateTile:: ; cfde
ds $1
-wcfdf:: ; cfdf
+; temporarily stores value of wCardListNumCursorPositions
+wTempCardListNumCursorPositions:: ; cfdf
ds $1
- ds $3
+; which Card Set selected by the player to view
+wSelectedCardSet:: ; cfe0
+ ds $1
+
+; number of cards the player owns from the given Card Set
+wNumOwnedCardsInSet:: ; cfe1
+ ds $1
+
+; flags that corresponds to each Phantom Card owned by the player
+; see src/constants/menu_constants.asm
+wOwnedPhantomCardFlags:: ; cfe2
+ ds $1
; a flag indicating whether sfx should be played.
wPlaysSfx:: ; cfe3
ds $1
wcfe4:: ; cfe4
- ds $3
+ ds $1
+
+; collection index of the first owned card
+wFirstOwnedCardIndex:: ; cfe5
+ ds $1
+
+wNumCardListEntries:: ; cfe6
+ ds $1
; a name buffer in the naming screen.
wNamingScreenBuffer:: ; cfe7
@@ -2091,48 +2212,59 @@ wNamingScreenNamePosition:: ; d007
wd009:: ; d009
ds $4
-wd00d:: ; d00d
- ds $1
-
- ds $78
+; pointers to all decks of current deck machine
+wMachineDeckPtrs:: ; d00d
+ ds 2 * NUM_DECK_SAVE_MACHINE_SLOTS
-wd086:: ; d086
+wNumSavedDecks:: ; d085
ds $1
-wd087:: ; d087
+; temporarily holds value of wCardListCursorPos
+wTempDeckMachineCursorPos:: ; d086
ds $1
-wd088:: ; d088
+; temporarily holds value of wCardListVisibleOffset
+wTempCardListVisibleOffset:: ; d087
ds $1
-wd089:: ; d089
+; which list entry was selected in the Deck Machine screen
+wSelectedDeckMachineEntry:: ; d088
ds $1
-wd08a:: ; d08a
- ds $18
+wDismantledDeckName:: ; d089
+ ds DECK_NAME_SIZE
-wd0a2:: ; d0a2
+; which deck slot to be used to
+; build a new deck
+wDeckSlotForNewDeck:: ; d0a1
+ ds $1
+
+wDeckMachineTitleText:: ; d0a2
ds $2
-wd0a4:: ; d0a4
+wTempBankSRAM:: ; d0a4
ds $1
-wd0a5:: ; d0a5
+wNumDeckMachineEntries:: ; d0a5
ds $1
-wd0a6:: ; d0a6
+; DECK_* flags to be dismantled to build a given deck
+wDecksToBeDismantled:: ; d0a6
ds $1
-wd0a7:: ; d0a7
+; text ID to print in the text box when
+; inside the Deck Machine menu
+wDeckMachineText:: ; d0a7
ds $2
-wd0a9:: ; d0a9
- ds $1
-
-wd0aa:: ; d0aa
+; which deck machine is being used
+wCurAutoDeckMachine:: ; d0a9
ds $1
- ds $9
+; text IDs for each deck descriptions of the
+; Auto Deck Machine currently being shown
+wAutoDeckMachineTextDescriptions:: ; d0aa
+ ds 2 * NUM_DECK_MACHINE_SLOTS
wd0b4:: ; d0b4
ds $1