From b0f4c725dccb621ff42552aae0809f605818e57b Mon Sep 17 00:00:00 2001 From: xCrystal Date: Wed, 19 Sep 2018 16:27:07 +0200 Subject: Document some early duel functions --- src/engine/bank01.asm | 105 +++++++++++++++++++++++++++++++++----------------- src/engine/bank03.asm | 4 +- 2 files changed, 72 insertions(+), 37 deletions(-) (limited to 'src/engine') diff --git a/src/engine/bank01.asm b/src/engine/bank01.asm index dc01bb7..1729b77 100644 --- a/src/engine/bank01.asm +++ b/src/engine/bank01.asm @@ -1822,9 +1822,9 @@ Func_4b60: ; 4b60 (1:4b60) push af ld a, PLAYER_TURN ldh [hWhoseTurn], a - call Func_4cd5 + call ChooseInitialArenaAndBenchPokemon call SwapTurn - call Func_4cd5 + call ChooseInitialArenaAndBenchPokemon call SwapTurn jp c, .asm_4c77 call Func_311d @@ -1943,13 +1943,19 @@ Func_4b60: ; 4b60 (1:4b60) db $06, $08, $0d, $03 ; 0x4cd5 -Func_4cd5: ; 4cd5 (1:4cd5) +; have the turn duelist place, at the beginning of the duel, the active Pokemon +; and 0 more bench Pokemon, all of which must be basic Pokemon cards. +; also transmits the turn holder's duelvars to the other duelist in a link duel. +; called twice, once for each duelist. +ChooseInitialArenaAndBenchPokemon: ; 4cd5 (1:4cd5) ld a, DUELVARS_DUELIST_TYPE call GetTurnDuelistVariable cp DUELIST_TYPE_PLAYER - jr z, .player_choose_arena + jr z, .choose_arena cp DUELIST_TYPE_LINK_OPP jr z, .exchange_duelvars + +; AI opponent's turn push af push hl call Func_2bc3 @@ -1959,6 +1965,7 @@ Func_4cd5: ; 4cd5 (1:4cd5) or a ret +; link opponent's turn .exchange_duelvars ldtx hl, TransmitingDataText call DrawWideTextBox_PrintText @@ -1979,7 +1986,9 @@ Func_4cd5: ; 4cd5 (1:4cd5) .error jp DuelTransmissionError -.player_choose_arena +; player's turn (either AI or link duel) +; prompt (force) the player to choose a basic Pokemon card to place in the arena +.choose_arena call EmptyScreen ld a, BOXMSG_ARENA_POKEMON call DrawDuelBoxMessage @@ -1987,16 +1996,16 @@ Func_4cd5: ; 4cd5 (1:4cd5) call DrawWideTextBox_WaitForInput ld a, $1 call DoPracticeDuelAction -.asm_4d28 +.choose_arena_loop xor a ldtx hl, PleaseChooseAnActivePokemonText - call Func_5502 - jr c, .asm_4d28 + call DisplayPlaceInitialPokemonCardsScreen + jr c, .choose_arena_loop ldh a, [hTempCardIndex_ff98] call LoadCardDataToBuffer1_FromDeckIndex ld a, $2 call DoPracticeDuelAction - jr c, .asm_4d28 + jr c, .choose_arena_loop ldh a, [hTempCardIndex_ff98] call PutHandPokemonCardInPlayArea ldh a, [hTempCardIndex_ff98] @@ -2004,6 +2013,8 @@ Func_4cd5: ; 4cd5 (1:4cd5) call DisplayCardDetailScreen jr .choose_bench +; after choosing the active Pokemon, let the player place 0 or more basic Pokemon +; cards in the bench. loop until the player decides to stop placing Pokemon cards. .choose_bench call EmptyScreen ld a, BOXMSG_BENCH_POKEMON @@ -2015,8 +2026,8 @@ Func_4cd5: ; 4cd5 (1:4cd5) .bench_loop ld a, $1 ldtx hl, ChooseYourBenchPokemonText - call Func_5502 - jr c, .asm_4d8e + call DisplayPlaceInitialPokemonCardsScreen + jr c, .bench_done ld a, DUELVARS_NUMBER_OF_POKEMON_IN_PLAY_AREA call GetTurnDuelistVariable cp MAX_PLAY_AREA_POKEMON @@ -2035,7 +2046,7 @@ Func_4cd5: ; 4cd5 (1:4cd5) call DrawWideTextBox_WaitForInput jr .bench_loop -.asm_4d8e +.bench_done ld a, $4 call DoPracticeDuelAction jr c, .bench_loop @@ -2068,7 +2079,7 @@ ShuffleDeckAndDrawSevenCards: ; 4d97 (1:4d97) push hl push bc call LoadCardDataToBuffer1_FromDeckIndex - call .check_basic_pokemon + call IsLoadedCard1BasicPokemon.skip_mysterious_fossil_clefairy_doll pop bc pop hl or b @@ -2082,13 +2093,19 @@ ShuffleDeckAndDrawSevenCards: ; 4d97 (1:4d97) scf ret -.asm_4dd1 +; return nc if the card at wLoadedCard1 is a basic Pokemon card +; MYSTERIOUS_FOSSIL and CLEFAIRY_DOLL do count as basic Pokemon cards +IsLoadedCard1BasicPokemon: ; 4dd1 (1:4dd1) ld a, [wLoadedCard1ID] cp MYSTERIOUS_FOSSIL jr z, .basic cp CLEFAIRY_DOLL jr z, .basic -.check_basic_pokemon +; fallthrough + +; return nc if the card at wLoadedCard1 is a basic Pokemon card +; MYSTERIOUS_FOSSIL and CLEFAIRY_DOLL do NOT count unless already checked +.skip_mysterious_fossil_clefairy_doll ld a, [wLoadedCard1Type] cp TYPE_ENERGY jr nc, .energy_trainer_nonbasic @@ -2098,15 +2115,17 @@ ShuffleDeckAndDrawSevenCards: ; 4d97 (1:4d97) ; basic ld a, $01 - ret + ret ; z + .energy_trainer_nonbasic xor a scf ret -.basic + +.basic ; MYSTERIOUS_FOSSIL or CLEFAIRY_DOLL ld a, $01 or a - ret + ret ; nz ; 0x4df3 DisplayNoBasicPokemonInHandScreenAndText: ; 4df3 (1:4df3) @@ -2154,7 +2173,9 @@ NoBasicPokemonCardListParameters: db SYM_SPACE ; tile behind cursor dw $0000 ; function pointer if non-0 -Func_4e40: ; 4e40 (1:4e40) +; used only during the practice duel with Sam. +; displays the list with the player's cards in hand, and the player's name above the list. +DisplayPracticeDuelPlayerHandScreen: ; 4e40 (1:4e40) call CreateHandCardList call EmptyScreen call LoadDuelCardSymbolTiles @@ -2656,7 +2677,7 @@ PracticeDuelActionTable: ; 51f8 (1:51f8) ; 0x520e Func_520e: ; 520e (1:520e) - call Func_4e40 + call DisplayPracticeDuelPlayerHandScreen call EnableLCD ldtx hl, Text01a4 jp Func_52bc @@ -2673,7 +2694,7 @@ Func_521a: ; 521a (1:521a) ; 0x522a Func_522a: ; 522a (1:522a) - call Func_4e40 + call DisplayPracticeDuelPlayerHandScreen call EnableLCD ldtx hl, Text01a6 jp Func_52bc @@ -2690,7 +2711,7 @@ Func_5236: ; 5236 (1:5236) ; 0x5245 Func_5245: ; 5245 (1:5245) - call Func_4e40 + call DisplayPracticeDuelPlayerHandScreen call EnableLCD ld a, $ff ld [wcc00], a @@ -2801,7 +2822,13 @@ DuelMenuData: ; 54e9 (1:54e9) db $ff ; 0x5502 -Func_5502: ; 5502 (1:5502) +; display the screen that prompts the player to choose a Pokemon card to +; place in the arena or in the bench at the beginning of the duel. +; input: + ; a = 0 -> prompted to place Pokemon card in arena + ; a = 1 -> prompted to place Pokemon card in bench +; return carry if no card was placed (only allowed for bench) +DisplayPlaceInitialPokemonCardsScreen: ; 5502 (1:5502) ld [wcbfd], a push hl call CreateHandCardList @@ -2810,24 +2837,30 @@ Func_5502: ; 5502 (1:5502) call SetCardListInfoBoxText ld a, PLAY_CHECK ld [wCardListItemSelectionMenuType], a -.asm_5515 +.display_card_list call DisplayCardList - jr nc, .asm_5523 + jr nc, .card_selected + ; attempted to exit screen ld a, [wcbfd] or a - jr z, .asm_5515 + ; player is forced to place a Pokemon card in the arena + jr z, .display_card_list + ; in the bench, however, we can get away without placing anything + ; alternatively, the player doesn't want or can't place more bench Pokemon scf - jr .asm_5538 -.asm_5523 + jr .done +.card_selected ldh a, [hTempCardIndex_ff98] call LoadCardDataToBuffer1_FromDeckIndex - call Func_4dd1 - jr nc, .asm_5538 + call IsLoadedCard1BasicPokemon + jr nc, .done + ; invalid card selected, tell the player and go back ldtx hl, YouCannotSelectThisCardText call DrawWideTextBox_WaitForInput call DrawCardListScreenLayout - jr .asm_5515 -.asm_5538 + jr .display_card_list +.done + ; valid basic Pokemon card selected, or no card selected (bench only) push af ld a, [wSortCardListByID] or a @@ -2903,6 +2936,8 @@ Func_5591: ; 5591 (1:5591) ; Discard Pile card list, including a bottom-right image of the current card. ; since this loads the text for the Hand card list screen, SetDiscardPileScreenTexts ; is called after this if the screen corresponds to a Discard Pile list. +; the dimensions of text box where the card list is printed are 20x13, in order to accomodate +; another text box below it (wCardListInfoBoxText) as well as the image of the selected card. InitAndDrawCardListScreenLayout: ; 559a (1:559a) xor a ld hl, wSelectedDuelSubMenuItem @@ -2953,14 +2988,14 @@ DrawCardListScreenLayout: ; 0x55f0 ; displays a list of cards and handles input in order to navigate through the list, -; select a card, open a card page... +; select a card, open a card page, etc. ; input: ; - text IDs at wCardListInfoBoxText and wCardListHeaderText ; - $ff-terminated list of cards to display at wDuelTempList ; - wSelectedDuelSubMenuItem (initial item) and wSelectedDuelSubMenuScrollOffset ; (initial page scroll offset). Usually both 0 to begin with the first card. -; returns carry if B is pressed to exit the card list screen, or the selected -; card at hTempCardIndex_ff98 and at a. +; returns carry if B is pressed to exit the card list screen. +; otherwise returns the selected card at hTempCardIndex_ff98 and at a. DisplayCardList: ; 55f0 (1:55f0) call DrawNarrowTextBox call PrintCardListHeaderAndInfoBoxTexts diff --git a/src/engine/bank03.asm b/src/engine/bank03.asm index 1c346d5..5539d38 100644 --- a/src/engine/bank03.asm +++ b/src/engine/bank03.asm @@ -1850,7 +1850,7 @@ OWScript_PrintTextCloseBox: ; cdb9 (3:4db9) Func_cdcb: ; cdcb (3:4dcb) ld a, [wd3b6] ld [wd3aa], a -Func_4dd1: ; cdd1 (3:4dd1) +Func_cdd1: ; cdd1 (3:4dd1) farcall Func_1c50a jp IncreaseOWScriptPointerBy1 @@ -1862,7 +1862,7 @@ Func_cdd8: ; cdd8 (3:4dd8) ld a, [wd696] ld [wd3ab], a call Func_39c3 - call Func_4dd1 + call Func_cdd1 pop af ld [wd3ab], a pop af -- cgit v1.2.3 From 602a9a97bce5ab51abcac33e5e464923f0d47279 Mon Sep 17 00:00:00 2001 From: xCrystal Date: Thu, 20 Sep 2018 16:58:10 +0200 Subject: Dump practice duel text table --- src/engine/bank01.asm | 134 +++++++++++++++++++++++++++++++++++++------------- 1 file changed, 101 insertions(+), 33 deletions(-) (limited to 'src/engine') diff --git a/src/engine/bank01.asm b/src/engine/bank01.asm index 1729b77..ba62547 100644 --- a/src/engine/bank01.asm +++ b/src/engine/bank01.asm @@ -2664,62 +2664,62 @@ DoPracticeDuelAction: ; 51e7 (1:51e7) PracticeDuelActionTable: ; 51f8 (1:51f8) dw $0000 - dw Func_520e - dw Func_521a - dw Func_522a - dw Func_5236 - dw Func_5245 - dw Func_5256 - dw Func_5278 - dw Func_5284 - dw Func_529b - dw Func_52b0 + dw PracticeDuel_520e + dw PracticeDuel_521a + dw PracticeDuel_522a + dw PracticeDuel_5236 + dw PracticeDuel_5245 + dw PracticeDuel_5256 + dw PracticeDuel_5278 + dw PracticeDuel_5284 + dw PracticeDuel_529b + dw PracticeDuel_52b0 ; 0x520e -Func_520e: ; 520e (1:520e) +PracticeDuel_520e: ; 520e (1:520e) call DisplayPracticeDuelPlayerHandScreen call EnableLCD - ldtx hl, Text01a4 - jp Func_52bc + ldtx hl, DrawSevenCardsPracticeDuelText + jp PrintDrMasonInstructions ; 0x521a -Func_521a: ; 521a (1:521a) +PracticeDuel_521a: ; 521a (1:521a) ld a, [wLoadedCard1ID] cp GOLDEEN ret z - ldtx hl, Text01a5 + ldtx hl, ChooseGoldeenPracticeDuelText ldtx de, DrMasonText scf - jp Func_52bc + jp PrintDrMasonInstructions ; 0x522a -Func_522a: ; 522a (1:522a) +PracticeDuel_522a: ; 522a (1:522a) call DisplayPracticeDuelPlayerHandScreen call EnableLCD - ldtx hl, Text01a6 - jp Func_52bc + ldtx hl, PutPokemonOnBenchPracticeDuelText + jp PrintDrMasonInstructions ; 0x5236 -Func_5236: ; 5236 (1:5236) +PracticeDuel_5236: ; 5236 (1:5236) ld a, DUELVARS_NUMBER_OF_POKEMON_IN_PLAY_AREA call GetTurnDuelistVariable cp 2 ret z - ldtx hl, Text01a7 + ldtx hl, ChooseStaryuPracticeDuelText scf - jp Func_52bc + jp PrintDrMasonInstructions ; 0x5245 -Func_5245: ; 5245 (1:5245) +PracticeDuel_5245: ; 5245 (1:5245) call DisplayPracticeDuelPlayerHandScreen call EnableLCD ld a, $ff ld [wcc00], a - ldtx hl, Text01a8 - jp Func_52bc + ldtx hl, PressBToFinishPracticeDuelText + jp PrintDrMasonInstructions ; 0x5256 -Func_5256: ; 5256 (1:5256) +PracticeDuel_5256: ; 5256 (1:5256) call $5351 call EnableLCD ld a, [wDuelTurns] @@ -2735,7 +2735,7 @@ Func_5256: ; 5256 (1:5256) jp $5382 ; 0x5278 -Func_5278: ; 5278 (1:5278) +PracticeDuel_5278: ; 5278 (1:5278) ld a, [wDuelTurns] srl a ld hl, $541f @@ -2743,9 +2743,9 @@ Func_5278: ; 5278 (1:5278) ret nc ; fallthrough -Func_5284: ; 5284 (1:5284) +PracticeDuel_5284: ; 5284 (1:5284) ldtx hl, Text01da - call Func_52bc + call PrintDrMasonInstructions ld a, $02 call BankswitchSRAM ld de, sCurrentDuel @@ -2756,7 +2756,7 @@ Func_5284: ; 5284 (1:5284) ret ; 0x529b -Func_529b: ; 529b (1:529b) +PracticeDuel_529b: ; 529b (1:529b) ld a, [wDuelTurns] cp 7 jr z, .asm_52a4 @@ -2769,7 +2769,7 @@ Func_529b: ; 529b (1:529b) jp $5396 ; 0x52b0 -Func_52b0: ; 52b0 (1:52b0) +PracticeDuel_52b0: ; 52b0 (1:52b0) ldh a, [hTempPlayAreaLocation_ff9d] cp PLAY_AREA_BENCH_1 ret z @@ -2778,7 +2778,8 @@ Func_52b0: ; 52b0 (1:52b0) scf ; fallthrough -Func_52bc: ; 52bc (1:52bc) +; print a text box with given the text id at hl, labeled as 'Dr. Mason' +PrintDrMasonInstructions: ; 52bc (1:52bc) push af ldtx de, DrMasonText call PrintScrollableText_WithTextBoxLabel @@ -2786,7 +2787,74 @@ Func_52bc: ; 52bc (1:52bc) ret ; 0x52c5 - INCROM $52c5, $54c8 +PracticeDuelTextPointerTable: ; 52c5 (1:52c5) + dw PracticeDuelText_52d5 + dw PracticeDuelText_52e5 + dw PracticeDuelText_52f5 + dw PracticeDuelText_5305 + dw PracticeDuelText_5315 + dw PracticeDuelText_5320 + dw PracticeDuelText_5330 + dw PracticeDuelText_533b +; 0x52d5 + +practicetext: MACRO + db \1 ; Y coord to place text + tx \2 ; help text + tx \3 ; instruction text +ENDM + +PracticeDuelText_52d5: + practicetext 2, Text01c0, Text01a9 + practicetext 5, Text01c1, Text01aa + practicetext 8, Text01c2, Text01ab + db $00 + +PracticeDuelText_52e5: + practicetext 2, Text01c3, Text01ac + practicetext 5, Text01c4, Text01ad + practicetext 8, Text01c5, Text01ae + db $00 + +PracticeDuelText_52f5: + practicetext 2, Text01c6, Text01af + practicetext 5, Text01c7, Text01b0 + practicetext 8, Text01c8, Text01b1 + db $00 + +PracticeDuelText_5305: + practicetext 2, Text01c9, Text01b2 + practicetext 5, Text01ca, Text01b3 + practicetext 8, Text01cb, Text01b4 + db $00 + +PracticeDuelText_5315: + practicetext 2, Text01cc, Text01b5 + practicetext 6, Text01cd, Text01b6 + db $00 + +PracticeDuelText_5320: + practicetext 2, Text01ce, Text01b7 + practicetext 5, Text01cf, Text01b8 + practicetext 8, Text01d0, Text01b9 + db $00 + +PracticeDuelText_5330: + practicetext 2, Text01d1, Text01ba + practicetext 5, Text01d2, Text01bb + db $00 + +PracticeDuelText_533b: + practicetext 2, Text01d3, Text01bc + practicetext 5, Text01d4, Text01bd + db $00 + +PracticeDuelText_5346: + practicetext 2, Text01d5, Text01be + practicetext 7, Text01d6, Text01bf + db $00 + + INCROM $5351, $54c8 ; display BOXMSG_PLAYERS_TURN or BOXMSG_OPPONENTS_TURN and print ; DuelistsTurnText in a textbox. also call ExchangeRNG. -- cgit v1.2.3 From 44cc025c1e122646d478edc6d73d79dbbeb59da9 Mon Sep 17 00:00:00 2001 From: xCrystal Date: Thu, 20 Sep 2018 18:33:56 +0200 Subject: Disassemble practice duel code --- src/engine/bank01.asm | 173 ++++++++++++++++++++++++++++++++++++++++++++++---- 1 file changed, 162 insertions(+), 11 deletions(-) (limited to 'src/engine') diff --git a/src/engine/bank01.asm b/src/engine/bank01.asm index ba62547..1237c3d 100644 --- a/src/engine/bank01.asm +++ b/src/engine/bank01.asm @@ -2720,36 +2720,36 @@ PracticeDuel_5245: ; 5245 (1:5245) ; 0x5256 PracticeDuel_5256: ; 5256 (1:5256) - call $5351 + call Func_5351 call EnableLCD ld a, [wDuelTurns] ld hl, wcc00 cp [hl] ld [hl], a ld a, $00 - jp nz, $5382 + jp nz, Func_5382 ldtx de, DrMasonText - ldtx hl, Text01d9 + ldtx hl, NeedPracticeAgainPracticeDuelText call PrintScrollableText_WithTextBoxLabel_NoWait call YesOrNoMenu - jp $5382 + jp Func_5382 ; 0x5278 PracticeDuel_5278: ; 5278 (1:5278) ld a, [wDuelTurns] srl a - ld hl, $541f + ld hl, PointerTable_541f call JumpToFunctionInTable ret nc ; fallthrough PracticeDuel_5284: ; 5284 (1:5284) - ldtx hl, Text01da + ldtx hl, ThisIsPracticeModePracticeDuelText call PrintDrMasonInstructions ld a, $02 call BankswitchSRAM ld de, sCurrentDuel - call $66ff + call LoadSavedDuelData xor a call BankswitchSRAM scf @@ -2763,10 +2763,10 @@ PracticeDuel_529b: ; 529b (1:529b) or a ret .asm_52a4 - call $5351 + call Func_5351 call EnableLCD - ld hl, $5346 - jp $5396 + ld hl, PracticeDuelText_5346 + jp Func_5396 ; 0x52b0 PracticeDuel_52b0: ; 52b0 (1:52b0) @@ -2854,7 +2854,158 @@ PracticeDuelText_5346: practicetext 7, Text01d6, Text01bf db $00 - INCROM $5351, $54c8 +Func_5351: ; 5351 (1:5351) + call EmptyScreen + lb de, 0, 0 + lb bc, 20, 12 + call DrawRegularTextBox +; fallthrough + +Func_535d: ; 535d (1:535d) + ld a, [wDuelTurns] + cp 7 + jr z, .replace_due_to_knockout + ; load the player's turn number to TX_RAM3 in order to print it + srl a + inc a + ld l, a + ld h, $00 + call LoadTxRam3 + lb de, 1, 0 + call InitTextPrinting + ldtx hl, PlayersTurnPracticeDuelText + jp PrintText +.replace_due_to_knockout + lb de, 1, 0 + ldtx hl, ReplaceDueToKnockoutPracticeDuelText + jp InitTextPrinting_ProcessTextFromID +; 0x5382 + +Func_5382: ; 5382 (1:5382) + push af + ld a, [wDuelTurns] + and %11111110 + ld e, a + ld d, $00 + ld hl, PracticeDuelTextPointerTable + add hl, de + ld a, [hli] + ld h, [hl] + ld l, a + pop af + or a + jr nz, Func_53da +; fallthrough + +Func_5396: ; 5396 (1:5396) + xor a + ld [wcbca], a + ld a, l + ld [wcc01], a + ld a, h + ld [wcc01 + 1], a +.asm_53a2 + call Func_53fa + ld a, [hli] + ld [wcbca], a + or a + jr z, Func_53d3 + ld e, [hl] + inc hl + ld d, [hl] + inc hl + push hl + ld l, e + ld h, d + ldtx de, DrMasonText + call PrintScrollableText_WithTextBoxLabel + pop hl + ld e, [hl] + inc hl + ld d, [hl] + inc hl + push hl + call SetNoLineSeparation + ld l, e + ld h, d + ld a, [wcbca] + ld e, a + ld d, 1 + call InitTextPrinting_ProcessTextFromID + call SetOneLineSeparation + pop hl + jr .asm_53a2 + +Func_53d3: ; 53d3 (1:53d3) + ldtx hl, LetsPlayTheGamePracticeDuelText + call PrintDrMasonInstructions + ret + +Func_53da: ; 53da (1:53da) + ld a, [hli] + or a + jr z, Func_53d3 + ld e, a + ld d, 1 + call Func_53e6 + jr Func_53da +; 0x53e6 + +Func_53e6: ; 53e6 (1:53e6) + inc hl + inc hl + ld c, [hl] + inc hl + ld b, [hl] + inc hl + push hl + ld l, c + ld h, b + call SetNoLineSeparation + call InitTextPrinting_ProcessTextFromID + call SetOneLineSeparation + pop hl + ret +; 0x53fa + +Func_53fa: ; 53fa (1:53fa) + ld a, $01 + ldh [hffb0], a + push hl + call Func_535d + ld hl, wcc01 + ld a, [hli] + ld h, [hl] + ld l, a +.asm_5408 + ld a, [wcbca] + cp [hl] + jr c, .asm_541a + ld a, [hli] + or a + jr z, .asm_541a + ld e, a + ld d, $01 + call Func_53e6 + jr .asm_5408 +.asm_541a + pop hl + xor a + ldh [hffb0], a + ret +; 0x541f + +PointerTable_541f: ; 541f (1:541f) + dw $542f + dw $5438 + dw $5454 + dw $5467 + dw $5488 + dw $549c + dw $54b7 + dw $54b7 + + INCROM $542f, $54c8 ; display BOXMSG_PLAYERS_TURN or BOXMSG_OPPONENTS_TURN and print ; DuelistsTurnText in a textbox. also call ExchangeRNG. -- cgit v1.2.3 From 2bf36c743705e426b68d1a053ebcc99c15e2aa33 Mon Sep 17 00:00:00 2001 From: xCrystal Date: Thu, 20 Sep 2018 20:31:02 +0200 Subject: Finish disassembling and begin documenting practice duel code --- src/engine/bank01.asm | 220 +++++++++++++++++++++++++++++++++++++------------- 1 file changed, 165 insertions(+), 55 deletions(-) (limited to 'src/engine') diff --git a/src/engine/bank01.asm b/src/engine/bank01.asm index 1237c3d..767e6a0 100644 --- a/src/engine/bank01.asm +++ b/src/engine/bank01.asm @@ -2664,75 +2664,78 @@ DoPracticeDuelAction: ; 51e7 (1:51e7) PracticeDuelActionTable: ; 51f8 (1:51f8) dw $0000 - dw PracticeDuel_520e - dw PracticeDuel_521a - dw PracticeDuel_522a - dw PracticeDuel_5236 - dw PracticeDuel_5245 - dw PracticeDuel_5256 + dw PracticeDuel_DrawSevenCards + dw PracticeDuel_PlayGoldeen + dw PracticeDuel_PutStaryuInBench + dw PracticeDuel_VerifyInitialPlay + dw PracticeDuel_DonePuttingOnBench + dw PracticeDuel_PrintTurnInstructions dw PracticeDuel_5278 dw PracticeDuel_5284 dw PracticeDuel_529b dw PracticeDuel_52b0 ; 0x520e -PracticeDuel_520e: ; 520e (1:520e) +PracticeDuel_DrawSevenCards: ; 520e (1:520e) call DisplayPracticeDuelPlayerHandScreen call EnableLCD ldtx hl, DrawSevenCardsPracticeDuelText - jp PrintDrMasonInstructions + jp PrintPracticeDuelDrMasonInstructions ; 0x521a -PracticeDuel_521a: ; 521a (1:521a) +PracticeDuel_PlayGoldeen: ; 521a (1:521a) ld a, [wLoadedCard1ID] cp GOLDEEN ret z ldtx hl, ChooseGoldeenPracticeDuelText ldtx de, DrMasonText scf - jp PrintDrMasonInstructions + jp PrintPracticeDuelDrMasonInstructions ; 0x522a -PracticeDuel_522a: ; 522a (1:522a) +PracticeDuel_PutStaryuInBench: ; 522a (1:522a) call DisplayPracticeDuelPlayerHandScreen call EnableLCD ldtx hl, PutPokemonOnBenchPracticeDuelText - jp PrintDrMasonInstructions + jp PrintPracticeDuelDrMasonInstructions ; 0x5236 -PracticeDuel_5236: ; 5236 (1:5236) +PracticeDuel_VerifyInitialPlay: ; 5236 (1:5236) ld a, DUELVARS_NUMBER_OF_POKEMON_IN_PLAY_AREA call GetTurnDuelistVariable cp 2 ret z ldtx hl, ChooseStaryuPracticeDuelText scf - jp PrintDrMasonInstructions + jp PrintPracticeDuelDrMasonInstructions ; 0x5245 -PracticeDuel_5245: ; 5245 (1:5245) +PracticeDuel_DonePuttingOnBench: ; 5245 (1:5245) call DisplayPracticeDuelPlayerHandScreen call EnableLCD ld a, $ff - ld [wcc00], a + ld [wPracticeDuelTurn], a ldtx hl, PressBToFinishPracticeDuelText - jp PrintDrMasonInstructions + jp PrintPracticeDuelDrMasonInstructions ; 0x5256 -PracticeDuel_5256: ; 5256 (1:5256) - call Func_5351 +PracticeDuel_PrintTurnInstructions: ; 5256 (1:5256) + call DrawPracticeDuelInstructionsTextBox call EnableLCD ld a, [wDuelTurns] - ld hl, wcc00 + ld hl, wPracticeDuelTurn cp [hl] ld [hl], a - ld a, $00 - jp nz, Func_5382 + ; calling PrintPracticeDuelInstructionsForCurrentTurn with a = 0 means that Dr. Mason's + ; instructions are also printed along with each of the point-by-point instructions + ld a, 0 + jp nz, PrintPracticeDuelInstructionsForCurrentTurn + ; practice duel over ldtx de, DrMasonText ldtx hl, NeedPracticeAgainPracticeDuelText call PrintScrollableText_WithTextBoxLabel_NoWait call YesOrNoMenu - jp Func_5382 + jp PrintPracticeDuelInstructionsForCurrentTurn ; 0x5278 PracticeDuel_5278: ; 5278 (1:5278) @@ -2745,7 +2748,7 @@ PracticeDuel_5278: ; 5278 (1:5278) PracticeDuel_5284: ; 5284 (1:5284) ldtx hl, ThisIsPracticeModePracticeDuelText - call PrintDrMasonInstructions + call PrintPracticeDuelDrMasonInstructions ld a, $02 call BankswitchSRAM ld de, sCurrentDuel @@ -2763,10 +2766,10 @@ PracticeDuel_529b: ; 529b (1:529b) or a ret .asm_52a4 - call Func_5351 + call DrawPracticeDuelInstructionsTextBox call EnableLCD ld hl, PracticeDuelText_5346 - jp Func_5396 + jp PrintPracticeDuelInstructions ; 0x52b0 PracticeDuel_52b0: ; 52b0 (1:52b0) @@ -2779,7 +2782,7 @@ PracticeDuel_52b0: ; 52b0 (1:52b0) ; fallthrough ; print a text box with given the text id at hl, labeled as 'Dr. Mason' -PrintDrMasonInstructions: ; 52bc (1:52bc) +PrintPracticeDuelDrMasonInstructions: ; 52bc (1:52bc) push af ldtx de, DrMasonText call PrintScrollableText_WithTextBoxLabel @@ -2799,9 +2802,9 @@ PracticeDuelTextPointerTable: ; 52c5 (1:52c5) ; 0x52d5 practicetext: MACRO - db \1 ; Y coord to place text - tx \2 ; help text - tx \3 ; instruction text + db \1 ; Y coord to place the point-by-point instruction + tx \2 ; Dr. Mason's instruction + tx \3 ; Static point-by-point instruction ENDM PracticeDuelText_52d5: @@ -2854,14 +2857,17 @@ PracticeDuelText_5346: practicetext 7, Text01d6, Text01bf db $00 -Func_5351: ; 5351 (1:5351) +; in a practice duel, draws the text box where the point-by-point +; instructions for the next player action will be written into +DrawPracticeDuelInstructionsTextBox: ; 5351 (1:5351) call EmptyScreen lb de, 0, 0 lb bc, 20, 12 call DrawRegularTextBox ; fallthrough -Func_535d: ; 535d (1:535d) +; print "'s Turn [wDuelTurns]" (usually) as the textbox label +PrintPracticeDuelInstructionsTextBoxLabel: ; 535d (1:535d) ld a, [wDuelTurns] cp 7 jr z, .replace_due_to_knockout @@ -2881,7 +2887,11 @@ Func_535d: ; 535d (1:535d) jp InitTextPrinting_ProcessTextFromID ; 0x5382 -Func_5382: ; 5382 (1:5382) +; print the instructions of the current practice duel turn, taken from +; one of the structs in PracticeDuelTextPointerTable. +; if a != 0, only the point-by-point instructions are printed, otherwise +; Dr. Mason instructions are also shown in a textbox at the bottom of the screen. +PrintPracticeDuelInstructionsForCurrentTurn: ; 5382 (1:5382) push af ld a, [wDuelTurns] and %11111110 @@ -2894,10 +2904,13 @@ Func_5382: ; 5382 (1:5382) ld l, a pop af or a - jr nz, Func_53da + jr nz, PrintPracticeDuelInstructions_Debug ; fallthrough -Func_5396: ; 5396 (1:5396) +; print practice duel instructions given hl = PracticeDuelText_* +; each practicetext entry (see above) contains a Dr. Mason text along with +; a numbered instruction text, that is later printed without text delay. +PrintPracticeDuelInstructions: ; 5396 (1:5396) xor a ld [wcbca], a ld a, l @@ -2909,7 +2922,7 @@ Func_5396: ; 5396 (1:5396) ld a, [hli] ld [wcbca], a or a - jr z, Func_53d3 + jr z, PrintPracticeDuelLetsPlayTheGame ld e, [hl] inc hl ld d, [hl] @@ -2936,22 +2949,28 @@ Func_5396: ; 5396 (1:5396) pop hl jr .asm_53a2 -Func_53d3: ; 53d3 (1:53d3) +; print the generic Dr. Mason's text that completes all his practice duel instructions +PrintPracticeDuelLetsPlayTheGame: ; 53d3 (1:53d3) ldtx hl, LetsPlayTheGamePracticeDuelText - call PrintDrMasonInstructions + call PrintPracticeDuelDrMasonInstructions ret -Func_53da: ; 53da (1:53da) +; simplified version of PrintPracticeDuelInstructions that skips Dr. Mason's text +; and instead places the point-by-point instructions all at once. +; doesn't appear to be ever used, so it was probably used for testing during development. +PrintPracticeDuelInstructions_Debug: ; 53da (1:53da) ld a, [hli] or a - jr z, Func_53d3 + jr z, PrintPracticeDuelLetsPlayTheGame ld e, a ld d, 1 - call Func_53e6 - jr Func_53da + call PrintPracticeDuelNumberedInstruction + jr PrintPracticeDuelInstructions_Debug ; 0x53e6 -Func_53e6: ; 53e6 (1:53e6) +; print a practice duel point-by-point instruction at d,e, with text id at hl, +; that has been read from an entry of PracticeDuelText_* +PrintPracticeDuelNumberedInstruction: ; 53e6 (1:53e6) inc hl inc hl ld c, [hl] @@ -2972,7 +2991,7 @@ Func_53fa: ; 53fa (1:53fa) ld a, $01 ldh [hffb0], a push hl - call Func_535d + call PrintPracticeDuelInstructionsTextBoxLabel ld hl, wcc01 ld a, [hli] ld h, [hl] @@ -2986,7 +3005,7 @@ Func_53fa: ; 53fa (1:53fa) jr z, .asm_541a ld e, a ld d, $01 - call Func_53e6 + call PrintPracticeDuelNumberedInstruction jr .asm_5408 .asm_541a pop hl @@ -2996,16 +3015,107 @@ Func_53fa: ; 53fa (1:53fa) ; 0x541f PointerTable_541f: ; 541f (1:541f) - dw $542f - dw $5438 - dw $5454 - dw $5467 - dw $5488 - dw $549c - dw $54b7 - dw $54b7 - - INCROM $542f, $54c8 + dw Func_542f + dw Func_5438 + dw Func_5454 + dw Func_5467 + dw Func_5488 + dw Func_549c + dw Func_54b7 + dw Func_54b7 + +Func_542f: ; 542f (1:542f) + ld a, [wTempCardID_ccc2] + cp GOLDEEN + jp nz, Func_54c6 + ret +; 0x5438 + +Func_5438: ; 5438 (1:5438) + ld a, [wTempCardID_ccc2] + cp SEAKING + jp nz, Func_54c6 + ld a, [wSelectedMoveIndex] + cp 1 + jp nz, Func_54c6 + ld e, PLAY_AREA_ARENA + call GetPlayAreaCardAttachedEnergies + ld a, [wAttachedEnergies + PSYCHIC] + or a + jr z, Func_54c6 + ret +; 0x5454 + +Func_5454: ; 5454 (1:5454) + ld a, [wTempCardID_ccc2] + cp SEAKING + jr nz, Func_54c6 + ld e, PLAY_AREA_BENCH_1 + call GetPlayAreaCardAttachedEnergies + ld a, [wAttachedEnergies + WATER] + or a + jr z, Func_54c6 + ret +; 0x5467 + +Func_5467: ; 5467 (1:5467) + ld a, [wPlayerNumberOfPokemonInPlayArea] + cp 3 + jr nz, Func_54c6 + ld e, PLAY_AREA_BENCH_2 + call GetPlayAreaCardAttachedEnergies + ld a, [wAttachedEnergies + WATER] + or a + jr z, Func_54c6 + ld a, [wTempCardID_ccc2] + cp SEAKING + jr nz, Func_54c6 + ld a, [wSelectedMoveIndex] + cp 1 + jr nz, Func_54c6 + ret +; 0x5488 + +Func_5488: ; 5488 (1:5488) + ld e, PLAY_AREA_ARENA + call GetPlayAreaCardAttachedEnergies + ld a, [wAttachedEnergies + WATER] + cp 2 + jr nz, Func_54c6 + ld a, [wTempCardID_ccc2] + cp STARYU + jr nz, Func_54c6 + ret +; 0x549c + +Func_549c: ; 549c (1:549c) + ld e, PLAY_AREA_ARENA + call GetPlayAreaCardAttachedEnergies + ld a, [wAttachedEnergies + WATER] + cp 3 + jr nz, Func_54c6 + ld a, [wPlayerArenaCardHP] + cp 40 + jr nz, Func_54c6 + ld a, [wTempCardID_ccc2] + cp STARYU + jr nz, Func_54c6 + ret +; 0x54b7 + +Func_54b7: ; 54b7 (1:54b7) + ld a, [wTempCardID_ccc2] + cp STARMIE + jr nz, Func_54c6 + ld a, [wSelectedMoveIndex] + cp 1 + jr nz, Func_54c6 + ret + +Func_54c6: + scf + ret +; 0x54c8 ; display BOXMSG_PLAYERS_TURN or BOXMSG_OPPONENTS_TURN and print ; DuelistsTurnText in a textbox. also call ExchangeRNG. -- cgit v1.2.3 From 89e3b966a0dd1ff78757c0b4056cb0b1b1c8c898 Mon Sep 17 00:00:00 2001 From: xCrystal Date: Fri, 21 Sep 2018 19:32:34 +0200 Subject: Document most practice duel code --- src/engine/bank01.asm | 227 +++++++++++++++++++++++++++----------------------- 1 file changed, 121 insertions(+), 106 deletions(-) (limited to 'src/engine') diff --git a/src/engine/bank01.asm b/src/engine/bank01.asm index 767e6a0..c612498 100644 --- a/src/engine/bank01.asm +++ b/src/engine/bank01.asm @@ -164,7 +164,7 @@ MainDuelLoop ; 40ee (1:40ee) or a jr z, .next_turn ld a, [hl] - cp 15 ; the practice duel lasts 15 turns + cp 15 ; the practice duel lasts 15 turns (8 player turns and 7 opponent turns) jr c, .next_turn xor a ; DUEL_WIN ld [wDuelResult], a @@ -330,7 +330,9 @@ HandleTurn: ; 4225 (1:4225) call SaveDuelStateToSRAM ; fallthrough -Func_4268: +; when a practice duel turn needs to be restarted because the player did not +; follow the instructions correctly, the game jumps here +RestartPracticeDuelTurn: ; 4268 (1:4268) ld a, $06 call DoPracticeDuelAction ; fallthrough @@ -521,9 +523,10 @@ DuelMenu_PkmnPower: ; 438e (1:438e) ; triggered by selecting the "Done" item in the duel menu DuelMenu_Done: ; 439a (1:439a) - ld a, $08 + ld a, PRACTICEDUEL_REPEAT_INSTRUCTIONS call DoPracticeDuelAction - jp c, Func_4268 + ; always jumps on practice duel (no action requires player to select Done) + jp c, RestartPracticeDuelTurn ld a, $05 call SetAIAction_SerialSendDuelData call ClearNonTurnTemporaryDuelvars @@ -1105,9 +1108,10 @@ DuelMenu_Attack: ; 46fc (1:46fc) call CopyMoveDataAndDamage_FromDeckIndex call HandleAmnesiaSubstatus jr c, .cannot_use_due_to_amnesia - ld a, $07 + ld a, PRACTICEDUEL_VERIFY_PLAYER_TURN_ACTIONS call DoPracticeDuelAction - jp c, Func_4268 + ; if player did something wrong in the practice duel, jump in order to restart turn + jp c, RestartPracticeDuelTurn call UseAttackOrPokemonPower jp c, DuelMainInterface ret @@ -1994,7 +1998,7 @@ ChooseInitialArenaAndBenchPokemon: ; 4cd5 (1:4cd5) call DrawDuelBoxMessage ldtx hl, ChooseBasicPkmnToPlaceInArenaText call DrawWideTextBox_WaitForInput - ld a, $1 + ld a, PRACTICEDUEL_DRAW_SEVEN_CARDS call DoPracticeDuelAction .choose_arena_loop xor a @@ -2003,7 +2007,7 @@ ChooseInitialArenaAndBenchPokemon: ; 4cd5 (1:4cd5) jr c, .choose_arena_loop ldh a, [hTempCardIndex_ff98] call LoadCardDataToBuffer1_FromDeckIndex - ld a, $2 + ld a, PRACTICEDUEL_PLAY_GOLDEEN call DoPracticeDuelAction jr c, .choose_arena_loop ldh a, [hTempCardIndex_ff98] @@ -2021,7 +2025,7 @@ ChooseInitialArenaAndBenchPokemon: ; 4cd5 (1:4cd5) call DrawDuelBoxMessage ldtx hl, ChooseUpTo5BasicPkmnToPlaceOnBenchText call PrintScrollableText_NoTextBoxLabel - ld a, $3 + ld a, PRACTICEDUEL_PUT_STARYU_IN_BENCH call DoPracticeDuelAction .bench_loop ld a, $1 @@ -2037,7 +2041,7 @@ ChooseInitialArenaAndBenchPokemon: ; 4cd5 (1:4cd5) ldh a, [hTempCardIndex_ff98] ldtx hl, PlacedOnTheBenchText call DisplayCardDetailScreen - ld a, $5 + ld a, PRACTICEDUEL_DONE_PUTTING_ON_BENCH call DoPracticeDuelAction jr .bench_loop @@ -2047,7 +2051,7 @@ ChooseInitialArenaAndBenchPokemon: ; 4cd5 (1:4cd5) jr .bench_loop .bench_done - ld a, $4 + ld a, PRACTICEDUEL_VERIFY_INITIAL_PLAY call DoPracticeDuelAction jr c, .bench_loop or a @@ -2652,6 +2656,8 @@ DuelHorizontalSeparatorCGBPalData: ; 51c0 (1:51c0) ; 0x51e7 ; if this is a practice duel, execute the practice duel action at wPracticeDuelAction +; if not a practice duel, always return nc +; the practice duel functions below return carry when something's wrong DoPracticeDuelAction: ; 51e7 (1:51e7) ld [wPracticeDuelAction], a ld a, [wIsPracticeDuel] @@ -2670,10 +2676,10 @@ PracticeDuelActionTable: ; 51f8 (1:51f8) dw PracticeDuel_VerifyInitialPlay dw PracticeDuel_DonePuttingOnBench dw PracticeDuel_PrintTurnInstructions - dw PracticeDuel_5278 - dw PracticeDuel_5284 - dw PracticeDuel_529b - dw PracticeDuel_52b0 + dw PracticeDuel_VerifyPlayerTurnActions + dw PracticeDuel_RepeatInstructions + dw PracticeDuel_PlayStaryuFromBench + dw PracticeDuel_ReplaceKnockedOutPokemon ; 0x520e PracticeDuel_DrawSevenCards: ; 520e (1:520e) @@ -2730,7 +2736,9 @@ PracticeDuel_PrintTurnInstructions: ; 5256 (1:5256) ; instructions are also printed along with each of the point-by-point instructions ld a, 0 jp nz, PrintPracticeDuelInstructionsForCurrentTurn - ; practice duel over + ; if we're here, the player followed the current turn actions wrong and has to + ; epeat them. ask the player whether to show detailed instructions again, in + ; order to call PrintPracticeDuelInstructionsForCurrentTurn with a = 0 or a = 1. ldtx de, DrMasonText ldtx hl, NeedPracticeAgainPracticeDuelText call PrintScrollableText_WithTextBoxLabel_NoWait @@ -2738,46 +2746,51 @@ PracticeDuel_PrintTurnInstructions: ; 5256 (1:5256) jp PrintPracticeDuelInstructionsForCurrentTurn ; 0x5278 -PracticeDuel_5278: ; 5278 (1:5278) +PracticeDuel_VerifyPlayerTurnActions: ; 5278 (1:5278) ld a, [wDuelTurns] srl a - ld hl, PointerTable_541f + ld hl, PracticeDuelTurnVerificationPointerTable call JumpToFunctionInTable + ; return nc if player followed instructions correctly ret nc ; fallthrough -PracticeDuel_5284: ; 5284 (1:5284) - ldtx hl, ThisIsPracticeModePracticeDuelText +PracticeDuel_RepeatInstructions: ; 5284 (1:5284) + ldtx hl, FollowMyGuidancePracticeDuelText call PrintPracticeDuelDrMasonInstructions + ; restart the turn from the saved data of the previous turn ld a, $02 call BankswitchSRAM ld de, sCurrentDuel call LoadSavedDuelData xor a call BankswitchSRAM + ; return carry in order to repeat instructions scf ret ; 0x529b -PracticeDuel_529b: ; 529b (1:529b) +PracticeDuel_PlayStaryuFromBench: ; 529b (1:529b) ld a, [wDuelTurns] cp 7 - jr z, .asm_52a4 + jr z, .its_sam_turn_4 or a ret -.asm_52a4 +.its_sam_turn_4 + ; ask player to choose Staryu from bench to replace knocked out Seaking call DrawPracticeDuelInstructionsTextBox call EnableLCD - ld hl, PracticeDuelText_5346 + ld hl, PracticeDuelText_SamTurn4 jp PrintPracticeDuelInstructions ; 0x52b0 -PracticeDuel_52b0: ; 52b0 (1:52b0) +PracticeDuel_ReplaceKnockedOutPokemon: ; 52b0 (1:52b0) ldh a, [hTempPlayAreaLocation_ff9d] cp PLAY_AREA_BENCH_1 ret z + ; if player selected Drowzee instead (which is at PLAY_AREA_BENCH_2) call HasAlivePokemonOnBench - ldtx hl, Text01d7 + ldtx hl, SelectStaryuPracticeDuelText scf ; fallthrough @@ -2791,70 +2804,71 @@ PrintPracticeDuelDrMasonInstructions: ; 52bc (1:52bc) ; 0x52c5 PracticeDuelTextPointerTable: ; 52c5 (1:52c5) - dw PracticeDuelText_52d5 - dw PracticeDuelText_52e5 - dw PracticeDuelText_52f5 - dw PracticeDuelText_5305 - dw PracticeDuelText_5315 - dw PracticeDuelText_5320 - dw PracticeDuelText_5330 - dw PracticeDuelText_533b + dw PracticeDuelText_Turn1 + dw PracticeDuelText_Turn2 + dw PracticeDuelText_Turn3 + dw PracticeDuelText_Turn4 + dw PracticeDuelText_Turn5 + dw PracticeDuelText_Turn6 + dw PracticeDuelText_Turn7 + dw PracticeDuelText_Turn8 ; 0x52d5 practicetext: MACRO db \1 ; Y coord to place the point-by-point instruction tx \2 ; Dr. Mason's instruction - tx \3 ; Static point-by-point instruction + tx \3 ; static point-by-point instruction ENDM -PracticeDuelText_52d5: - practicetext 2, Text01c0, Text01a9 - practicetext 5, Text01c1, Text01aa - practicetext 8, Text01c2, Text01ab +PracticeDuelText_Turn1: + practicetext 2, Turn1DrMason1PracticeDuelText, Turn1Instr1PracticeDuelText + practicetext 5, Turn1DrMason2PracticeDuelText, Turn1Instr2PracticeDuelText + practicetext 8, Turn1DrMason3PracticeDuelText, Turn1Instr3PracticeDuelText db $00 -PracticeDuelText_52e5: - practicetext 2, Text01c3, Text01ac - practicetext 5, Text01c4, Text01ad - practicetext 8, Text01c5, Text01ae +PracticeDuelText_Turn2: + practicetext 2, Turn2DrMason1PracticeDuelText, Turn2Instr1PracticeDuelText + practicetext 5, Turn2DrMason2PracticeDuelText, Turn2Instr2PracticeDuelText + practicetext 8, Turn2DrMason3PracticeDuelText, Turn2Instr3PracticeDuelText db $00 -PracticeDuelText_52f5: - practicetext 2, Text01c6, Text01af - practicetext 5, Text01c7, Text01b0 - practicetext 8, Text01c8, Text01b1 +PracticeDuelText_Turn3: + practicetext 2, Turn3DrMason1PracticeDuelText, Turn3Instr1PracticeDuelText + practicetext 5, Turn3DrMason2PracticeDuelText, Turn3Instr2PracticeDuelText + practicetext 8, Turn3DrMason3PracticeDuelText, Turn3Instr3PracticeDuelText db $00 -PracticeDuelText_5305: - practicetext 2, Text01c9, Text01b2 - practicetext 5, Text01ca, Text01b3 - practicetext 8, Text01cb, Text01b4 +PracticeDuelText_Turn4: + practicetext 2, Turn4DrMason1PracticeDuelText, Turn4Instr1PracticeDuelText + practicetext 5, Turn4DrMason2PracticeDuelText, Turn4Instr2PracticeDuelText + practicetext 8, Turn4DrMason3PracticeDuelText, Turn4Instr3PracticeDuelText db $00 -PracticeDuelText_5315: - practicetext 2, Text01cc, Text01b5 - practicetext 6, Text01cd, Text01b6 +PracticeDuelText_Turn5: + practicetext 2, Turn5DrMason1PracticeDuelText, Turn5Instr1PracticeDuelText + practicetext 6, Turn5DrMason2PracticeDuelText, Turn5Instr2PracticeDuelText db $00 -PracticeDuelText_5320: - practicetext 2, Text01ce, Text01b7 - practicetext 5, Text01cf, Text01b8 - practicetext 8, Text01d0, Text01b9 +PracticeDuelText_Turn6: + practicetext 2, Turn6DrMason1PracticeDuelText, Turn6Instr1PracticeDuelText + practicetext 5, Turn6DrMason2PracticeDuelText, Turn6Instr2PracticeDuelText + practicetext 8, Turn6DrMason3PracticeDuelText, Turn6Instr3PracticeDuelText db $00 -PracticeDuelText_5330: - practicetext 2, Text01d1, Text01ba - practicetext 5, Text01d2, Text01bb +PracticeDuelText_Turn7: + practicetext 2, Turn7DrMason1PracticeDuelText, Turn7Instr1PracticeDuelText + practicetext 5, Turn7DrMason2PracticeDuelText, Turn7Instr2PracticeDuelText db $00 -PracticeDuelText_533b: - practicetext 2, Text01d3, Text01bc - practicetext 5, Text01d4, Text01bd +PracticeDuelText_Turn8: + practicetext 2, Turn8DrMason1PracticeDuelText, Turn8Instr1PracticeDuelText + practicetext 5, Turn8DrMason2PracticeDuelText, Turn8Instr2PracticeDuelText db $00 -PracticeDuelText_5346: - practicetext 2, Text01d5, Text01be - practicetext 7, Text01d6, Text01bf +; on player's Seaking knocked out +PracticeDuelText_SamTurn4: + practicetext 2, SamTurn4DrMason1PracticeDuelText, SamTurn4Instr1PracticeDuelText + practicetext 7, SamTurn4DrMason2PracticeDuelText, SamTurn4Instr2PracticeDuelText db $00 ; in a practice duel, draws the text box where the point-by-point @@ -2882,6 +2896,8 @@ PrintPracticeDuelInstructionsTextBoxLabel: ; 535d (1:535d) ldtx hl, PlayersTurnPracticeDuelText jp PrintText .replace_due_to_knockout + ; when the player needs to replace a knocked out Pokemon, the label text is different + ; this happens at the end of Sam's fourth turn lb de, 1, 0 ldtx hl, ReplaceDueToKnockoutPracticeDuelText jp InitTextPrinting_ProcessTextFromID @@ -2904,7 +2920,7 @@ PrintPracticeDuelInstructionsForCurrentTurn: ; 5382 (1:5382) ld l, a pop af or a - jr nz, PrintPracticeDuelInstructions_Debug + jr nz, PrintPracticeDuelInstructions_Fast ; fallthrough ; print practice duel instructions given hl = PracticeDuelText_* @@ -2957,15 +2973,14 @@ PrintPracticeDuelLetsPlayTheGame: ; 53d3 (1:53d3) ; simplified version of PrintPracticeDuelInstructions that skips Dr. Mason's text ; and instead places the point-by-point instructions all at once. -; doesn't appear to be ever used, so it was probably used for testing during development. -PrintPracticeDuelInstructions_Debug: ; 53da (1:53da) +PrintPracticeDuelInstructions_Fast: ; 53da (1:53da) ld a, [hli] or a jr z, PrintPracticeDuelLetsPlayTheGame ld e, a ld d, 1 call PrintPracticeDuelNumberedInstruction - jr PrintPracticeDuelInstructions_Debug + jr PrintPracticeDuelInstructions_Fast ; 0x53e6 ; print a practice duel point-by-point instruction at d,e, with text id at hl, @@ -3014,105 +3029,105 @@ Func_53fa: ; 53fa (1:53fa) ret ; 0x541f -PointerTable_541f: ; 541f (1:541f) - dw Func_542f - dw Func_5438 - dw Func_5454 - dw Func_5467 - dw Func_5488 - dw Func_549c - dw Func_54b7 - dw Func_54b7 - -Func_542f: ; 542f (1:542f) +PracticeDuelTurnVerificationPointerTable: ; 541f (1:541f) + dw PracticeDuelVerify_Turn1 + dw PracticeDuelVerify_Turn2 + dw PracticeDuelVerify_Turn3 + dw PracticeDuelVerify_Turn4 + dw PracticeDuelVerify_Turn5 + dw PracticeDuelVerify_Turn6 + dw PracticeDuelVerify_Turn7Or8 + dw PracticeDuelVerify_Turn7Or8 + +PracticeDuelVerify_Turn1: ; 542f (1:542f) ld a, [wTempCardID_ccc2] cp GOLDEEN - jp nz, Func_54c6 + jp nz, ReturnWrongAction ret ; 0x5438 -Func_5438: ; 5438 (1:5438) +PracticeDuelVerify_Turn2: ; 5438 (1:5438) ld a, [wTempCardID_ccc2] cp SEAKING - jp nz, Func_54c6 + jp nz, ReturnWrongAction ld a, [wSelectedMoveIndex] cp 1 - jp nz, Func_54c6 + jp nz, ReturnWrongAction ld e, PLAY_AREA_ARENA call GetPlayAreaCardAttachedEnergies ld a, [wAttachedEnergies + PSYCHIC] or a - jr z, Func_54c6 + jr z, ReturnWrongAction ret ; 0x5454 -Func_5454: ; 5454 (1:5454) +PracticeDuelVerify_Turn3: ; 5454 (1:5454) ld a, [wTempCardID_ccc2] cp SEAKING - jr nz, Func_54c6 + jr nz, ReturnWrongAction ld e, PLAY_AREA_BENCH_1 call GetPlayAreaCardAttachedEnergies ld a, [wAttachedEnergies + WATER] or a - jr z, Func_54c6 + jr z, ReturnWrongAction ret ; 0x5467 -Func_5467: ; 5467 (1:5467) +PracticeDuelVerify_Turn4: ; 5467 (1:5467) ld a, [wPlayerNumberOfPokemonInPlayArea] cp 3 - jr nz, Func_54c6 + jr nz, ReturnWrongAction ld e, PLAY_AREA_BENCH_2 call GetPlayAreaCardAttachedEnergies ld a, [wAttachedEnergies + WATER] or a - jr z, Func_54c6 + jr z, ReturnWrongAction ld a, [wTempCardID_ccc2] cp SEAKING - jr nz, Func_54c6 + jr nz, ReturnWrongAction ld a, [wSelectedMoveIndex] cp 1 - jr nz, Func_54c6 + jr nz, ReturnWrongAction ret ; 0x5488 -Func_5488: ; 5488 (1:5488) +PracticeDuelVerify_Turn5: ; 5488 (1:5488) ld e, PLAY_AREA_ARENA call GetPlayAreaCardAttachedEnergies ld a, [wAttachedEnergies + WATER] cp 2 - jr nz, Func_54c6 + jr nz, ReturnWrongAction ld a, [wTempCardID_ccc2] cp STARYU - jr nz, Func_54c6 + jr nz, ReturnWrongAction ret ; 0x549c -Func_549c: ; 549c (1:549c) +PracticeDuelVerify_Turn6: ; 549c (1:549c) ld e, PLAY_AREA_ARENA call GetPlayAreaCardAttachedEnergies ld a, [wAttachedEnergies + WATER] cp 3 - jr nz, Func_54c6 + jr nz, ReturnWrongAction ld a, [wPlayerArenaCardHP] cp 40 - jr nz, Func_54c6 + jr nz, ReturnWrongAction ld a, [wTempCardID_ccc2] cp STARYU - jr nz, Func_54c6 + jr nz, ReturnWrongAction ret ; 0x54b7 -Func_54b7: ; 54b7 (1:54b7) +PracticeDuelVerify_Turn7Or8: ; 54b7 (1:54b7) ld a, [wTempCardID_ccc2] cp STARMIE - jr nz, Func_54c6 + jr nz, ReturnWrongAction ld a, [wSelectedMoveIndex] cp 1 - jr nz, Func_54c6 + jr nz, ReturnWrongAction ret -Func_54c6: +ReturnWrongAction: scf ret ; 0x54c8 -- cgit v1.2.3 From 6ca10ce0a94bd705080425f0cc9ba0efebc476e8 Mon Sep 17 00:00:00 2001 From: xCrystal Date: Fri, 21 Sep 2018 19:38:04 +0200 Subject: Forgot a constant --- src/engine/bank01.asm | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'src/engine') diff --git a/src/engine/bank01.asm b/src/engine/bank01.asm index c612498..1fca015 100644 --- a/src/engine/bank01.asm +++ b/src/engine/bank01.asm @@ -331,9 +331,9 @@ HandleTurn: ; 4225 (1:4225) ; fallthrough ; when a practice duel turn needs to be restarted because the player did not -; follow the instructions correctly, the game jumps here +; follow the instructions correctly, the game loops back here RestartPracticeDuelTurn: ; 4268 (1:4268) - ld a, $06 + ld a, PRACTICEDUEL_PRINT_TURN_INSTRUCTIONS call DoPracticeDuelAction ; fallthrough -- cgit v1.2.3