diff options
Diffstat (limited to 'src')
-rw-r--r-- | src/constants.asm | 1 | ||||
-rw-r--r-- | src/constants/card_data_constants.asm | 26 | ||||
-rw-r--r-- | src/constants/duel_constants.asm | 66 | ||||
-rw-r--r-- | src/constants/duel_interface_constants.asm | 70 | ||||
-rw-r--r-- | src/engine/bank01.asm | 450 | ||||
-rw-r--r-- | src/engine/bank02.asm | 18 | ||||
-rw-r--r-- | src/engine/bank06.asm | 1704 | ||||
-rw-r--r-- | src/engine/bank07.asm | 2 | ||||
-rw-r--r-- | src/engine/effect_functions.asm | 77 | ||||
-rw-r--r-- | src/engine/home.asm | 77 | ||||
-rw-r--r-- | src/macros/text.asm | 4 | ||||
-rw-r--r-- | src/text/text1.asm | 10 | ||||
-rw-r--r-- | src/text/text2.asm | 4 | ||||
-rw-r--r-- | src/text/text3.asm | 8 | ||||
-rw-r--r-- | src/text/text_offsets.asm | 22 | ||||
-rw-r--r-- | src/wram.asm | 61 |
16 files changed, 1787 insertions, 813 deletions
diff --git a/src/constants.asm b/src/constants.asm index aec75af..76b206c 100644 --- a/src/constants.asm +++ b/src/constants.asm @@ -3,6 +3,7 @@ INCLUDE "constants/card_constants.asm" INCLUDE "constants/card_data_constants.asm" INCLUDE "constants/deck_constants.asm" INCLUDE "constants/duel_constants.asm" +INCLUDE "constants/duel_interface_constants.asm" INCLUDE "constants/event_constants.asm" INCLUDE "constants/gfx_constants.asm" INCLUDE "constants/hardware_constants.asm" diff --git a/src/constants/card_data_constants.asm b/src/constants/card_data_constants.asm index 616a23e..641d04b 100644 --- a/src/constants/card_data_constants.asm +++ b/src/constants/card_data_constants.asm @@ -193,29 +193,3 @@ FLAG_3_BIT_1 EQU %00000010 ; special CARD_DATA_RETREAT_COST values UNABLE_RETREAT EQU $64 - -; wCardPageNumber constants -CARDPAGE_POKEMON_OVERVIEW EQU $01 -CARDPAGE_POKEMON_MOVE1_1 EQU $02 -CARDPAGE_POKEMON_MOVE1_2 EQU $03 -CARDPAGE_POKEMON_MOVE2_1 EQU $04 -CARDPAGE_POKEMON_MOVE2_2 EQU $05 -CARDPAGE_POKEMON_DESCRIPTION EQU $06 -CARDPAGE_ENERGY EQU $09 -CARDPAGE_TRAINER_1 EQU $0d -CARDPAGE_TRAINER_2 EQU $0e - -; wMovePageNumber constants -MOVEPAGE_MOVE1_1 EQU $00 -MOVEPAGE_MOVE1_2 EQU $01 -MOVEPAGE_MOVE2_1 EQU $02 -MOVEPAGE_MOVE2_2 EQU $03 - -; wCardPageType constants -CARDPAGETYPE_NOT_PLAY_AREA EQU $00 -CARDPAGETYPE_PLAY_AREA EQU $01 - -; card type header constants ($10-tile headers in DuelCardHeaderGraphics) -HEADER_TRAINER EQU $00 -HEADER_ENERGY EQU $01 -HEADER_POKEMON EQU $02 diff --git a/src/constants/duel_constants.asm b/src/constants/duel_constants.asm index dd448aa..f3e2912 100644 --- a/src/constants/duel_constants.asm +++ b/src/constants/duel_constants.asm @@ -13,9 +13,10 @@ DUELTYPE_PRACTICE EQU $80 ; for normal duels (vs AI), wDuelType is $80 + [wOpponentDeckID] ; wDuelFinished constants -TURN_PLAYER_WON EQU $1 -TURN_PLAYER_LOST EQU $2 -TURN_PLAYER_TIED EQU $3 +DUEL_NOT_FINISHED EQU $0 +TURN_PLAYER_WON EQU $1 +TURN_PLAYER_LOST EQU $2 +TURN_PLAYER_TIED EQU $3 ; wDuelResult constants DUEL_WIN EQU $0 @@ -167,6 +168,17 @@ EFFECTCMDTYPE_PKMN_POWER_TRIGGER EQU $07 EFFECTCMDTYPE_AI EQU $09 EFFECTCMDTYPE_UNKNOWN_08 EQU $08 +; wDamageEffectiveness constants +WEAKNESS EQU 1 +RESISTANCE EQU 2 + +; wNoDamageOrEffect constants +NO_DAMAGE_OR_EFFECT_AGILITY EQU $01 +NO_DAMAGE_OR_EFFECT_BARRIER EQU $02 +NO_DAMAGE_OR_EFFECT_FLY EQU $03 +NO_DAMAGE_OR_EFFECT_TRANSPARENCY EQU $04 +NO_DAMAGE_OR_EFFECT_NSHIELD EQU $05 + ; OppAction_* constants (OppActionTable) const_def const OPPACTION_ERROR ; $00 @@ -179,7 +191,7 @@ EFFECTCMDTYPE_UNKNOWN_08 EQU $08 const OPPACTION_EXECUTE_TRAINER_EFFECTS ; $07 const OPPACTION_BEGIN_ATTACK ; $08 const OPPACTION_USE_ATTACK ; $09 - const OPPACTION_DEAL_ATTACK_DAMAGE ; $0a + const OPPACTION_ATTACK_ANIM_AND_DAMAGE ; $0a const OPPACTION_DRAW_CARD ; $0b const OPPACTION_USE_PKMN_POWER ; $0c const OPPACTION_EXECUTE_PKMN_POWER_EFFECT ; $0d @@ -193,45 +205,6 @@ EFFECTCMDTYPE_UNKNOWN_08 EQU $08 const OPPACTION_6B15 ; $15 const OPPACTION_DUEL_MAIN_SCENE ; $16 -; wNoDamageOrEffect constants -NO_DAMAGE_OR_EFFECT_AGILITY EQU $01 -NO_DAMAGE_OR_EFFECT_BARRIER EQU $02 -NO_DAMAGE_OR_EFFECT_FLY EQU $03 -NO_DAMAGE_OR_EFFECT_TRANSPARENCY EQU $04 -NO_DAMAGE_OR_EFFECT_NSHIELD EQU $05 - -; wDamageEffectiveness constants -WEAKNESS EQU 1 -RESISTANCE EQU 2 - -; wEffectFailed constants -EFFECT_FAILED_NO_EFFECT EQU $01 -EFFECT_FAILED_UNSUCCESSFUL EQU $02 - -; Box message id's - const_def - const BOXMSG_PLAYERS_TURN - const BOXMSG_OPPONENTS_TURN - const BOXMSG_BETWEEN_TURNS - const BOXMSG_DECISION - const BOXMSG_BENCH_POKEMON - const BOXMSG_ARENA_POKEMON - const BOXMSG_COIN_TOSS - -; wDuelDisplayedScreen constants -DUEL_MAIN_SCENE EQU $01 -PLAY_AREA_CARD_LIST EQU $02 -COIN_TOSS EQU $06 -DRAW_CARDS EQU $07 -LARGE_CARD_PICTURE EQU $08 -SHUFFLE_DECK EQU $09 -CHECK_PLAY_AREA EQU $0a - -; wCardListItemSelectionMenuType constants -;NONE EQU $00 -PLAY_CHECK EQU $01 -SELECT_CHECK EQU $02 - ; constants for PracticeDuelActionTable entries const_def 1 const PRACTICEDUEL_DRAW_SEVEN_CARDS @@ -244,3 +217,10 @@ SELECT_CHECK EQU $02 const PRACTICEDUEL_REPEAT_INSTRUCTIONS const PRACTICEDUEL_PLAY_STARYU_FROM_BENCH const PRACTICEDUEL_REPLACE_KNOCKED_OUT_POKEMON + +; wEffectFailed constants +EFFECT_FAILED_NO_EFFECT EQU $01 +EFFECT_FAILED_UNSUCCESSFUL EQU $02 + +; wAnimationQueue length +ANIMATION_QUEUE_LENGTH EQU 7 diff --git a/src/constants/duel_interface_constants.asm b/src/constants/duel_interface_constants.asm new file mode 100644 index 0000000..baf0a4c --- /dev/null +++ b/src/constants/duel_interface_constants.asm @@ -0,0 +1,70 @@ +; wCardPageNumber constants +CARDPAGE_POKEMON_OVERVIEW EQU $01 +CARDPAGE_POKEMON_MOVE1_1 EQU $02 +CARDPAGE_POKEMON_MOVE1_2 EQU $03 +CARDPAGE_POKEMON_MOVE2_1 EQU $04 +CARDPAGE_POKEMON_MOVE2_2 EQU $05 +CARDPAGE_POKEMON_DESCRIPTION EQU $06 +CARDPAGE_ENERGY EQU $09 +CARDPAGE_TRAINER_1 EQU $0d +CARDPAGE_TRAINER_2 EQU $0e + +; wMovePageNumber constants +MOVEPAGE_MOVE1_1 EQU $00 +MOVEPAGE_MOVE1_2 EQU $01 +MOVEPAGE_MOVE2_1 EQU $02 +MOVEPAGE_MOVE2_2 EQU $03 + +; wCardPageType constants +CARDPAGETYPE_NOT_PLAY_AREA EQU $00 +CARDPAGETYPE_PLAY_AREA EQU $01 + +; card type header constants ($10-tile headers in DuelCardHeaderGraphics) +HEADER_TRAINER EQU $00 +HEADER_ENERGY EQU $01 +HEADER_POKEMON EQU $02 + +; Box message id's + const_def + const BOXMSG_PLAYERS_TURN + const BOXMSG_OPPONENTS_TURN + const BOXMSG_BETWEEN_TURNS + const BOXMSG_DECISION + const BOXMSG_BENCH_POKEMON + const BOXMSG_ARENA_POKEMON + const BOXMSG_COIN_TOSS + +; wDuelDisplayedScreen constants +DUEL_MAIN_SCENE EQU $01 +PLAY_AREA_CARD_LIST EQU $02 +COIN_TOSS EQU $06 +DRAW_CARDS EQU $07 +LARGE_CARD_PICTURE EQU $08 +SHUFFLE_DECK EQU $09 +CHECK_PLAY_AREA EQU $0a + +; wCardListItemSelectionMenuType constants +;NONE EQU $00 +PLAY_CHECK EQU $01 +SELECT_CHECK EQU $02 + +; wInPlayAreaCurPosition constants + const_def + const INPLAYAREA_PLAYER_BENCH_1 ; $00 + const INPLAYAREA_PLAYER_BENCH_2 ; $01 + const INPLAYAREA_PLAYER_BENCH_3 ; $02 + const INPLAYAREA_PLAYER_BENCH_4 ; $03 + const INPLAYAREA_PLAYER_BENCH_5 ; $04 + const INPLAYAREA_PLAYER_ACTIVE ; $05 + const INPLAYAREA_PLAYER_HAND ; $06 + const INPLAYAREA_PLAYER_DISCARD_PILE ; $07 + const INPLAYAREA_OPP_ACTIVE ; $08 + const INPLAYAREA_OPP_HAND ; $09 + const INPLAYAREA_OPP_DISCARD_PILE ; $0a + const INPLAYAREA_OPP_BENCH_1 ; $0b + const INPLAYAREA_OPP_BENCH_2 ; $0c + const INPLAYAREA_OPP_BENCH_3 ; $0d + const INPLAYAREA_OPP_BENCH_4 ; $0e + const INPLAYAREA_OPP_BENCH_5 ; $0f + const INPLAYAREA_PLAYER_PLAY_AREA ; $10 + const INPLAYAREA_OPP_PLAY_AREA ; $11 diff --git a/src/engine/bank01.asm b/src/engine/bank01.asm index f0ac3ae..f9f8781 100644 --- a/src/engine/bank01.asm +++ b/src/engine/bank01.asm @@ -822,7 +822,7 @@ DuelMenuShortcut_BothActivePokemon: ; 458e (1:458e) ; 0x4597 Func_4597: ; 4597 (1:4597) - call Func_30a6 + call OpenInPlayAreaScreen_FromSelectButton ret c call Func_45a9 ret c @@ -852,7 +852,7 @@ CheckAbleToRetreat: ; 45bb (1:45bb) ret c call CheckIfActiveCardParalyzedOrAsleep ret c - call HasAlivePokemonOnBench + call HasAlivePokemonInBench jr c, .unable_to_retreat ld a, DUELVARS_ARENA_CARD call GetTurnDuelistVariable @@ -1545,7 +1545,7 @@ Func_49a8: ; 49a8 (1:49a8) call DoFrame call CheckSkipDelayAllowed jr c, .asm_49c6 - call Func_3b52 + call CheckAnyAnimationPlaying jr c, .asm_49b9 .asm_49c6 call Func_3b31 @@ -2258,7 +2258,7 @@ Func_4e98: ; 4e98 (1:4e98) call DoFrame call CheckSkipDelayAllowed jr c, .asm_4edd - call Func_3b52 + call CheckAnyAnimationPlaying jr c, .asm_4ed0 .asm_4edd call Func_3b31 @@ -2277,7 +2277,7 @@ Func_4e98: ; 4e98 (1:4e98) call DoFrame call CheckSkipDelayAllowed jr c, .asm_4f28 - call Func_3b52 + call CheckAnyAnimationPlaying jr c, .asm_4ef4 ld hl, wNumCardsBeingDrawn inc [hl] @@ -2342,7 +2342,7 @@ Func_4f2d: ; 4f2d (1:4f2d) call DoFrame call CheckSkipDelayAllowed jr c, .asm_4f7d - call Func_3b52 + call CheckAnyAnimationPlaying jr c, .asm_4f70 .asm_4f7d call Func_3b31 @@ -2794,7 +2794,7 @@ PracticeDuel_ReplaceKnockedOutPokemon: ; 52b0 (1:52b0) cp PLAY_AREA_BENCH_1 ret z ; if player selected Drowzee instead (which is at PLAY_AREA_BENCH_2) - call HasAlivePokemonOnBench + call HasAlivePokemonInBench ldtx hl, SelectStaryuPracticeDuelText scf ; fallthrough @@ -3700,8 +3700,100 @@ DisplayCardPageOnLeftOrRightPressed: ; 57cd (1:57cd) ret ; 0x57df -Func_57df: - INCROM $57df, $5892 +Func_57df: ; 57df (1:57df) + push hl + call EmptyScreen + lb de, 0, 0 + lb bc, 20, 18 + call DrawRegularTextBox + ld a, 19 + lb de, 1, 1 + call InitTextPrintingInTextbox + call SetNoLineSeparation + pop hl + call ProcessTextFromID + call EnableLCD + call SetOneLineSeparation + call WaitForWideTextBoxInput + ret +; 0x5805 + +Func_5805: ; 5805 (1:5805) + call Func_3b31 + ld a, [wccc8] + ld l, a + ld h, $00 + call LoadTxRam3 + ld a, DUELVARS_DUELIST_TYPE + call GetTurnDuelistVariable + cp DUELIST_TYPE_PLAYER + jr nz, .opponent + + ldtx hl, WillDrawNPrizesText + call DrawWideTextBox_WaitForInput + ld a, [wccc8] + call Func_310a + ld hl, hTemp_ffa0 + ld d, [hl] + inc hl + ld e, [hl] + call SerialSend8Bytes +.asm_582f + call ExchangeRNG + ld a, DUELVARS_PRIZES + call GetTurnDuelistVariable + or a + ret nz + scf + ret + +.opponent + call Func_588a + ldtx hl, WillDrawNPrizesText + call DrawWideTextBox_PrintText + call CountPrizes + ld [wcbfc], a + ld a, DUELVARS_DUELIST_TYPE + call GetTurnDuelistVariable + cp DUELIST_TYPE_LINK_OPP + jr z, .link_opponent + call Func_2bd7 + ld c, DECK_SIZE +.asm_5858 + call DoFrame + dec c + jr nz, .asm_5858 + jr .asm_586f + +.link_opponent + call SerialRecv8Bytes + ld a, DUELVARS_PRIZES + call GetTurnDuelistVariable + ld [hl], d + ld a, e + cp $ff + call nz, AddCardToHand +.asm_586f + ld a, [wcbfc] + ld hl, wccc8 + cp [hl] + jr nc, .asm_587e + ld l, a + ld h, $00 + call LoadTxRam3 +.asm_587e + farcall Func_82b6 + ldtx hl, DrewNPrizesText + call DrawWideTextBox_WaitForInput + jr .asm_582f +; 0x588a + +Func_588a: ; 588a (1:588a) + ld l, PLAYER_TURN + ldh a, [hWhoseTurn] + ld h, a + jp DrawYourOrOppPlayAreaScreen_Bank0 +; 0x5892 ; display the previous valid card page DisplayPreviousCardPage: ; 5892 (1:5892) @@ -4985,7 +5077,7 @@ PrintPokemonCardLength: ; 5f9a (1:5f9a) ; return carry if the turn holder has any Pokemon with non-zero HP on the bench. ; return how many Pokemon with non-zero HP in b. ; does this by calculating how many Pokemon in play area minus one -HasAlivePokemonOnBench: ; 5fd9 (1:5fd9) +HasAlivePokemonInBench: ; 5fd9 (1:5fd9) ld a, $01 jr _HasAlivePokemonInPlayArea @@ -5186,7 +5278,7 @@ Func_60dd: ; 60dd (1:60dd) and SELECT jr z, .asm_60f2 .asm_6119 - call HasAlivePokemonOnBench + call HasAlivePokemonInBench ld a, $01 ld [wcbd4], a .asm_6121 @@ -6372,7 +6464,7 @@ Func_6862: ; 6862 (1:6862) ld a, [wcbff] or a jr nz, .asm_68ad - call Func_30a6 + call OpenInPlayAreaScreen_FromSelectButton jr .return_carry .asm_68ad call Func_4597 @@ -6496,7 +6588,7 @@ OppActionTable: ; 695e (1:695e) dw OppAction_ExecuteTrainerCardEffectCommands dw OppAction_BeginUseAttack dw OppAction_UseAttack - dw OppAction_DealAttackDamage + dw OppAction_PlayAttackAnimationDealAttackDamage dw OppAction_DrawCard dw OppAction_UsePokemonPower dw OppAction_ExecutePokemonPowerEffect @@ -6679,15 +6771,15 @@ OppAction_UseAttack: ; 6a8c (1:6a8c) ld [wSkipDuelistIsThinkingDelay], a ret .confusion_damage - call DealConfusionDamageToSelf + call HandleConfusionDamageToSelf ; end the turn if dealing damage to self due to confusion ld a, 1 ld [wOpponentTurnEnded], a ret ; 0x6ab1 -OppAction_DealAttackDamage: ; 6ab1 (1:6ab1) - call DealAttackDamage +OppAction_PlayAttackAnimationDealAttackDamage: ; 6ab1 (1:6ab1) + call PlayAttackAnimation_DealAttackDamage ld a, 1 ld [wOpponentTurnEnded], a ret @@ -6698,7 +6790,7 @@ OppAction_ForceSwitchActive: ; 6aba (1:6aba) ldtx hl, SelectPkmnOnBenchToSwitchWithActiveText call DrawWideTextBox_WaitForInput call SwapTurn - call HasAlivePokemonOnBench + call HasAlivePokemonInBench ld a, $01 ld [wcbd4], a .force_selection @@ -7016,7 +7108,7 @@ Func_6cab: ; 6cab (1:6cab) call Func_3b6a .asm_6cd8 call DoFrame - call Func_3b52 + call CheckAnyAnimationPlaying jr c, .asm_6cd8 call Func_6c7e.asm_6c98 ret @@ -7211,7 +7303,284 @@ ApplyStatusConditionToArenaPokemon: ; 6e38 (1:6e38) ; 0x6e49 Func_6e49: ; 6e49 (1:6e49) - INCROM $6e49, $700a + call HandleDestinyBondSubstatus + call ClearDamageReductionSubstatus2OfKnockedOutPokemon + xor a + ld [wcce8], a + call SwapTurn + call Func_6ef6 + call SwapTurn + ld a, [wcce8] + or a + jr z, .asm_6e86 + call Func_6ff7 + jr c, .asm_6e86 + call CountKnockedOutPokemon + ld c, a + call SwapTurn + call CountPrizes + call SwapTurn + dec a + cp c + jr c, .asm_6e86 + ld a, c + call SwapTurn + call TakeAPrizes + call SwapTurn + ld a, $01 + jr .asm_6ecc +.asm_6e86 + call Func_6ef6 + ld a, [wcce8] + cp $01 + jr nz, .asm_6e9f + call SwapTurn + call Func_6ff7 + call SwapTurn + jr c, .asm_6e9f + ld a, $02 + jr .asm_6ecc +.asm_6e9f + call SwapTurn + call Func_6eff + call SwapTurn + call Func_6eff + ld a, [wcce8] + or a + jr nz, .asm_6ec4 + xor a +.asm_6eb2 + push af + call MoveAllTurnHolderKnockedOutPokemonToDiscardPile + call SwapTurn + call MoveAllTurnHolderKnockedOutPokemonToDiscardPile + call SwapTurn + call ShiftAllPokemonToFirstPlayAreaSlots + pop af + ret +.asm_6ec4 + ld e, a + ld d, $00 + ld hl, Data_6ed2 + add hl, de + ld a, [hl] +.asm_6ecc + ld [wDuelFinished], a + scf + jr .asm_6eb2 +; 0x6ed2 + +Data_6ed2: ; 6ed2 (1:6ed2) + db DUEL_NOT_FINISHED, TURN_PLAYER_LOST, TURN_PLAYER_WON, TURN_PLAYER_TIED + db TURN_PLAYER_LOST, TURN_PLAYER_LOST, TURN_PLAYER_TIED, TURN_PLAYER_LOST + db TURN_PLAYER_WON, TURN_PLAYER_TIED, TURN_PLAYER_WON, TURN_PLAYER_WON + db TURN_PLAYER_TIED, TURN_PLAYER_LOST, TURN_PLAYER_WON, TURN_PLAYER_TIED + +; clears SUBSTATUS2_REDUCE_BY_20, SUBSTATUS2_POUNCE, SUBSTATUS2_GROWL, +; SUBSTATUS2_TAIL_WAG, and SUBSTATUS2_LEER for each arena Pokemon with 0 HP +ClearDamageReductionSubstatus2OfKnockedOutPokemon: ; 6ee2 (1:6ee2) + call SwapTurn + call .clear + call SwapTurn +.clear + ld a, DUELVARS_ARENA_CARD_HP + call GetNonTurnDuelistVariable + or a + ret nz + call ClearDamageReductionSubstatus2 + ret +; 0x6ef6 + +Func_6ef6: ; 6ef6 (1:6ef6) + call Func_6fa5 + ld hl, wcce8 + rl [hl] + ret +; 0x6eff + +Func_6eff: ; 6eff (1:6eff) + call ReplaceKnockedOutPokemon + ld hl, wcce8 + rl [hl] + ret +; 0x6f08 + +; for each Pokemon in the turn holder's play area (arena and bench), +; move that card to the discard pile if its HP is 0 +MoveAllTurnHolderKnockedOutPokemonToDiscardPile: ; 6f08 (1:6f08) + ld a, DUELVARS_NUMBER_OF_POKEMON_IN_PLAY_AREA + call GetTurnDuelistVariable + ld d, a + ld l, DUELVARS_ARENA_CARD_HP + ld e, PLAY_AREA_ARENA +.loop + ld a, [hl] + or a + jr nz, .next + push hl + push de + call MovePlayAreaCardToDiscardPile + pop de + pop hl +.next + inc hl + inc e + dec d + jr nz, .loop + ret +; 0x6f23 + +; have the turn holder replace the arena Pokemon card when it's been knocked out. +; if there are no Pokemon cards in the turn holder's bench, return carry. +ReplaceKnockedOutPokemon: ; 6f23 (1:6f23) + ld a, DUELVARS_ARENA_CARD_HP + call GetTurnDuelistVariable + or a + ret nz + call ClearAllStatusConditions + call HasAlivePokemonInBench + jr nc, .can_replace_pokemon + +; if we made it here, the duelist can't replace the knocked out Pokemon + bank1call DrawDuelMainScene + ldtx hl, ThereAreNoPokemonInPlayAreaText + call DrawWideTextBox_WaitForInput + call ExchangeRNG + scf + ret + +.can_replace_pokemon + ld a, DUELVARS_DUELIST_TYPE + call GetTurnDuelistVariable + cp DUELIST_TYPE_PLAYER + jr nz, .opponent + +; prompt the player to replace the knocked out Pokemon with one from bench + bank1call DrawDuelMainScene + ldtx hl, SelectPokemonToPlaceInTheArenaText + call DrawWideTextBox_WaitForInput + ld a, $01 + ld [wcbd4], a + ld a, PRACTICEDUEL_PLAY_STARYU_FROM_BENCH + call DoPracticeDuelAction +.select_pokemon + call OpenPlayAreaScreenForSelection + jr c, .select_pokemon + ldh a, [hTempPlayAreaLocation_ff9d] + call SerialSend8Bytes + +; replace the arena Pokemon with the one at location [hTempPlayAreaLocation_ff9d] +.replace_pokemon + call Func_3b31 + ld a, PRACTICEDUEL_REPLACE_KNOCKED_OUT_POKEMON + call DoPracticeDuelAction + jr c, .select_pokemon + ldh a, [hTempPlayAreaLocation_ff9d] + ld d, a + ld e, PLAY_AREA_ARENA + call SwapPlayAreaPokemon + ld a, DUELVARS_ARENA_CARD + call GetTurnDuelistVariable + ldtx hl, DuelistPlacedACardText + bank1call DisplayCardDetailScreen + call ExchangeRNG + or a + ret + +; the AI opponent replaces the knocked out Pokemon with one from bench +.opponent + cp DUELIST_TYPE_LINK_OPP + jr z, .link_opponent + call Func_2bcf + ldh a, [hTemp_ffa0] + ldh [hTempPlayAreaLocation_ff9d], a + jr .replace_pokemon + +; wait for link opponent to replace the knocked out Pokemon with one from bench +.link_opponent + bank1call DrawDuelMainScene + ldtx hl, DuelistIsSelectingPokemonToPlaceInArenaText + call DrawWideTextBox_PrintText + call SerialRecv8Bytes + ldh [hTempPlayAreaLocation_ff9d], a + jr .replace_pokemon +; 0x6fa5 + +Func_6fa5: ; 6fa5 (1:6fa5) + call CountKnockedOutPokemon + ret nc + ; at least one Pokemon knocked out + call SwapTurn + bank1call Func_5805 + call SwapTurn + ret nc + call SwapTurn + bank1call DrawDuelMainScene + ldtx hl, TookAllThePrizesText + call DrawWideTextBox_WaitForInput + call ExchangeRNG + call SwapTurn + scf + ret +; 0x6fc7 + +; return in wccc8 the amount of Pokemon in the turn holder's +; play area that are still there despite having 0 HP. +; that is, the number of Pokemon that have just been knocked out. +; Clefairy Doll and Mysterious Fossil don't count. +CountKnockedOutPokemon: ; 6fc7 (1:6fc7) + ld a, DUELVARS_ARENA_CARD_HP + call GetTurnDuelistVariable + ld d, h + ld e, DUELVARS_ARENA_CARD + ld b, PLAY_AREA_ARENA + ld c, MAX_PLAY_AREA_POKEMON +.loop + ld a, [de] + cp -1 + jr z, .next ; jump if no Pokemon in this location + ld a, [hl] + or a + jr nz, .next ; jump if this Pokemon's HP isn't 0 + ; this Pokemon's HP has just become 0 + ld a, [de] + push de + call GetCardIDFromDeckIndex + call GetCardType + pop de + cp TYPE_TRAINER + jr z, .next ; jump if this is a trainer card (Clefairy Doll or Mysterious Fossil) + inc b +.next + inc hl + inc de + dec c + jr nz, .loop + ld a, b + ld [wccc8], a + or a + ret z + scf + ret +; 0x6ff7 + +Func_6ff7: ; 6ff7 (1:6ff7) + ld a, DUELVARS_NUMBER_OF_POKEMON_IN_PLAY_AREA + call GetTurnDuelistVariable + ld c, a + ld l, DUELVARS_ARENA_CARD_HP +.loop + ld a, [hli] + or a + jr nz, .non_zero_hp + dec c + jr nz, .loop + scf + ret +.non_zero_hp + or a + ret +; 0x700a ; print one of the "There was no effect from" texts depending ; on the value at wNoEffectFromStatus (NO_STATUS or a status condition constant) @@ -7391,15 +7760,17 @@ PrizeBitmasks: ; 715a (1:715a) db %0, %1, %11, %111, %1111, %11111, %111111 ; 0x7161 -Func_7161: ; 7161 (1:7161) +; update the turn holder's DUELVARS_PRIZES following that duelist +; drawing a number of prizes equal to register a +TakeAPrizes: ; 7161 (1:7161) or a ret z ld c, a call CountPrizes sub c - jr nc, .asm_716b + jr nc, .no_underflow xor a -.asm_716b +.no_underflow ld c, a ld b, $00 ld hl, PrizeBitmasks @@ -7555,7 +7926,7 @@ _TossCoin: ; 71ad (1:71ad) .asm_725e push de call DoFrame - call Func_3b52 + call CheckAnyAnimationPlaying pop de jr c, .asm_725e ld a, e @@ -7709,18 +8080,21 @@ Func_741a: ; 741a (1:741a) xor a ld [wd4b0], a push hl - farcall $6, $4f9c + farcall Func_18f9c pop hl jr .loop .done ret ; 0x7469 -Func_7469: ; 7469 (1:7469) +; this is a simple version of PlayAttackAnimation_DealAttackDamage that doesn't +; take into account status conditions, damage modifiers, etc, for damage calculation. +; used for confusion damage to self and for damage to benched Pokemon, for example +PlayAttackAnimation_DealAttackDamageSimple: ; 7469 (1:7469) push hl push de - call Func_7494 - call Func_7484 + call PlayMoveAnimation + call WaitMoveAnimation pop de pop hl call SubstractHP @@ -7735,20 +8109,26 @@ Func_7469: ; 7469 (1:7469) ret ; 0x7484 -Func_7484: ; 7484 (1:7484) +; if [wLoadedMoveAnimation] != 0, wait until the animation is over +WaitMoveAnimation: ; 7484 (1:7484) ld a, [wLoadedMoveAnimation] or a ret z push de -.asm_748a +.anim_loop call DoFrame - call Func_3b52 - jr c, .asm_748a + call CheckAnyAnimationPlaying + jr c, .anim_loop pop de ret ; 0x7494 -Func_7494: ; 7494 (1:7494) +; play move animation +; input: +; - [wLoadedMoveAnimation]: animation to play +; - de: damage dealt by the move (to display the animation with the number) +; - c: a wDamageEffectiveness constant (to print WEAK or RESIST if necessary) +PlayMoveAnimation: ; 7494 (1:7494) ldh a, [hWhoseTurn] push af push hl @@ -7782,7 +8162,7 @@ Func_7494: ; 7494 (1:7494) ld a, $02 ld [wLoadedMoveAnimation], a .asm_74d1 - farcall Func_006_4f9c + farcall Func_18f9c pop bc pop de pop hl @@ -7797,7 +8177,7 @@ Func_7571: ; 7571 (1:7571) INCROM $7571, $7576 Func_7576: ; 7576 (1:7576) - farcall $6, $591f + farcall Func_1991f ret ; 0x757b @@ -7812,7 +8192,7 @@ Func_7594: ; 7594 (1:7594) ; 0x7599 Func_7599: ; 7599 (1:7599) - farcall Func_006_668d + farcall Func_1a68d ret ; 0x759e diff --git a/src/engine/bank02.asm b/src/engine/bank02.asm index a4a0f62..be38fad 100644 --- a/src/engine/bank02.asm +++ b/src/engine/bank02.asm @@ -22,11 +22,11 @@ _OpenDuelCheckMenu: ; 8000 (2:4000) ld b, a ld a, [wCheckMenuCursorXPosition] add b - ld hl, .table + ld hl, .jump_table call JumpToFunctionInTable jr _OpenDuelCheckMenu -.table: ; 8031 (2:4031) +.jump_table: ; 8031 (2:4031) dw DuelCheckMenu_InPlayArea dw DuelCheckMenu_Glossary dw DuelCheckMenu_YourPlayArea @@ -35,13 +35,13 @@ _OpenDuelCheckMenu: ; 8000 (2:4000) ; opens the In Play Area submenu DuelCheckMenu_InPlayArea: ; 8039 (2:4039) xor a - ld [wce60], a - farcall Func_180d5 + ld [wInPlayAreaFromSelectButton], a + farcall OpenInPlayAreaScreen ret ; opens the Glossary submenu DuelCheckMenu_Glossary: ; 8042 (2:4042) - farcall Func_006_44c8 + farcall Func_184c8 ret ; opens the Your Play Area submenu @@ -88,11 +88,11 @@ DuelCheckMenu_YourPlayArea: ; 8047 (2:4047) ld b, a ld a, [wCheckMenuCursorXPosition] add b - ld hl, .table + ld hl, .jump_table call JumpToFunctionInTable jr .draw -.table ; 8098 (2:4098) +.jump_table ; 8098 (2:4098) dw OpenYourOrOppPlayAreaScreen_TurnHolderPlayArea dw OpenYourOrOppPlayAreaScreen_TurnHolderHand dw OpenYourOrOppPlayAreaScreen_TurnHolderDiscardPile @@ -225,11 +225,11 @@ DuelCheckMenu_OppPlayArea: ; 80da (2:40da) ld b, a ld a, [wCheckMenuCursorXPosition] add b - ld hl, .table + ld hl, .jump_table call JumpToFunctionInTable jr .turns -.table +.jump_table dw OpenYourOrOppPlayAreaScreen_NonTurnHolderPlayArea dw OpenYourOrOppPlayAreaScreen_NonTurnHolderHand dw OpenYourOrOppPlayAreaScreen_NonTurnHolderDiscardPile diff --git a/src/engine/bank06.asm b/src/engine/bank06.asm index cb1b0a9..bb9d872 100644 --- a/src/engine/bank06.asm +++ b/src/engine/bank06.asm @@ -152,147 +152,196 @@ _CopyCardNameAndLevel_HalfwidthText: ret ; 0x180d5 -Func_180d5: ; 180d5 (6:40d5) - ld a, $05 - ld [wPrizeCardCursorPosition], a -.asm_006_40da +; this function is called when the player is shown the "In Play Area" screen. +; it can be called with either the select button (DuelMenuShortcut_BothActivePokemon), +; or via the "In Play Area" item of the Check menu (DuelCheckMenu_InPlayArea) +OpenInPlayAreaScreen: ; 180d5 (6:40d5) + ld a, INPLAYAREA_PLAYER_ACTIVE + ld [wInPlayAreaCurPosition], a +.start xor a ld [wCheckMenuCursorBlinkCounter], a farcall DrawInPlayAreaScreen call EnableLCD call IsClairvoyanceActive - jr c, .asm_006_40ef - ld de, $42db - jr .asm_006_40f2 -.asm_006_40ef - ld de, $434b -.asm_006_40f2 - ld hl, $ce53 + jr c, .clairvoyance_on + + ld de, OpenInPlayAreaScreen_TransitionTable1 + jr .clairvoyance_off + +.clairvoyance_on + ld de, OpenInPlayAreaScreen_TransitionTable2 +.clairvoyance_off + ld hl, wInPlayAreaInputTablePointer ld [hl], e inc hl ld [hl], d - ld a, [wPrizeCardCursorPosition] - call .asm_006_4171 -.asm_006_40fe + ld a, [wInPlayAreaCurPosition] + call .print_associated_text +.on_frame ld a, $01 ld [wVBlankOAMCopyToggle], a call DoFrame + ldh a, [hDPadHeld] - and $08 - jr nz, .asm_006_4153 - ld a, [wce60] + and START + jr nz, .selection + + ; if this function's been called from 'select' button, + ; wInPlayAreaFromSelectButton is on. + ld a, [wInPlayAreaFromSelectButton] or a - jr z, .asm_006_4118 + jr z, .handle_input ; if it's from the Check menu, jump. + ldh a, [hDPadHeld] - and $04 - jr nz, .asm_006_4148 -.asm_006_4118 - ld a, [wPrizeCardCursorPosition] - ld [$ce58], a - call Func_006_43bb - jr c, .asm_006_4139 - ld a, [wPrizeCardCursorPosition] - cp $10 - jp z, .asm_006_41f8 - cp $11 - jp z, .asm_006_4210 - ld hl, $ce58 + and SELECT + jr nz, .skip_input + +.handle_input + ld a, [wInPlayAreaCurPosition] + ld [wInPlayAreaTemporaryPosition], a + call OpenInPlayAreaScreen_HandleInput + jr c, .pressed + + ld a, [wInPlayAreaCurPosition] + cp INPLAYAREA_PLAYER_PLAY_AREA + jp z, .show_turn_holder_play_area + cp INPLAYAREA_OPP_PLAY_AREA + jp z, .show_non_turn_holder_play_area + + ; check if the cursor moved. + ld hl, wInPlayAreaTemporaryPosition cp [hl] - call nz, .asm_006_4171 - jr .asm_006_40fe -.asm_006_4139 - cp $ff - jr nz, .asm_006_4153 - call Func_006_44bf + call nz, .print_associated_text + + jr .on_frame + +.pressed + cp -1 + jr nz, .selection + + ; pressed b button. + call ZeroObjectPositionsAndToggleOAMCopy_Bank6 lb de, $38, $9f call SetupText scf ret -.asm_006_4148 - call Func_006_44bf + +.skip_input + call ZeroObjectPositionsAndToggleOAMCopy_Bank6 lb de, $38, $9f call SetupText or a ret -.asm_006_4153 - call Func_006_44bf + +.selection ; pressed a button or start button. + call ZeroObjectPositionsAndToggleOAMCopy_Bank6 lb de, $38, $9f call SetupText - ld a, [wPrizeCardCursorPosition] - ld [$ce57], a + ld a, [wInPlayAreaCurPosition] + ld [wInPlayAreaPreservedPosition], a ld hl, .jump_table call JumpToFunctionInTable - ld a, [$ce57] - ld [wPrizeCardCursorPosition], a - jp .asm_006_40da -.asm_006_4171 ; 18171 (6:4171) + ld a, [wInPlayAreaPreservedPosition] + ld [wInPlayAreaCurPosition], a + + jp .start + +.print_associated_text ; 18171 (6:4171) +; each position has a text associated to it, +; which is printed at the bottom of the screen push af lb de, 1, 17 call InitTextPrinting ldtx hl, EmptyLineText call ProcessTextFromID + ld hl, hffb0 ld [hl], $01 ldtx hl, HandText_2 call ProcessTextFromID + ld hl, hffb0 ld [hl], $00 lb de, 1, 17 call InitTextPrinting pop af - ld hl, TextIDTable_182bb + ld hl, OpenInPlayAreaScreen_TextTable ld b, 0 sla a ld c, a add hl, bc + + ; hl = OpenInPlayAreaScreen_TextTable + 2 * (wInPlayAreaCurPosition) ld a, [hli] ld h, [hl] ld l, a ld a, h + + ; jump ahead if entry does not contain null text (it's not active pokemon) or a - jr nz, .asm_006_41e3 + jr nz, .print_hand_or_discard_pile + ld a, l - cp $06 - jr nc, .asm_006_41e3 - ld a, [wPrizeCardCursorPosition] - cp $06 - jr nc, .asm_006_41c2 + ; bench slots have dummy text IDs assigned to them, which are never used. + ; these are secretly not text id's, but rather, 2-byte PLAY_AREA_BENCH_* constants + ; check if the value at register l is one of those, and jump ahead if not + cp PLAY_AREA_BENCH_5 + $01 + jr nc, .print_hand_or_discard_pile + +; if we make it here, we need to print a Pokemon card name. +; wInPlayAreaCurPosition determines which duelist +; and l contains the PLAY_AREA_* location of the card. + ld a, [wInPlayAreaCurPosition] + cp INPLAYAREA_PLAYER_HAND + jr nc, .opponent_side + ld a, l add DUELVARS_ARENA_CARD call GetTurnDuelistVariable cp -1 ret z + call GetCardIDFromDeckIndex call LoadCardDataToBuffer1_FromCardID - jr .asm_006_41d7 -.asm_006_41c2 + jr .display_card_name + +.opponent_side ld a, l add DUELVARS_ARENA_CARD call GetNonTurnDuelistVariable cp -1 ret z + call SwapTurn call GetCardIDFromDeckIndex call LoadCardDataToBuffer1_FromCardID call SwapTurn -.asm_006_41d7 + +.display_card_name ld a, 18 call CopyCardNameAndLevel ld hl, wDefaultText call ProcessText ret -.asm_006_41e3 - ld a, [wPrizeCardCursorPosition] - cp $08 - jr nc, .asm_006_41ee + +.print_hand_or_discard_pile +; if we make it here, cursor position is to Hand or Discard Pile +; so DuelistHandText_2 or DuelistDiscardPileText will be printed + + ld a, [wInPlayAreaCurPosition] + cp INPLAYAREA_OPP_ACTIVE + jr nc, .opp_side_print_hand_or_discard_pile call PrintTextNoDelay ret -.asm_006_41ee + +.opp_side_print_hand_or_discard_pile call SwapTurn call PrintTextNoDelay call SwapTurn ret -.asm_006_41f8 + +.show_turn_holder_play_area lb de, $38, $9f call SetupText ldh a, [hWhoseTurn] @@ -300,10 +349,11 @@ Func_180d5: ; 180d5 (6:40d5) bank1call OpenTurnHolderPlayAreaScreen pop af ldh [hWhoseTurn], a - ld a, [$ce57] - ld [wPrizeCardCursorPosition], a - jp .asm_006_40da -.asm_006_4210 + ld a, [wInPlayAreaPreservedPosition] + ld [wInPlayAreaCurPosition], a + jp .start + +.show_non_turn_holder_play_area lb de, $38, $9f call SetupText ldh a, [hWhoseTurn] @@ -311,34 +361,37 @@ Func_180d5: ; 180d5 (6:40d5) bank1call OpenNonTurnHolderPlayAreaScreen pop af ldh [hWhoseTurn], a - ld a, [$ce57] - ld [wPrizeCardCursorPosition], a - jp .asm_006_40da + ld a, [wInPlayAreaPreservedPosition] + ld [wInPlayAreaCurPosition], a + jp .start + .jump_table ; (6:4228) - dw Func_006_4248 - dw Func_006_4248 - dw Func_006_4248 - dw Func_006_4248 - dw Func_006_4248 - dw Func_006_4248 - dw Func_006_4293 - dw Func_006_42a7 - dw Func_006_426a - dw Func_006_429d - dw Func_006_42b1 - dw Func_006_426a - dw Func_006_426a - dw Func_006_426a - dw Func_006_426a - dw Func_006_426a - -Func_006_4248: - ld a, [wPrizeCardCursorPosition] + dw OpenInPlayAreaScreen_TurnHolderPlayArea ; 0x00: INPLAYAREA_PLAYER_BENCH_1 + dw OpenInPlayAreaScreen_TurnHolderPlayArea ; 0x01: INPLAYAREA_PLAYER_BENCH_2 + dw OpenInPlayAreaScreen_TurnHolderPlayArea ; 0x02: INPLAYAREA_PLAYER_BENCH_3 + dw OpenInPlayAreaScreen_TurnHolderPlayArea ; 0x03: INPLAYAREA_PLAYER_BENCH_4 + dw OpenInPlayAreaScreen_TurnHolderPlayArea ; 0x04: INPLAYAREA_PLAYER_BENCH_5 + dw OpenInPlayAreaScreen_TurnHolderPlayArea ; 0x05: INPLAYAREA_PLAYER_ACTIVE + dw OpenInPlayAreaScreen_TurnHolderHand ; 0x06: INPLAYAREA_PLAYER_HAND + dw OpenInPlayAreaScreen_TurnHolderDiscardPile ; 0x07: INPLAYAREA_PLAYER_DISCARD_PILE + dw OpenInPlayAreaScreen_NonTurnHolderPlayArea ; 0x08: INPLAYAREA_OPP_ACTIVE + dw OpenInPlayAreaScreen_NonTurnHolderHand ; 0x09: INPLAYAREA_OPP_HAND + dw OpenInPlayAreaScreen_NonTurnHolderDiscardPile ; 0x0a: INPLAYAREA_OPP_DISCARD_PILE + dw OpenInPlayAreaScreen_NonTurnHolderPlayArea ; 0x0b: INPLAYAREA_OPP_BENCH_1 + dw OpenInPlayAreaScreen_NonTurnHolderPlayArea ; 0x0c: INPLAYAREA_OPP_BENCH_2 + dw OpenInPlayAreaScreen_NonTurnHolderPlayArea ; 0x0d: INPLAYAREA_OPP_BENCH_3 + dw OpenInPlayAreaScreen_NonTurnHolderPlayArea ; 0x0e: INPLAYAREA_OPP_BENCH_4 + dw OpenInPlayAreaScreen_NonTurnHolderPlayArea ; 0x0f: INPLAYAREA_OPP_BENCH_5 + +OpenInPlayAreaScreen_TurnHolderPlayArea: + ; wInPlayAreaCurPosition constants conveniently map to (PLAY_AREA_* constants - 1) + ; for bench locations. this mapping is taken for granted in the following code. + ld a, [wInPlayAreaCurPosition] inc a - cp PLAY_AREA_BENCH_5 + $01 - jr nz, .asm_006_4251 + cp INPLAYAREA_PLAYER_ACTIVE + $01 + jr nz, .on_bench xor a ; PLAY_AREA_ARENA -.asm_006_4251 +.on_bench ld [wCurPlayAreaSlot], a add DUELVARS_ARENA_CARD call GetTurnDuelistVariable @@ -351,13 +404,14 @@ Func_006_4248: bank1call OpenCardPage_FromCheckPlayArea ret -Func_006_426a: - ld a, [wPrizeCardCursorPosition] - sub $08 +OpenInPlayAreaScreen_NonTurnHolderPlayArea: + ld a, [wInPlayAreaCurPosition] + sub INPLAYAREA_OPP_ACTIVE or a - jr z, .asm_006_4274 - sub $02 -.asm_006_4274 + jr z, .active + ; convert INPLAYAREA_OPP_BENCH_* constant to PLAY_AREA_BENCH_* constant + sub INPLAYAREA_OPP_BENCH_1 - INPLAYAREA_OPP_ACTIVE - PLAY_AREA_BENCH_1 +.active ld [wCurPlayAreaSlot], a add DUELVARS_ARENA_CARD call GetNonTurnDuelistVariable @@ -372,7 +426,7 @@ Func_006_426a: call SwapTurn ret -Func_006_4293: +OpenInPlayAreaScreen_TurnHolderHand: ldh a, [hWhoseTurn] push af bank1call OpenTurnHolderHandScreen_Simple @@ -380,7 +434,7 @@ Func_006_4293: ldh [hWhoseTurn], a ret -Func_006_429d: +OpenInPlayAreaScreen_NonTurnHolderHand: ldh a, [hWhoseTurn] push af bank1call OpenNonTurnHolderHandScreen_Simple @@ -388,7 +442,7 @@ Func_006_429d: ldh [hWhoseTurn], a ret -Func_006_42a7: +OpenInPlayAreaScreen_TurnHolderDiscardPile: ldh a, [hWhoseTurn] push af bank1call OpenTurnHolderDiscardPileScreen @@ -396,7 +450,7 @@ Func_006_42a7: ldh [hWhoseTurn], a ret -Func_006_42b1: +OpenInPlayAreaScreen_NonTurnHolderDiscardPile: ldh a, [hWhoseTurn] push af bank1call OpenNonTurnHolderDiscardPileScreen @@ -404,200 +458,287 @@ Func_006_42b1: ldh [hWhoseTurn], a ret -TextIDTable_182bb: - tx HandText - tx CheckText - tx AttackText - tx PKMNPowerText - tx DoneText - dw NONE - tx DuelistHandText_2 - tx DuelistDiscardPileText - dw NONE - tx DuelistHandText_2 - tx DuelistDiscardPileText - tx HandText - tx CheckText - tx AttackText - tx PKMNPowerText - tx DoneText - - INCROM $182db, $183bb - -Func_006_43bb: ; 183bb (6:43bb) +OpenInPlayAreaScreen_TextTable: +; note that for bench slots, the entries are +; PLAY_AREA_BENCH_* constants in practice + tx HandText ; INPLAYAREA_PLAYER_BENCH_1 + tx CheckText ; INPLAYAREA_PLAYER_BENCH_2 + tx AttackText ; INPLAYAREA_PLAYER_BENCH_3 + tx PKMNPowerText ; INPLAYAREA_PLAYER_BENCH_4 + tx DoneText ; INPLAYAREA_PLAYER_BENCH_5 + dw NONE ; INPLAYAREA_PLAYER_ACTIVE + tx DuelistHandText_2 ; INPLAYAREA_PLAYER_HAND + tx DuelistDiscardPileText ; INPLAYAREA_PLAYER_DISCARD_PILE + dw NONE ; INPLAYAREA_OPP_ACTIVE + tx DuelistHandText_2 ; INPLAYAREA_OPP_HAND + tx DuelistDiscardPileText ; INPLAYAREA_OPP_DISCARD_PILE + tx HandText ; INPLAYAREA_OPP_BENCH_1 + tx CheckText ; INPLAYAREA_OPP_BENCH_2 + tx AttackText ; INPLAYAREA_OPP_BENCH_3 + tx PKMNPowerText ; INPLAYAREA_OPP_BENCH_4 + tx DoneText ; INPLAYAREA_OPP_BENCH_5 + +; cursor x / cursor y / attribute / idx-up / idx-down / idx-right / idx-left +in_play_area_transition: MACRO + db \1, \2, \3 + rept 4 + db INPLAYAREA_\4 + shift + endr +ENDM + +; it's related to wInPlayAreaInputTablePointer. +; with this table, the cursor moves into the proper location by the input. +; note that the unit of the position is not a 8x8 tile. +; idx-[direction] means the index to get when the input is in the direction. +; its attribute is used for drawing a flipped cursor. +OpenInPlayAreaScreen_TransitionTable1: + in_play_area_transition $18, $8c, $00, PLAYER_ACTIVE, PLAYER_PLAY_AREA, PLAYER_BENCH_2, PLAYER_BENCH_5 + in_play_area_transition $30, $8c, $00, PLAYER_ACTIVE, PLAYER_PLAY_AREA, PLAYER_BENCH_3, PLAYER_BENCH_1 + in_play_area_transition $48, $8c, $00, PLAYER_ACTIVE, PLAYER_PLAY_AREA, PLAYER_BENCH_4, PLAYER_BENCH_2 + in_play_area_transition $60, $8c, $00, PLAYER_ACTIVE, PLAYER_PLAY_AREA, PLAYER_BENCH_5, PLAYER_BENCH_3 + in_play_area_transition $78, $8c, $00, PLAYER_ACTIVE, PLAYER_PLAY_AREA, PLAYER_BENCH_1, PLAYER_BENCH_4 + in_play_area_transition $30, $6c, $00, OPP_ACTIVE, PLAYER_BENCH_1, PLAYER_DISCARD_PILE, PLAYER_DISCARD_PILE + in_play_area_transition $78, $80, $00, PLAYER_DISCARD_PILE, PLAYER_BENCH_1, PLAYER_ACTIVE, PLAYER_ACTIVE + in_play_area_transition $78, $70, $00, OPP_ACTIVE, PLAYER_HAND, PLAYER_ACTIVE, PLAYER_ACTIVE + in_play_area_transition $78, $34, 1 << OAM_X_FLIP, OPP_BENCH_1, PLAYER_ACTIVE, OPP_DISCARD_PILE, OPP_DISCARD_PILE + in_play_area_transition $30, $20, 1 << OAM_X_FLIP, OPP_BENCH_1, OPP_DISCARD_PILE, OPP_ACTIVE, OPP_ACTIVE + in_play_area_transition $30, $38, 1 << OAM_X_FLIP, OPP_BENCH_1, PLAYER_ACTIVE, OPP_ACTIVE, OPP_ACTIVE + in_play_area_transition $90, $14, 1 << OAM_X_FLIP, OPP_PLAY_AREA, OPP_ACTIVE, OPP_BENCH_5, OPP_BENCH_2 + in_play_area_transition $78, $14, 1 << OAM_X_FLIP, OPP_PLAY_AREA, OPP_ACTIVE, OPP_BENCH_1, OPP_BENCH_3 + in_play_area_transition $60, $14, 1 << OAM_X_FLIP, OPP_PLAY_AREA, OPP_ACTIVE, OPP_BENCH_2, OPP_BENCH_4 + in_play_area_transition $48, $14, 1 << OAM_X_FLIP, OPP_PLAY_AREA, OPP_ACTIVE, OPP_BENCH_3, OPP_BENCH_5 + in_play_area_transition $30, $14, 1 << OAM_X_FLIP, OPP_PLAY_AREA, OPP_ACTIVE, OPP_BENCH_4, OPP_BENCH_1 + +OpenInPlayAreaScreen_TransitionTable2: + in_play_area_transition $18, $8c, $00, PLAYER_ACTIVE, PLAYER_PLAY_AREA, PLAYER_BENCH_2, PLAYER_BENCH_5 + in_play_area_transition $30, $8c, $00, PLAYER_ACTIVE, PLAYER_PLAY_AREA, PLAYER_BENCH_3, PLAYER_BENCH_1 + in_play_area_transition $48, $8c, $00, PLAYER_ACTIVE, PLAYER_PLAY_AREA, PLAYER_BENCH_4, PLAYER_BENCH_2 + in_play_area_transition $60, $8c, $00, PLAYER_ACTIVE, PLAYER_PLAY_AREA, PLAYER_BENCH_5, PLAYER_BENCH_3 + in_play_area_transition $78, $8c, $00, PLAYER_ACTIVE, PLAYER_PLAY_AREA, PLAYER_BENCH_1, PLAYER_BENCH_4 + in_play_area_transition $30, $6c, $00, OPP_ACTIVE, PLAYER_BENCH_1, PLAYER_DISCARD_PILE, PLAYER_DISCARD_PILE + in_play_area_transition $78, $80, $00, PLAYER_DISCARD_PILE, PLAYER_BENCH_1, PLAYER_ACTIVE, PLAYER_ACTIVE + in_play_area_transition $78, $70, $00, OPP_ACTIVE, PLAYER_HAND, PLAYER_ACTIVE, PLAYER_ACTIVE + in_play_area_transition $78, $34, 1 << OAM_X_FLIP, OPP_BENCH_1, PLAYER_ACTIVE, OPP_DISCARD_PILE, OPP_DISCARD_PILE + in_play_area_transition $30, $20, 1 << OAM_X_FLIP, OPP_BENCH_1, OPP_DISCARD_PILE, OPP_ACTIVE, OPP_ACTIVE + in_play_area_transition $30, $38, 1 << OAM_X_FLIP, OPP_HAND, PLAYER_ACTIVE, OPP_ACTIVE, OPP_ACTIVE + in_play_area_transition $90, $14, 1 << OAM_X_FLIP, OPP_PLAY_AREA, OPP_ACTIVE, OPP_BENCH_5, OPP_BENCH_2 + in_play_area_transition $78, $14, 1 << OAM_X_FLIP, OPP_PLAY_AREA, OPP_ACTIVE, OPP_BENCH_1, OPP_BENCH_3 + in_play_area_transition $60, $14, 1 << OAM_X_FLIP, OPP_PLAY_AREA, OPP_ACTIVE, OPP_BENCH_2, OPP_BENCH_4 + in_play_area_transition $48, $14, 1 << OAM_X_FLIP, OPP_PLAY_AREA, OPP_ACTIVE, OPP_BENCH_3, OPP_BENCH_5 + in_play_area_transition $30, $14, 1 << OAM_X_FLIP, OPP_PLAY_AREA, OPP_ACTIVE, OPP_BENCH_4, OPP_BENCH_1 + +OpenInPlayAreaScreen_HandleInput: ; 183bb (6:43bb) xor a ld [wcfe3], a - ld hl, $ce53 -.asm_006_43c2 + ld hl, wInPlayAreaInputTablePointer ld e, [hl] inc hl ld d, [hl] - ld a, [wPrizeCardCursorPosition] + ld a, [wInPlayAreaCurPosition] ld l, a -.asm_006_43c9 ld h, $07 call HtimesL add hl, de + ldh a, [hDPadHeld] or a - jp z, .asm_006_446b + jp z, .check_button + inc hl inc hl inc hl + + ; check d-pad bit D_UP_F, a - jr z, .asm_006_43df -.asm_006_43dc + jr z, .else_if_down + + ; up ld a, [hl] - jr .asm_006_43f5 -.asm_006_43df + jr .process_dpad + +.else_if_down inc hl bit D_DOWN_F, a - jr z, .asm_006_43e7 + jr z, .else_if_right + + ; down ld a, [hl] - jr .asm_006_43f5 -.asm_006_43e7 + jr .process_dpad + +.else_if_right inc hl bit D_RIGHT_F, a - jr z, .asm_006_43ef + jr z, .else_if_left + + ; right ld a, [hl] - jr .asm_006_43f5 -.asm_006_43ef + jr .process_dpad + +.else_if_left inc hl bit D_LEFT_F, a - jr z, .asm_006_446b + jr z, .check_button + + ; left ld a, [hl] -.asm_006_43f5 +.process_dpad push af - ld a, [wPrizeCardCursorPosition] - ld [$ce57], a + ld a, [wInPlayAreaCurPosition] + ld [wInPlayAreaPreservedPosition], a pop af - ld [wPrizeCardCursorPosition], a - cp $05 - jr c, .asm_006_440e - cp $0b - jr c, .asm_006_4462 - cp $10 - jr c, .asm_006_4437 - jr .asm_006_4462 -.asm_006_440e + + ld [wInPlayAreaCurPosition], a + cp INPLAYAREA_PLAYER_ACTIVE + jr c, .player_area + cp INPLAYAREA_OPP_BENCH_1 + jr c, .next + cp INPLAYAREA_PLAYER_PLAY_AREA + jr c, .opponent_area + + jr .next + +.player_area ld a, DUELVARS_NUMBER_OF_POKEMON_IN_PLAY_AREA call GetTurnDuelistVariable dec a - jr nz, .asm_006_441d - ld a, $10 - ld [wPrizeCardCursorPosition], a - jr .asm_006_4462 -.asm_006_441d + jr nz, .bench_pokemon_exists + + ; no pokemon in player's bench. + ; then move to player's play area. + ld a, INPLAYAREA_PLAYER_PLAY_AREA + ld [wInPlayAreaCurPosition], a + jr .next + +.bench_pokemon_exists ld b, a - ld a, [wPrizeCardCursorPosition] + ld a, [wInPlayAreaCurPosition] cp b - jr c, .asm_006_4462 + jr c, .next + + ; handle index overflow ldh a, [hDPadHeld] bit D_RIGHT_F, a - jr z, .asm_006_4430 + jr z, .on_left + xor a - ld [wPrizeCardCursorPosition], a - jr .asm_006_4462 -.asm_006_4430: + ld [wInPlayAreaCurPosition], a + jr .next + +.on_left ld a, b dec a - ld [wPrizeCardCursorPosition], a - jr .asm_006_4462 -.asm_006_4437: + ld [wInPlayAreaCurPosition], a + jr .next + +.opponent_area ld a, DUELVARS_NUMBER_OF_POKEMON_IN_PLAY_AREA call GetNonTurnDuelistVariable dec a - jr nz, .asm_006_4446 - ld a, $11 - ld [wPrizeCardCursorPosition], a - jr .asm_006_4462 -.asm_006_4446 + jr nz, .bench_pokemon_exists_2 + + ld a, INPLAYAREA_OPP_PLAY_AREA + ld [wInPlayAreaCurPosition], a + jr .next + +.bench_pokemon_exists_2 ld b, a - ld a, [wPrizeCardCursorPosition] - sub $0b + ld a, [wInPlayAreaCurPosition] + sub INPLAYAREA_OPP_BENCH_1 cp b - jr c, .asm_006_4462 + jr c, .next + ldh a, [hDPadHeld] bit D_LEFT_F, a - jr z, .asm_006_445c - ld a, $0b - ld [wPrizeCardCursorPosition], a - jr .asm_006_4462 -.asm_006_445c + jr z, .on_right + + ld a, INPLAYAREA_OPP_BENCH_1 + ld [wInPlayAreaCurPosition], a + jr .next + +.on_right ld a, b - add $0a - ld [wPrizeCardCursorPosition], a -.asm_006_4462 + add INPLAYAREA_OPP_DISCARD_PILE + ld [wInPlayAreaCurPosition], a +.next ld a, $01 ld [wcfe3], a xor a ld [wCheckMenuCursorBlinkCounter], a -.asm_006_446b +.check_button ldh a, [hKeysPressed] - and $03 - jr z, .asm_006_448b - and $01 - jr nz, .asm_006_447d - ld a, $ff + and A_BUTTON | B_BUTTON + jr z, .return + + and A_BUTTON + jr nz, .a_button + + ; pressed b button + ld a, -1 farcall PlaySFXConfirmOrCancel scf ret -.asm_006_447d - call Func_006_44a0 + +.a_button + call .draw_cursor ld a, $01 farcall PlaySFXConfirmOrCancel - ld a, [wPrizeCardCursorPosition] + ld a, [wInPlayAreaCurPosition] scf ret -.asm_006_448b + +.return ld a, [wcfe3] or a - jr z, .asm_006_4494 + jr z, .skip_sfx call PlaySFX -.asm_006_4494 +.skip_sfx ld hl, wCheckMenuCursorBlinkCounter ld a, [hl] inc [hl] - and $0f + and $10 - 1 ret nz - bit D_RIGHT_F, [hl] - jr nz, Func_006_44bf -Func_006_44a0: ; 184a0 (6:44a0) + bit 4, [hl] ; = and $10 + jr nz, ZeroObjectPositionsAndToggleOAMCopy_Bank6 + +.draw_cursor ; 184a0 (6:44a0) call ZeroObjectPositions - ld hl, $ce53 + ld hl, wInPlayAreaInputTablePointer ld e, [hl] inc hl ld d, [hl] - ld a, [wPrizeCardCursorPosition] + ld a, [wInPlayAreaCurPosition] ld l, a ld h, $07 call HtimesL add hl, de - ld d, [hl] + + ld d, [hl] ; x position. inc hl - ld e, [hl] + ld e, [hl] ; y position. inc hl - ld b, [hl] + ld b, [hl] ; attribute. ld c, $00 call SetOneObjectAttributes or a ret -Func_006_44bf: ; 184bf (6:44bf) +ZeroObjectPositionsAndToggleOAMCopy_Bank6 ; 184bf (6:44bf) call ZeroObjectPositions ld a, $01 ld [wVBlankOAMCopyToggle], a ret -Func_006_44c8: ; 184c8 (6:44c8) +Func_184c8: ; 184c8 (6:44c8) xor a ld [wGlossaryPageNo], a - call Func_006_452b + call Func_1852b + xor a - ld [wPrizeCardCursorPosition], a - ld de, $4c8e - ld hl, $ce53 + ld [wInPlayAreaCurPosition], a + ld de, $4c8e ; this data is stored in bank 2. + ld hl, wInPlayAreaInputTablePointer ld [hl], e inc hl ld [hl], d @@ -605,41 +746,49 @@ Func_006_44c8: ; 184c8 (6:44c8) ld [wDuelInitialPrizesUpperBitsSet], a xor a ld [wCheckMenuCursorBlinkCounter], a -.asm_006_44e5 +.next ld a, $01 ld [wVBlankOAMCopyToggle], a call DoFrame ldh a, [hKeysPressed] - and $04 - jr nz, .asm_006_4518 - farcall $2, $49ae - jr nc, .asm_006_44e5 - cp $ff - jr nz, .asm_006_4502 + and SELECT + jr nz, .on_select + + farcall Func_89ae + jr nc, .next + + cp -1 ; b button + jr nz, .check_button + farcall $2, $4aa1 ret -.asm_006_4502 + +.check_button push af - farcall $2, $4aa1 + farcall Func_8aa1 pop af - cp $09 - jr z, .asm_006_451e - call Func_006_4598 - call Func_006_452b + + cp $09 ; $09: next page or prev page + jr z, .change_page + + call Func_18598 + call Func_1852b xor a ld [wCheckMenuCursorBlinkCounter], a - jr .asm_006_44e5 -.asm_006_4518 + jr .next + +.on_select ld a, $01 farcall PlaySFXConfirmOrCancel -.asm_006_451e +.change_page ld a, [wGlossaryPageNo] - xor $01 + xor $01 ; swap page ld [wGlossaryPageNo], a - call Func_006_455a - jr .asm_006_44e5 + call Func_1855a + jr .next -Func_006_452b: ; 1852b (6:452b) +; display glossary menu. +Func_1852b: ; 1852b (6:452b) xor a ld [wTileMapFill], a call ZeroObjectPositions @@ -649,31 +798,39 @@ Func_006_452b: ; 1852b (6:452b) call EmptyScreen call Set_OBJ_8x8 farcall $2, $4992 + lb de, 5, 0 call InitTextPrinting - ldtx hl, Text02f6 + ldtx hl, PokemonCardGlossaryText call ProcessTextFromID - call Func_006_455a - ldtx hl, Text02f9 + call Func_1855a + ldtx hl, ChooseWordAndPressAButtonText call DrawWideTextBox_PrintText ret -; print glossary -Func_006_455a: ; 1855a (6:455a) +; print texts in glossary menu. +Func_1855a: ; 1855a (6:455a) ld hl, wDefaultText + ld a, TX_SYMBOL ld [hli], a + ld a, [wGlossaryPageNo] add SYM_1 ld [hli], a + ld a, TX_SYMBOL ld [hli], a + ld a, SYM_SLASH ld [hli], a + ld a, TX_SYMBOL ld [hli], a + ld a, SYM_2 ld [hli], a + ld [hl], TX_END lb de, 16, 1 @@ -685,35 +842,40 @@ Func_006_455a: ; 1855a (6:455a) call InitTextPrinting ld a, [wGlossaryPageNo] or a - jr nz, .page_two - ldtx hl, Text02f7 + + ldtx hl, GlossaryMenuPage1Text jr .page_one + .page_two - ldtx hl, Text02f8 + ldtx hl, GlossaryMenuPage2Text .page_one call ProcessTextFromID ret -Func_006_4598: ; 18598 (6:4598) +; display glossary description. +Func_18598: ; 18598 (6:4598) push af xor a ld [wTileMapFill], a call EmptyScreen lb de, 5, 0 call InitTextPrinting - ldtx hl, Text02f6 + ldtx hl, PokemonCardGlossaryText call ProcessTextFromID - ld de, $0004 - ld bc, $140e + lb de, 0, 4 + lb bc, 20, 14 call DrawRegularTextBox + ld a, [wGlossaryPageNo] or a jr nz, .back_page - ld hl, GlossaryData1 + + ld hl, GlossaryData_1 jr .front_page + .back_page - ld hl, GlossaryData2 + ld hl, GlossaryData_2 .front_page pop af ; hl += (a + (a << 2)). @@ -749,24 +911,26 @@ Func_006_4598: ; 18598 (6:4598) xor a ld [wLineSeparation], a call EnableLCD -.asm_006_45f7 +.loop call DoFrame ldh a, [hKeysPressed] and B_BUTTON - jr z, .asm_006_45f7 - ld a, $ff + jr z, .loop + + ld a, -1 farcall PlaySFXConfirmOrCancel ret ; unit: 5 bytes. ; [structure] -; horizonal align (1) / text id 1 (2) / text id 2 (2) +; horizonal align (1) / title text id (2) / desc. text id (2) glossary_entry: MACRO db \1 tx \2 tx \3 ENDM -GlossaryData1: + +GlossaryData_1: glossary_entry 7, Text02fa, Text030c glossary_entry 5, Text02fb, Text030d glossary_entry 7, Text02fc, Text030e @@ -776,7 +940,8 @@ GlossaryData1: glossary_entry 5, Text0300, Text0312 glossary_entry 7, Text0301, Text0313 glossary_entry 5, Text0302, Text0314 -GlossaryData2: + +GlossaryData_2: glossary_entry 5, Text0303, Text0315 glossary_entry 5, Text0304, Text0316 glossary_entry 5, Text0305, Text0317 @@ -787,7 +952,7 @@ GlossaryData2: glossary_entry 6, Text030a, Text031c glossary_entry 6, Text030b, Text031d -; (6:4661) +Func_18661: ; 18661 (6:4661) xor a ld [wcfe3], a ld a, [wCheckMenuCursorXPosition] @@ -796,30 +961,30 @@ GlossaryData2: ld e, a ldh a, [hDPadHeld] or a - jr z, .asm_006_46a2 + jr z, .asm_46a2 bit D_LEFT_F, a - jr nz, .asm_006_467a + jr nz, .asm_467a bit D_RIGHT_F, a - jr z, .asm_006_4680 -.asm_006_467a + jr z, .asm_4680 +.asm_467a ld a, d xor $01 ld d, a - jr .asm_006_468c -.asm_006_4680 + jr .asm_468c +.asm_4680 bit D_UP_F, a - jr nz, .asm_006_4688 + jr nz, .asm_4688 bit D_DOWN_F, a - jr z, .asm_006_46a2 -.asm_006_4688 + jr z, .asm_46a2 +.asm_4688 ld a, e xor $01 ld e, a -.asm_006_468c +.asm_468c ld a, $01 ld [wcfe3], a push de - call .asm_006_46d4 + call .asm_46d4 pop de ld a, d ld [wCheckMenuCursorXPosition], a @@ -827,28 +992,28 @@ GlossaryData2: ld [wCheckMenuCursorYPosition], a xor a ld [wCheckMenuCursorBlinkCounter], a -.asm_006_46a2 +.asm_46a2 ldh a, [hKeysPressed] - and $03 - jr z, .asm_006_46bd - and $01 - jr nz, .asm_006_46b3 + and A_BUTTON | B_BUTTON + jr z, .asm_46bd + and A_BUTTON + jr nz, .asm_46b3 ld a, $ff - call Func_006_50fb + call Func_190fb scf ret -.asm_006_46b3 - call .asm_006_46f3 +.asm_46b3 + call .asm_46f3 ld a, $01 - call Func_006_50fb + call Func_190fb scf ret -.asm_006_46bd +.asm_46bd ld a, [wcfe3] or a - jr z, .asm_006_46c6 + jr z, .asm_46c6 call PlaySFX -.asm_006_46c6 +.asm_46c6 ld hl, wCheckMenuCursorBlinkCounter ld a, [hl] inc [hl] @@ -856,10 +1021,10 @@ GlossaryData2: ret nz ld a, $0f bit D_RIGHT_F, [hl] - jr z, .asm_006_46d6 -.asm_006_46d4 ; 186d4 (6:46d4) + jr z, .asm_46d6 +.asm_46d4 ; 186d4 (6:46d4) ld a, $00 -.asm_006_46d6 +.asm_46d6 ld e, a ld a, $0a ld l, a @@ -877,22 +1042,22 @@ GlossaryData2: call WriteByteToBGMap0 or a ret -.asm_006_46f3: ; 186f3 (6:46f3) +.asm_46f3: ; 186f3 (6:46f3) ld a, $0f - jr .asm_006_46d6 + jr .asm_46d6 ; (6:46f7) INCLUDE "data/effect_commands.asm" -Func_006_4f9c: ; 18f9c (6:4f9c) +Func_18f9c: ; 18f9c (6:4f9c) ld a, [wLoadedMoveAnimation] or a ret z ld l, a ld h, 0 add hl, hl - ld de, $51a4 -.asm_006_4fa8 + ld de, Data_006_51a4 +.asm_4fa8 add hl, de ld e, [hl] inc hl @@ -901,7 +1066,7 @@ Func_006_4f9c: ; 18f9c (6:4f9c) ld hl, wce7e ld a, [hl] or a - jr nz, .asm_006_4fd3 + jr nz, .asm_4fd3 ld [hl], $01 call Func_3b21 pop de @@ -914,66 +1079,66 @@ Func_006_4f9c: ; 18f9c (6:4f9c) ld [wd4b0], a ld a, [de] cp $04 - jr z, .asm_006_4fd3 + jr z, .asm_4fd3 ld a, $96 call Func_3b6a -.asm_006_4fd3 +.asm_4fd3 pop de -.asm_006_4fd4 +.asm_4fd4 ld a, [de] inc de ld hl, PointerTable_006_508f jp JumpToFunctionInTable -Func_006_4fdc: +Func_18fdc: ; 18fdc (6:4fdc) ret -Func_006_4fdd: +Func_18fdd: ; 18fdd (6:4fdd) ldh a, [hWhoseTurn] ld [wd4af], a ld a, [wDuelType] cp $00 - jr nz, Func_006_5014 + jr nz, Func_19014 ld a, $c2 ld [wd4af], a - jr Func_006_5014 + jr Func_19014 -Func_006_4ff0: +Func_18ff0: ; 18ff0 (6:4ff0) call SwapTurn ldh a, [hWhoseTurn] ld [wd4af], a call SwapTurn ld a, [wDuelType] cp $00 - jr nz, Func_006_5014 + jr nz, Func_19014 ld a, $c3 ld [wd4af], a - jr Func_006_5014 + jr Func_19014 -Func_006_5009: +Func_19009: ; 19009 (6:5009) ld a, [wce82] and $7f ld [wd4b0], a - jr Func_006_5014 + jr Func_19014 -Func_006_5013: +Func_19013: ; 19013 (6:5013) ret -Func_006_5014: +Func_19014: ; 19014 (6:5014) ld a, [de] inc de cp $09 - jr z, .asm_006_502b + jr z, .asm_502b cp $fa - jr z, .asm_006_5057 + jr z, .asm_5057 cp $fb - jr z, .asm_006_505d + jr z, .asm_505d cp $fc - jr z, .asm_006_5063 -.asm_006_5026 + jr z, .asm_5063 +.asm_5026 call Func_3b6a - jr Func_006_4f9c.asm_006_4fd4 -.asm_006_502b + jr Func_18f9c.asm_4fd4 +.asm_502b ld a, $97 call Func_3b6a ld a, [wce81] @@ -991,104 +1156,104 @@ Func_006_5014: call Func_3b6a ld a, [wDuelDisplayedScreen] cp $01 - jr nz, .asm_006_5054 + jr nz, .asm_5054 ld a, $98 call Func_3b6a -.asm_006_5054 - jp Func_006_4f9c.asm_006_4fd4 -.asm_006_5057 +.asm_5054 + jp Func_18f9c.asm_4fd4 +.asm_5057 ld c, $61 ld b, $63 - jr .asm_006_5067 -.asm_006_505d + jr .asm_5067 +.asm_505d ld c, $62 ld b, $64 - jr .asm_006_5067 -.asm_006_5063 + jr .asm_5067 +.asm_5063 ld c, $63 ld b, $61 -.asm_006_5067 +.asm_5067 ldh a, [hWhoseTurn] cp $c2 ld a, c - jr z, .asm_006_5026 + jr z, .asm_5026 ld a, [wDuelType] cp $00 ld a, c - jr z, .asm_006_5026 + jr z, .asm_5026 ld a, b - jr .asm_006_5026 + jr .asm_5026 -Func_006_5079: +Func_19079: ; 19079 (6:5079) ld a, [de] inc de ld [$d4b3], a ld a, [wce82] ld [wd4b0], a - call Func_006_509d + call Func_1909d ld a, $96 call Func_3b6a - jp Func_006_4f9c.asm_006_4fd4 + jp Func_18f9c.asm_4fd4 PointerTable_006_508f: ; (6:508f) - dw Func_006_4fdc - dw Func_006_5014 - dw Func_006_4fdd - dw Func_006_4ff0 - dw Func_006_5079 - dw Func_006_5009 - dw Func_006_5013 - -Func_006_509d: ; 1909d (6:509d) + dw Func_18fdc + dw Func_19014 + dw Func_18fdd + dw Func_18ff0 + dw Func_19079 + dw Func_19009 + dw Func_19013 + +Func_1909d: ; 1909d (6:509d) ld a, [$d4b3] cp $04 - jr z, .asm_006_50ad + jr z, .asm_50ad cp $01 ret nz ld a, $00 ld [wd4ae], a ret -.asm_006_50ad +.asm_50ad ld a, [wd4b0] ld l, a ld a, [wWhoseTurn] ld h, a cp $c2 - jr z, .asm_006_50cc + jr z, .asm_50cc ld a, [wDuelType] cp $00 - jr z, .asm_006_50c6 + jr z, .asm_50c6 bit 7, l - jr z, .asm_006_50e2 - jr .asm_006_50d2 -.asm_006_50c6 + jr z, .asm_50e2 + jr .asm_50d2 +.asm_50c6 bit 7, l - jr z, .asm_006_50da - jr .asm_006_50ea -.asm_006_50cc + jr z, .asm_50da + jr .asm_50ea +.asm_50cc bit 7, l - jr z, .asm_006_50d2 - jr .asm_006_50e2 -.asm_006_50d2 + jr z, .asm_50d2 + jr .asm_50e2 +.asm_50d2 ld l, $04 ld h, $c2 ld a, $01 - jr .asm_006_50f0 -.asm_006_50da + jr .asm_50f0 +.asm_50da ld l, $04 ld h, $c3 ld a, $01 - jr .asm_006_50f0 -.asm_006_50e2 + jr .asm_50f0 +.asm_50e2 ld l, $05 ld h, $c3 ld a, $02 - jr .asm_006_50f0 -.asm_006_50ea + jr .asm_50f0 +.asm_50ea ld l, $05 ld h, $c2 ld a, $02 -.asm_006_50f0: +.asm_50f0: ld [wd4ae], a ret @@ -1096,36 +1261,36 @@ Func_006_509d: ; 1909d (6:509d) ; needs some fix. ld a, [$d4b3] cp $04 - jr z, Func_006_50fb.asm_006_510f -Func_006_50fb: ; 190fb (6:50fb) + jr z, Func_190fb.asm_510f +Func_190fb: ; 190fb (6:50fb) cp $01 - jr nz, .asm_006_510e + jr nz, .asm_510e ld a, $00 ld [wd4ae], a ld a, [wDuelDisplayedScreen] cp $01 - jr z, .asm_006_510e + jr z, .asm_510e bank1call DrawDuelMainScene -.asm_006_510e +.asm_510e ret -.asm_006_510f - call Func_006_509d +.asm_510f + call Func_1909d ld a, [wDuelDisplayedScreen] cp l - jr z, .asm_006_512e + jr z, .asm_512e ld a, l push af ld l, $c2 ld a, [wDuelType] cp $00 - jr nz, .asm_006_5127 + jr nz, .asm_5127 ld a, [wWhoseTurn] ld l, a -.asm_006_5127 +.asm_5127 call DrawYourOrOppPlayAreaScreen_Bank0 pop af ld [wDuelDisplayedScreen], a -.asm_006_512e +.asm_512e call DrawWideTextBox ret @@ -1135,9 +1300,9 @@ Func_006_50fb: ; 190fb (6:50fb) push de ld a, [wLoadedMoveAnimation] cp $79 - jr z, .asm_006_5164 + jr z, .asm_5164 cp $86 - jr z, .asm_006_5164 + jr z, .asm_5164 ld a, [wTempNonTurnDuelistCardID] ld e, a ld d, $00 @@ -1153,20 +1318,20 @@ Func_006_50fb: ; 190fb (6:50fb) ld a, [hli] ld h, [hl] ld l, a - call Func_006_5168 + call Func_19168 ld a, l or h call nz, DrawWideTextBox_PrintText -.asm_006_5164 +.asm_5164 pop de pop bc pop hl ret -Func_006_5168: ; 19168 (6:5168) +Func_19168: ; 19168 (6:5168) ld a, l or h - jr z, .asm_006_5188 + jr z, .asm_5188 call LoadTxRam3 ld a, [wce81] ld hl, $003a @@ -1180,7 +1345,7 @@ Func_006_5168: ; 19168 (6:5168) ret nz ld hl, $0036 ret -.asm_006_5188 +.asm_5188 call CheckNoDamageOrEffect ret c ld hl, $003b @@ -1197,7 +1362,204 @@ Func_006_5168: ; 19168 (6:5168) bank1call DrawDuelHUDs ret - INCROM $191a3, $1996e + ret + +Data_006_51a4: + dw $0000 + dw $52c6 + dw $52cf + dw $52c6 + dw $52c6 + dw $52c6 + dw $52d8 + dw $52d8 + dw $52e3 + dw $52d8 + dw $52f0 + dw $52f0 + dw $52f0 + dw $52f0 + dw $52fd + dw $5308 + dw $5313 + dw $531e + dw $5329 + dw $5334 + dw $533f + dw $534a + dw $5357 + dw $5362 + dw $5362 + dw $536d + dw $536d + dw $536d + dw $5378 + dw $5383 + dw $538e + dw $5383 + dw $5399 + dw $53a4 + dw $53af + dw $53ba + dw $53c5 + dw $53d0 + dw $53d5 + dw $53e0 + dw $53eb + dw $53f6 + dw $53f6 + dw $53f6 + dw $5401 + dw $540c + dw $5417 + dw $5422 + dw $542d + dw $542d + dw $5438 + dw $5438 + dw $5438 + dw $5438 + dw $5438 + dw $5443 + dw $5443 + dw $544e + dw $5443 + dw $5443 + dw $5443 + dw $5453 + dw $5453 + dw $5460 + dw $5453 + dw $5467 + dw $5467 + dw $5472 + dw $5472 + dw $547d + dw $5488 + dw $548f + dw $549c + dw $549c + dw $54a9 + dw $54a9 + dw $54ae + dw $54ae + dw $54b3 + dw $54be + dw $54c3 + dw $54c8 + dw $54d3 + dw $54e0 + dw $54eb + dw $54f2 + dw $54f9 + dw $5504 + dw $5513 + dw $5516 + dw $5521 + dw $552e + dw $5533 + dw $553a + dw $5543 + dw $554a + dw $5555 + dw $555e + dw $556d + dw $5574 + dw $557b + dw $557e + dw $5583 + dw $5583 + dw $5583 + dw $558c + dw $5597 + dw $559c + dw $55a1 + dw $55a4 + dw $55a9 + dw $55b4 + dw $55b4 + dw $55bf + dw $55c4 + dw $55c9 + dw $55ce + dw $55d5 + dw $55e0 + dw $55e5 + dw $55e6 + dw $55ed + dw $55f2 + dw $55fb + dw $55fe + dw $5601 + dw $5604 + dw $5607 + dw $560a + dw $560f + dw $5612 + dw $561d + dw $5628 + dw $562d + dw $5632 + dw $5637 + dw $5644 + dw $564f + dw $5654 + dw $5659 + dw $565e + dw $5665 + dw $5668 + dw $5673 + dw $5673 + + INCROM $192c6, $1991f + +Func_1991f: ; 1991f (6:591f) + add a + ld e, a + ld d, 0 + ld hl, .data + add hl, de + ld a, PLAYER_TURN + ldh [hWhoseTurn], a + ld a, [hli] + add $02 + push hl + ld hl, sDeck1Name + call Func_199e0 + pop hl + call SwapTurn + ld a, [hli] + add $02 + call LoadDeck + call SwapTurn + call EnableSRAM + ld h, $a1 + ld de, wPlayerDeck + ld c, $3c +.asm_594c + ld a, [de] + inc de + ld l, a + res 7, [hl] + dec c + jr nz, .asm_594c + + ld h, $a1 + ld de, wOpponentDeck + ld c, $1e +.asm_595b + ld a, [de] + inc de + ld l, a + res 7, [hl] + inc [hl] + dec c + jr nz, .asm_595b + + call DisableSRAM + ret +.data + db $03, $04, $05, $06, $07, $08 Func_1996e: ; 1996e (6:596e) call EnableSRAM @@ -1364,38 +1726,38 @@ Func_1a61f: ; 1a61f (6:661f) ret ; 0x1a68d -Func_006_668d: +Func_1a68d: ; 1a68d (6:668d) ld a, $c2 ; player's turn ldh [hWhoseTurn], a ld h, a ld l, $00 -.asm_006_6694 +.asm_6694 xor a ld [hli], a ld a, l cp $3c - jr c, .asm_006_6694 + jr c, .asm_6694 xor a ld hl, wBoosterCardsDrawn ld de, wDuelTempList ld c, $00 -.asm_006_66a4 +.asm_66a4 ld a, [hli] or a - jr z, .asm_006_66ae + jr z, .asm_66ae ld a, c ld [de], a inc de inc c - jr .asm_006_66a4 -.asm_006_66ae + jr .asm_66a4 +.asm_66ae ld a, $ff ld [de], a lb de, $38, $9f call SetupText bank1call InitAndDrawCardListScreenLayout - ld hl, $0056 - ld de, $0196 + ldtx hl, ChooseTheCardYouWishToExamineText + ldtx de, Text0196 bank1call SetCardListHeaderText ld a, A_BUTTON | START ld [wNoItemSelectionMenuKeys], a @@ -1405,7 +1767,7 @@ Func_006_668d: CommentedOut_1a6cc: ; 1a6cc (6:66cc) ret -Func_006_66cd: ; (6:66cd) +Func_1a6cd: ; 1a6cd (6:66cd) ldh a, [hBankSRAM] or a ret nz @@ -1416,14 +1778,14 @@ Func_006_66cd: ; (6:66cd) ld bc, $0250 ld a, [s0a000 + $b] ld e, a -.asm_006_66de +.asm_66de ld a, [hli] xor e ld e, a dec bc ld a, c or b - jr nz, .asm_006_66de + jr nz, .asm_66de ld a, e pop bc pop de @@ -1443,13 +1805,13 @@ Func_006_66cd: ; (6:66cd) bank1call SetDefaultPalettes ld a, [wConsole] cp $01 - jr nz, .asm_006_6719 + jr nz, .asm_6719 ld a, $e4 ld [wOBP0], a ld [wBGP], a ld a, $01 ld [wFlushPaletteFlags], a -.asm_006_6719 +.asm_6719 lb de, $38, $9f call SetupText ld hl, $00a3 @@ -1464,7 +1826,7 @@ Func_006_66cd: ; (6:66cd) jp Reset ret -Func_006_673a: ; (6:673a) +Func_1a73a: ; 1a73a (6:673a) ldh a, [hBankSRAM] or a ret nz @@ -1474,14 +1836,14 @@ Func_006_673a: ; (6:673a) ld hl, sCardCollection ld bc, $0250 ld e, $00 -.asm_006_6749 +.asm_6749 ld a, [hli] xor e ld e, a dec bc ld a, c or b - jr nz, .asm_006_6749 + jr nz, .asm_6749 ld a, $0a ld [$0000], a ld a, e @@ -1592,12 +1954,12 @@ InputPlayerName: ; (6:67a3) ; if pressed start button. ld a, $01 call PlayAcceptOrDeclineSFX - call Func_006_6a07 + call Func_1aa07 ld a, 6 ld [wNamingScreenCursorX], a ld a, 5 ld [wNamingScreenCursorY], a - call Func_006_6a23 + call Func_1aa23 jr .loop .else call NamingScreen_CheckButtonState @@ -1738,7 +2100,7 @@ PrintPlayerNameFromInput: sub e inc a ld e, a - ld d, $00 + ld d, 0 ; print the underbars ; before print the input. ld hl, .char_underbar @@ -1774,35 +2136,35 @@ NamingScreen_CheckButtonState: ld a, [wNamingScreenCursorY] ld l, a bit D_UP_F, b - jr z, .asm_006_692c + jr z, .asm_692c ; up dec a bit D_DOWN_F, a - jr z, .asm_006_69a7 + jr z, .asm_69a7 ld a, c dec a - jr .asm_006_69a7 -.asm_006_692c + jr .asm_69a7 +.asm_692c bit D_DOWN_F, b - jr z, .asm_006_6937 + jr z, .asm_6937 ; down inc a cp c - jr c, .asm_006_69a7 + jr c, .asm_69a7 xor a - jr .asm_006_69a7 -.asm_006_6937 + jr .asm_69a7 +.asm_6937 ld a, [wd005] ld c, a ld a, h bit D_LEFT_F, b - jr z, .asm_006_6974 + jr z, .asm_6974 ; left ld d, a ld a, $06 cp l ld a, d - jr nz, .asm_006_696b + jr nz, .asm_696b push hl push bc push af @@ -1820,31 +2182,31 @@ NamingScreen_CheckButtonState: pop hl sub d cp $ff - jr nz, .asm_006_6962 + jr nz, .asm_6962 ld a, c sub $02 - jr .asm_006_69aa -.asm_006_6962 + jr .asm_69aa +.asm_6962 cp $fe - jr nz, .asm_006_696b + jr nz, .asm_696b ld a, c sub $03 - jr .asm_006_69aa -.asm_006_696b + jr .asm_69aa +.asm_696b dec a bit D_DOWN_F, a - jr z, .asm_006_69aa + jr z, .asm_69aa ld a, c dec a - jr .asm_006_69aa -.asm_006_6974 + jr .asm_69aa +.asm_6974 bit D_RIGHT_F, b jr z, .no_press ld d, a ld a, $06 cp l ld a, d - jr nz, .asm_006_6990 + jr nz, .asm_6990 push hl push bc push af @@ -1860,30 +2222,30 @@ NamingScreen_CheckButtonState: pop bc pop hl add d -.asm_006_6990 +.asm_6990 inc a cp c - jr c, .asm_006_69aa + jr c, .asm_69aa inc c cp c - jr c, .asm_006_69a4 + jr c, .asm_69a4 inc c cp c - jr c, .asm_006_69a0 + jr c, .asm_69a0 ld a, $02 - jr .asm_006_69aa -.asm_006_69a0 + jr .asm_69aa +.asm_69a0 ld a, $01 - jr .asm_006_69aa -.asm_006_69a4 + jr .asm_69aa +.asm_69a4 xor a - jr .asm_006_69aa -.asm_006_69a7 + jr .asm_69aa +.asm_69a7 ld l, a - jr .asm_006_69ab -.asm_006_69aa + jr .asm_69ab +.asm_69aa ld h, a -.asm_006_69ab +.asm_69ab push hl call GetCharInfoFromPos_Player inc hl @@ -1891,13 +2253,13 @@ NamingScreen_CheckButtonState: inc hl ld a, [wd009] cp $02 - jr nz, .asm_006_69bb + jr nz, .asm_69bb inc hl inc hl -.asm_006_69bb +.asm_69bb ld d, [hl] push de - call Func_006_6a07 + call Func_1aa07 pop de pop hl ld a, l @@ -1914,23 +2276,23 @@ NamingScreen_CheckButtonState: .no_press ldh a, [hKeysPressed] and A_BUTTON | B_BUTTON - jr z, .asm_006_69ef + jr z, .asm_69ef and A_BUTTON - jr nz, .asm_006_69e5 + jr nz, .asm_69e5 ld a, $ff -.asm_006_69e5 +.asm_69e5 call PlayAcceptOrDeclineSFX push af - call Func_006_6a23 + call Func_1aa23 pop af scf ret -.asm_006_69ef +.asm_69ef ld a, [wcfe3] or a - jr z, .asm_006_69f8 + jr z, .asm_69f8 call PlaySFX -.asm_006_69f8 +.asm_69f8 ld hl, wCheckMenuCursorBlinkCounter ld a, [hl] inc [hl] @@ -1938,11 +2300,11 @@ NamingScreen_CheckButtonState: ret nz ld a, [wceaa] bit 4, [hl] - jr z, Func_006_6a07.asm_006_6a0a + jr z, Func_1aa07.asm_6a0a -Func_006_6a07: +Func_1aa07: ; 1aa07 (6:6a07) ld a, [wceab] -.asm_006_6a0a +.asm_6a0a ld e, a ld a, [wNamingScreenCursorX] ld h, a @@ -1954,16 +2316,16 @@ Func_006_6a07: ld b, [hl] dec b ld a, e - call Func_006_6a28 + call Func_1aa28 call WriteByteToBGMap0 or a ret -Func_006_6a23: +Func_1aa23: ; 1aa23 (6:6a23) ld a, [wceaa] - jr Func_006_6a07.asm_006_6a0a + jr Func_1aa07.asm_6a0a -Func_006_6a28: +Func_1aa28: ; 1aa28 (6:6a28) push af push bc push de @@ -1974,7 +2336,7 @@ Func_006_6a28: ld b, a ld a, [wceab] cp b - jr z, .asm_006_6a60 + jr z, .asm_6a60 ld a, [wNamingScreenBufferLength] srl a ld d, a @@ -1983,9 +2345,9 @@ Func_006_6a28: ld e, a ld a, d cp e - jr nz, .asm_006_6a49 + jr nz, .asm_6a49 dec a -.asm_006_6a49 +.asm_6a49 ld hl, wNamingScreenNamePosition add [hl] ld d, a @@ -1998,7 +2360,7 @@ Func_006_6a28: ld e, $18 ld bc, $0000 call SetOneObjectAttributes -.asm_006_6a60 +.asm_6a60 pop hl pop de pop bc @@ -2045,71 +2407,71 @@ NamingScreen_ProcessInput: cp $09 jp z, .on_end cp $07 - jr nz, .asm_006_6ab8 + jr nz, .asm_6ab8 ld a, [wd009] or a - jr nz, .asm_006_6aac + jr nz, .asm_6aac ld a, $01 - jp .asm_006_6ace -.asm_006_6aac + jp .asm_6ace +.asm_6aac dec a - jr nz, .asm_006_6ab4 + jr nz, .asm_6ab4 ld a, $02 - jp .asm_006_6ace -.asm_006_6ab4 + jp .asm_6ace +.asm_6ab4 xor a - jp .asm_006_6ace -.asm_006_6ab8 + jp .asm_6ace +.asm_6ab8 cp $08 - jr nz, .asm_006_6ad6 + jr nz, .asm_6ad6 ld a, [wd009] or a - jr nz, .asm_006_6ac6 + jr nz, .asm_6ac6 ld a, $02 - jr .asm_006_6ace -.asm_006_6ac6 + jr .asm_6ace +.asm_6ac6 dec a - jr nz, .asm_006_6acc + jr nz, .asm_6acc xor a - jr .asm_006_6ace -.asm_006_6acc + jr .asm_6ace +.asm_6acc ld a, $01 -.asm_006_6ace +.asm_6ace ld [wd009], a call DrawNamingScreenBG or a ret -.asm_006_6ad6 +.asm_6ad6 ld a, [wd009] cp $02 jr z, .read_char - ld bc, $0359 ; “ + ldfw3 bc, "“" ld a, d cp b - jr nz, .asm_006_6af4 + jr nz, .asm_6af4 ld a, e cp c - jr nz, .asm_006_6af4 + jr nz, .asm_6af4 push hl ld hl, TransitionTable1 ; from 55th. call TransformCharacter pop hl jr c, .nothing - jr .asm_006_6b09 -.asm_006_6af4 - ld bc, $035b ; º + jr .asm_6b09 +.asm_6af4 + ldfw3 bc, "º(2)" ld a, d cp b - jr nz, .asm_006_6b1d + jr nz, .asm_6b1d ld a, e cp c - jr nz, .asm_006_6b1d + jr nz, .asm_6b1d push hl ld hl, TransitionTable2 ; from 72th. call TransformCharacter pop hl jr c, .nothing -.asm_006_6b09 +.asm_6b09 ld a, [wNamingScreenBufferLength] dec a dec a @@ -2121,19 +2483,19 @@ NamingScreen_ProcessInput: add hl, de pop de ld a, [hl] - jr .asm_006_6b37 -.asm_006_6b1d + jr .asm_6b37 +.asm_6b1d ld a, d or a - jr nz, .asm_006_6b37 + jr nz, .asm_6b37 ld a, [wd009] or a - jr nz, .asm_006_6b2b + jr nz, .asm_6b2b ld a, TX_HIRAGANA - jr .asm_006_6b37 -.asm_006_6b2b + jr .asm_6b37 +.asm_6b2b ld a, TX_KATAKANA - jr .asm_006_6b37 + jr .asm_6b37 ; read character code from info. to register. ; hl: pointer. .read_char @@ -2142,12 +2504,12 @@ NamingScreen_ProcessInput: ld a, [hl] ; a: first byte of the code. or a ; if 2 bytes code, jump. - jr nz, .asm_006_6b37 + jr nz, .asm_6b37 ; if 1 byte code(ascii), ; set first byte to $0e. ld a, $0e ; on 2 bytes code. -.asm_006_6b37 +.asm_6b37 ld d, a ; de: character code. ld hl, wNamingScreenBufferLength ld a, [hl] @@ -2156,22 +2518,22 @@ NamingScreen_ProcessInput: ld hl, wNamingScreenBufferMaxLength cp [hl] pop hl - jr nz, .asm_006_6b4c + jr nz, .asm_6b4c ; if the buffer is full ; just change the last character of it. ld hl, wNamingScreenBuffer dec hl dec hl - jr .asm_006_6b51 + jr .asm_6b51 ; increase name length before add the character. -.asm_006_6b4c +.asm_6b4c inc [hl] inc [hl] ld hl, wNamingScreenBuffer ; write 2 bytes character codes to the name buffer. ; de: 2 bytes character codes. ; hl: dest. -.asm_006_6b51 +.asm_6b51 ld b, 0 add hl, bc ld [hl], d @@ -2274,67 +2636,83 @@ GetCharInfoFromPos_Player: ; unit: 6 bytes. ; structure: ; abs. y pos. (1) / abs. x pos. (1) / type 1 (1) / type 2 (1) / char. code (2) -; - unused data contains its character code as zero. +; unused data contains its character code as zero. kbitem: MACRO db \1, \2, \3, \4 +if (_NARG == 5) dw \5 +elif (\5 == TX_FULLWIDTH3) + dw (\5 << 8) | STRCAT("FW3_", \6) +else + dw (\5 << 8) | \6 +endc ENDM + KeyboardData_Player: ; (6:6baf) - kbitem $04, $02, $11, $00, $0330 - kbitem $06, $02, $12, $00, $0339 - kbitem $08, $02, $13, $00, $0342 - kbitem $0a, $02, $14, $00, $006f - kbitem $0c, $02, $15, $00, $0064 + kbitem $04, $02, $11, $00, TX_FULLWIDTH3, "A" + kbitem $06, $02, $12, $00, TX_FULLWIDTH3, "J" + kbitem $08, $02, $13, $00, TX_FULLWIDTH3, "S" + kbitem $0a, $02, $14, $00, "o" + kbitem $0c, $02, $15, $00, "d" kbitem $10, $0f, $01, $09, $0000 - kbitem $04, $04, $16, $00, $0331 - kbitem $06, $04, $17, $00, $033a - kbitem $08, $04, $18, $00, $0343 - kbitem $0a, $04, $19, $00, $035d - kbitem $0c, $04, $1a, $00, $0065 + + kbitem $04, $04, $16, $00, TX_FULLWIDTH3, "B" + kbitem $06, $04, $17, $00, TX_FULLWIDTH3, "K" + kbitem $08, $04, $18, $00, TX_FULLWIDTH3, "T" + kbitem $0a, $04, $19, $00, TX_FULLWIDTH3, "&" + kbitem $0c, $04, $1a, $00, "e" kbitem $10, $0f, $01, $09, $0000 - kbitem $04, $06, $1b, $00, $0332 - kbitem $06, $06, $1c, $00, $033b - kbitem $08, $06, $1d, $00, $0344 - kbitem $0a, $06, $1e, $00, $006a - kbitem $0c, $06, $1f, $00, $0066 + + kbitem $04, $06, $1b, $00, TX_FULLWIDTH3, "C" + kbitem $06, $06, $1c, $00, TX_FULLWIDTH3, "L" + kbitem $08, $06, $1d, $00, TX_FULLWIDTH3, "U" + kbitem $0a, $06, $1e, $00, "j" + kbitem $0c, $06, $1f, $00, "f" kbitem $10, $0f, $01, $09, $0000 - kbitem $04, $08, $20, $00, $0333 - kbitem $06, $08, $21, $00, $033c - kbitem $08, $08, $22, $00, $0345 - kbitem $0a, $08, $23, $00, $006b - kbitem $0c, $08, $24, $00, $0067 + + kbitem $04, $08, $20, $00, TX_FULLWIDTH3, "D" + kbitem $06, $08, $21, $00, TX_FULLWIDTH3, "M" + kbitem $08, $08, $22, $00, TX_FULLWIDTH3, "V" + kbitem $0a, $08, $23, $00, "k" + kbitem $0c, $08, $24, $00, "g" kbitem $10, $0f, $01, $09, $0000 - kbitem $04, $0a, $25, $00, $0334 - kbitem $06, $0a, $26, $00, $033d - kbitem $08, $0a, $27, $00, $0346 - kbitem $0a, $0a, $28, $00, $0077 - kbitem $0c, $0a, $29, $00, $0068 + + kbitem $04, $0a, $25, $00, TX_FULLWIDTH3, "E" + kbitem $06, $0a, $26, $00, TX_FULLWIDTH3, "N" + kbitem $08, $0a, $27, $00, TX_FULLWIDTH3, "W" + kbitem $0a, $0a, $28, $00, "w" + kbitem $0c, $0a, $29, $00, "h" kbitem $10, $0f, $01, $09, $0000 - kbitem $04, $0c, $2a, $00, $0335 - kbitem $06, $0c, $2b, $00, $033e - kbitem $08, $0c, $2c, $00, $0347 - kbitem $0a, $0c, $2d, $00, $0060 - kbitem $0c, $0c, $2e, $00, $0069 + + kbitem $04, $0c, $2a, $00, TX_FULLWIDTH3, "F" + kbitem $06, $0c, $2b, $00, TX_FULLWIDTH3, "O" + kbitem $08, $0c, $2c, $00, TX_FULLWIDTH3, "X" + kbitem $0a, $0c, $2d, $00, "`" + kbitem $0c, $0c, $2e, $00, "i" kbitem $10, $0f, $01, $09, $0000 - kbitem $04, $0e, $2f, $00, $0336 - kbitem $06, $0e, $30, $00, $033f - kbitem $08, $0e, $31, $00, $0348 - kbitem $0a, $0e, $32, $00, $0061 - kbitem $0c, $0e, $33, $00, $0513 + + kbitem $04, $0e, $2f, $00, TX_FULLWIDTH3, "G" + kbitem $06, $0e, $30, $00, TX_FULLWIDTH3, "P" + kbitem $08, $0e, $31, $00, TX_FULLWIDTH3, "Y" + kbitem $0a, $0e, $32, $00, "a" + kbitem $0c, $0e, $33, $00, TX_SYMBOL, SYM_No kbitem $10, $0f, $01, $09, $0000 - kbitem $04, $10, $34, $00, $0337 - kbitem $06, $10, $35, $00, $0340 - kbitem $08, $10, $36, $00, $0349 - kbitem $0a, $10, $3c, $00, $0062 - kbitem $0c, $10, $3d, $00, $0511 + + kbitem $04, $10, $34, $00, TX_FULLWIDTH3, "H" + kbitem $06, $10, $35, $00, TX_FULLWIDTH3, "Q" + kbitem $08, $10, $36, $00, TX_FULLWIDTH3, "Z" + kbitem $0a, $10, $3c, $00, "b" + kbitem $0c, $10, $3d, $00, TX_SYMBOL, SYM_Lv kbitem $10, $0f, $01, $09, $0000 - kbitem $04, $12, $37, $00, $0338 - kbitem $06, $12, $38, $00, $0341 - kbitem $08, $12, $39, $00, $006e - kbitem $0a, $12, $3a, $00, $0063 - kbitem $0c, $12, $3b, $00, $0070 + + kbitem $04, $12, $37, $00, TX_FULLWIDTH3, "I" + kbitem $06, $12, $38, $00, TX_FULLWIDTH3, "R" + kbitem $08, $12, $39, $00, "n" + kbitem $0a, $12, $3a, $00, "c" + kbitem $0c, $12, $3b, $00, "p" kbitem $10, $0f, $01, $09, $0000 kbitem $00, $00, $00, $00, $0000 + ; a set of transition datum. ; unit: 4 bytes. ; structure: @@ -2368,6 +2746,7 @@ TransitionTable1: dw $0e55, $0050 dw $0e56, $0051 dw $0000 + TransitionTable2: dw $0e2a, $0052 dw $0e2b, $0053 @@ -2414,7 +2793,7 @@ InputDeckName: ; 1ad89 (6:6d89) xor a ld [wd009], a - call Func_006_6e99 + call Func_1ae99 xor a ld [wNamingScreenCursorX], a @@ -2441,22 +2820,22 @@ InputDeckName: ; 1ad89 (6:6d89) ld a, $01 call PlayAcceptOrDeclineSFX - call Func_006_6fa1 + call Func_1afa1 ld a, 6 ld [wNamingScreenCursorX], a ld [wNamingScreenCursorY], a - call Func_006_6fbd + call Func_1afbd jr .loop .on_start - call Func_006_6efb + call Func_1aefb jr nc, .loop cp $ff - jr z, .asm_006_6e1c + jr z, .asm_6e1c - call Func_006_6ec3 + call Func_1aec3 jr nc, .loop call FinalizeInputName @@ -2475,7 +2854,7 @@ InputDeckName: ; 1ad89 (6:6d89) ld [hl], TX_END .return ret -.asm_006_6e1c +.asm_6e1c ld a, [wNamingScreenBufferLength] cp $02 jr c, .loop @@ -2551,7 +2930,7 @@ rept MAX_DECK_NAME_LENGTH endr db TX_END -Func_006_6e99: +Func_1ae99: ; 1ae99 (6:6e99) call DrawTextboxForKeyboard call ProcessTextWithUnderbar ld hl, wNamingScreenQuestionPointer @@ -2576,7 +2955,7 @@ Func_006_6e99: call EnableLCD ret -Func_006_6ec3: +Func_1aec3: ; 1aec3 (6:6ec3) ld a, [wNamingScreenCursorX] ld h, a ld a, [wNamingScreenCursorY] @@ -2586,10 +2965,10 @@ Func_006_6ec3: inc hl ld a, [hl] cp $01 - jr nz, .asm_006_6ed7 + jr nz, .asm_6ed7 scf ret -.asm_006_6ed7 +.asm_6ed7 ld d, a ld hl, wNamingScreenBufferLength ld a, [hl] @@ -2598,14 +2977,14 @@ Func_006_6ec3: ld hl, wNamingScreenBufferMaxLength cp [hl] pop hl - jr nz, .asm_006_6eeb + jr nz, .asm_6eeb ld hl, wNamingScreenBuffer dec hl - jr .asm_006_6eef -.asm_006_6eeb + jr .asm_6eef +.asm_6eeb inc [hl] ld hl, wNamingScreenBuffer -.asm_006_6eef +.asm_6eef ld b, 0 add hl, bc ld [hl], d @@ -2615,12 +2994,12 @@ Func_006_6ec3: or a ret -Func_006_6efb: +Func_1aefb: ; 1aefb (6:6efb) xor a ld [wcfe3], a ldh a, [hDPadHeld] or a - jp z, .asm_006_6f73 + jp z, .asm_6f73 ld b, a ld a, [wNamingScreenKeyboardHeight] ld c, a @@ -2629,56 +3008,56 @@ Func_006_6efb: ld a, [wNamingScreenCursorY] ld l, a bit 6, b - jr z, .asm_006_6f1f + jr z, .asm_6f1f dec a bit 7, a - jr z, .asm_006_6f4b + jr z, .asm_6f4b ld a, c dec a - jr .asm_006_6f4b -.asm_006_6f1f + jr .asm_6f4b +.asm_6f1f bit 7, b - jr z, .asm_006_6f2a + jr z, .asm_6f2a inc a cp c - jr c, .asm_006_6f4b + jr c, .asm_6f4b xor a - jr .asm_006_6f4b -.asm_006_6f2a + jr .asm_6f4b +.asm_6f2a cp $06 - jr z, .asm_006_6f73 + jr z, .asm_6f73 ld a, [wd005] ld c, a ld a, h bit 5, b - jr z, .asm_006_6f40 + jr z, .asm_6f40 dec a bit 7, a - jr z, .asm_006_6f4e + jr z, .asm_6f4e ld a, c dec a - jr .asm_006_6f4e -.asm_006_6f40 + jr .asm_6f4e +.asm_6f40 bit 4, b - jr z, .asm_006_6f73 + jr z, .asm_6f73 inc a cp c - jr c, .asm_006_6f4e + jr c, .asm_6f4e xor a - jr .asm_006_6f4e -.asm_006_6f4b + jr .asm_6f4e +.asm_6f4b ld l, a - jr .asm_006_6f4f -.asm_006_6f4e + jr .asm_6f4f +.asm_6f4e ld h, a -.asm_006_6f4f +.asm_6f4f push hl call GetCharInfoFromPos_Deck inc hl inc hl ld d, [hl] push de - call Func_006_6fa1 + call Func_1afa1 pop de pop hl ld a, l @@ -2689,29 +3068,29 @@ Func_006_6efb: ld [wCheckMenuCursorBlinkCounter], a ld a, $02 cp d - jp z, Func_006_6efb + jp z, Func_1aefb ld a, $01 ld [wcfe3], a -.asm_006_6f73 +.asm_6f73 ldh a, [hKeysPressed] and $03 - jr z, .asm_006_6f89 + jr z, .asm_6f89 and $01 - jr nz, .asm_006_6f7f + jr nz, .asm_6f7f ld a, $ff -.asm_006_6f7f +.asm_6f7f call PlayAcceptOrDeclineSFX push af - call Func_006_6fbd + call Func_1afbd pop af scf ret -.asm_006_6f89 +.asm_6f89 ld a, [wcfe3] or a - jr z, .asm_006_6f92 + jr z, .asm_6f92 call PlaySFX -.asm_006_6f92 +.asm_6f92 ld hl, wCheckMenuCursorBlinkCounter ld a, [hl] inc [hl] @@ -2719,11 +3098,11 @@ Func_006_6efb: ret nz ld a, [wceaa] bit 4, [hl] - jr z, Func_006_6fa1.asm_006_6fa4 + jr z, Func_1afa1.asm_6fa4 -Func_006_6fa1: +Func_1afa1: ; 1afa1 (6:6fa1) ld a, [wceab] -.asm_006_6fa4 +.asm_6fa4 ld e, a ld a, [wNamingScreenCursorX] ld h, a @@ -2735,16 +3114,16 @@ Func_006_6fa1: ld b, [hl] dec b ld a, e - call Func_006_6fc2 + call Func_1afc2 call WriteByteToBGMap0 or a ret -Func_006_6fbd: +Func_1afbd: ; 1afbd (6:6fbd) ld a, [wceaa] - jr Func_006_6fa1.asm_006_6fa4 + jr Func_1afa1.asm_6fa4 -Func_006_6fc2: +Func_1afc2: ; 1afc2 (6:6fc2) push af push bc push de @@ -2755,16 +3134,16 @@ Func_006_6fc2: ld b, a ld a, [wceab] cp b - jr z, .asm_006_6ffb + jr z, .asm_6ffb ld a, [wNamingScreenBufferLength] ld d, a ld a, [wNamingScreenBufferMaxLength] ld e, a ld a, d cp e - jr nz, .asm_006_6fdf + jr nz, .asm_6fdf dec a -.asm_006_6fdf +.asm_6fdf dec a ld d, a ld hl, wNamingScreenNamePosition @@ -2781,7 +3160,7 @@ Func_006_6fc2: ld e, $18 ld bc, $0000 call SetOneObjectAttributes -.asm_006_6ffb +.asm_6ffb pop hl pop de pop bc @@ -2817,12 +3196,85 @@ GetCharInfoFromPos_Deck: jr nz, .loop ret -; a bunch of data KeyboardData_Deck: ; (6:7019) - INCROM $1b019, $1b8e8 - INCROM $1b8e8, $1ba12 + db $04, $02, "A" + db $06, $02, "J" + db $08, $02, "S" + db $0a, $02, "?" + db $0c, $02, "4" + db $0e, $02, $02 + db $10, $0f, $01 + + db $04, $04, "B" + db $06, $04, "K" + db $08, $04, "T" + db $0a, $04, "&" + db $0c, $04, "5" + db $0e, $04, $02 + db $10, $0f, $01 + + db $04, $06, "C" + db $06, $06, "L" + db $08, $06, "U" + db $0a, $06, "+" + db $0c, $06, "6" + db $0e, $06, $02 + db $10, $0f, $01 + + db $04, $08, "D" + db $06, $08, "M" + db $08, $08, "V" + db $0a, $08, "-" + db $0c, $08, "7" + db $0e, $08, $02 + db $10, $0f, $01 + + db $04, $0a, "E" + db $06, $0a, "N" + db $08, $0a, "W" + db $0a, $0a, "'" + db $0c, $0a, "8" + db $0e, $0a, $02 + db $10, $0f, $01 + + db $04, $0c, "F" + db $06, $0c, "O" + db $08, $0c, "X" + db $0a, $0c, "0" + db $0c, $0c, "9" + db $0e, $0c, $02 + db $10, $0f, $01 + + db $04, $0e, "G" + db $06, $0e, "P" + db $08, $0e, "Y" + db $0a, $0e, "1" + db $0c, $0e, " " + db $0e, $0e, $02 + db $10, $0f, $01 + + db $04, $10, "H" + db $06, $10, "Q" + db $08, $10, "Z" + db $0a, $10, "2" + db $0c, $10, " " + db $0e, $10, $02 + db $10, $0f, $01 + + db $04, $12, "I" + db $06, $12, "R" + db $08, $12, "!" + db $0a, $12, "3" + db $0c, $12, " " + db $0e, $12, $02 + db $10, $0f, $01 + +; unknown data. +; needs analyze. +; (6:70d6) + INCROM $1b0d6, $1ba12 -Func_006_7a12: ; (6:7a12) +Func_1ba12: ; 1ba12 (6:7a12) push af ld [bc], a call EnableSRAM @@ -2833,10 +3285,10 @@ Func_006_7a12: ; (6:7a12) ld bc, $78e8 add hl, bc ld b, $00 -.asm_006_7a26 - call Func_006_7a4c - call Func_006_7a5b - call Func_006_7a7d +.asm_7a26 + call Func_1ba4c + call Func_1ba5b + call Func_1ba7d push hl ld de, wd0aa ld h, b @@ -2854,11 +3306,11 @@ Func_006_7a12: ; (6:7a12) inc b ld a, b cp $05 - jr nz, .asm_006_7a26 + jr nz, .asm_7a26 call DisableSRAM ret -Func_006_7a4c: +Func_1ba4c: ; 1ba4c (6:7a4c) push hl ld l, b ld h, $54 @@ -2870,7 +3322,7 @@ Func_006_7a4c: pop hl ret -Func_006_7a5b: +Func_1ba5b: ; 1ba5b (6:7a5b) push hl push bc push de @@ -2881,22 +3333,22 @@ Func_006_7a5b: pop hl ld bc, $0018 add hl, bc -.asm_006_7a67 +.asm_7a67 ld a, [de] inc de ld b, a or a - jr z, .asm_006_7a77 + jr z, .asm_7a77 ld a, [de] inc de ld c, a -.asm_006_7a70 +.asm_7a70 ld [hl], c inc hl dec b - jr nz, .asm_006_7a70 - jr .asm_006_7a67 -.asm_006_7a77 + jr nz, .asm_7a70 + jr .asm_7a67 +.asm_7a77 pop de pop bc pop hl @@ -2904,7 +3356,7 @@ Func_006_7a5b: inc hl ret -Func_006_7a7d: +Func_1ba7d: ; 1ba7d (6:7a7d) push hl push bc push de @@ -2915,14 +3367,14 @@ Func_006_7a7d: call CopyText pop hl ld de, wd089 -.asm_006_7a8d +.asm_7a8d ld a, [de] ld [hli], a or a - jr z, .asm_006_7a95 + jr z, .asm_7a95 inc de - jr .asm_006_7a8d -.asm_006_7a95 + jr .asm_7a8d +.asm_7a95 pop bc pop hl inc hl @@ -2930,61 +3382,61 @@ Func_006_7a7d: ret ; farcall from 0xb87e(2:787d): [EF|06|9A|7A] -Func_006_7a9a: ; (6:7a9a) +Func_1ba9a: ; 1ba9a (6:7a9a) xor a ld [wd0a6], a ld a, $01 -.asm_006_7aa0 - call Func_006_7ae4 +.asm_7aa0 + call Func_1bae4 ret nc sla a cp $10 - jr z, .asm_006_7aac - jr .asm_006_7aa0 -.asm_006_7aac + jr z, .asm_7aac + jr .asm_7aa0 +.asm_7aac ld a, $03 - call Func_006_7ae4 + call Func_1bae4 ret nc ld a, $05 - call Func_006_7ae4 + call Func_1bae4 ret nc ld a, $09 - call Func_006_7ae4 + call Func_1bae4 ret nc ld a, $06 - call Func_006_7ae4 + call Func_1bae4 ret nc ld a, $0a - call Func_006_7ae4 + call Func_1bae4 ret nc ld a, $0c - call Func_006_7ae4 + call Func_1bae4 ret nc ld a, $f7 -.asm_006_7ad2 - call Func_006_7ae4 +.asm_7ad2 + call Func_1bae4 ret nc sra a cp $ff - jr z, .asm_006_7ade - jr .asm_006_7ad2 -.asm_006_7ade - call Func_006_7ae4 + jr z, .asm_7ade + jr .asm_7ad2 +.asm_7ade + call Func_1bae4 ret nc scf ret -Func_006_7ae4: +Func_1bae4: ; 1bae4 (6:7ae4) push af ld hl, wd088 ld b, [hl] farcall $2, $7625 - jr c, .asm_006_7af5 + jr c, .asm_7af5 pop af ld [wd0a6], a or a ret -.asm_006_7af5 +.asm_7af5 pop af scf ret diff --git a/src/engine/bank07.asm b/src/engine/bank07.asm index a79f27a..7c53b96 100644 --- a/src/engine/bank07.asm +++ b/src/engine/bank07.asm @@ -384,7 +384,7 @@ Func_1cb18: ; 1cb18 (7:4b18) ld a, [wd42a] cp $ff call nz, $4cd4 - ld hl, wd423 + ld hl, wAnimationQueue ld c, $07 .asm_1cb3b push bc diff --git a/src/engine/effect_functions.asm b/src/engine/effect_functions.asm index ab7bd38..116d545 100644 --- a/src/engine/effect_functions.asm +++ b/src/engine/effect_functions.asm @@ -109,7 +109,7 @@ Func_2c08a: ; 2c08a (b:408a) Func_2c08c: push de push af - ld a, $11 + ld a, OPPACTION_TOSS_COIN_A_TIMES call SetOppAction_SerialSendDuelData pop af pop de @@ -130,7 +130,39 @@ SetWasUnsuccessful: ; 2c0a2 (b:40a2) ret ; 0x2c0a8 - INCROM $2c0a8, $2c0d4 +Func_2c0a8: ; 2c0a8 (b:40a8) + ldh a, [hTemp_ffa0] + push af + ldh a, [hWhoseTurn] + ldh [hTemp_ffa0], a + ld a, OPPACTION_6B30 + call SetOppAction_SerialSendDuelData + bank1call Func_4f2d + ld c, a + pop af + ldh [hTemp_ffa0], a + ld a, c + ret +; 0x2c0bd + +Func_2c0bd: ; 2c0bd (b:40bd) + call ExchangeRNG + bank1call Func_4f2d + call ShuffleDeck + ret +; 0x2c0c7 + +Func_2c0c7: ; 2c0c7 (b:40c7) + ld a, DUELVARS_DUELIST_TYPE + call GetTurnDuelistVariable + cp DUELIST_TYPE_PLAYER + jr z, .player + or a + ret +.player + scf + ret +; 0x2c0d4 ; Sets some flags for AI use ; if target poisoned @@ -184,7 +216,46 @@ Func_2c0fb: ; 2c0fb (b:40fb) ret ; 0x2c10b - INCROM $2c10b, $2c140 +Func_2c10b: ; 2c10b (b:410b) + ldh [hTempPlayAreaLocation_ff9d], a + bank1call Func_61a1 + bank1call PrintPlayAreaCardList_EnableLCD + bank1call Func_6194 + ret +; 0x2c117 + +; deal damage to all the turn holder's benched Pokemon +; input: a = amount of damage to deal to each Pokemon +DealDamageToAllBenchedPokemon: ; 2c117 (b:4117) + ld e, a + ld d, $00 + ld a, DUELVARS_NUMBER_OF_POKEMON_IN_PLAY_AREA + call GetTurnDuelistVariable + ld c, a + ld b, PLAY_AREA_ARENA + jr .skip_to_bench +.loop + push bc + call DealDamageToPlayAreaPokemon + pop bc +.skip_to_bench + inc b + dec c + jr nz, .loop + ret +; 0x2c12e + +Func_2c12e: ; 2c12e (b:412e) + ld [wLoadedMoveAnimation], a + ldh a, [hTempPlayAreaLocation_ff9d] + ld b, a + ld c, $0 ; neither WEAKNESS nor RESISTANCE + ldh a, [hWhoseTurn] + ld h, a + bank1call PlayMoveAnimation + bank1call WaitMoveAnimation + ret +; 0x2c140 ; apply a status condition of type 1 identified by register a to the target ApplySubstatus1ToDefendingCard: ; 2c140 (b:4140) diff --git a/src/engine/home.asm b/src/engine/home.asm index 6a64246..15778ca 100644 --- a/src/engine/home.asm +++ b/src/engine/home.asm @@ -3290,8 +3290,8 @@ MoveDiscardPileCardToHand: ; 1182 (0:1182) ret ; 0x11a5 -; return in the z flag whether turn holder's prize a (0-7) has been taken or not -; z: taken, nz: not taken +; return in the z flag whether turn holder's prize a (0-7) has been drawn or not +; z: drawn, nz: not drawn CheckPrizeTaken: ; 11a5 (0:11a5) ld e, a ld d, 0 @@ -4023,8 +4023,8 @@ PutHandCardInPlayArea: ; 14d2 (0:14d2) ret ; 0x14dd -; move the play area Pokemon card of the turn holder at CARD_LOCATION_PLAY_AREA + a -; to the discard pile +; move the Pokemon card of the turn holder in the +; PLAY_AREA_* location given in e to the discard pile MovePlayAreaCardToDiscardPile: ; 14dd (0:14dd) call EmptyPlayAreaSlot ld l, DUELVARS_NUMBER_OF_POKEMON_IN_PLAY_AREA @@ -4293,9 +4293,9 @@ GetNonTurnDuelistVariable: ; 1611 (0:1611) ldh a, [hWhoseTurn] ld h, OPPONENT_TURN cp PLAYER_TURN - jr z, .asm_161c + jr z, .ok ld h, PLAYER_TURN -.asm_161c +.ok ld a, [hl] ret ; 0x161e @@ -4498,17 +4498,17 @@ UseAttackOrPokemonPower: ; 1730 (0:1730) ld a, EFFECTCMDTYPE_DISCARD_ENERGY call TryExecuteEffectCommandFunction call CheckSelfConfusionDamage - jp c, DealConfusionDamageToSelf + jp c, HandleConfusionDamageToSelf call DrawDuelMainScene_PrintPokemonsAttackText call WaitForWideTextBoxInput call ExchangeRNG ld a, EFFECTCMDTYPE_REQUIRE_SELECTION call TryExecuteEffectCommandFunction - ld a, OPPACTION_DEAL_ATTACK_DAMAGE + ld a, OPPACTION_ATTACK_ANIM_AND_DAMAGE call SetOppAction_SerialSendDuelData ; fallthrough -DealAttackDamage: ; 179a (0:179a) +PlayAttackAnimation_DealAttackDamage: ; 179a (0:179a) call Func_7415 ld a, [wLoadedMoveCategory] and RESIDUAL @@ -4534,9 +4534,9 @@ DealAttackDamage: ; 179a (0:179a) call GetNonTurnDuelistVariable push de push hl - call Func_7494 + call PlayMoveAnimation call Func_741a - call Func_7484 + call WaitMoveAnimation pop hl pop de call SubstractHP @@ -4579,9 +4579,11 @@ DisplayUsePokemonPowerScreen_WaitForInput: ; 1819 (0:1819) push hl call DisplayUsePokemonPowerScreen pop hl +; fallthrough DrawWideTextBox_WaitForInput_ReturnCarry: ; 181e (0:181e) call DrawWideTextBox_WaitForInput +; fallthrough ReturnCarry: ; 1821 (0:1821) scf @@ -4592,7 +4594,9 @@ ClearNonTurnTemporaryDuelvars_ResetCarry: ; 1823 (0:1823) or a ret -DealConfusionDamageToSelf: ; 1828 (0:1828) +; called when attacker deals damage to itself due to confusion +; display the corresponding animation and deal damage to self +HandleConfusionDamageToSelf: ; 1828 (0:1828) bank1call DrawDuelMainScene ld a, 1 ld [wIsDamageToSelf], a @@ -4601,7 +4605,7 @@ DealConfusionDamageToSelf: ; 1828 (0:1828) ld a, $75 ld [wLoadedMoveAnimation], a ld a, 20 ; damage - call Func_195c + call DealConfusionDamageToSelf call Func_1bb4 call Func_6e49 bank1call ClearNonTurnTemporaryDuelvars @@ -4775,8 +4779,7 @@ Func_1955: ; 1955 (0:1955) pop af ; fallthrough -; this function appears to handle dealing damage to self due to confusion -Func_195c: ; 195c (0:195c) +DealConfusionDamageToSelf: ; 195c (0:195c) ld hl, wDamage ld [hli], a ld [hl], 0 @@ -4789,13 +4792,13 @@ Func_195c: ; 195c (0:195c) push af ld a, [wTempTurnDuelistCardID] ld [wTempNonTurnDuelistCardID], a - bank1call ApplyDamageModifiers_DamageToSelf ; switch to bank 1, but call a home func + bank1call ApplyDamageModifiers_DamageToSelf ; this is at bank 0 ld a, [wDamageEffectiveness] ld c, a ld b, $0 ld a, DUELVARS_ARENA_CARD_HP call GetTurnDuelistVariable - bank1call Func_7469 + bank1call PlayAttackAnimation_DealAttackDamageSimple call PrintKnockedOutIfHLZero pop af ld [wTempNonTurnDuelistCardID], a @@ -5042,11 +5045,11 @@ PrintKnockedOut: ; 1ad3 (0:1ad3) ret ; 0x1af3 -; seems to be a function to deal damage to a card, but can be used -; to deal damage to a benched Pokemon. +; deal damage to turn holder's Pokemon card at play area location at b (PLAY_AREA_*). +; damage to deal is given in de. ; shows the defending player's play area screen when dealing the damage -; instead of the main duel interface, and has a fixed move animation -Func_1af3: ; 1af3 (0:1af3) +; instead of the main duel interface, and has a fixed move animation. +DealDamageToPlayAreaPokemon: ; 1af3 (0:1af3) ld a, $78 ld [wLoadedMoveAnimation], a ld a, b @@ -5110,7 +5113,7 @@ Func_1af3: ; 1af3 (0:1af3) ld b, a or a ; cp PLAY_AREA_ARENA jr nz, .benched - ; add damage at de to [wDealtDamage] + ; if arena Pokemon, add damage at de to [wDealtDamage] ld hl, wDealtDamage ld a, e add [hl] @@ -5123,7 +5126,7 @@ Func_1af3: ; 1af3 (0:1af3) add DUELVARS_ARENA_CARD_HP call GetTurnDuelistVariable push af - bank1call Func_7469 + bank1call PlayAttackAnimation_DealAttackDamageSimple pop af or a jr z, .skip_knocked_out @@ -9294,14 +9297,14 @@ OpenDuelCheckMenu: ; 3096 (0:3096) call BankswitchROM ret -Func_30a6: ; 30a6 (0:30a6) +OpenInPlayAreaScreen_FromSelectButton: ; 30a6 (0:30a6) ldh a, [hBankROM] push af - ld a, BANK(Func_180d5) + ld a, BANK(OpenInPlayAreaScreen) call BankswitchROM ld a, $1 - ld [wce60], a - call Func_180d5 + ld [wInPlayAreaFromSelectButton], a + call OpenInPlayAreaScreen pop bc ld a, b call BankswitchROM @@ -10211,8 +10214,10 @@ IsPrehistoricPowerActive: ; 35b7 (0:35b7) ret ; 0x35c7 -; clears some SUBSTATUS2 conditions from the turn holder's active Pokemon -Func_35c7: ; 35c7 (0:35c7) +; clears some SUBSTATUS2 conditions from the turn holder's active Pokemon. +; more specifically, those conditions that reduce the damage from an attack +; or prevent the opposing Pokemon from attacking the substatus condition inducer. +ClearDamageReductionSubstatus2: ; 35c7 (0:35c7) ld a, DUELVARS_ARENA_CARD_SUBSTATUS2 call GetTurnDuelistVariable or a @@ -11215,19 +11220,21 @@ Func_3b31: ; 3b31 (0:3b31) call BankswitchROM ret -Func_3b52: ; 3b52 (0:3b52) +; return nc if wd42a, wd4c0, and wAnimationQueue[] are all equal to $ff +; nc means no animation is playing (or animation(s) has/have ended) +CheckAnyAnimationPlaying: ; 3b52 (0:3b52) push hl push bc ld a, [wd42a] ld hl, wd4c0 and [hl] - ld hl, wd423 - ld c, $7 -.asm_3b60 + ld hl, wAnimationQueue + ld c, ANIMATION_QUEUE_LENGTH +.loop and [hl] inc hl dec c - jr nz, .asm_3b60 + jr nz, .loop cp $ff pop bc pop hl @@ -11250,7 +11257,7 @@ Func_3b6a: ; 3b6a (0:3b6a) ld a, [wd4ac] cp [hl] jr nz, .asm_3b90 - call Func_3b52 + call CheckAnyAnimationPlaying jr nc, .asm_3b95 .asm_3b90 call $4a31 diff --git a/src/macros/text.asm b/src/macros/text.asm index dd47c02..8ad94e8 100644 --- a/src/macros/text.asm +++ b/src/macros/text.asm @@ -82,3 +82,7 @@ endc shift endr ENDM + +ldfw3: MACRO + ld \1, (TX_FULLWIDTH3 << 8) | STRCAT("FW3_", \2) +ENDM
\ No newline at end of file diff --git a/src/text/text1.asm b/src/text/text1.asm index 8789758..075a9ef 100644 --- a/src/text/text1.asm +++ b/src/text/text1.asm @@ -277,15 +277,15 @@ DiscardDescription: ; 36757 (d:6757) line "a Pokémon Power)" done -Text0042: ; 367cc (d:67cc) +WillDrawNPrizesText: ; 367cc (d:67cc) text "<RAMNAME> will draw <RAMNUM> Prize(s)." done -Text0043: ; 367e5 (d:67e5) +DrewNPrizesText: ; 367e5 (d:67e5) text "<RAMNAME> drew <RAMNUM> Prize(s)." done -Text0044: ; 367f9 (d:67f9) +DuelistPlacedACardText: ; 367f9 (d:67f9) text "<RAMNAME> placed" line "a <RAMTEXT>." done @@ -561,12 +561,12 @@ CardsText: ; 36e63 (d:6e63) text "Cards" done -Text007f: ; 36e6a (d:6e6a) +TookAllThePrizesText: ; 36e6a (d:6e6a) text "<RAMNAME> took" line "all the Prizes!" done -Text0080: ; 36e82 (d:6e82) +ThereAreNoPokemonInPlayAreaText: ; 36e82 (d:6e82) text "There are no Pokémon" line "in <RAMNAME>'s Play Area!" done diff --git a/src/text/text2.asm b/src/text/text2.asm index 8dac791..97ecf45 100644 --- a/src/text/text2.asm +++ b/src/text/text2.asm @@ -126,12 +126,12 @@ SelectPkmnOnBenchToSwitchWithActiveText: ; 38533 (e:4533) line "to switch with the Active Pokémon." done -Text010f: ; 38575 (e:4575) +SelectPokemonToPlaceInTheArenaText: ; 38575 (e:4575) text "Select a Pokémon to place" line "in the Arena." done -Text0110: ; 3859e (e:459e) +DuelistIsSelectingPokemonToPlaceInArenaText: ; 3859e (e:459e) text "<RAMNAME> is selecting a Pokémon" line "to place in the Arena." done diff --git a/src/text/text3.asm b/src/text/text3.asm index 04d0b05..60b3c25 100644 --- a/src/text/text3.asm +++ b/src/text/text3.asm @@ -619,11 +619,11 @@ Text02f5: ; 3d2e6 (f:52e6) line "very rare Pokémon cards!" done -Text02f6: ; 3d31c (f:531c) +PokemonCardGlossaryText: ; 3d31c (f:531c) text "Pokémon Card Glossary" done -Text02f7: ; 3d333 (f:5333) +GlossaryMenuPage1Text: ; 3d333 (f:5333) text "Deck Active Pokémon" line "Discard Pile Bench Pokémon" line "Hand Prizes " @@ -631,7 +631,7 @@ Text02f7: ; 3d333 (f:5333) line "Bench To next page " done -Text02f8: ; 3d3e0 (f:53e0) +GlossaryMenuPage2Text: ; 3d3e0 (f:53e0) text "Energy Card Pokémon Power " line "Trainer Card Weakness " line "Basic Pokémon Resistance" @@ -639,7 +639,7 @@ Text02f8: ; 3d3e0 (f:53e0) line "Attack To previous page" done -Text02f9: ; 3d48f (f:548f) +ChooseWordAndPressAButtonText: ; 3d48f (f:548f) text "Choose a word and press the" line "A button." done diff --git a/src/text/text_offsets.asm b/src/text/text_offsets.asm index 6e03ba2..56f1f41 100644 --- a/src/text/text_offsets.asm +++ b/src/text/text_offsets.asm @@ -67,9 +67,9 @@ TextOffsets:: ; 34000 (d:4000) textpointer Text003f ; 0x003f textpointer Text0040 ; 0x0040 textpointer DiscardDescription ; 0x0041 - textpointer Text0042 ; 0x0042 - textpointer Text0043 ; 0x0043 - textpointer Text0044 ; 0x0044 + textpointer WillDrawNPrizesText ; 0x0042 + textpointer DrewNPrizesText ; 0x0043 + textpointer DuelistPlacedACardText ; 0x0044 textpointer Text0045 ; 0x0045 textpointer Text0046 ; 0x0046 textpointer Text0047 ; 0x0047 @@ -128,8 +128,8 @@ TextOffsets:: ; 34000 (d:4000) textpointer NoneText ; 0x007c textpointer YesText ; 0x007d textpointer CardsText ; 0x007e - textpointer Text007f ; 0x007f - textpointer Text0080 ; 0x0080 + textpointer TookAllThePrizesText ; 0x007f + textpointer ThereAreNoPokemonInPlayAreaText ; 0x0080 textpointer WasKnockedOutText ; 0x0081 textpointer HavePokemonPowerText ; 0x0082 textpointer UnableToUsePkmnPowerDueToToxicGasText ; 0x0083 @@ -272,8 +272,8 @@ TextOffsets:: ; 34000 (d:4000) textpointer NoDamageOrEffectDueToTransparencyText ; 0x010c textpointer Text010d ; 0x010d textpointer SelectPkmnOnBenchToSwitchWithActiveText ; 0x010e - textpointer Text010f ; 0x010f - textpointer Text0110 ; 0x0110 + textpointer SelectPokemonToPlaceInTheArenaText ; 0x010f + textpointer DuelistIsSelectingPokemonToPlaceInArenaText ; 0x0110 textpointer Text0111 ; 0x0111 textpointer Text0112 ; 0x0112 textpointer Text0113 ; 0x0113 @@ -759,10 +759,10 @@ TextOffsets:: ; 34000 (d:4000) textpointer Text02f3 ; 0x02f3 textpointer Text02f4 ; 0x02f4 textpointer Text02f5 ; 0x02f5 - textpointer Text02f6 ; 0x02f6 - textpointer Text02f7 ; 0x02f7 - textpointer Text02f8 ; 0x02f8 - textpointer Text02f9 ; 0x02f9 + textpointer PokemonCardGlossaryText ; 0x02f6 + textpointer GlossaryMenuPage1Text ; 0x02f7 + textpointer GlossaryMenuPage2Text ; 0x02f8 + textpointer ChooseWordAndPressAButtonText ; 0x02f9 textpointer Text02fa ; 0x02fa textpointer Text02fb ; 0x02fb textpointer Text02fc ; 0x02fc diff --git a/src/wram.asm b/src/wram.asm index 9c8bfc1..d2a5ac5 100644 --- a/src/wram.asm +++ b/src/wram.asm @@ -161,7 +161,7 @@ wPlayerArenaCardChangedResistance:: ; c2ea wPlayerArenaCardSubstatus3:: ; c2eb ds $1 -; Each bit represents a prize (1 = not taken ; 0 = taken) +; each bit represents a prize that this duelist can draw (1 = not drawn ; 0 = drawn) wPlayerPrizes:: ; c2ec ds $1 @@ -780,6 +780,8 @@ wcbfa:: ; cbfa wcbfb:: ; cbfb ds $1 +; used by Func_5805 to store the remaining Prizes, so that if more than that +; amount would be taken, only the remaining amount is taken wcbfc:: ; cbfc ds $1 @@ -959,7 +961,12 @@ wSelectedMoveIndex:: ; ccc6 ; if affected by a no damage or effect substatus, this flag indicates what the cause was wNoDamageOrEffect:: ; ccc7 - ds $2 + ds $1 + +; used by CountKnockedOutPokemon and Func_5805 to store the amount +; of prizes to take (equal to the number of Pokemon knocked out) +wccc8:: ; ccc8 + ds $1 ; set to 1 if the coin toss in the confusion check is heads (CheckSelfConfusionDamage) wGotHeadsFromConfusionCheck:: ; ccc9 @@ -982,6 +989,7 @@ wIsDamageToSelf:: ; cce6 wcce7:: ; cce7 ds $1 +wcce8:: ; cce8 ds $1 ; used in CopyDeckData @@ -1385,20 +1393,35 @@ wCheckMenuPlayAreaWhichDuelist:: ; ce50 wCheckMenuPlayAreaWhichLayout:: ; ce51 ds $1 -; holds the position of the cursor -; when selecting a prize card -wPrizeCardCursorPosition:: +; 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 ds $1 +; pointer to the table which contains information for each key-press. +wInPlayAreaInputTablePointer:: ; ce53 + wce53:: ; ce53 ds $2 -; same as wDuelInitialPrizes but -; with upper 2 bits set +; same as wDuelInitialPrizes but with upper 2 bits set wDuelInitialPrizesUpperBitsSet:: ; ce55 ds $1 - ds $3 + ds $1 + +; it's used for restore the position of cursor +; when going into another view, and returning to +; the previous view. +wInPlayAreaPreservedPosition:: ; ce57 + ds $1 + +; it's used for checking if the player changed +; the cursor in the play area view. +wInPlayAreaTemporaryPosition:: ; ce58 + ds $1 wce59:: ; ce59 ds $1 @@ -1419,7 +1442,9 @@ wce5e:: ; ce5e wYourOrOppPlayAreaLastCursorPosition:: ; ce5f ds $1 -wce60:: ; ce60 +; $00 when the "In Play Area" screen has been opened from the Check menu +; $01 when the "In Play Area" screen has been opened by pressing the select button +wInPlayAreaFromSelectButton:: ; ce60 ds $1 wce61:: ; ce61 @@ -1506,7 +1531,9 @@ wcea1:: ; cea1 ds $1 -; used to blink the cursor in duel menu +; it's used when the player enters check menu, and its sub-menus. +; increases from 0x00 to 0xff. the game makes its blinking cursor by this. +; note that the check menu also contains the pokemon glossary. wCheckMenuCursorBlinkCounter:: ; cea3 ds $1 @@ -1604,8 +1631,13 @@ wcfda:: ; cfda ds $7 +; it's a flag variable being used in play-area view. +; need analysis. wcfe3:: ; cfe3 - ds $4 + ds $1 + +wcfe4:: ; cfe4 + ds $3 ; a name buffer in the naming screen. wNamingScreenBuffer:: ; cfe7 @@ -2090,8 +2122,11 @@ wd421:: ; d421 wd422:: ; d422 ds $1 -wd423:: ; d423 - ds $7 +; holds a list of animations to play +; as long as any of the slot isn't $ff, there's something to play +; it may actually not be a queue +wAnimationQueue:: ; d423 + ds ANIMATION_QUEUE_LENGTH wd42a:: ; d42a ds $1 |