diff options
Diffstat (limited to 'src')
-rw-r--r-- | src/constants/duel_constants.asm | 19 | ||||
-rw-r--r-- | src/data/effect_commands.asm | 16 | ||||
-rw-r--r-- | src/engine/bank01.asm | 4 | ||||
-rw-r--r-- | src/engine/bank07.asm | 49 | ||||
-rw-r--r-- | src/engine/effect_functions.asm | 291 | ||||
-rw-r--r-- | src/engine/home.asm | 5 | ||||
-rw-r--r-- | src/text/text1.asm | 2 | ||||
-rw-r--r-- | src/text/text2.asm | 10 | ||||
-rw-r--r-- | src/text/text_offsets.asm | 12 | ||||
-rw-r--r-- | src/wram.asm | 12 |
10 files changed, 377 insertions, 43 deletions
diff --git a/src/constants/duel_constants.asm b/src/constants/duel_constants.asm index 928e78c..d3883fe 100644 --- a/src/constants/duel_constants.asm +++ b/src/constants/duel_constants.asm @@ -234,9 +234,16 @@ EFFECT_FAILED_UNSUCCESSFUL EQU $02 ; wAnimationQueue length ANIMATION_QUEUE_LENGTH EQU 7 -PRIZES_1 EQU $01 -PRIZES_2 EQU $02 -PRIZES_3 EQU $03 -PRIZES_4 EQU $04 -PRIZES_5 EQU $05 -PRIZES_6 EQU $06 +PRIZES_1 EQU $01 +PRIZES_2 EQU $02 +PRIZES_3 EQU $03 +PRIZES_4 EQU $04 +PRIZES_5 EQU $05 +PRIZES_6 EQU $06 + +; constants to use as input to LookForCardInDeck +SEARCHEFFECT_CARD_ID EQU $0 +SEARCHEFFECT_NIDORAN EQU $1 +SEARCHEFFECT_BASIC_FIGHTING EQU $2 +SEARCHEFFECT_BASIC_ENERGY EQU $3 +SEARCHEFFECT_POKEMON EQU $4 diff --git a/src/data/effect_commands.asm b/src/data/effect_commands.asm index 88938fa..60d2004 100644 --- a/src/data/effect_commands.asm +++ b/src/data/effect_commands.asm @@ -60,8 +60,8 @@ WeepinbellPoisonPowderEffectCommands: VictreebelLureEffectCommands: dbw EFFECTCMDTYPE_INITIAL_EFFECT_1, VictreebelLure_CheckBenchPokemon dbw EFFECTCMDTYPE_AFTER_DAMAGE, VictreebelLure_SwitchDefendingPokemon - dbw EFFECTCMDTYPE_REQUIRE_SELECTION, VictreebelLure_PlayerSelectBenchPokemon - dbw EFFECTCMDTYPE_UNKNOWN_08, VictreebelLure_AISelectBenchPokemon + dbw EFFECTCMDTYPE_REQUIRE_SELECTION, VictreebelLure_PlayerSelect + dbw EFFECTCMDTYPE_UNKNOWN_08, VictreebelLure_AISelect db $00 VictreebelAcidEffectCommands: @@ -125,7 +125,7 @@ BeedrillTwineedleEffectCommands: BeedrillPoisonStingEffectCommands: dbw EFFECTCMDTYPE_BEFORE_DAMAGE, Poison50PercentEffect - dbw EFFECTCMDTYPE_AI, $480d + dbw EFFECTCMDTYPE_AI, BeedrillPoisonSting_AIEffect db $00 ExeggcuteHypnosisEffectCommands: @@ -133,7 +133,7 @@ ExeggcuteHypnosisEffectCommands: db $00 ExeggcuteLeechSeedEffectCommands: - dbw EFFECTCMDTYPE_AFTER_DAMAGE, $4815 + dbw EFFECTCMDTYPE_AFTER_DAMAGE, ExeggcuteLeechSeedEffect db $00 KoffingFoulGasEffectCommands: @@ -154,10 +154,10 @@ OddishStunSporeEffectCommands: db $00 OddishSproutEffectCommands: - dbw EFFECTCMDTYPE_INITIAL_EFFECT_1, $484a - dbw EFFECTCMDTYPE_AFTER_DAMAGE, $48cc - dbw EFFECTCMDTYPE_REQUIRE_SELECTION, $485a - dbw EFFECTCMDTYPE_UNKNOWN_08, $48b7 + dbw EFFECTCMDTYPE_INITIAL_EFFECT_1, SproutEffect_CheckDeckAndPlayArea + dbw EFFECTCMDTYPE_AFTER_DAMAGE, SproutEffect_PutInPlayArea + dbw EFFECTCMDTYPE_REQUIRE_SELECTION, SproutEffect_SelectFromDeck + dbw EFFECTCMDTYPE_UNKNOWN_08, SproutEffect_AISelect db $00 ExeggutorTeleportEffectCommands: diff --git a/src/engine/bank01.asm b/src/engine/bank01.asm index c4a6b27..83db5a4 100644 --- a/src/engine/bank01.asm +++ b/src/engine/bank01.asm @@ -2268,11 +2268,11 @@ Func_4e98: ; 4e98 (1:4e98) Func_4f2d: ; 4f2d (1:4f2d) ld a, [wDuelDisplayedScreen] cp SHUFFLE_DECK - jr z, .asm_4f3d + jr z, .skip_draw_scene call ZeroObjectPositionsAndToggleOAMCopy call EmptyScreen call DrawDuelistPortraitsAndNames -.asm_4f3d +.skip_draw_scene ld a, SHUFFLE_DECK ld [wDuelDisplayedScreen], a ld a, DUELVARS_NUMBER_OF_CARDS_NOT_IN_DECK diff --git a/src/engine/bank07.asm b/src/engine/bank07.asm index af41613..aab0cd9 100644 --- a/src/engine/bank07.asm +++ b/src/engine/bank07.asm @@ -553,7 +553,35 @@ Func_1c83d: ; 1c83d (7:483d) ret ; 0x1c858 - INCROM $1c858, $1c8ef + INCROM $1c858, $1c8bc + +Func_1c8bc: ; 1c8bc (7:48bc) + push hl + push bc + call Set_OBJ_8x8 + ld a, $a2 + ld [wDoFrameFunction], a + ld a, $3b + ld [wDoFrameFunction + 1], a + ld a, $ff + ld hl, wAnimationQueue + ld c, ANIMATION_QUEUE_LENGTH +.fill_queue + ld [hli], a + dec c + jr nz, .fill_queue + ld [wd42a], a + ld [wd4c0], a + xor a + ld [wd4ac], a + ld [wd4ad], a + ld [wd4b3], a + call Func_1ccbc + call Func_3ca0 + pop bc + pop hl + ret +; 0x1c8ef Func_1c8ef: ; 1c8ef (7:48ef) ld a, [wDoFrameFunction + 0] @@ -895,7 +923,24 @@ Func_1cb18: ; 1cb18 (7:4b18) jr .asm_1cb57 ; 0x1cb5e - INCROM $1cb5e, $1d078 + INCROM $1cb5e, $1ccbc + +Func_1ccbc: ; 1ccbc (7:4cbc) + ld a, $ff + ld [wd42a], a + call DisableInt_LYCoincidence + xor a + ldh [hSCX], a + ldh [rSCX], a + ldh [hSCY], a + ld hl, wd4b9 + ld [hl], $bc + inc hl + ld [hl], $4c + ret +; 0x1ccd4 + + INCROM $1ccd4, $1d078 Func_1d078: ; 1d078 (7:5078) ld a, [wd627] diff --git a/src/engine/effect_functions.asm b/src/engine/effect_functions.asm index d254f5c..839c814 100644 --- a/src/engine/effect_functions.asm +++ b/src/engine/effect_functions.asm @@ -143,7 +143,8 @@ Func_2c0bd: ; 2c0bd (b:40bd) call ShuffleDeck ret -Func_2c0c7: ; 2c0c7 (b:40c7) +; return carry if Turn Duelist is the Player +CheckIfTurnDuelistIsPlayer: ; 2c0c7 (b:40c7) ld a, DUELVARS_DUELIST_TYPE call GetTurnDuelistVariable cp DUELIST_TYPE_PLAYER @@ -336,7 +337,7 @@ HandleSwitchDefendingPokemonEffect: ; 2c1ec (b:41ec) ; and handles its animation. ; input: ; d = damage effectiveness -; e = damage dealt +; e = HP amount to recover ApplyAndAnimateHPDrain: ; 2c221 (b:4221) push de ld hl, wccbd @@ -456,7 +457,158 @@ CreateEnergyCardListFromOpponentDiscardPile: ; 2c2a4 (b:42a4) ret ; 0x2c2e0 - INCROM $2c2e0, $2c487 +; returns carry if Deck is empty +CheckIfDeckIsEmpty: ; 2c2e0 (b:42e0) + ld a, DUELVARS_NUMBER_OF_CARDS_NOT_IN_DECK + call GetTurnDuelistVariable + ldtx hl, NoCardsLeftInTheDeckText + cp DECK_SIZE + ccf + ret +; 0x2c2ec + +; searches through Deck in wDuelTempList looking for +; a certain card or cards, and prints text depending +; on whether at least one was found. +; if none were found, asks the Player whether to look +; in the Deck anyway, and returns carry if No is selected. +; uses SEARCHEFFECT_* as input which determines what to search for: +; SEARCHEFFECT_CARD_ID = search for card ID in e +; SEARCHEFFECT_NIDORAN = search for either NidoranM or NidoranF +; SEARCHEFFECT_BASIC_FIGHTING = search for any Basic Fighting Pokemon +; SEARCHEFFECT_BASIC_ENERGY = search for any Basic Energy +; SEARCHEFFECT_POKEMON = search for any Pokemon card +; input: +; d = SEARCHEFFECT_* constant +; e = (optional) card ID to search for in deck +; hl = text to print if Deck has card(s) +; output: +; carry set if refuse to look at deck +LookForCardInDeck: ; 2c2ec (b:42ec) + push hl + push bc + ld a, [wDuelTempList] + cp $ff + jr z, .none_in_deck + ld a, d + ld hl, .search_table + call JumpToFunctionInTable + jr c, .none_in_deck + pop bc + pop hl + call DrawWideTextBox_WaitForInput + or a + ret + +.none_in_deck + pop hl + call LoadTxRam2 + pop hl + ldtx hl, ThereIsNoInTheDeckText + call DrawWideTextBox_WaitForInput + ldtx hl, WouldYouLikeToCheckTheDeckText + call YesOrNoMenuWithText_SetCursorToYes + ret +; 0x2c317 + +.search_table + dw .SearchDeckForE + dw .SearchDeckForNidoran + dw .SearchDeckForBasicFighting + dw .SearchDeckForBasicEnergy + dw .SearchDeckForPokemon + +.set_carry ; 2c321 (b:4321) + scf + ret +; 0x2c323 + +; returns carry if no card with +; same card ID as e is found in Deck +.SearchDeckForE ; 2c323 (b:4323) + ld hl, wDuelTempList +.loop_deck_e + ld a, [hli] + cp $ff + jr z, .set_carry + push de + call GetCardIDFromDeckIndex + ld a, e + pop de + cp e + jr nz, .loop_deck_e + or a + ret +; 0x2c336 + +; returns carry if no NidoranM or NidoranF card is found in Deck +.SearchDeckForNidoran ; 2c336 (b:4336) + ld hl, wDuelTempList +.loop_deck_nidoran + ld a, [hli] + cp $ff + jr z, .set_carry + call GetCardIDFromDeckIndex + ld a, e + cp NIDORANF + jr z, .found_nidoran + cp NIDORANM + jr nz, .loop_deck_nidoran +.found_nidoran + or a + ret +; 0x2c34c + +; returns carry if no Basic Fighting Pokemon is found in Deck +.SearchDeckForBasicFighting ; 2c34c (b:434c) + ld hl, wDuelTempList +.loop_deck_fighting + ld a, [hli] + cp $ff + jr z, .set_carry + call LoadCardDataToBuffer2_FromDeckIndex + ld a, [wLoadedCard2Type] + cp TYPE_PKMN_FIGHTING + jr nz, .loop_deck_fighting + ld a, [wLoadedCard2Stage] + or a ; BASIC + jr nz, .loop_deck_fighting + ret +; 0x2c365 + +; returns carry if no Basic Energy cards are found in Deck +.SearchDeckForBasicEnergy ; 2c365 (b:4365) + ld hl, wDuelTempList +.loop_deck_energy + ld a, [hli] + cp $ff + jr z, .set_carry + call GetCardIDFromDeckIndex + call GetCardType + cp TYPE_ENERGY_DOUBLE_COLORLESS + jr z, .loop_deck_energy + and TYPE_ENERGY + jr z, .loop_deck_energy + or a + ret +; 0x2c37d + +; returns carry if no Pokemon cards are found in Deck +.SearchDeckForPokemon ; 2c37d (b:437d) + ld hl, wDuelTempList +.loop_deck_pkmn + ld a, [hli] + cp $ff + jr z, .set_carry + call GetCardIDFromDeckIndex + call GetCardType + cp TYPE_ENERGY + jr nc, .loop_deck_pkmn + or a + ret +; 0x2c391 + + INCROM $2c391, $2c487 ; handles the selection of a forced switch ; by link/AI opponent or by the player. @@ -621,7 +773,7 @@ VictreebelLure_CheckBenchPokemon: ; 2c740 (b:4740) ret ; 0x2c74b -VictreebelLure_PlayerSelectBenchPokemon: ; 2c74b (b:474b) +VictreebelLure_PlayerSelect: ; 2c74b (b:474b) ldtx hl, SelectPkmnOnBenchToSwitchWithActiveText call DrawWideTextBox_WaitForInput call SwapTurn @@ -635,7 +787,7 @@ VictreebelLure_PlayerSelectBenchPokemon: ; 2c74b (b:474b) ret ; 0x2c764 -VictreebelLure_AISelectBenchPokemon: ; 2c764 (b:4764) +VictreebelLure_AISelect: ; 2c764 (b:4764) call AIFindBenchWithLowestHP ldh [hTemp_ffa0], a ret @@ -734,8 +886,6 @@ ZubatLeechLifeEffect: ; 2c7e3 (b:47e3) ret ; 0x2c7ed - INCROM $2c7ed, $2c7ed - Twineedle_AIEffect: ; 2c7ed (b:47ed) ld a, 30 lb de, 0, 60 @@ -756,7 +906,21 @@ Twineedle_MultiplierEffect: ; 2c7f5 (b:47f5) ret ; 0x2c80d - INCROM $2c80d, $2c822 +BeedrillPoisonSting_AIEffect: ; 2c80d (b:480d) + ld a, 5 + lb de, 0, 10 + jp Func_2c0d4 +; 0x2c815 + +ExeggcuteLeechSeedEffect: ; 2c815 (b:4815) + ld hl, wDealtDamage + ld a, [hli] + or a + ret z ; return if no damage dealt + ld de, 10 + call ApplyAndAnimateHPDrain + ret +; 0x2c822 FoulGas_AIEffect: ; 2c822 (b:4822) ld a, 5 @@ -783,7 +947,116 @@ MetapodStiffenEffect: ; 2c836 (b:4836) ret ; 0x2c84a - INCROM $2c84a, $2c925 +; returns carry if no cards in Deck or if +; Play Area is full already. +SproutEffect_CheckDeckAndPlayArea: ; 2c84a (b:484a) + call CheckIfDeckIsEmpty + ret c ; return if no cards in deck + ld a, DUELVARS_NUMBER_OF_POKEMON_IN_PLAY_AREA + call GetTurnDuelistVariable + ldtx hl, NoSpaceOnTheBenchText + cp MAX_PLAY_AREA_POKEMON + ccf + ret +; 0x2c85a + +SproutEffect_SelectFromDeck: ; 2c85a (b:485a) + ld a, $ff + ldh [hTemp_ffa0], a + + call CreateDeckCardList + ldtx hl, ChooseAnOddishFromTheDeckText + ldtx bc, OddishText + lb de, SEARCHEFFECT_CARD_ID, ODDISH + call LookForCardInDeck + ret c + +; draw Deck list interface and print text + bank1call Func_5591 + ldtx hl, ChooseAnOddishText + ldtx de, DuelistDeckText + bank1call SetCardListHeaderText + +.loop + bank1call DisplayCardList + jr c, .pressed_b + call GetCardIDFromDeckIndex + ld bc, ODDISH + call CompareDEtoBC + jr nz, .play_sfx + +; Oddish was selected + ldh a, [hTempCardIndex_ff98] + ldh [hTemp_ffa0], a + or a + ret + +.play_sfx + ; play SFX and loop back + call Func_3794 + jr .loop + +.pressed_b +; figure if Player can exit the screen without selecting, +; that is, if the Deck has no Oddish card. + ld a, DUELVARS_CARD_LOCATIONS + call GetTurnDuelistVariable +.loop_b_press + ld a, [hl] + cp CARD_LOCATION_DECK + jr nz, .next + ld a, l + call GetCardIDFromDeckIndex + ld bc, ODDISH + call CompareDEtoBC + jr z, .play_sfx ; found Oddish, go back to top loop +.next + inc l + ld a, l + cp DECK_SIZE + jr c, .loop_b_press + +; no Oddish in Deck, can safely exit screen + ld a, $ff + ldh [hTemp_ffa0], a + or a + ret +; 0x2c8b7 + +SproutEffect_AISelect: ; 2c8b7 (b:48b7) + call CreateDeckCardList + ld hl, wDuelTempList +.loop_deck + ld a, [hli] + ldh [hTemp_ffa0], a + cp $ff + ret z ; no Oddish + call GetCardIDFromDeckIndex + ld a, e + cp ODDISH + jr nz, .loop_deck + ret ; Oddish found +; 0x2c8cc + +SproutEffect_PutInPlayArea: ; 2c8cc (b:48cc) + ldh a, [hTemp_ffa0] + cp $ff + jr z, .shuffle + call SearchCardInDeckAndAddToHand + call AddCardToHand + call PutHandPokemonCardInPlayArea + call CheckIfTurnDuelistIsPlayer + jr c, .shuffle + ; display card on screen + ldh a, [hTemp_ffa0] + ldtx hl, PlacedOnTheBenchText + bank1call DisplayCardDetailScreen +.shuffle + call Func_2c0bd + ret +; 0x2c8ec + + INCROM $2c8ec, $2c925 BigEggsplosion_AIEffect: ; 2c925 (b:4925) ldh a, [hTempPlayAreaLocation_ff9d] diff --git a/src/engine/home.asm b/src/engine/home.asm index 98b10ac..edbd6f5 100644 --- a/src/engine/home.asm +++ b/src/engine/home.asm @@ -11051,9 +11051,10 @@ Func_3b11: ; 3b11 (0:3b11) Func_3b21: ; 3b21 (0:3b21) ldh a, [hBankROM] push af - ld a, $07 + ld a, BANK(Func_1c8bc) call BankswitchROM - call $48bc + call Func_1c8bc + pop af call BankswitchROM ret diff --git a/src/text/text1.asm b/src/text/text1.asm index 00dc22f..46bb72d 100644 --- a/src/text/text1.asm +++ b/src/text/text1.asm @@ -831,7 +831,7 @@ Text00b0: ; 3749e (d:749e) line "in the Discard Pile." done -Text00b1: ; 374d4 (d:74d4) +NoCardsLeftInTheDeckText: ; 374d4 (d:74d4) text "There are no cards left in the Deck." done diff --git a/src/text/text2.asm b/src/text/text2.asm index 97ecf45..b9ffa9b 100644 --- a/src/text/text2.asm +++ b/src/text/text2.asm @@ -242,12 +242,12 @@ Text0125: ; 3899f (e:499f) line "from the Deck." done -Text0126: ; 389cf (e:49cf) +ChooseAnOddishFromTheDeckText: ; 389cf (e:49cf) text "Choose an Oddish" line "from the Deck." done -Text0127: ; 389f0 (e:49f0) +ChooseAnOddishText: ; 389f0 (e:49f0) text "Choose an Oddish" done @@ -406,12 +406,12 @@ Text013a: ; 391dc (e:51dc) line "to be used with Metronome." done -Text013b: ; 39215 (e:5215) +ThereIsNoInTheDeckText: ; 39215 (e:5215) text "There is no <RAMTEXT>" line "in the Deck." done -Text013c: ; 39231 (e:5231) +WouldYouLikeToCheckTheDeckText: ; 39231 (e:5231) text "Would you like to check the Deck?" done @@ -429,7 +429,7 @@ Text013f: ; 392c9 (e:52c9) text "Nidoran♂ Nidoran♀" done -Text0140: ; 392dc (e:52dc) +OddishText: ; 392dc (e:52dc) text "Oddish" done diff --git a/src/text/text_offsets.asm b/src/text/text_offsets.asm index 7ff0d44..941f9ae 100644 --- a/src/text/text_offsets.asm +++ b/src/text/text_offsets.asm @@ -178,7 +178,7 @@ TextOffsets:: ; 34000 (d:4000) textpointer NoEnergyAttachedToOpponentsActiveText ; 0x00ae textpointer Text00af ; 0x00af textpointer Text00b0 ; 0x00b0 - textpointer Text00b1 ; 0x00b1 + textpointer NoCardsLeftInTheDeckText ; 0x00b1 textpointer NoSpaceOnTheBenchText ; 0x00b2 textpointer NoPokemonCapableOfEvolvingText ; 0x00b3 textpointer CantEvolvePokemonInSameTurnItsPlacedText ; 0x00b4 @@ -295,8 +295,8 @@ TextOffsets:: ; 34000 (d:4000) textpointer Text0123 ; 0x0123 textpointer Text0124 ; 0x0124 textpointer Text0125 ; 0x0125 - textpointer Text0126 ; 0x0126 - textpointer Text0127 ; 0x0127 + textpointer ChooseAnOddishFromTheDeckText ; 0x0126 + textpointer ChooseAnOddishText ; 0x0127 textpointer Text0128 ; 0x0128 textpointer Text0129 ; 0x0129 textpointer Text012a ; 0x012a @@ -316,12 +316,12 @@ TextOffsets:: ; 34000 (d:4000) textpointer Text0138 ; 0x0138 textpointer Text0139 ; 0x0139 textpointer Text013a ; 0x013a - textpointer Text013b ; 0x013b - textpointer Text013c ; 0x013c + textpointer ThereIsNoInTheDeckText ; 0x013b + textpointer WouldYouLikeToCheckTheDeckText ; 0x013c textpointer Text013d ; 0x013d textpointer Text013e ; 0x013e textpointer Text013f ; 0x013f - textpointer Text0140 ; 0x0140 + textpointer OddishText ; 0x0140 textpointer Text0141 ; 0x0141 textpointer Text0142 ; 0x0142 textpointer Text0143 ; 0x0143 diff --git a/src/wram.asm b/src/wram.asm index 1d678b6..3613eba 100644 --- a/src/wram.asm +++ b/src/wram.asm @@ -2325,8 +2325,16 @@ wd4b1:: ; d4b1 wd4b2:: ; d4b2 ds $1 - - ds $b + +wd4b3:: ; d4b3 + ds $1 + + ds $5 + +wd4b9:: ; d4b9 + ds $1 + + ds $4 wd4be:: ; d4be ds $1 |