diff options
author | xCrystal <rgr.crystal@gmail.com> | 2018-02-23 11:42:25 +0100 |
---|---|---|
committer | xCrystal <rgr.crystal@gmail.com> | 2018-02-23 11:42:25 +0100 |
commit | 0e0e574c821606bee1014329852b2f4eea150103 (patch) | |
tree | b5bb7d7964c486a2048646bab5fc3c7af7b0b44b /src | |
parent | 51c2bbf24927ed87310fd8b96729104c175e3953 (diff) |
More bank0 duel related disassembly
Diffstat (limited to 'src')
-rw-r--r-- | src/engine/bank1.asm | 26 | ||||
-rw-r--r-- | src/engine/bank5.asm | 2 | ||||
-rw-r--r-- | src/engine/bank8.asm | 2 | ||||
-rw-r--r-- | src/engine/home.asm | 94 | ||||
-rw-r--r-- | src/wram.asm | 3 |
5 files changed, 91 insertions, 36 deletions
diff --git a/src/engine/bank1.asm b/src/engine/bank1.asm index 73c1a8a..76113d8 100644 --- a/src/engine/bank1.asm +++ b/src/engine/bank1.asm @@ -570,10 +570,10 @@ Func_4436: ; 4436 (1:4436) ; c contains the type of energy card being played PlayerUseEnergyCard: ; 4477 (1:4477) ld a, c - cp TYPE_ENERGY_WATER ; XXX why treat water energy card differently? + cp TYPE_ENERGY_WATER jr nz, .not_water_energy - call $3615 - jr c, .water_energy + call IsRainDanceActive + jr c, .rain_dance_active .not_water_energy ld a, [wAlreadyPlayedEnergy] @@ -582,31 +582,31 @@ PlayerUseEnergyCard: ; 4477 (1:4477) call $5fdd call $600c ; choose card to play energy card on jp c, DuelMainScene ; exit if no card was chosen -.asm_4490 +.play_energy_set_played ld a, $1 ld [wAlreadyPlayedEnergy], a -.asm_4495 +.play_energy ldh a, [hTempPlayAreaLocationOffset_ff9d] ldh [hTempPlayAreaLocationOffset_ffa1], a ld e, a ldh a, [hTempCardIndex_ff98] ldh [hffa0], a - call $14d2 + call PutHandCardInPlayArea call $61b8 ld a, $3 call SetDuelAIAction call $68e4 jp DuelMainScene -.water_energy +.rain_dance_active call $5fdd call $600c ; choose card to play energy card on jp c, DuelMainScene ; exit if no card was chosen - call $3622 - jr c, .asm_4495 + call CheckRainDanceScenario + jr c, .play_energy ld a, [wAlreadyPlayedEnergy] or a - jr z, .asm_4490 + jr z, .play_energy_set_played ldtx hl, OnlyOneEnergyCardText call DrawWideTextBox_WaitForInput jp Func_4436 @@ -1214,7 +1214,7 @@ Func_4cd5: ; 4cd5 (1:4cd5) call $51e7 jr c, .asm_4d28 ldh a, [hTempCardIndex_ff98] - call Func_1485 + call PutHandPokemonCardInPlayArea ldh a, [hTempCardIndex_ff98] ld hl, $0062 call $4b31 @@ -1238,7 +1238,7 @@ Func_4cd5: ; 4cd5 (1:4cd5) cp MAX_PLAY_AREA_POKEMON jr nc, .asm_4d86 ldh a, [hTempCardIndex_ff98] - call Func_1485 + call PutHandPokemonCardInPlayArea ldh a, [hTempCardIndex_ff98] ld hl, $0061 call $4b31 @@ -1373,7 +1373,7 @@ AIUseEnergyCard: ; 69a5 (1:69a5) ld e, a ldh a, [hffa0] ldh [hTempCardIndex_ff98], a - call $14d2 + call PutHandCardInPlayArea ldh a, [hffa0] call LoadDeckCardToBuffer1 call $5e75 diff --git a/src/engine/bank5.asm b/src/engine/bank5.asm index 631fdb4..79a5dd2 100644 --- a/src/engine/bank5.asm +++ b/src/engine/bank5.asm @@ -73,7 +73,7 @@ Func_14226: ; 14226 (5:4226) jr nz, .check_for_next_pokemon push hl ldh a, [hTempCardIndex_ff98] - call Func_1485 + call PutHandPokemonCardInPlayArea pop hl jr .check_for_next_pokemon ; 0x1424b diff --git a/src/engine/bank8.asm b/src/engine/bank8.asm index 8923a9e..413061c 100644 --- a/src/engine/bank8.asm +++ b/src/engine/bank8.asm @@ -46,7 +46,7 @@ Func_200e5: ; 200e5 (8:40e5) push de ld a, [$ce16] ldh [hTempCardIndex_ff9f], a - bank1call $35a9 + bank1call CheckCantUseTrainerDueToHeadache jp c, $41a8 call LoadNonPokemonCardEffectCommands ld a, $1 diff --git a/src/engine/home.asm b/src/engine/home.asm index 96eef97..efacd4c 100644 --- a/src/engine/home.asm +++ b/src/engine/home.asm @@ -3292,35 +3292,73 @@ LoadDeckCardToBuffer2: ; 138c (0:138c) ret ; 0x13a2 - INCROM $13a2, $1485 + INCROM $13a2, $1461 -Func_1485: ; 1485 (0:1485) +; init the status and all substatuses of the turn holder's arena Pokemon. +; called when sending a new Pokemon into the arena. +; does not reset Headache, since it targets a player rather than a Pokemon. +ResetStatusConditions: ; 1461 (0:1461) + push hl + ldh a, [hWhoseTurn] + ld h, a + xor a + ld l, DUELVARS_ARENA_CARD_STATUS + ld [hl], a + ld l, DUELVARS_ARENA_CARD_SUBSTATUS1 + ld [hl], a + ld l, DUELVARS_ARENA_CARD_SUBSTATUS2 + ld [hl], a + ld l, DUELVARS_ARENA_CARD_CHANGED_WEAKNESS + ld [hl], a + ld l, DUELVARS_ARENA_CARD_CHANGED_RESISTANCE + ld [hl], a + ld l, DUELVARS_ARENA_CARD_SUBSTATUS3 + res SUBSTATUS3_THIS_TURN_DOUBLE_DAMAGE, [hl] + ld l, DUELVARS_ARENA_CARD_DISABLED_MOVE_INDEX + ld [hli], a + ld [hli], a + ld [hli], a + ld [hli], a + ld [hli], a + ld [hli], a + ld [hli], a + ld [hl], a + pop hl + ret +; 0x1485 + +; Removes a Pokemon card from the hand and places it in the arena or first available bench slot. +; If the Pokemon is placed in the arena, the status conditions of the player's arena card are zeroed. +; input: +; - a = deck index of the card +; return carry if there is no room for more Pokemon +PutHandPokemonCardInPlayArea: ; 1485 (0:1485) push af ld a, DUELVARS_NUMBER_OF_POKEMON_IN_PLAY call GetTurnDuelistVariable cp MAX_PLAY_AREA_POKEMON jr nc, .already_max_pkmn_in_play inc [hl] - ld e, a + ld e, a ; play area offset to place card pop af push af - call $14d2 + call PutHandCardInPlayArea ld a, e - add $bb + add DUELVARS_ARENA_CARD ld l, a pop af - ld [hl], a + ld [hl], a ; set card in arena or benchx call LoadDeckCardToBuffer2 - ld a, $c8 + ld a, DUELVARS_ARENA_CARD_HP add e ld l, a ld a, [wLoadedCard2HP] - ld [hl], a + ld [hl], a ; set card's HP ld a, $c2 add e ld l, a ld [hl], $0 - ld a, $d4 + ld a, DUELVARS_ARENA_CARD_CHANGED_TYPE add e ld l, a ld [hl], $0 @@ -3339,7 +3377,7 @@ Func_1485: ; 1485 (0:1485) ld [hl], a ld a, e or a - call z, $1461 + call z, ResetStatusConditions ; only call if Pokemon is being place in the arena ld a, e or a ret @@ -3350,7 +3388,23 @@ Func_1485: ; 1485 (0:1485) ret ; 0x14d2 - INCROM $14d2, $159f +; Removes a card from the hand and changes its location to arena or bench. Given that +; DUELVARS_ARENA_CARD or DUELVARS_BENCH aren't affected, this function is meant for energy and trainer cards. +; input: +; - a = deck index of the card +; - e = play area location offset +; returns +; - a = CARD_LOCATION_PLAY_AREA + e +PutHandCardInPlayArea: ; 14d2 (0:14d2) + call RemoveCardFromHand + call GetTurnDuelistVariable + ld a, e + or CARD_LOCATION_PLAY_AREA + ld [hl], a + ret +; 0x14dd + + INCROM $14dd, $159f ; Find which and how many energy cards are attached to the Pokemon card in the arena, ; or to a Pokemon card in the bench, depending on the value of register e. @@ -4037,11 +4091,11 @@ Func_1ad3: ; 1ad3 (0:1ad3) call Func_2ebb ldtx hl, WasKnockedOutText call DrawWideTextBox_PrintText - ld a, $28 -.asm_1aeb + ld a, 40 +.wait_frames call DoFrame dec a - jr nz, .asm_1aeb + jr nz, .wait_frames scf ret ; 0x1af3 @@ -7677,11 +7731,11 @@ CheckIfUnderAnyCannotUseStatus2: ; 34f0 (0:34f0) ; input: a = Pokemon card ID to search CountPokemonIDInBothPlayAreas: ; 3509 (0:3509) push bc - ld [wTempPokemonID], a + ld [wTempPokemonID_ce7e], a call CountPokemonIDInPlayArea ld c, a call SwapTurn - ld a, [wTempPokemonID] + ld a, [wTempPokemonID_ce7e] call CountPokemonIDInPlayArea call SwapTurn add c @@ -7701,14 +7755,14 @@ CountPokemonIDInPlayArea: ; 3525 (0:3525) push hl push de push bc - ld [wTempPokemonID], a + ld [wTempPokemonID_ce7e], a ld c, $0 ld a, DUELVARS_ARENA_CARD call GetTurnDuelistVariable cp -1 jr z, .check_bench call GetCardIDFromDeckIndex - ld a, [wTempPokemonID] + ld a, [wTempPokemonID_ce7e] cp e jr nz, .check_bench ld a, DUELVARS_ARENA_CARD_STATUS @@ -7724,7 +7778,7 @@ CountPokemonIDInPlayArea: ; 3525 (0:3525) cp -1 jr z, .done call GetCardIDFromDeckIndex - ld a, [wTempPokemonID] + ld a, [wTempPokemonID_ce7e] cp e jr nz, .skip inc c @@ -7887,7 +7941,7 @@ IsRainDanceActive: ; 3615 (0:3615) ; return carry if card at [hTempCardIndex_ff98] is a water energy card AND ; if card at [hTempPlayAreaLocationOffset_ff9d] is a water Pokemon card. -Func_3622: ; 3622 (0:3622) +CheckRainDanceScenario: ; 3622 (0:3622) ldh a, [hTempCardIndex_ff98] call GetCardIDFromDeckIndex call GetCardType diff --git a/src/wram.asm b/src/wram.asm index cd7b1a0..c55fab3 100644 --- a/src/wram.asm +++ b/src/wram.asm @@ -834,7 +834,8 @@ wce6e:: ; ce6e wce6f:: ; ce6f ds $d -wTempPokemonID:: ; ce7c +; used in CountPokemonIDInPlayArea +wTempPokemonID_ce7e:: ; ce7c ds $1 ds $26 |