More duel bank1 disasm

This commit is contained in:
xCrystal
2018-07-29 18:17:43 +02:00
parent 5621850eb4
commit 00f7e80381
7 changed files with 644 additions and 258 deletions
+129 -129
View File
@@ -8,12 +8,12 @@
const DOUBLE_COLORLESS_ENERGY ; $07
const BULBASAUR ; $08
const IVYSAUR ; $09
const VENUSAUR1 ; $0A
const VENUSAUR2 ; $0B
const CATERPIE ; $0C
const METAPOD ; $0D
const BUTTERFREE ; $0E
const WEEDLE ; $0F
const VENUSAUR1 ; $0a
const VENUSAUR2 ; $0b
const CATERPIE ; $0c
const METAPOD ; $0d
const BUTTERFREE ; $0e
const WEEDLE ; $0f
const KAKUNA ; $10
const BEEDRILL ; $11
const EKANS ; $12
@@ -24,12 +24,12 @@
const NIDORANM ; $17
const NIDORINO ; $18
const NIDOKING ; $19
const ZUBAT ; $1A
const GOLBAT ; $1B
const ODDISH ; $1C
const GLOOM ; $1D
const VILEPLUME ; $1E
const PARAS ; $1F
const ZUBAT ; $1a
const GOLBAT ; $1b
const ODDISH ; $1c
const GLOOM ; $1d
const VILEPLUME ; $1e
const PARAS ; $1f
const PARASECT ; $20
const VENONAT ; $21
const VENOMOTH ; $22
@@ -40,12 +40,12 @@
const MUK ; $27
const EXEGGCUTE ; $28
const EXEGGUTOR ; $29
const KOFFING ; $2A
const WEEZING ; $2B
const TANGELA1 ; $2C
const TANGELA2 ; $2D
const SCYTHER ; $2E
const PINSIR ; $2F
const KOFFING ; $2a
const WEEZING ; $2b
const TANGELA1 ; $2c
const TANGELA2 ; $2d
const SCYTHER ; $2e
const PINSIR ; $2f
const CHARMANDER ; $30
const CHARMELEON ; $31
const CHARIZARD ; $32
@@ -56,12 +56,12 @@
const ARCANINE1 ; $37
const ARCANINE2 ; $38
const PONYTA ; $39
const RAPIDASH ; $3A
const MAGMAR1 ; $3B
const MAGMAR2 ; $3C
const FLAREON1 ; $3D
const FLAREON2 ; $3E
const MOLTRES1 ; $3F
const RAPIDASH ; $3a
const MAGMAR1 ; $3b
const MAGMAR2 ; $3c
const FLAREON1 ; $3d
const FLAREON2 ; $3e
const MOLTRES1 ; $3f
const MOLTRES2 ; $40
const SQUIRTLE ; $41
const WARTORTLE ; $42
@@ -72,12 +72,12 @@
const POLIWHIRL ; $47
const POLIWRATH ; $48
const TENTACOOL ; $49
const TENTACRUEL ; $4A
const SEEL ; $4B
const DEWGONG ; $4C
const SHELLDER ; $4D
const CLOYSTER ; $4E
const KRABBY ; $4F
const TENTACRUEL ; $4a
const SEEL ; $4b
const DEWGONG ; $4c
const SHELLDER ; $4d
const CLOYSTER ; $4e
const KRABBY ; $4f
const KINGLER ; $50
const HORSEA ; $51
const SEADRA ; $52
@@ -88,12 +88,12 @@
const MAGIKARP ; $57
const GYARADOS ; $58
const LAPRAS ; $59
const VAPOREON1 ; $5A
const VAPOREON2 ; $5B
const OMANYTE ; $5C
const OMASTAR ; $5D
const ARTICUNO1 ; $5E
const ARTICUNO2 ; $5F
const VAPOREON1 ; $5a
const VAPOREON2 ; $5b
const OMANYTE ; $5c
const OMASTAR ; $5d
const ARTICUNO1 ; $5e
const ARTICUNO2 ; $5f
const PIKACHU1 ; $60
const PIKACHU2 ; $61
const PIKACHU3 ; $62
@@ -104,12 +104,12 @@
const RAICHU1 ; $67
const RAICHU2 ; $68
const MAGNEMITE1 ; $69
const MAGNEMITE2 ; $6A
const MAGNETON1 ; $6B
const MAGNETON2 ; $6C
const VOLTORB ; $6D
const ELECTRODE1 ; $6E
const ELECTRODE2 ; $6F
const MAGNEMITE2 ; $6a
const MAGNETON1 ; $6b
const MAGNETON2 ; $6c
const VOLTORB ; $6d
const ELECTRODE1 ; $6e
const ELECTRODE2 ; $6f
const ELECTABUZZ1 ; $70
const ELECTABUZZ2 ; $71
const JOLTEON1 ; $72
@@ -120,12 +120,12 @@
const SANDSHREW ; $77
const SANDSLASH ; $78
const DIGLETT ; $79
const DUGTRIO ; $7A
const MANKEY ; $7B
const PRIMEAPE ; $7C
const MACHOP ; $7D
const MACHOKE ; $7E
const MACHAMP ; $7F
const DUGTRIO ; $7a
const MANKEY ; $7b
const PRIMEAPE ; $7c
const MACHOP ; $7d
const MACHOKE ; $7e
const MACHAMP ; $7f
const GEODUDE ; $80
const GRAVELER ; $81
const GOLEM ; $82
@@ -136,12 +136,12 @@
const HITMONLEE ; $87
const HITMONCHAN ; $88
const RHYHORN ; $89
const RHYDON ; $8A
const KABUTO ; $8B
const KABUTOPS ; $8C
const AERODACTYL ; $8D
const ABRA ; $8E
const KADABRA ; $8F
const RHYDON ; $8a
const KABUTO ; $8b
const KABUTOPS ; $8c
const AERODACTYL ; $8d
const ABRA ; $8e
const KADABRA ; $8f
const ALAKAZAM ; $90
const SLOWPOKE1 ; $91
const SLOWPOKE2 ; $92
@@ -152,79 +152,79 @@
const HAUNTER2 ; $97
const GENGAR ; $98
const DROWZEE ; $99
const HYPNO ; $9A
const MR_MIME ; $9B
const JYNX ; $9C
const MEWTWO1 ; $9D
const MEWTWO2 ; $9E
const MEWTWO3 ; $9F
const MEW1 ; $A0
const MEW2 ; $A1
const MEW3 ; $A2
const PIDGEY ; $A3
const PIDGEOTTO ; $A4
const PIDGEOT1 ; $A5
const PIDGEOT2 ; $A6
const RATTATA ; $A7
const RATICATE ; $A8
const SPEAROW ; $A9
const FEAROW ; $AA
const CLEFAIRY ; $AB
const CLEFABLE ; $AC
const JIGGLYPUFF1 ; $AD
const JIGGLYPUFF2 ; $AE
const JIGGLYPUFF3 ; $AF
const WIGGLYTUFF ; $B0
const MEOWTH1 ; $B1
const MEOWTH2 ; $B2
const PERSIAN ; $B3
const FARFETCHD ; $B4
const DODUO ; $B5
const DODRIO ; $B6
const LICKITUNG ; $B7
const CHANSEY ; $B8
const KANGASKHAN ; $B9
const TAUROS ; $BA
const DITTO ; $BB
const EEVEE ; $BC
const PORYGON ; $BD
const SNORLAX ; $BE
const DRATINI ; $BF
const DRAGONAIR ; $C0
const DRAGONITE1 ; $C1
const DRAGONITE2 ; $C2
const PROFESSOR_OAK ; $C3
const IMPOSTER_PROFESSOR_OAK ; $C4
const BILL ; $C5
const MR_FUJI ; $C6
const LASS ; $C7
const IMAKUNI_CARD ; $C8
const POKEMON_TRADER ; $C9
const POKEMON_BREEDER ; $CA
const CLEFAIRY_DOLL ; $CB
const MYSTERIOUS_FOSSIL ; $CC
const ENERGY_RETRIEVAL ; $CD
const SUPER_ENERGY_RETRIEVAL ; $CE
const ENERGY_SEARCH ; $CF
const ENERGY_REMOVAL ; $D0
const SUPER_ENERGY_REMOVAL ; $D1
const SWITCH ; $D2
const POKEMON_CENTER ; $D3
const POKE_BALL ; $D4
const SCOOP_UP ; $D5
const COMPUTER_SEARCH ; $D6
const POKEDEX ; $D7
const PLUSPOWER ; $D8
const DEFENDER ; $D9
const ITEM_FINDER ; $DA
const GUST_OF_WIND ; $DB
const DEVOLUTION_SPRAY ; $DC
const POTION ; $DD
const SUPER_POTION ; $DE
const FULL_HEAL ; $DF
const REVIVE ; $E0
const MAINTENANCE ; $E1
const POKEMON_FLUTE ; $E2
const GAMBLER ; $E3
const RECYCLE ; $E4
const HYPNO ; $9a
const MR_MIME ; $9b
const JYNX ; $9c
const MEWTWO1 ; $9d
const MEWTWO2 ; $9e
const MEWTWO3 ; $9f
const MEW1 ; $a0
const MEW2 ; $a1
const MEW3 ; $a2
const PIDGEY ; $a3
const PIDGEOTTO ; $a4
const PIDGEOT1 ; $a5
const PIDGEOT2 ; $a6
const RATTATA ; $a7
const RATICATE ; $a8
const SPEAROW ; $a9
const FEAROW ; $aa
const CLEFAIRY ; $ab
const CLEFABLE ; $ac
const JIGGLYPUFF1 ; $ad
const JIGGLYPUFF2 ; $ae
const JIGGLYPUFF3 ; $af
const WIGGLYTUFF ; $b0
const MEOWTH1 ; $b1
const MEOWTH2 ; $b2
const PERSIAN ; $b3
const FARFETCHD ; $b4
const DODUO ; $b5
const DODRIO ; $b6
const LICKITUNG ; $b7
const CHANSEY ; $b8
const KANGASKHAN ; $b9
const TAUROS ; $ba
const DITTO ; $bb
const EEVEE ; $bc
const PORYGON ; $bd
const SNORLAX ; $be
const DRATINI ; $bf
const DRAGONAIR ; $c0
const DRAGONITE1 ; $c1
const DRAGONITE2 ; $c2
const PROFESSOR_OAK ; $c3
const IMPOSTER_PROFESSOR_OAK ; $c4
const BILL ; $c5
const MR_FUJI ; $c6
const LASS ; $c7
const IMAKUNI_CARD ; $c8
const POKEMON_TRADER ; $c9
const POKEMON_BREEDER ; $ca
const CLEFAIRY_DOLL ; $cb
const MYSTERIOUS_FOSSIL ; $cc
const ENERGY_RETRIEVAL ; $cd
const SUPER_ENERGY_RETRIEVAL ; $ce
const ENERGY_SEARCH ; $cf
const ENERGY_REMOVAL ; $d0
const SUPER_ENERGY_REMOVAL ; $d1
const SWITCH ; $d2
const POKEMON_CENTER ; $d3
const POKE_BALL ; $d4
const SCOOP_UP ; $d5
const COMPUTER_SEARCH ; $d6
const POKEDEX ; $d7
const PLUSPOWER ; $d8
const DEFENDER ; $d9
const ITEM_FINDER ; $da
const GUST_OF_WIND ; $db
const DEVOLUTION_SPRAY ; $dc
const POTION ; $dd
const SUPER_POTION ; $de
const FULL_HEAL ; $df
const REVIVE ; $e0
const MAINTENANCE ; $e1
const POKEMON_FLUTE ; $e2
const GAMBLER ; $e3
const RECYCLE ; $e4
NUM_CARDS EQU const_value + -1
+1
View File
@@ -33,6 +33,7 @@ DUEL_LOSS EQU $1
; wPlayerDuelVariables or wOpponentDuelVariables constants
DUELVARS_CARD_LOCATIONS EQUS "LOW(wPlayerCardLocations)" ; 00
DUELVARS_PRIZE_CARDS EQUS "LOW(wPlayerPrizeCards)" ; 3c
DUELVARS_HAND EQUS "LOW(wPlayerHand)" ; 42
DUELVARS_DECK_CARDS EQUS "LOW(wPlayerDeckCards)" ; 7e
DUELVARS_NUMBER_OF_CARDS_NOT_IN_DECK EQUS "LOW(wPlayerNumberOfCardsNotInDeck)" ; ba
+476 -105
View File
@@ -87,8 +87,8 @@ HandleFailedToContinueDuel: ; 4097 (1:4097)
ret
; 0x409f
; this function begins the duel after the opponent's
; graphics, name and deck have been introduced
; this function begins the duel after the opponent's graphics, name and deck have been introduced
; loads both player's decks and sets up the variables and resources required to begin a duel.
StartDuel: ; 409f (1:409f)
ld a, PLAYER_TURN
ldh [hWhoseTurn], a
@@ -122,7 +122,7 @@ StartDuel: ; 409f (1:409f)
call SetupDuel
ld a, [wcc18]
ld [wDuelInitialPrizes], a
call Func_70aa
call InitVariablesToBeginDuel
ld a, [wDuelTheme]
call PlaySong
call Func_4b60
@@ -134,7 +134,7 @@ MainDuelLoop ; 40ee (1:40ee)
xor a
ld [wCurrentDuelMenuItem], a
call UpdateSubstatusConditions_StartOfTurn
call DisplayDuelistsTurnScreen
call DisplayDuelistTurnScreen
call HandleTurn
.between_turns
@@ -182,8 +182,8 @@ MainDuelLoop ; 40ee (1:40ee)
push af
ld a, PLAYER_TURN
ldh [hWhoseTurn], a
call Func_4a97
call Func_4ad6
call DrawDuelistPortraitsAndNames
call PrintDuelResultStats
pop af
ldh [hWhoseTurn], a
call Func_3b21
@@ -253,7 +253,7 @@ MainDuelLoop ; 40ee (1:40ee)
call DrawWideTextBox_WaitForInput
ld a, 1
ld [wDuelInitialPrizes], a
call Func_70aa
call InitVariablesToBeginDuel
ld a, [wDuelType]
cp DUELTYPE_LINK
jr z, .link_duel
@@ -261,7 +261,6 @@ MainDuelLoop ; 40ee (1:40ee)
ldh [hWhoseTurn], a
call Func_4b60
jp MainDuelLoop
.link_duel
call ExchangeRNG
ld h, PLAYER_TURN
@@ -269,7 +268,6 @@ MainDuelLoop ; 40ee (1:40ee)
cp $29
jr z, .got_turn
ld h, OPPONENT_TURN
.got_turn
ld a, h
ldh [hWhoseTurn], a
@@ -292,7 +290,9 @@ SetupDuel: ; 420b (1:420b)
ret
; 0x4225
; handle the turn of the duelist identified by hWhoseTurn
; handle the turn of the duelist identified by hWhoseTurn.
; if player's turn, display the animation of the player drawing the card at
; hTempCardIndex_ff98, and save the duel state to SRAM.
HandleTurn: ; 4225 (1:4225)
ld a, DUELVARS_DUELIST_TYPE
call GetTurnDuelistVariable
@@ -301,7 +301,6 @@ HandleTurn: ; 4225 (1:4225)
cp 2
jr c, .skip_let_evolve ; jump if it's the turn holder's first turn
call SetAllPlayAreaPokemonCanEvolve
.skip_let_evolve
call Func_70e6
call Func_4933
@@ -316,17 +315,17 @@ HandleTurn: ; 4225 (1:4225)
call AddCardToHand
ld a, [wDuelistType]
cp DUELIST_TYPE_PLAYER
jr z, HandleTurn_PlayerDrewCard
jr z, .player_turn
; opponent's turn
call SwapTurn
call IsClairvoyanceActive
call SwapTurn
call c, DisplayPlayerDrawCardScreen
jr DuelMainInterface
; display the animation of the player drawing the card at hTempCardIndex_ff98,
; save duel state to SRAM, and fall through to DuelMainInterface
; to effectively begin the turn
HandleTurn_PlayerDrewCard:
; player's turn
.player_turn
call DisplayPlayerDrawCardScreen
call SaveDuelStateToSRAM
; fallthrough
@@ -1439,7 +1438,7 @@ Func_4933: ; 4933 (1:4933)
cp $09
jr z, .asm_495f
call EmptyScreen
call Func_4a97
call DrawDuelistPortraitsAndNames
.asm_495f
ld a, $07
ld [wcac2], a
@@ -1560,8 +1559,11 @@ Func_49ed: ; 49ed (1:49ed)
INCROM $4a35, $4a97
Func_4a97: ; 4a97 (1:4a97)
; draw the portraits of the two duelists and print their names.
; also draw an horizontal line separating the two sides.
DrawDuelistPortraitsAndNames: ; 4a97 (1:4a97)
call LoadSymbolsFont
; player's name
ld de, wDefaultText
push de
call CopyPlayerName
@@ -1569,8 +1571,10 @@ Func_4a97: ; 4a97 (1:4a97)
call InitTextPrinting
pop hl
call ProcessText
ld bc, $5
; player's portrait
lb bc, 0, 5
call Func_3e10
; opponent's name (aligned to the right)
ld de, wDefaultText
push de
call CopyOpponentName
@@ -1583,45 +1587,52 @@ Func_4a97: ; 4a97 (1:4a97)
call InitTextPrinting
pop hl
call ProcessText
; opponent's portrait
ld a, [wOpponentPortrait]
ld bc, $d01
lb bc, 13, 1
call Func_3e2a
; middle line
call DrawDuelHorizontalSeparator
ret
; 0x4ad6
Func_4ad6: ; 4ad6 (1:4ad6)
; print the number of prizes left, of active Pokemon, and of cards left in the deck
; of both duelists. this is called when the duel ends.
PrintDuelResultStats: ; 4ad6 (1:4ad6)
lb de, 8, 8
call Func_4ae9
call PrintDuelistResultStats
call SwapTurn
lb de, 1, 1
call Func_4ae9
call PrintDuelistResultStats
call SwapTurn
ret
; 0x4ae9
Func_4ae9: ; 4ae9 (1:4ae9)
call $5f4a
ld hl, $7b
; print, at d,e, the number of prizes left, of active Pokemon, and of cards left in
; the deck of the turn duelist. b,c are used throughout as input coords for
; WriteTwoDigitNumberInTxSymbolFormat, and d,e for InitTextPrinting_ProcessTextFromID.
PrintDuelistResultStats: ; 4ae9 (1:4ae9)
call SetNoLineSeparation
ldtx hl, PrizesLeftActivePokemonCardsInDeckText
call InitTextPrinting_ProcessTextFromID
call $5f50
call SetOneLineSeparation
ld c, e
ld a, d
add $07
add 7
ld b, a
inc a
inc a
ld d, a
call CountPrizes
call .asm_4b22
call .print_x_cards
inc e
inc c
ld a, DUELVARS_NUMBER_OF_POKEMON_IN_PLAY_AREA
call GetTurnDuelistVariable
ld hl, $7d
ldtx hl, YesText
or a
jr nz, .pkmn_in_play_area
ld hl, $7c
ldtx hl, NoneText
.pkmn_in_play_area
dec d
call InitTextPrinting_ProcessTextFromID
@@ -1632,9 +1643,9 @@ Func_4ae9: ; 4ae9 (1:4ae9)
call GetTurnDuelistVariable
ld a, DECK_SIZE
sub [hl]
.asm_4b22
.print_x_cards
call WriteTwoDigitNumberInTxSymbolFormat
ld hl, $7e
ldtx hl, CardsText
call InitTextPrinting_ProcessTextFromID
ret
; 0x4b2c
@@ -1673,59 +1684,61 @@ Func_4b38: ; 4b38 (1:4b38)
; 0x4b60
Func_4b60: ; 4b60 (1:4b60)
call $7107
call InitializeDuelVariables
call SwapTurn
call $7107
call InitializeDuelVariables
call SwapTurn
call $4e84
call $4d97
call Func_4e84
call ShuffleDeckAndDrawSevenCards
ldh [hTemp_ffa0], a
call SwapTurn
call $4d97
call ShuffleDeckAndDrawSevenCards
call SwapTurn
ld c, a
ldh a, [hTemp_ffa0]
ld b, a
and c
jr nz, .asm_4bd0
jr nz, .hand_cards_ok
ld a, b
or c
jr z, .asm_4bb2
jr z, .neither_drew_basic_pkmn
ld a, b
or a
jr nz, .asm_4b9c
.asm_4b8c
call $4df3
call $7107
call $4e6e
call $4d97
jr c, .asm_4b8c
jr .asm_4bd0
jr nz, .opp_drew_no_basic_pkmn
.asm_4b9c
call SwapTurn
.asm_4b9f
call $4df3
call $7107
call $4e6e
call $4d97
jr c, .asm_4b9f
call SwapTurn
jr .asm_4bd0
;.player_drew_no_basic_pkmn
.ensure_player_basic_pkmn_loop
call DisplayNoBasicPokemonInHandScreenAndText
call InitializeDuelVariables
call Func_4e6e
call ShuffleDeckAndDrawSevenCards
jr c, .ensure_player_basic_pkmn_loop
jr .hand_cards_ok
.asm_4bb2
.opp_drew_no_basic_pkmn
call SwapTurn
.ensure_opp_basic_pkmn_loop
call DisplayNoBasicPokemonInHandScreenAndText
call InitializeDuelVariables
call Func_4e6e
call ShuffleDeckAndDrawSevenCards
jr c, .ensure_opp_basic_pkmn_loop
call SwapTurn
jr .hand_cards_ok
.neither_drew_basic_pkmn
ldtx hl, NeitherPlayerHasBasicPkmnText
call DrawWideTextBox_WaitForInput
call $4e06
call $7107
call DisplayNoBasicPokemonInHandScreen
call InitializeDuelVariables
call SwapTurn
call $4e06
call $7107
call DisplayNoBasicPokemonInHandScreen
call InitializeDuelVariables
call SwapTurn
call $4dfc
call PrintReturnCardsToDeckDrawAgain
jp Func_4b60
.asm_4bd0
.hand_cards_ok
ldh a, [hWhoseTurn]
push af
ld a, PLAYER_TURN
@@ -1734,7 +1747,7 @@ Func_4b60: ; 4b60 (1:4b60)
call SwapTurn
call Func_4cd5
call SwapTurn
jp c, $4c77
jp c, .asm_4c77
call Func_311d
ldtx hl, PlacingThePrizesText
call DrawWideTextBox_WaitForInput
@@ -1746,13 +1759,13 @@ Func_4b60: ; 4b60 (1:4b60)
ldtx hl, PleasePlacePrizesText
call DrawWideTextBox_PrintText
call EnableLCD
call $4c7c
call .asm_4c7c
call WaitForWideTextBoxInput
pop af
ldh [hWhoseTurn], a
call $7133
call InitTurnDuelistPrizes
call SwapTurn
call $7133
call InitTurnDuelistPrizes
call SwapTurn
call EmptyScreen
ld a, BOXMSG_COIN_TOSS
@@ -1772,7 +1785,6 @@ Func_4b60: ; 4b60 (1:4b60)
jr c, .asm_4c4a
call SwapTurn
ldtx hl, YouPlaySecondText
.asm_4c4a
call DrawWideTextBox_WaitForInput
call ExchangeRNG
@@ -1790,24 +1802,75 @@ Func_4b60: ; 4b60 (1:4b60)
jr c, .asm_4c6f
call SwapTurn
ldtx hl, YouPlayFirstText
.asm_4c6f
call DrawWideTextBox_WaitForInput
call ExchangeRNG
or a
ret
; 0x4c77
INCROM $4c77, $4cd5
.asm_4c77
pop af
ldh [hWhoseTurn], a
scf
ret
.asm_4c7c
ld hl, .data_4cbd
ld e, $34
ld a, [wDuelInitialPrizes]
ld d, a
.asm_4c85
push de
ld b, $14
.asm_4c88
call DoFrame
call Func_67b2
jr c, .asm_4c93
dec b
jr nz, .asm_4c88
.asm_4c93
call .asm_4cb4
call .asm_4cb4
push hl
ld a, $08
call PlaySFX
lb bc, 3, 5
ld a, e
call WriteTwoDigitNumberInTxSymbolFormat
lb bc, 18, 7
ld a, e
call WriteTwoDigitNumberInTxSymbolFormat
pop hl
pop de
dec e
dec d
jr nz, .asm_4c85
ret
.asm_4cb4
ld b, [hl]
inc hl
ld c, [hl]
inc hl
ld a, $ac
jp WriteByteToBGMap0
.data_4cbd
db $05, $06, $0e, $05
db $06, $06, $0d, $05
db $05, $07, $0e, $04
db $06, $07, $0d, $04
db $05, $08, $0e, $03
db $06, $08, $0d, $03
; 0x4cd5
; Select Basic Pokemon From Hand
Func_4cd5: ; 4cd5 (1:4cd5)
ld a, DUELVARS_DUELIST_TYPE
call GetTurnDuelistVariable
cp DUELIST_TYPE_PLAYER
jr z, .asm_4d15
jr z, .player_choose_arena
cp DUELIST_TYPE_LINK_OPP
jr z, .asm_4cec
jr z, .exchange_duelvars
push af
push hl
call Func_2bc3
@@ -1817,28 +1880,27 @@ Func_4cd5: ; 4cd5 (1:4cd5)
or a
ret
.asm_4cec
.exchange_duelvars
ldtx hl, TransmitingDataText
call DrawWideTextBox_PrintText
call ExchangeRNG
ld hl, wPlayerCardLocations
ld de, wOpponentCardLocations
ld c, $80
ld hl, wPlayerDuelVariables
ld de, wOpponentDuelVariables
ld c, (wOpponentDuelVariables - wPlayerDuelVariables) / 2
call SerialExchangeBytes
jr c, .asm_4d12
ld c, $80
jr c, .error
ld c, (wOpponentDuelVariables - wPlayerDuelVariables) / 2
call SerialExchangeBytes
jr c, .asm_4d12
jr c, .error
ld a, DUELVARS_DUELIST_TYPE
call GetTurnDuelistVariable
ld [hl], DUELIST_TYPE_LINK_OPP
or a
ret
.asm_4d12
.error
jp DuelTransmissionError
.asm_4d15
.player_choose_arena
call EmptyScreen
ld a, BOXMSG_ARENA_POKEMON
call DrawDuelBoxMessage
@@ -1848,8 +1910,8 @@ Func_4cd5: ; 4cd5 (1:4cd5)
call DoPracticeDuelAction
.asm_4d28
xor a
ld hl, $006e
call $5502
ldtx hl, PleaseChooseAnActivePokemonText
call Func_5502
jr c, .asm_4d28
ldh a, [hTempCardIndex_ff98]
call LoadCardDataToBuffer1_FromDeckIndex
@@ -1861,9 +1923,9 @@ Func_4cd5: ; 4cd5 (1:4cd5)
ldh a, [hTempCardIndex_ff98]
ldtx hl, PlacedInTheArenaText
call DisplayCardDetailScreen
jr .asm_4d4c
jr .choose_bench
.asm_4d4c
.choose_bench
call EmptyScreen
ld a, BOXMSG_BENCH_POKEMON
call DrawDuelBoxMessage
@@ -1871,15 +1933,15 @@ Func_4cd5: ; 4cd5 (1:4cd5)
call PrintScrollableText_NoTextBoxLabel
ld a, $3
call DoPracticeDuelAction
.asm_4d5f
.bench_loop
ld a, $1
ld hl, $006f
call $5502
ldtx hl, ChooseYourBenchPokemonText
call Func_5502
jr c, .asm_4d8e
ld a, DUELVARS_NUMBER_OF_POKEMON_IN_PLAY_AREA
call GetTurnDuelistVariable
cp MAX_PLAY_AREA_POKEMON
jr nc, .asm_4d86
jr nc, .no_space
ldh a, [hTempCardIndex_ff98]
call PutHandPokemonCardInPlayArea
ldh a, [hTempCardIndex_ff98]
@@ -1887,22 +1949,131 @@ Func_4cd5: ; 4cd5 (1:4cd5)
call DisplayCardDetailScreen
ld a, $5
call DoPracticeDuelAction
jr .asm_4d5f
jr .bench_loop
.asm_4d86
.no_space
ldtx hl, NoSpaceOnTheBenchText
call DrawWideTextBox_WaitForInput
jr .asm_4d5f
jr .bench_loop
.asm_4d8e
ld a, $4
call DoPracticeDuelAction
jr c, .asm_4d5f
jr c, .bench_loop
or a
ret
; 0x4d97
INCROM $4d97, $4e40
; the turn duelist shuffles the deck unless it's a practice duel, then draws 7 cards
; returns $00 in a and carry if no basic Pokemon cards are drawn, and $01 in a otherwise
ShuffleDeckAndDrawSevenCards: ; 4d97 (1:4d97)
call InitializeDuelVariables
ld a, [wDuelType]
cp DUELTYPE_PRACTICE
jr z, .deck_ready
call ShuffleDeck
call ShuffleDeck
.deck_ready
ld b, 7
.draw_loop
call DrawCardFromDeck
call AddCardToHand
dec b
jr nz, .draw_loop
ld a, DUELVARS_HAND
call GetTurnDuelistVariable
ld b, $00
ld c, 7
.cards_loop
ld a, [hli]
push hl
push bc
call LoadCardDataToBuffer1_FromDeckIndex
call .check_basic_pokemon
pop bc
pop hl
or b
ld b, a
dec c
jr nz, .cards_loop
ld a, b
or a
ret nz
xor a
scf
ret
.asm_4dd1
ld a, [wLoadedCard1ID]
cp MYSTERIOUS_FOSSIL
jr z, .basic
cp CLEFAIRY_DOLL
jr z, .basic
.check_basic_pokemon
ld a, [wLoadedCard1Type]
cp TYPE_ENERGY
jr nc, .energy_trainer_nonbasic
ld a, [wLoadedCard1Stage]
or a
jr nz, .energy_trainer_nonbasic
; basic
ld a, $01
ret
.energy_trainer_nonbasic
xor a
scf
ret
.basic
ld a, $01
or a
ret
; 0x4df3
DisplayNoBasicPokemonInHandScreenAndText: ; 4df3 (1:4df3)
ldtx hl, ThereAreNoBasicPokemonInHand
call DrawWideTextBox_WaitForInput
call DisplayNoBasicPokemonInHandScreen
; fallthrough
; prints ReturnCardsToDeckAndDrawAgainText in a textbox and calls ExchangeRNG
PrintReturnCardsToDeckDrawAgain: ; 4dfc (1:4dfc)
ldtx hl, ReturnCardsToDeckAndDrawAgainText
call DrawWideTextBox_WaitForInput
call ExchangeRNG
ret
; 0x4e06
; display a bare list of seven hand cards of the turn duelist, and the duelist's name above
; used to let the player know that there are no basic Pokemon in the hand and need to redraw
DisplayNoBasicPokemonInHandScreen: ; 4e06 (1:4e06)
call EmptyScreen
call LoadDuelCardSymbolTiles
lb de, 0, 0
lb bc, 20, 18
call DrawRegularTextBox
call CreateHandCardList
call CountCardsInDuelTempList
ld hl, NoBasicPokemonCardListParameters
lb de, 0, 0
call PrintCardListItems
ldtx hl, DuelistHandText
lb de, 1, 1
call InitTextPrinting
call PrintTextNoDelay
call EnableLCD
call WaitForWideTextBoxInput
ret
; 0x4e37
NoBasicPokemonCardListParameters:
db 1, 3 ; cursor x, cursor y
db 4 ; item x
db 14 ; maximum length, in tiles, occupied by the name and level string of each card in the list
db 7 ; number of items selectable without scrolling
db SYM_CURSOR_R ; cursor tile number
db SYM_SPACE ; tile behind cursor
dw $0000 ; function pointer if non-0
Func_4e40: ; 4e40 (1:4e40)
call CreateHandCardList
@@ -1923,7 +2094,108 @@ Func_4e40: ; 4e40 (1:4e40)
ret
; 0x4e6e
INCROM $4e6e, $4f2d
Func_4e6e: ; 4e6e (1:4e6e)
ld b, $51
ld c, $56
ldh a, [hWhoseTurn]
cp PLAYER_TURN
jr z, .asm_4e7c
ld b, $52
ld c, $57
.asm_4e7c
ld hl, $63
ld de, $67
jr Func_4e98
Func_4e84: ; 4e84 (1:4e84)
ld b, $53
ld c, $55
ld hl, $65
ld de, $66
ld a, [wDuelType]
cp DUELTYPE_PRACTICE
jr nz, Func_4e98
ld hl, $64
; fallthrough
Func_4e98: ; 4e98 (1:4e98)
push bc
push de
push hl
call ZeroObjectPositionsAndToggleOAMCopy
call EmptyScreen
call DrawDuelistPortraitsAndNames
call LoadDuelDrawCardsScreenTiles
ld a, $09
ld [wcac2], a
pop hl
call DrawWideTextBox_PrintText
call EnableLCD
ld a, [wDuelType]
cp DUELTYPE_PRACTICE
jr nz, .asm_4ebf
call WaitForWideTextBoxInput
jr .asm_4ee0
.asm_4ebf
call Func_3b21
ld hl, sp+$03
ld a, [hl]
call Func_3b6a
ld a, [hl]
call Func_3b6a
ld a, [hl]
call Func_3b6a
.asm_4ed0
call DoFrame
call Func_67b2
jr c, .asm_4edd
call Func_3b52
jr c, .asm_4ed0
.asm_4edd
call Func_3b31
.asm_4ee0
xor a
ld [wcbe9], a
call Func_49ca
call Func_3b21
pop hl
call DrawWideTextBox_PrintText
.asm_4eee
ld hl, sp+$00
ld a, [hl]
call Func_3b6a
.asm_4ef4
call DoFrame
call Func_67b2
jr c, .asm_4f28
call Func_3b52
jr c, .asm_4ef4
ld hl, wcbe9
inc [hl]
ld hl, sp+$00
ld a, [hl]
cp $55
jr nz, .asm_4f11
call Func_49ca.not_cgb
jr .asm_4f14
.asm_4f11
call Func_49ed
.asm_4f14
ld a, [wcbe9]
cp $07
jr c, .asm_4eee
ld c, $1e
.asm_4f1d
call DoFrame
call Func_67b2
jr c, .asm_4f28
dec c
jr nz, .asm_4f1d
.asm_4f28
call Func_3b31
pop bc
ret
; 0x4f2d
Func_4f2d: ; 4f2d (1:4f2d)
ld a, [wcac2]
@@ -1931,7 +2203,7 @@ Func_4f2d: ; 4f2d (1:4f2d)
jr z, .asm_4f3d
call ZeroObjectPositionsAndToggleOAMCopy
call EmptyScreen
call Func_4a97
call DrawDuelistPortraitsAndNames
.asm_4f3d
ld a, $09
ld [wcac2], a
@@ -2418,7 +2690,7 @@ Func_52bc: ; 52bc (1:52bc)
; display BOXMSG_PLAYERS_TURN or BOXMSG_OPPONENTS_TURN and print
; DuelistsTurnText in a textbox. also call ExchangeRNG.
DisplayDuelistsTurnScreen: ; 54c8 (1:54c8)
DisplayDuelistTurnScreen: ; 54c8 (1:54c8)
call EmptyScreen
ld c, BOXMSG_PLAYERS_TURN
ldh a, [hWhoseTurn]
@@ -2450,7 +2722,49 @@ DuelMenuData: ; 54e9 (1:54e9)
db $ff
; 0x5502
INCROM $5502, $5550
Func_5502: ; 5502 (1:5502)
ld [wcbfd], a
push hl
call CreateHandCardList
call DrawCardListScreenLayout
pop hl
call SetCardListInfoBoxText
ld a, $01
ld [wcbde], a
.asm_5515
call Func_55f0
jr nc, .asm_5523
ld a, [wcbfd]
or a
jr z, .asm_5515
scf
jr .asm_5538
.asm_5523
ldh a, [hTempCardIndex_ff98]
call LoadCardDataToBuffer1_FromDeckIndex
call Func_4dd1
jr nc, .asm_5538
ldtx hl, YouCannotSelectThisCardText
call DrawWideTextBox_WaitForInput
call DrawCardListScreenLayout.draw
jr .asm_5515
.asm_5538
push af
ld a, [wSortCardListByID]
or a
call nz, SortHandCardsByID
pop af
ret
; 0x5542
Func_5542: ; 5542 (1:5542)
call CreateDiscardPileCardList
ret c
call DrawCardListScreenLayout
call SetDiscardPileScreenTexts
call Func_55f0
ret
; 0x5550
; draw the turn holder's discard pile screen
OpenDiscardPileScreen: ; 5550 (1:5550)
@@ -5202,7 +5516,9 @@ PrintThereWasNoEffectFromStatusText: ; 700a (1:700a)
INCROM $7045, $70aa
Func_70aa: ; 70aa (1:70aa)
; initializes variables when a duel begins, such as zeroing wDuelFinished or wDuelTurns,
; and setting wDuelType based on wPlayerDuelistType and wOpponentDuelistType
InitVariablesToBeginDuel: ; 70aa (1:70aa)
xor a
ld [wDuelFinished], a
ld [wDuelTurns], a
@@ -5298,7 +5614,62 @@ InitializeDuelVariables: ; 7107 (1:7107)
ret
; 0x7133
INCROM $7133, $717a
; draw [wDuelInitialPrizes] cards from the turn holder's deck and place them as prizes:
; write their deck indexes to DUELVARS_PRIZE_CARDS, set their location to
; CARD_LOCATION_PRIZE, and set [wDuelInitialPrizes] bits of DUELVARS_PRIZES.
InitTurnDuelistPrizes: ; 7133 (1:7133)
ldh a, [hWhoseTurn]
ld d, a
ld e, DUELVARS_PRIZE_CARDS
ld a, [wDuelInitialPrizes]
ld c, a
ld b, 0
.draw_prizes_loop
call DrawCardFromDeck
ld [de], a
inc de
ld h, d
ld l, a
ld [hl], CARD_LOCATION_PRIZE
inc b
ld a, b
cp c
jr nz, .draw_prizes_loop
push hl
ld e, c
ld d, $00
ld hl, PrizeBitmasks
add hl, de
ld a, [hl]
pop hl
ld l, DUELVARS_PRIZES
ld [hl], a
ret
; 0x715a
PrizeBitmasks: ; 715a (1:715a)
db %0, %1, %11, %111, %1111, %11111, %111111
; 0x7161
Func_7161: ; 7161 (1:7161)
or a
ret z
ld c, a
call CountPrizes
sub c
jr nc, .asm_716b
xor a
.asm_716b
ld c, a
ld b, $00
ld hl, PrizeBitmasks
add hl, bc
ld b, [hl]
ld a, DUELVARS_PRIZES
call GetTurnDuelistVariable
ld [hl], b
ret
; 0x717a
; clear the non-turn holder's duelvars starting at DUELVARS_ARENA_CARD_DISABLED_MOVE_INDEX
; these duelvars only last a two-player turn at most.
+12 -5
View File
@@ -7541,7 +7541,10 @@ DuelMenuCursorCoords: ; 278d (0:278d)
db 14, 16 ; Done
; print the items of a list of cards (hand cards in a duel, cards from a booster pack...)
; and initialize the parameters of the list
; and initialize the parameters of the list given:
; a = list length
; de = initial page scroll offset, initial item (in the visible page)
; hl: 9 bytes with the rest of the parameters
PrintCardListItems: ; 2799 (0:2799)
call InitializeCardListParameters
ld hl, wMenuFunctionPointer
@@ -11164,7 +11167,7 @@ Func_3b11: ; 3b11 (0:3b11)
Func_3b21: ; 3b21 (0:3b21)
ldh a, [hBankROM]
push af
ld a, $7
ld a, $07
call BankswitchROM
call $48bc
pop af
@@ -11174,9 +11177,9 @@ Func_3b21: ; 3b21 (0:3b21)
Func_3b31: ; 3b31 (0:3b31)
ldh a, [hBankROM]
push af
ld a, $7
ld a, BANK(Func_1cb18)
call BankswitchROM
call $4b18
call Func_1cb18
jr c, .asm_3b45
xor a
ld [wDoFrameFunction], a
@@ -11215,7 +11218,7 @@ Func_3b6a: ; 3b6a (0:3b6a)
push hl
push bc
push de
ld a, $7
ld a, $07
call BankswitchROM
ld a, [wd422]
cp $61
@@ -11711,10 +11714,13 @@ Func_3df3: ; 3df3 (0:3df3)
ret
; 0x3e10
; draws player's portrait at b,c
Func_3e10: ; 3e10 (0:3e10)
ld a, $1
ld [wd61e], a
ld a, $62
; fallthrough
Func_3e17: ; 3e17 (0:3e17)
ld [wd131], a
ldh a, [hBankROM]
@@ -11726,6 +11732,7 @@ Func_3e17: ; 3e17 (0:3e17)
call BankswitchROM
ret
; draws opponent's portrait given in a at b,c
Func_3e2a: ; 3e2a (0:3e2a)
ld [wd61e], a
ld a, $63
+9 -9
View File
@@ -462,7 +462,7 @@ ChooseBasicPkmnToPlaceInArenaText: ; 36bc2 (d:6bc2)
line "to place in the Arena."
done
Text006a: ; 36bf1 (d:6bf1)
ThereAreNoBasicPokemonInHand: ; 36bf1 (d:6bf1)
text "There are no Basic Pokémon"
line "in <RAMNAME>'s hand."
done
@@ -472,7 +472,7 @@ NeitherPlayerHasBasicPkmnText: ; 36c1a (d:6c1a)
line "Pokémon in his or her hand."
done
Text006c: ; 36c54 (d:6c54)
ReturnCardsToDeckAndDrawAgainText: ; 36c54 (d:6c54)
text "Return the cards to the Deck"
line "and draw again."
done
@@ -482,12 +482,12 @@ ChooseUpTo5BasicPkmnToPlaceOnBenchText: ; 36c82 (d:6c82)
line "to place on the Bench."
done
Text006e: ; 36cbf (d:6cbf)
PleaseChooseAnActivePokemonText: ; 36cbf (d:6cbf)
text "Please choose an"
line "Active Pokémon."
done
Text006f: ; 36ce1 (d:6ce1)
ChooseYourBenchPokemonText: ; 36ce1 (d:6ce1)
text "Choose your"
line "Bench Pokémon."
done
@@ -496,7 +496,7 @@ YouDrewText: ; 36cfd (d:6cfd)
text "You drew <RAMTEXT>."
done
Text0071: ; 36d0a (d:6d0a)
YouCannotSelectThisCardText: ; 36d0a (d:6d0a)
text "You cannot select this card."
done
@@ -543,21 +543,21 @@ StartSuddenDeathMatchText: ; 36e05 (d:6e05)
line "Match for 1 Prize!"
done
Text007b: ; 36e2e (d:6e2e)
PrizesLeftActivePokemonCardsInDeckText: ; 36e2e (d:6e2e)
text "Prizes Left"
line "Active Pokémon"
line "Cards in Deck"
done
Text007c: ; 36e58 (d:6e58)
NoneText: ; 36e58 (d:6e58)
text "None"
done
Text007d: ; 36e5e (d:6e5e)
YesText: ; 36e5e (d:6e5e)
text "Yes"
done
Text007e: ; 36e63 (d:6e63)
CardsText: ; 36e63 (d:6e63)
text "Cards"
done
+9 -9
View File
@@ -107,14 +107,14 @@ TextOffsets:: ; 34000 (d:4000)
textpointer Text0067 ; 0x0067
textpointer DeckHasXCardsText ; 0x0068
textpointer ChooseBasicPkmnToPlaceInArenaText ; 0x0069
textpointer Text006a ; 0x006a
textpointer ThereAreNoBasicPokemonInHand ; 0x006a
textpointer NeitherPlayerHasBasicPkmnText ; 0x006b
textpointer Text006c ; 0x006c
textpointer ReturnCardsToDeckAndDrawAgainText ; 0x006c
textpointer ChooseUpTo5BasicPkmnToPlaceOnBenchText ; 0x006d
textpointer Text006e ; 0x006e
textpointer Text006f ; 0x006f
textpointer PleaseChooseAnActivePokemonText ; 0x006e
textpointer ChooseYourBenchPokemonText ; 0x006f
textpointer YouDrewText ; 0x0070
textpointer Text0071 ; 0x0071
textpointer YouCannotSelectThisCardText ; 0x0071
textpointer PlacingThePrizesText ; 0x0072
textpointer PleasePlacePrizesText ; 0x0073
textpointer IfHeadPlayerPlaysFirstText ; 0x0074
@@ -124,10 +124,10 @@ TextOffsets:: ; 34000 (d:4000)
textpointer WonDuelText ; 0x0078
textpointer LostDuelText ; 0x0079
textpointer StartSuddenDeathMatchText ; 0x007a
textpointer Text007b ; 0x007b
textpointer Text007c ; 0x007c
textpointer Text007d ; 0x007d
textpointer Text007e ; 0x007e
textpointer PrizesLeftActivePokemonCardsInDeckText ; 0x007b
textpointer NoneText ; 0x007c
textpointer YesText ; 0x007d
textpointer CardsText ; 0x007e
textpointer Text007f ; 0x007f
textpointer Text0080 ; 0x0080
textpointer WasKnockedOutText ; 0x0081
+8 -1
View File
@@ -43,6 +43,8 @@ wPlayerDuelVariables:: ; c200
wPlayerCardLocations:: ; c200
ds DECK_SIZE
; deck indexes of the up to 6 cards placed as prizes
wPlayerPrizeCards:: ; c23c
ds $6
; Deck indexes of the cards that are in the player's hand
@@ -203,6 +205,7 @@ wOpponentDuelVariables:: ; c300
wOpponentCardLocations:: ; c300
ds DECK_SIZE
wOpponentPrizeCards:: ; c33c
ds $6
wOpponentHand:: ; c342
@@ -750,7 +753,11 @@ wcbfa:: ; cbfa
wcbfb:: ; cbfb
ds $1
ds $2
wcbfc:: ; cbfc
ds $1
wcbfd:: ; cbfd
ds $1
; during a practice duel, identifies an entry of PracticeDuelActionTable
wPracticeDuelAction:: ; cbfe