diff options
author | ElectroDeoxys <ElectroDeoxys@gmail.com> | 2019-09-10 19:08:37 +0100 |
---|---|---|
committer | ElectroDeoxys <ElectroDeoxys@gmail.com> | 2019-09-10 19:08:37 +0100 |
commit | a8d40599bf1c767c7247695c49a7272d2e54cedd (patch) | |
tree | b499f6981a35fc0bbf39424e67a7f24bf6d11362 /src | |
parent | d4959345dfa703a0054dd84d2e2c54ca9eac25ee (diff) |
Label GetCardOneStageBelow
Diffstat (limited to 'src')
-rw-r--r-- | src/engine/bank01.asm | 82 | ||||
-rw-r--r-- | src/engine/bank05.asm | 6 | ||||
-rw-r--r-- | src/wram.asm | 2 |
3 files changed, 87 insertions, 3 deletions
diff --git a/src/engine/bank01.asm b/src/engine/bank01.asm index 0880839..644a6c2 100644 --- a/src/engine/bank01.asm +++ b/src/engine/bank01.asm @@ -7620,8 +7620,86 @@ PrintThereWasNoEffectFromStatusText: ; 700a (1:700a) ret ; 0x7045 -Func_7045: ; 7045 (1:7045) - INCROM $7045, $70aa +; returns carry if card at hTempPlayAreaLocation_ff9d +; is a basic card. +; otherwise, lists the card indices of all stages in +; in that card location, and returns the card one +; stage below. +; input: +; hTempPlayAreaLocation_ff9d = play area location to check; +; output: +; a = card index in hTempPlayAreaLocation_ff9d; +; d = card index of card one stage below; +; carry set if card is a basic card. +GetCardOneStageBelow: ; 7045 (1:7045) + ldh a, [hTempPlayAreaLocation_ff9d] + add DUELVARS_ARENA_CARD + call GetTurnDuelistVariable + call LoadCardDataToBuffer2_FromDeckIndex + ld a, [wLoadedCard2Stage] + or a + jr nz, .not_basic + scf + ret + +.not_basic + ld hl, wAllStagesIndices + ld a, $ff + ld [hli], a + ld [hli], a + ld [hl], a + +; loads deck indices of the stages present in hTempPlayAreaLocation_ff9d. +; the three stages are loaded consecutively in wAllStagesIndices. + ldh a, [hTempPlayAreaLocation_ff9d] + or CARD_LOCATION_ARENA + ld c, a + ld a, DUELVARS_CARD_LOCATIONS + call GetTurnDuelistVariable +.loop + ld a, [hl] + cp c + jr nz, .next + ld a, l + call LoadCardDataToBuffer2_FromDeckIndex + ld a, [wLoadedCard2Type] + cp TYPE_ENERGY + jr nc, .next + ld b, l + push hl + ld a, [wLoadedCard2Stage] + ld e, a + ld d, $00 + ld hl, wAllStagesIndices + add hl, de + ld [hl], b + pop hl +.next + inc l + ld a, l + cp DECK_SIZE + jr c, .loop + +; if card at hTempPlayAreaLocation_ff9d is a stage 1, load d with basic card. +; otherwise if stage 2, load d with the stage 1 card. + ldh a, [hTempPlayAreaLocation_ff9d] + add DUELVARS_ARENA_CARD_STAGE + call GetTurnDuelistVariable + ld hl, wAllStagesIndices ; pointing to basic + cp STAGE1 + jr z, .done + cp STAGE2 + 1 ; unnecessary check? + jr z, .done + inc hl ; pointing to stage 1 +.done + ld d, [hl] + ldh a, [hTempPlayAreaLocation_ff9d] + add DUELVARS_ARENA_CARD + call GetTurnDuelistVariable + ld e, a + or a + ret +; 0x70aa ; initializes variables when a duel begins, such as zeroing wDuelFinished or wDuelTurns, ; and setting wDuelType based on wPlayerDuelistType and wOpponentDuelistType diff --git a/src/engine/bank05.asm b/src/engine/bank05.asm index 8c78a94..2991bf8 100644 --- a/src/engine/bank05.asm +++ b/src/engine/bank05.asm @@ -5241,6 +5241,7 @@ CheckIfAnyBasicPokemonInDeck: ; 17057 (5:7057) ret ; 0x17080 + Func_17080: ; 17080 (5:7080) ldh a, [hTempPlayAreaLocation_ff9d] push af @@ -5254,9 +5255,11 @@ Func_17080: ; 17080 (5:7080) ld a, c ldh [hTempPlayAreaLocation_ff9d], a push bc - bank1call Func_7045 + bank1call GetCardOneStageBelow pop bc jr c, .next + ; is not a basic card + ; compare its HP with current damage ld a, d push bc call LoadCardDataToBuffer2_FromDeckIndex @@ -5283,6 +5286,7 @@ Func_17080: ; 17080 (5:7080) ldh [hTempPlayAreaLocation_ff9d], a or a ret + .set_carry call SwapTurn pop af diff --git a/src/wram.asm b/src/wram.asm index c5cdd18..ef395e6 100644 --- a/src/wram.asm +++ b/src/wram.asm @@ -972,6 +972,8 @@ wccc8:: ; ccc8 wGotHeadsFromConfusionCheck:: ; ccc9 ds $1 +; used to store card indices of all stages, in order, of a Play Area Pokémon +wAllStagesIndices:: ; ccca ds $3 wEffectFunctionsFeedbackIndex:: ; cccd |