diff options
Diffstat (limited to 'src')
-rw-r--r-- | src/constants/gfx_constants.asm | 2 | ||||
-rw-r--r-- | src/constants/hardware_constants.asm | 1 | ||||
-rw-r--r-- | src/engine/bank1.asm | 347 | ||||
-rw-r--r-- | src/engine/booster_packs.asm | 2 | ||||
-rw-r--r-- | src/engine/home.asm | 40 | ||||
-rw-r--r-- | src/macros/wram.asm | 2 | ||||
-rw-r--r-- | src/text/text1.asm | 2 | ||||
-rw-r--r-- | src/text/text2.asm | 8 | ||||
-rw-r--r-- | src/text/text_offsets.asm | 10 | ||||
-rw-r--r-- | src/wram.asm | 24 |
10 files changed, 386 insertions, 52 deletions
diff --git a/src/constants/gfx_constants.asm b/src/constants/gfx_constants.asm index 386e158..7ff205c 100644 --- a/src/constants/gfx_constants.asm +++ b/src/constants/gfx_constants.asm @@ -39,4 +39,4 @@ SPRITE_ANIM_BUFFER_CAPACITY EQU 16 ; sprites const SPRITE_ANIM_FIELD_0D const SPRITE_ANIM_MOVEMENT_COUNTER const SPRITE_ANIM_FIELD_0F -SPRITE_ANIM_LENGTH EQU const_value
\ No newline at end of file +SPRITE_ANIM_LENGTH EQU const_value diff --git a/src/constants/hardware_constants.asm b/src/constants/hardware_constants.asm index 0471e74..098b569 100644 --- a/src/constants/hardware_constants.asm +++ b/src/constants/hardware_constants.asm @@ -113,4 +113,3 @@ rUNKNOWN5 EQU $ff75 ; (8Fh) - Bit 4-6 (Read/Write) rUNKNOWN6 EQU $ff76 ; (00h) - Always 00h (Read Only) rUNKNOWN7 EQU $ff77 ; (00h) - Always 00h (Read Only) rIE EQU $ffff ; Interrupt Enable (R/W) - diff --git a/src/engine/bank1.asm b/src/engine/bank1.asm index 9701656..82fa6a4 100644 --- a/src/engine/bank1.asm +++ b/src/engine/bank1.asm @@ -179,8 +179,8 @@ StartDuel: ; 409f (1:409f) push af ld a, PLAYER_TURN ldh [hWhoseTurn], a - call $4a97 - call $4ad6 + call Func_4a97 + call Func_4ad6 pop af ldh [hWhoseTurn], a call Func_3b21 @@ -294,12 +294,12 @@ HandleTurn: ; 4225 (1:4225) ld [wDuelistType], a ld a, [wDuelTurns] cp 2 - jr c, .first_turn ; jump if it's the turn holder's first turn - call $70f6 + jr c, .skip_let_evolve ; jump if it's the turn holder's first turn + call SetAllPlayAreaPokemonCanEvolve -.first_turn - call $70e6 - call $4933 +.skip_let_evolve + call Func_70e6 + call Func_4933 call DrawCardFromDeck jr nc, .deck_not_empty ld a, TURN_PLAYER_LOST @@ -315,11 +315,11 @@ HandleTurn: ; 4225 (1:4225) call SwapTurn call IsClairvoyanceActive call SwapTurn - call c, $4b2c + call c, Func_4b2c jr DuelMainScene Func_4262: - call $4b2c + call Func_4b2c call Func_100b Func_4268: @@ -572,10 +572,38 @@ DuelMenu_Hand: ; 4425 (1:4425) jp PrintDuelMenu Func_4436: ; 4436 (1:4436) - INCROM $4436, $4477 + call CreateHandCardList + call $559a + ld hl, $00aa + call $5588 + ld a, $1 + ld [wcbde], a +.asm_4447 + call $55f0 + push af + ld a, [wcbdf] + or a + call nz, SortHandCardsByID + pop af + jp c, DuelMainScene + ldh a, [hTempCardIndex_ff98] + call LoadCardDataToBuffer1_FromDeckIndex + ld a, [wLoadedCard1Type] + ld c, a + bit TYPE_TRAINER_F, c + jr nz, .asm_446f + bit TYPE_ENERGY_F, c + jr nz, UseEnergyCard + call $44db + jr c, UseEnergyCard.asm_44d2 + jp DuelMainScene +.asm_446f + call UseTrainerCard + jr c, UseEnergyCard.asm_44d2 + jp DuelMainScene ; c contains the type of energy card being played -PlayerUseEnergyCard: ; 4477 (1:4477) +UseEnergyCard: ; 4477 (1:4477) ld a, c cp TYPE_ENERGY_WATER jr nz, .not_water_energy @@ -621,9 +649,11 @@ PlayerUseEnergyCard: ; 4477 (1:4477) .already_played_energy ldtx hl, OnlyOneEnergyCardText call DrawWideTextBox_WaitForInput + +.asm_44d2 call CreateHandCardList call $55be - jp $4447 + jp Func_4436.asm_4447 ; 0x44db INCROM $44db, $4585 @@ -1011,6 +1041,8 @@ _CheckIfEnoughEnergiesOfType: ; 4900 (1:4900) ret ; 0x4918 +; return carry and the corresponding text in hl if the turn holder's +; arena Pokemon card is paralyzed or asleep. CheckIfActiveCardParalyzedOrAsleep: ; 4918 (1:4918) ld a, DUELVARS_ARENA_CARD_STATUS call GetTurnDuelistVariable @@ -1021,19 +1053,264 @@ CheckIfActiveCardParalyzedOrAsleep: ; 4918 (1:4918) jr z, .asleep or a ret - .paralyzed ldtx hl, UnableDueToParalysisText jr .return_with_status_condition - .asleep ldtx hl, UnableDueToSleepText - .return_with_status_condition scf ret - INCROM $4933, $4b60 +; this handles drawing a card at the beginning of the turn among other things +Func_4933: ; 4933 (1:4933) + ld a, $01 + push hl + push de + push bc + ld [wcbe8], a + xor a + ld [wcbe9], a + ld a, DUELVARS_NUMBER_OF_CARDS_NOT_IN_DECK + call GetTurnDuelistVariable + ld a, DECK_SIZE + sub [hl] + ld hl, wcbe8 + cp [hl] + jr nc, .has_cards_left + ld [hl], a +.has_cards_left + ld a, [wcac2] + cp $07 + jr z, .asm_495f + cp $09 + jr z, .asm_495f + call EmptyScreen + call Func_4a97 +.asm_495f + ld a, $07 + ld [wcac2], a + call Func_49ca + ld a, [wcbe8] + or a + jr nz, .can_draw + ldtx hl, NoCardsInDeckCannotDraw + call DrawWideTextBox_WaitForInput + jr .done +.can_draw + ld l, a + ld h, 0 + call LoadTxRam3 + ldtx hl, DrawCardsFromTheDeck + call DrawWideTextBox_PrintText + call EnableLCD +.asm_4984 + call Func_49a8 + ld hl, wcbe9 + inc [hl] + call Func_49ed + ld a, [wcbe9] + ld hl, wcbe8 + cp [hl] + jr c, .asm_4984 + ld c, 30 +.asm_4999 + call DoFrame + call Func_67b2 + jr c, .done + dec c + jr nz, .asm_4999 +.done + pop bc + pop de + pop hl + ret +; 0x49a8 + +Func_49a8: ; 49a8 (1:49a8) + call Func_3b21 + ld e, $56 + ldh a, [hWhoseTurn] + cp PLAYER_TURN + jr z, .asm_49b5 + ld e, $57 +.asm_49b5 + ld a, e + call Func_3b6a +.asm_49b9 + call DoFrame + call Func_67b2 + jr c, .asm_49c6 + call Func_3b52 + jr c, .asm_49b9 +.asm_49c6 + call Func_3b31 + ret +; 0x49ca + +Func_49ca: ; 49ca (1:49ca) + call LoadDuelDrawCardsScreenTiles + ld hl, $4a35 + call Func_0695 + ld a, [wConsole] + cp CONSOLE_CGB + jr nz, .not_cgb + call BankswitchVRAM1 + ld hl, $4a6e + call Func_0695 + call BankswitchVRAM0 +.not_cgb + call Func_49ed.player_turn + call Func_49ed.opponent_turn + ret +; 0x49ed + +Func_49ed: ; 49ed (1:49ed) + ldh a, [hWhoseTurn] + cp PLAYER_TURN + jr nz, .opponent_turn +.player_turn + ld a, [wPlayerNumberOfCardsInHand] + ld hl, wcbe9 + add [hl] + ld d, a + ld a, DECK_SIZE + ld hl, wPlayerNumberOfCardsNotInDeck + sub [hl] + ld hl, wcbe9 + sub [hl] + ld e, a + ld a, d + lb bc, 16, 10 + call $65b7 + ld a, e + lb bc, 10, 10 + jp $65b7 +.opponent_turn + ld a, [wOpponentNumberOfCardsInHand] + ld hl, wcbe9 + add [hl] + ld d, a + ld a, DECK_SIZE + ld hl, wOpponentNumberOfCardsNotInDeck + sub [hl] + ld hl, wcbe9 + sub [hl] + ld e, a + ld a, d + lb bc, 5, 3 + call $65b7 + ld a, e + lb bc, 11, 3 + jp $65b7 +; 0x4a35 + + INCROM $4a35, $4a97 + +Func_4a97: ; 4a97 (1:4a97) + call LoadDuelHUDTiles + ld de, wDefaultText + push de + call CopyPlayerName + ld de, $b + call Func_22ae + pop hl + call Func_21c5 + ld bc, $5 + call Func_3e10 + ld de, wDefaultText + push de + call CopyOpponentName + pop hl + call Func_23c1 + push hl + add $14 + ld d, a + ld e, $00 + call Func_22ae + pop hl + call Func_21c5 + ld a, [wOpponentPortrait] + ld bc, $d01 + call Func_3e2a + call $516f + ret +; 0x4ad6 + +Func_4ad6: ; 4ad6 (1:4ad6) + lb de, 8, 8 + call Func_4ae9 + call SwapTurn + lb de, 1, 1 + call Func_4ae9 + call SwapTurn + ret +; 0x4ae9 + +Func_4ae9: ; 4ae9 (1:4ae9) + call $5f4a + ld hl, $7b + call Func_2c1b + call $5f50 + ld c, e + ld a, d + add $07 + ld b, a + inc a + inc a + ld d, a + call CountPrizes + call .asm_4b22 + inc e + inc c + ld a, DUELVARS_NUMBER_OF_POKEMON_IN_PLAY_AREA + call GetTurnDuelistVariable + ld hl, $7d + or a + jr nz, .pkmn_in_play_area + ld hl, $7c +.pkmn_in_play_area + dec d + call Func_2c1b + inc e + inc d + inc c + ld a, DUELVARS_NUMBER_OF_CARDS_NOT_IN_DECK + call GetTurnDuelistVariable + ld a, DECK_SIZE + sub [hl] +.asm_4b22 + call $65b7 + ld hl, $7e + call Func_2c1b + ret +; 0x4b2c + +Func_4b2c: ; 4b2c (1:4b2c) + ldtx hl, YouDrewText + ldh a, [hTempCardIndex_ff98] + call LoadCardDataToBuffer1_FromDeckIndex + call $5e5f + ret +; 0x4b38 + +Func_4b38: ; 4b38 (1:4b38) + ld a, [wDuelTempList] + cp -1 + ret z + call $559a + call CountCardsInDuelTempList + ld hl, $5710 + ld de, $0 + call $2799 + ldtx hl, TheCardYouReceivedText + lb de, 1, 1 + call Func_22ae + call PrintTextNoDelay + ldtx hl, YouReceivedTheseCardsText + call DrawWideTextBox_WaitForInput + ret +; 0x4b60 Func_4b60: ; 4b60 (1:4b60) call $7107 @@ -1161,7 +1438,6 @@ Func_4b60: ; 4b60 (1:4b60) ret ; 0x4c77 - INCROM $4c77, $4cd5 ; Select Basic Pokemon From Hand @@ -1304,7 +1580,16 @@ LoadPlayerDeck: ; 6793 (1:6793) ret ; 0x67b2 - INCROM $67b2, $67be +Func_67b2: ; 67b2 (1:67b2) + ld a, [wccf2] + or a + ret z + ldh a, [hButtonsHeld] + and B_BUTTON + ret z + scf + ret +; 0x67be ; related to ai taking their turn in a duel ; called multiple times during one ai turn @@ -1448,7 +1733,31 @@ ConvertTrainerCardToPokemon: db UNABLE_RETREAT ; CARD_DATA_RETREAT_COST ds $0d ; PKMN_CARD_DATA_LENGTH - (CARD_DATA_RETREAT_COST + 1) - INCROM $6df1, $7107 + INCROM $6df1, $70e6 + +Func_70e6: ; 70e6 (1:70e6) + xor a + ld [wAlreadyPlayedEnergy], a + ld [wcc0c], a + ld [wGotHeadsFromSandAttackOrSmokescreenCheck], a + ldh a, [hWhoseTurn] + ld [wcc05], a + ret +; 0x70f6 + +SetAllPlayAreaPokemonCanEvolve: ; 70f6 (1:70f6) + ld a, DUELVARS_NUMBER_OF_POKEMON_IN_PLAY_AREA + call GetTurnDuelistVariable + ld c, a + ld l, DUELVARS_ARENA_CARD_FLAGS_C2 +.next_pkmn_loop + res 5, [hl] + set CAN_EVOLVE_THIS_TURN_F, [hl] + inc l + dec c + jr nz, .next_pkmn_loop + ret +; 0x7107 ; initializes duel variables such as cards in deck and in hand, or Pokemon in play area ; player turn: [c200, c2ff] diff --git a/src/engine/booster_packs.asm b/src/engine/booster_packs.asm index 98692d8..fc24355 100644 --- a/src/engine/booster_packs.asm +++ b/src/engine/booster_packs.asm @@ -590,4 +590,4 @@ LoadRarityAmountsToWram: ; 1e4ba (7:64ba) INCLUDE "data/booster_packs.asm" - INCROM $1e640, $20000
\ No newline at end of file + INCROM $1e640, $20000 diff --git a/src/engine/home.asm b/src/engine/home.asm index cd347aa..bc47a19 100644 --- a/src/engine/home.asm +++ b/src/engine/home.asm @@ -923,15 +923,15 @@ Func_061b: Func_0663: ; 0663 (0:0663) push bc - ld bc, $d8f0 + ld bc, -10000 call Func_0686 - ld bc, $fc18 + ld bc, -1000 call Func_0686 - ld bc, $ff9c + ld bc, -100 call Func_0686 - ld bc, $fff6 + ld bc, -10 call Func_0686 - ld bc, $ffff + ld bc, -1 call Func_0686 xor a ld [de], a @@ -940,10 +940,10 @@ Func_0663: ; 0663 (0:0663) Func_0686: ; 0686 (0:0686) ld a, $2f -.asm_688 +.substract_loop inc a add hl, bc - jr c, .asm_688 + jr c, .substract_loop ld [de], a inc de ld a, l @@ -969,7 +969,7 @@ Func_069d: ; 069d (0:069d) inc hl push hl push bc - ld b, $ff + ld b, -1 .asm_6a5 inc b ld a, [hli] @@ -4334,10 +4334,10 @@ Func_189d: ; 189d (0:189d) ld de, 0 ret -; return carry and 1 into wccc9 if damage is dealt to oneself due to confusion +; return carry and 1 into wGotHeadsFromConfusionCheck if damage will be dealt to oneself due to confusion CheckSelfConfusionDamage: ; 18d7 (0:18d7) xor a - ld [wccc9], a + ld [wGotHeadsFromConfusionCheck], a ld a, DUELVARS_ARENA_CARD_STATUS call GetTurnDuelistVariable and CNF_SLP_PRZ @@ -4350,7 +4350,7 @@ CheckSelfConfusionDamage: ; 18d7 (0:18d7) call TossCoin jr c, .no_confusion_damage ld a, $1 - ld [wccc9], a + ld [wGotHeadsFromConfusionCheck], a scf ret .no_confusion_damage @@ -5585,7 +5585,17 @@ FillRectangle: ; 1f5f (0:1f5f) ret ; 0x1f96 - INCROM $1f96, $20b0 + INCROM $1f96, $208d + +; load the Deck and Hand icons for the "Draw X card(s) from the deck." screen +LoadDuelDrawCardsScreenTiles: ; 208d (0:208d) + ld hl, DuelOtherGraphics + $29 tiles + ld de, v0Tiles1 + $74 tiles + ld b, $08 + jp CopyFontsOrDuelGraphicsTiles +; 0x2098 + + INCROM $2098, $20b0 ; loads the symbols that are displayed near the names of a list of cards in the hand or discard pile LoadDuelCardSymbolTiles: ; 20b0 (0:20b0) @@ -5636,7 +5646,7 @@ LoadPlacingThePrizesScreenTiles: ; 20f0 (0:20f0) ld de, v0Tiles1 + $20 tiles ld b, $d call CopyFontsOrDuelGraphicsTiles - ; load the Deck image and the Discard Pile image + ; load the Deck and the Discard Pile icons ld hl, DuelDmgSgbSymbolGraphics + $54 tiles - $4000 ld a, [wConsole] cp CONSOLE_CGB @@ -8388,7 +8398,7 @@ HandleSandAttackOrSmokescreenSubstatus: ; 3400 (0:3400) call CheckSandAttackOrSmokescreenSubstatus ret nc call TossCoin - ld [wcc0a], a + ld [wGotHeadsFromSandAttackOrSmokescreenCheck], a ccf ret nc ldtx hl, AttackUnsuccessfulText @@ -8411,7 +8421,7 @@ CheckSandAttackOrSmokescreenSubstatus: ; 3414 (0:3414) or a ret .card_is_affected - ld a, [wcc0a] + ld a, [wGotHeadsFromSandAttackOrSmokescreenCheck] or a ret nz scf diff --git a/src/macros/wram.asm b/src/macros/wram.asm index a984255..e692a92 100644 --- a/src/macros/wram.asm +++ b/src/macros/wram.asm @@ -57,4 +57,4 @@ sprite_anim_struct: MACRO \1Field0x0d:: ds 1 \1MovementCounter:: ds 1 \1Field0x0f:: ds 1 -ENDM
\ No newline at end of file +ENDM diff --git a/src/text/text1.asm b/src/text/text1.asm index 3de6280..cb2c804 100644 --- a/src/text/text1.asm +++ b/src/text/text1.asm @@ -492,7 +492,7 @@ Text006f: ; 36ce1 (d:6ce1) line "Bench Pok`mon." done -Text0070: ; 36cfd (d:6cfd) +YouDrewText: ; 36cfd (d:6cfd) text "You drew ", TX_RAM2, "." done diff --git a/src/text/text2.asm b/src/text/text2.asm index 55abfb9..1404520 100644 --- a/src/text/text2.asm +++ b/src/text/text2.asm @@ -173,11 +173,11 @@ Text0117: ; 386f2 (e:46f2) text "Draw 1 card from the Deck." done -Text0118: ; 3870e (e:470e) +DrawCardsFromTheDeck: ; 3870e (e:470e) text "Draw ", TX_RAM3, " card(s) from the Deck." done -Text0119: ; 3872d (e:472d) +NoCardsInDeckCannotDraw: ; 3872d (e:472d) text "Cannot draw a card because" line "there are no cards in the Deck." done @@ -661,11 +661,11 @@ Text016f: ; 39a31 (e:5a31) line "in the Hand." done -Text0170: ; 39a4c (e:5a4c) +TheCardYouReceivedText: ; 39a4c (e:5a4c) text "The card you received" done -Text0171: ; 39a63 (e:5a63) +YouReceivedTheseCardsText: ; 39a63 (e:5a63) text "You received these cards:" done diff --git a/src/text/text_offsets.asm b/src/text/text_offsets.asm index 66c7a64..f2baf96 100644 --- a/src/text/text_offsets.asm +++ b/src/text/text_offsets.asm @@ -113,7 +113,7 @@ TextOffsets:: ; 34000 (d:4000) textpointer ChooseUpTo5BasicPkmnToPlaceOnBenchText ; 0x006d textpointer Text006e ; 0x006e textpointer Text006f ; 0x006f - textpointer Text0070 ; 0x0070 + textpointer YouDrewText ; 0x0070 textpointer Text0071 ; 0x0071 textpointer PlacingThePrizesText ; 0x0072 textpointer PleasePlacePrizesText ; 0x0073 @@ -281,8 +281,8 @@ TextOffsets:: ; 34000 (d:4000) textpointer Text0115 ; 0x0115 textpointer Text0116 ; 0x0116 textpointer Text0117 ; 0x0117 - textpointer Text0118 ; 0x0118 - textpointer Text0119 ; 0x0119 + textpointer DrawCardsFromTheDeck ; 0x0118 + textpointer NoCardsInDeckCannotDraw ; 0x0119 textpointer Text011a ; 0x011a textpointer Text011b ; 0x011b textpointer Text011c ; 0x011c @@ -369,8 +369,8 @@ TextOffsets:: ; 34000 (d:4000) textpointer Text016d ; 0x016d textpointer Text016e ; 0x016e textpointer Text016f ; 0x016f - textpointer Text0170 ; 0x0170 - textpointer Text0171 ; 0x0171 + textpointer TheCardYouReceivedText ; 0x0170 + textpointer YouReceivedTheseCardsText ; 0x0171 textpointer Text0172 ; 0x0172 textpointer Text0173 ; 0x0173 textpointer Text0174 ; 0x0174 diff --git a/src/wram.asm b/src/wram.asm index d9017ea..3081712 100644 --- a/src/wram.asm +++ b/src/wram.asm @@ -547,7 +547,16 @@ wSelectedDuelSubMenuScrollOffset:: ; cbd0 wcbd6:: ; cbd6 ds $1 - ds $a + ds $7 + +wcbde:: ; cbde + ds $1 + +wcbdf:: ; cbdf + ds $1 + +wcbe0:: ; cbe0 + ds $1 wcbe1:: ; cbe1 ds $1 @@ -563,7 +572,13 @@ wDuelReturnAddress:: ; cbe5 wcbe7:: ; cbe7 ds $1 - ds $5 +wcbe8:: ; cbe8 + ds $1 + +wcbe9:: ; cbe9 + ds $1 + + ds $3 wcbed:: ; cbed ds $8 @@ -601,7 +616,8 @@ wDuelInitialPrizes:: ; cc08 wDuelType:: ; cc09 ds $1 -wcc0a:: ; cc0a +; set to 1 if the coin toss during the CheckSandAttackOrSmokescreenSubstatus check is heads +wGotHeadsFromSandAttackOrSmokescreenCheck:: ; cc0a ds $1 wAlreadyPlayedEnergy:: ; cc0b @@ -714,7 +730,7 @@ wNoDamageOrEffect:: ; ccc7 ds $2 ; set to 1 if the coin toss in the confusion check is heads (CheckSelfConfusionDamage) -wccc9:: ; ccc9 +wGotHeadsFromConfusionCheck:: ; ccc9 ds $1 ds $3 |