diff options
| author | xCrystal <rgr.crystal@gmail.com> | 2016-03-05 17:25:30 +0100 | 
|---|---|---|
| committer | xCrystal <rgr.crystal@gmail.com> | 2016-03-05 20:10:31 +0100 | 
| commit | 102fa38ab095c26b49a23a1e75e3b2087d131541 (patch) | |
| tree | 45aabdd09ea871e7b746c8fb1da2c9020ead05ba | |
| parent | 4f740092b306c1652131fe37dde65d35a42a0b6b (diff) | |
figure out substatus duelvars
ex can't attack status
| -rw-r--r-- | src/constants/duel_constants.asm | 40 | ||||
| -rwxr-xr-x | src/data/cards.asm | 6 | ||||
| -rwxr-xr-x | src/engine/bank1.asm | 326 | ||||
| -rw-r--r-- | src/engine/effect_functions.asm | 134 | ||||
| -rwxr-xr-x | src/engine/home.asm | 326 | ||||
| -rwxr-xr-x | src/text/text_offsets.asm | 4 | ||||
| -rw-r--r-- | src/text/texta.asm | 2 | ||||
| -rw-r--r-- | src/text/textb.asm | 2 | ||||
| -rwxr-xr-x | src/wram.asm | 64 | 
9 files changed, 508 insertions, 396 deletions
| diff --git a/src/constants/duel_constants.asm b/src/constants/duel_constants.asm index 87bfdba..39de13d 100644 --- a/src/constants/duel_constants.asm +++ b/src/constants/duel_constants.asm @@ -17,15 +17,20 @@ DUELVARS_BENCH2_CARD_HP                  EQUS "wPlayerBench2CardHP & $ff"  DUELVARS_BENCH3_CARD_HP                  EQUS "wPlayerBench3CardHP & $ff"               ; cb  DUELVARS_BENCH4_CARD_HP                  EQUS "wPlayerBench4CardHP & $ff"               ; cc  DUELVARS_BENCH5_CARD_HP                  EQUS "wPlayerBench5CardHP & $ff"               ; cd -DUELVARS_CANT_ATTACK_STATUS              EQUS "wPlayerCantAttackStatus & $ff"           ; e8 +DUELVARS_ARENA_CARD_SUBSTATUS1           EQUS "wPlayerArenaCardSubstatus1 & $ff"        ; e7 +DUELVARS_ARENA_CARD_SUBSTATUS2           EQUS "wPlayerArenaCardSubstatus2 & $ff"        ; e8 +DUELVARS_ARENA_CARD_SUBSTATUS3           EQUS "wPlayerArenaCardSubstatus3 & $ff"        ; e9 +DUELVARS_ARENA_CARD_SUBSTATUS4           EQUS "wPlayerArenaCardSubstatus4 & $ff"        ; ea +DUELVARS_ARENA_CARD_SUBSTATUS5           EQUS "wPlayerArenaCardSubstatus5 & $ff"        ; eb  DUELVARS_PRIZES                          EQUS "wPlayerPrizes & $ff"                     ; ec  DUELVARS_NUMBER_OF_CARDS_IN_DISCARD_PILE EQUS "wPlayerNumberOfCardsInDiscardPile & $ff" ; ed  DUELVARS_NUMBER_OF_CARDS_IN_HAND         EQUS "wPlayerNumberOfCardsInHand & $ff"        ; ee  DUELVARS_NUMBER_OF_POKEMON_IN_PLAY       EQUS "wPlayerNumberOfPokemonInPlay & $ff"      ; ef  DUELVARS_ARENA_CARD_STATUS               EQUS "wPlayerArenaCardStatus & $ff"            ; f0  DUELVARS_DUELIST_TYPE                    EQUS "wPlayerDuelistType & $ff"                ; f1 +DUELVARS_ARENA_CARD_DISABLED_MOVE_INDEX  EQUS "wPlayerArenaCardDisabledMoveIndex & $ff" ; f2 -; card locations +;;; card locations  CARD_LOCATION_DECK         EQU $00  CARD_LOCATION_HAND         EQU $01  CARD_LOCATION_DISCARD_PILE EQU $02 @@ -37,9 +42,9 @@ CARD_LOCATION_BENCH_3      EQU $13  CARD_LOCATION_BENCH_4      EQU $14  CARD_LOCATION_BENCH_5      EQU $15 -; status condition constants +;;; status conditions  ; two statuses can be combined if they are identified by a different nybble -CARD_NOSTATUS   EQU $00 +NO_STATUS       EQU $00  CONFUSED        EQU $01  ASLEEP          EQU $02  PARALYZED       EQU $03 @@ -47,3 +52,30 @@ POISONED        EQU $80  DOUBLE_POISONED EQU $c0  PASSIVE_STATUS_MASK  EQU $f ; confused, asleep or paralyzed + +;;; substatus conditions +SUBSTATUS1_AGILITY      EQU $0c +SUBSTATUS1_FLY          EQU $0d +SUBSTATUS1_HARDEN       EQU $0e +SUBSTATUS1_NO_DAMAGE_F  EQU $0f +SUBSTATUS1_NO_DAMAGE_10 EQU $10 +SUBSTATUS1_NO_DAMAGE_11 EQU $11 +SUBSTATUS1_REDUCE_BY_20 EQU $13 +SUBSTATUS1_BARRIER      EQU $14 +SUBSTATUS1_KABUTO_ARMOR EQU $15 +SUBSTATUS1_DESTINY_BOND EQU $16 +SUBSTATUS1_NO_DAMAGE_17 EQU $17 +SUBSTATUS1_NEXT_TURN_DOUBLE_DAMAGE EQU $19 +SUBSTATUS1_REDUCE_BY_10 EQU $1e + +SUBSTATUS2_SMOKESCREEN  EQU $01 +SUBSTATUS2_SAND_ATTACK  EQU $02 +SUBSTATUS2_REDUCE_BY_20 EQU $03 +SUBSTATUS2_AMNESIA      EQU $04 +SUBSTATUS2_TAIL_WAG     EQU $05 +SUBSTATUS2_LEER         EQU $06 +SUBSTATUS2_POUNCE       EQU $07 +SUBSTATUS2_BONE_ATTACK  EQU $0b +SUBSTATUS2_GROWL        EQU $12 + +SUBSTATUS5_THIS_TURN_DOUBLE_DAMAGE EQU 0 diff --git a/src/data/cards.asm b/src/data/cards.asm index ca5aa34..a09d940 100755 --- a/src/data/cards.asm +++ b/src/data/cards.asm @@ -3967,7 +3967,7 @@ HorseaCard: ; 320b1 (c:60b1)  	; move 1  	energy WATER, 1 ; energies  	tx SmokescreenName ; name -	tx HorseasSmokescreenDescription ; description +	tx OpponentAttackMayDoNothingDescription ; description  	dw NONE ; description (cont)  	db 10 ; damage  	db DAMAGE_NORMAL ; category @@ -5905,7 +5905,7 @@ SandshrewCard: ; 32a57 (c:6a57)  	; move 1  	energy FIGHTING, 1 ; energies  	tx SandAttackName ; name -	tx HorseasSmokescreenDescription ; description +	tx OpponentAttackMayDoNothingDescription ; description  	dw NONE ; description (cont)  	db 10 ; damage  	db DAMAGE_NORMAL ; category @@ -6480,7 +6480,7 @@ GolemCard: ; 32d22 (c:6d22)  	; move 2  	energy FIGHTING, 4 ; energies  	tx SelfdestructName ; name -	tx AvalancheDescription ; description +	tx GolemsSelfdestructDescription ; description  	dw NONE ; description (cont)  	db 100 ; damage  	db DAMAGE_NORMAL ; category diff --git a/src/engine/bank1.asm b/src/engine/bank1.asm index 74687df..1ddf2dd 100755 --- a/src/engine/bank1.asm +++ b/src/engine/bank1.asm @@ -88,14 +88,14 @@ StartDuel: ; 409f (1:409f)  .mainDuelLoop  	xor a  	ld [wCurrentDuelMenuItem], a -	call Func_35e6 +	call HandleSwordsDanceOrFocusEnergySubstatus  	call $54c8  	call Func_4225  	call Func_0f58  	ld a, [wDuelFinished]  	or a  	jr nz, .duelIsOver -	call Func_35fa +	call UpdateSubstatusConditions  	call $6baf  	call Func_3b31  	call Func_0f58 @@ -477,7 +477,7 @@ OpenBattleCheckMenu: ; 4585 (1:4585)  INCBIN "baserom.gbc",$458e, $46fc - $458e  OpenBattleAttackMenu: ; 46fc (1:46fc) -	call CheckIfCantAttackDueToAttackEffect +	call HandleCantAttackSubstatus  	jr c, .alertCantAttackAndCancelMenu  	call CheckIfActiveCardParalyzedOrAsleep  	jr nc, .clearSubMenuSelection @@ -538,7 +538,7 @@ OpenBattleAttackMenu: ; 46fc (1:46fc)  	inc hl  	ld e, [hl]  	call Func_16c0 -	call Func_33e1 +	call HandleAmnesiaSubstatus  	jr c, .asm_477d  	ld a, $07  	call $51e7 @@ -892,195 +892,197 @@ InitializeDuelVariables: ; 7107 (1:7107)  INCBIN "baserom.gbc",$7133,$71ad - $7133  TossCoin: ; 71ad (1:71ad) -        ld [$cd9c], a -        ld a, [wcac2] -        cp $6 -        jr z, .asm_71c1 -        xor a -        ld [$cd9f], a -        call Func_04a2 -        call $210f +	ld [$cd9c], a +	ld a, [wcac2] +	cp $6 +	jr z, .asm_71c1 +	xor a +	ld [$cd9f], a +	call Func_04a2 +	call $210f  .asm_71c1 -        ld a, [$cd9f] -        or a -        jr nz, .asm_71ec -        ld a, $6 -        ld [wcac2], a -        ld de, $000c -        ld bc, $1406 -        ld hl, $0000 -        call DrawLabeledTextBox -        call EnableLCD -        ld de, $010e -        ld a, $13 -        call Func_22a6 -        ld hl, wCoinTossScreenTextId -        ld a, [hli] -        ld h, [hl] -        ld l, a -        call PrintText +	ld a, [$cd9f] +	or a +	jr nz, .asm_71ec +	ld a, $6 +	ld [wcac2], a +	ld de, $000c +	ld bc, $1406 +	ld hl, $0000 +	call DrawLabeledTextBox +	call EnableLCD +	ld de, $010e +	ld a, $13 +	call Func_22a6 +	ld hl, wCoinTossScreenTextId +	ld a, [hli] +	ld h, [hl] +	ld l, a +	call PrintText  .asm_71ec -        ld hl, wCoinTossScreenTextId -        xor a -        ld [hli], a -        ld [hl], a -        call EnableLCD -        ld a, $f1 -        call GetTurnDuelistVariable -        ld [$cd9e], a -        call Func_0f58 -        xor a -        ld [$cd9d], a -        ld a, [$cd9c] -        cp $2 -        jr c, .asm_7223 -        ld bc, $0f0b -        ld a, [$cd9f] -        inc a -        call $65b7 -        ld b, $11 -        ld a, $2e -        call Func_06c3 -        inc b -        ld a, [$cd9c] -        call $65b7 +	ld hl, wCoinTossScreenTextId +	xor a +	ld [hli], a +	ld [hl], a +	call EnableLCD +	ld a, $f1 +	call GetTurnDuelistVariable +	ld [$cd9e], a +	call Func_0f58 +	xor a +	ld [$cd9d], a + +.asm_7204 +	ld a, [$cd9c] +	cp $2 +	jr c, .asm_7223 +	ld bc, $0f0b +	ld a, [$cd9f] +	inc a +	call $65b7 +	ld b, $11 +	ld a, $2e +	call Func_06c3 +	inc b +	ld a, [$cd9c] +	call $65b7  .asm_7223 -        call Func_3b21 -        ld a, $58 -        call Func_3b6a -        ld a, [$cd9e] -        or a -        jr z, .asm_7236 -        call $7324 -        jr .asm_723c +	call Func_3b21 +	ld a, $58 +	call Func_3b6a +	ld a, [$cd9e] +	or a +	jr z, .asm_7236 +	call $7324 +	jr .asm_723c  .asm_7236 -        call WaitForWideTextBoxInput -        call $72ff +	call WaitForWideTextBoxInput +	call $72ff  .asm_723c -        call Func_3b21 -        ld d, $5a -        ld e, $0 -        call UpdateRNGSources -        rra -        jr c, .asm_724d -        ld d, $59 -        ld e, $1 +	call Func_3b21 +	ld d, $5a +	ld e, $0 +	call UpdateRNGSources +	rra +	jr c, .asm_724d +	ld d, $59 +	ld e, $1  .asm_724d -        ld a, d -        call Func_3b6a -        ld a, [$cd9e] -        or a -        jr z, .asm_725e -        ld a, e -        call $7310 -        ld e, a -        jr .asm_726c +	ld a, d +	call Func_3b6a +	ld a, [$cd9e] +	or a +	jr z, .asm_725e +	ld a, e +	call $7310 +	ld e, a +	jr .asm_726c  .asm_725e -        push de -        call DoFrame -        call Func_3b52 -        pop de -        jr c, .asm_725e -        ld a, e -        call $72ff +	push de +	call DoFrame +	call Func_3b52 +	pop de +	jr c, .asm_725e +	ld a, e +	call $72ff  .asm_726c -        ld b, $5c -        ld c, $34 -        ld a, e -        or a -        jr z, .asm_727c -        ld b, $5b -        ld c, $30 -        ld hl, $cd9d -        inc [hl] +	ld b, $5c +	ld c, $34 +	ld a, e +	or a +	jr z, .asm_727c +	ld b, $5b +	ld c, $30 +	ld hl, $cd9d +	inc [hl]  .asm_727c -        ld a, b -        call Func_3b6a -        ld a, [$cd9e] -        or a -        jr z, .asm_728a -        ld a, $1 -        xor e -        ld e, a +	ld a, b +	call Func_3b6a +	ld a, [$cd9e] +	or a +	jr z, .asm_728a +	ld a, $1 +	xor e +	ld e, a  .asm_728a -        ld d, $54 -        ld a, e -        or a -        jr nz, .asm_7292 -        ld d, $55 +	ld d, $54 +	ld a, e +	or a +	jr nz, .asm_7292 +	ld d, $55  .asm_7292 -        ld a, d -        call Func_3796 -        ld a, [$cd9c] -        dec a -        jr z, .asm_72b9 -        ld a, c -        push af -        ld e, $0 -        ld a, [$cd9f] +	ld a, d +	call Func_3796 +	ld a, [$cd9c] +	dec a +	jr z, .asm_72b9 +	ld a, c +	push af +	ld e, $0 +	ld a, [$cd9f]  .asm_72a3 -        cp $a -        jr c, .asm_72ad -        inc e -        inc e -        sub $a -        jr .asm_72a3 +	cp $a +	jr c, .asm_72ad +	inc e +	inc e +	sub $a +	jr .asm_72a3  .asm_72ad -        add a -        ld d, a -        ld bc, $0202 -        ld hl, $0102 -        pop af -        call Func_1f5f +	add a +	ld d, a +	ld bc, $0202 +	ld hl, $0102 +	pop af +	call Func_1f5f  .asm_72b9 -        ld hl, $cd9f -        inc [hl] -        ld a, [$cd9e] -        or a -        jr z, .asm_72dc -        ld a, [hl] -        ld hl, $cd9c -        cp [hl] -        call z, WaitForWideTextBoxInput -        call $7324 -        ld a, [$cd9c] -        ld hl, $cd9d -        or [hl] -        jr nz, .asm_72e2 -        call z, WaitForWideTextBoxInput -        jr .asm_72e2 +	ld hl, $cd9f +	inc [hl] +	ld a, [$cd9e] +	or a +	jr z, .asm_72dc +	ld a, [hl] +	ld hl, $cd9c +	cp [hl] +	call z, WaitForWideTextBoxInput +	call $7324 +	ld a, [$cd9c] +	ld hl, $cd9d +	or [hl] +	jr nz, .asm_72e2 +	call z, WaitForWideTextBoxInput +	jr .asm_72e2  .asm_72dc -        call WaitForWideTextBoxInput -        call $72ff +	call WaitForWideTextBoxInput +	call $72ff  .asm_72e2 -        call Func_3b31 -        ld a, [$cd9f] -        ld hl, $cd9c -        cp [hl] -        jp c, $7204 -        call Func_0f58 -        call Func_3b31 -        call Func_3b21 -        ld a, [$cd9d] -        or a -        ret z -        scf -        ret +	call Func_3b31 +	ld a, [$cd9f] +	ld hl, $cd9c +	cp [hl] +	jp c, .asm_7204 +	call Func_0f58 +	call Func_3b31 +	call Func_3b21 +	ld a, [$cd9d] +	or a +	ret z +	scf +	ret  ; 0x72ff  INCBIN "baserom.gbc",$72ff,$7354 - $72ff diff --git a/src/engine/effect_functions.asm b/src/engine/effect_functions.asm index 3fabccd..25c1ce2 100644 --- a/src/engine/effect_functions.asm +++ b/src/engine/effect_functions.asm @@ -1,95 +1,95 @@  Poison50PercentEffect: ; 2c000 (b:4000) -        text_de PoisonCheckText -        call DisplayCoinTossScreen2_BankB -        ret nc +	text_de PoisonCheckText +	call DisplayCoinTossScreen2_BankB +	ret nc  PoisonEffect: ; 2c007 (b:4007) -        lb bc, $0f, POISONED -        jr applyEffect +	lb bc, $0f, POISONED +	jr applyEffect -        lb bc, $0f, DOUBLE_POISONED -        jr applyEffect +	lb bc, $0f, DOUBLE_POISONED +	jr applyEffect  Paralysis50PercentEffect: ; 2c011 (b:4011) -        text_de ParalysisCheckText -        call DisplayCoinTossScreen2_BankB -        ret nc -        lb bc, $f0, PARALYZED -        jr applyEffect +	text_de ParalysisCheckText +	call DisplayCoinTossScreen2_BankB +	ret nc +	lb bc, $f0, PARALYZED +	jr applyEffect  Confusion50PercentEffect: ; 2c01d (b:401d) -        text_de ConfusionCheckText -        call DisplayCoinTossScreen2_BankB -        ret nc -        lb bc, $f0, CONFUSED -        jr applyEffect +	text_de ConfusionCheckText +	call DisplayCoinTossScreen2_BankB +	ret nc +	lb bc, $f0, CONFUSED +	jr applyEffect -        text_de SleepCheckText -        call DisplayCoinTossScreen2_BankB -        ret nc +	text_de SleepCheckText +	call DisplayCoinTossScreen2_BankB +	ret nc  SleepEffect: ; 2c030 (b:4030) -        lb bc, $f0, ASLEEP -        jr applyEffect +	lb bc, $f0, ASLEEP +	jr applyEffect  applyEffect -        ld a, [$ff97] -        ld hl, $cc05 -        cp [hl] -        jr nz, .asm_2c061 -        ld a, [wccc4] -        cp $cb -        jr z, .asm_2c058 -        cp $cc -        jr z, .asm_2c058 -        cp $be -        jr nz, .asm_2c061 -        call SwapTurn -        xor a -        call Func_34f0 -        call SwapTurn -        jr c, .asm_2c061 +	ld a, [$ff97] +	ld hl, $cc05 +	cp [hl] +	jr nz, .asm_2c061 +	ld a, [wccc4] +	cp $cb +	jr z, .asm_2c058 +	cp $cc +	jr z, .asm_2c058 +	cp $be +	jr nz, .asm_2c061 +	call SwapTurn +	xor a +	call Func_34f0 +	call SwapTurn +	jr c, .asm_2c061  .asm_2c058 -        ld a, c -        ld [wccf1], a -        call Func_2c09c -        or a -        ret +	ld a, c +	ld [wccf1], a +	call Func_2c09c +	or a +	ret  .asm_2c061 -        ld hl, wcccd -        push hl -        ld e, [hl] -        ld d, $0 -        ld hl, $ccce -        add hl, de -        call SwapTurn -        ld a, [$ff97] -        ld [hli], a -        call SwapTurn -        ld [hl], b -        inc hl -        ld [hl], c -        pop hl -        inc [hl] -        inc [hl] -        inc [hl] -        scf -        ret +	ld hl, wcccd +	push hl +	ld e, [hl] +	ld d, $0 +	ld hl, $ccce +	add hl, de +	call SwapTurn +	ld a, [$ff97] +	ld [hli], a +	call SwapTurn +	ld [hl], b +	inc hl +	ld [hl], c +	pop hl +	inc [hl] +	inc [hl] +	inc [hl] +	scf +	ret  ; 0x2c07e  DisplayCoinTossScreen2_BankB: ; 2c07e (b:407e) -        call DisplayCoinTossScreen2 -        ret +	call DisplayCoinTossScreen2 +	ret  ; 0x2c082  INCBIN "baserom.gbc",$2c082,$2c09c - $2c082  Func_2c09c: ; 2c09c (b:409c) -        ld a, $1 -        ld [wcced], a -        ret +	ld a, $1 +	ld [wcced], a +	ret  ; 0x2c0a2  INCBIN "baserom.gbc",$2c0a2,$30000 - $2c0a2 diff --git a/src/engine/home.asm b/src/engine/home.asm index 9e8144f..48a2fb2 100755 --- a/src/engine/home.asm +++ b/src/engine/home.asm @@ -2467,7 +2467,7 @@ CountCardIDInLocation: ; 15ef (0:15ef)  	pop bc  	ret -; returns [[hWhoseTurn] << 8 + a] in a +; returns [[hWhoseTurn] << 8 + a] in a and in [hl]  ; i.e. variable a of the player whose turn it is  GetTurnDuelistVariable: ; 160b (0:160b)  	ld l, a @@ -2476,7 +2476,7 @@ GetTurnDuelistVariable: ; 160b (0:160b)  	ld a, [hl]  	ret -; returns [([hWhoseTurn] ^ $1) << 8 + a] in a +; returns [([hWhoseTurn] ^ $1) << 8 + a] in a and in [hl]  ; i.e. variable a of the player whose turn it is not  GetOpposingTurnDuelistVariable: ; 1611 (0:1611)  	ld l, a @@ -2494,7 +2494,7 @@ INCBIN "baserom.gbc",$161e,$16c0 - $161e  Func_16c0: ; 16c0 (0:16c0)  	ld a, e -	ld [wccc6], a +	ld [wSelectedMoveIndex], a  	ld a, d  	ld [$ff9f], a  	call LoadDeckCardToBuffer1 @@ -2518,7 +2518,7 @@ Func_16c0: ; 16c0 (0:16c0)  	ld [hli], a  	xor a  	ld [hl], a -	ld [wccc7], a +	ld [wNoDamageOrEffect], a  	ld hl, $ccbf  	ld [hli], a  	ld [hl], a @@ -2550,7 +2550,7 @@ Func_16f6: ; 16f6 (0:16f6)  	ret  Func_1730: ; 1730 (0:1730) -	ld a, [wccc6] +	ld a, [wSelectedMoveIndex]  	ld [wcc10], a  	ld a, [$ff9f]  	ld [wcc11], a @@ -2563,7 +2563,7 @@ Func_1730: ; 1730 (0:1730)  	ld a, $1  	call TryExecuteEffectCommandFunction  	jp c, Func_181e -	call Func_3414 +	call CheckSandAttackOrSmokescreenSubstatus  	jr c, .asm_1766  	ld a, $2  	call TryExecuteEffectCommandFunction @@ -2572,7 +2572,7 @@ Func_1730: ; 1730 (0:1730)  	jr .asm_1777  .asm_1766  	call Func_1874 -	call Func_3400 +	call HandleSandAttackOrSmokescreenSubstatus  	jp c, Func_1823  	ld a, $2  	call TryExecuteEffectCommandFunction @@ -2596,7 +2596,7 @@ Func_1730: ; 1730 (0:1730)  	and $80  	jr nz, .asm_17ad  	call SwapTurn -	call Func_3432 +	call HandleNoDamageOrEffectSubstatus  	call SwapTurn  .asm_17ad  	xor a @@ -2639,7 +2639,7 @@ Func_17ed: ; 17ed (0:17ed)  	ld [hli], a  	ld [hl], a  	ld a, $1 -	ld [wccc7], a +	ld [wNoDamageOrEffect], a  Func_17fb: ; 17fb (0:17fb)  	ld a, [wccc4]  	push af @@ -2734,13 +2734,13 @@ Func_189d: ; 189d (0:189d)  	ld a, [wccb1]  	bit 7, a  	ret nz -	ld a, [wccc7] +	ld a, [wNoDamageOrEffect]  	or a  	ret nz  	ld a, e  	or d  	jr nz, .asm_18b9 -	ld a, DUELVARS_CANT_ATTACK_STATUS +	ld a, DUELVARS_ARENA_CARD_SUBSTATUS2  	call GetOpposingTurnDuelistVariable  	or a  	jr nz, .asm_18b9 @@ -2757,7 +2757,7 @@ Func_189d: ; 189d (0:189d)  	pop de  	ret nc  	bank1call $4f9d -	ld a, DUELVARS_CANT_ATTACK_STATUS +	ld a, DUELVARS_ARENA_CARD_SUBSTATUS2  	call GetOpposingTurnDuelistVariable  	ld [hl], $0  	ld de, $0000 @@ -2792,10 +2792,10 @@ Func_195c: ; 195c (0:195c)  	ld hl, $ccb9  	ld [hli], a  	ld [hl], $0 -	ld a, [wccc7] +	ld a, [wNoDamageOrEffect]  	push af  	xor a -	ld [wccc7], a +	ld [wNoDamageOrEffect], a  	bank1call $7415  	ld a, [wccc4]  	push af @@ -2812,7 +2812,7 @@ Func_195c: ; 195c (0:195c)  	pop af  	ld [wccc4], a  	pop af -	ld [wccc7], a +	ld [wNoDamageOrEffect], a  	ret  Func_1994: ; 1994 (0:1994) @@ -2835,10 +2835,10 @@ Func_1994: ; 1994 (0:1994)  	res 7, d  	xor a  	ld [wccc1], a -	call Func_321d +	call HandleDoubleDamageSubstatus  	jr .asm_19f3  .asm_19b8 -	call Func_321d +	call HandleDoubleDamageSubstatus  	ld a, e  	or d  	ret z @@ -2873,7 +2873,7 @@ Func_1994: ; 1994 (0:1994)  	call SwapTurn  	ld b, CARD_LOCATION_ARENA  	call ApplyAttachedDefender -	call Func_3244 +	call HandleDamageReduction  	bit 7, d  	jr z, .asm_1a0a  	ld de, $0000 @@ -5444,10 +5444,10 @@ Func_3061: ; 3061 (0:3061)  	pop de  	ret -; function that executes a coin toss during a duel, -; displaying the result ([O] or [X]) in the top left corner of the screen. +; function that executes one or more consecutive coin tosses during a duel (a = number of coin tosses), +; displaying each result ([O] or [X]) starting from the top left corner of the screen.  ; text at de is printed in a text box during the coin toss. -; returns c if heads, nc if tails. +;   returns: the number of heads in a and in $cd9d, and carry if at least one heads  DisplayCoinTossScreen1: ; 3071 (0:3071)  	push hl  	ld hl, wCoinTossScreenTextId @@ -5459,9 +5459,10 @@ DisplayCoinTossScreen1: ; 3071 (0:3071)  	pop hl  	ret -; function that executes a coin toss during a duel, without displaying the result. +; function that executes a single coin toss during a duel.  ; text at de is printed in a text box during the coin toss. -; returns c if heads, nc if tails. +;   returns: - carry, and 1 in a and in $cd9d if heads +;            - nc, and 0 in a and in $cd9d if tails  DisplayCoinTossScreen2: ; 307d (0:307d)  	push hl  	ld hl, wCoinTossScreenTextId @@ -5476,7 +5477,7 @@ DisplayCoinTossScreen2: ; 307d (0:307d)  	pop hl  	ret -Func_3090: ; 3090 (0:3090) +CompareDEtoBC: ; 3090 (0:3090)  	ld a, d  	cp b  	ret nz @@ -5746,25 +5747,26 @@ Func_3212: ; 3212 (0:3212)  	ld [rSC], a  	ret -Func_321d: ; 321d (0:321d) -	ld a, $eb +; doubles the damage at de if swords dance or focus energy was used in the last turn +HandleDoubleDamageSubstatus: ; 321d (0:321d) +	ld a, DUELVARS_ARENA_CARD_SUBSTATUS5  	call GetTurnDuelistVariable -	bit 0, [hl] -	call nz, Func_323b -	ld a, $e7 +	bit SUBSTATUS5_THIS_TURN_DOUBLE_DAMAGE, [hl] +	call nz, DoubleDamageAtDE +	ld a, DUELVARS_ARENA_CARD_SUBSTATUS1  	call GetTurnDuelistVariable  	or a -	call nz, Func_323a -	ld a, DUELVARS_CANT_ATTACK_STATUS +	call nz, CommentedOut_323a +	ld a, DUELVARS_ARENA_CARD_SUBSTATUS2  	call GetTurnDuelistVariable  	or a -	call nz, Func_3243 +	call nz, CommentedOut_3243  	ret -Func_323a: ; 323a (0:323a) +CommentedOut_323a: ; 323a (0:323a)  	ret -Func_323b: ; 323b (0:323b) +DoubleDamageAtDE: ; 323b (0:323b)  	ld a, e  	or d  	ret z @@ -5772,60 +5774,61 @@ Func_323b: ; 323b (0:323b)  	rl d  	ret -Func_3243: ; 3243 (0:3243) +CommentedOut_3243: ; 3243 (0:3243)  	ret -Func_3244: ; 3244 (0:3244) -	call Func_3269 -	ld a, DUELVARS_CANT_ATTACK_STATUS +; check if the attacked card has any substatus that reduces the damage this turn +HandleDamageReduction: ; 3244 (0:3244) +	call HandleSubstatus2DamageReduction +	ld a, DUELVARS_ARENA_CARD_SUBSTATUS2  	call GetOpposingTurnDuelistVariable  	or a  	ret z -	cp $3 -	jr z, .asm_325b -	cp $7 -	jr z, .asm_3262 -	cp $12 -	jr z, .asm_3262 -	ret -.asm_325b -	ld hl, $ffec +	cp SUBSTATUS2_REDUCE_BY_20 +	jr z, .reduceDamageBy20 +	cp SUBSTATUS2_POUNCE +	jr z, .reduceDamageBy10 +	cp SUBSTATUS2_GROWL +	jr z, .reduceDamageBy10 +	ret +.reduceDamageBy20 +	ld hl, -20  	add hl, de  	ld e, l  	ld d, h  	ret -.asm_3262 -	ld hl, $fff6 +.reduceDamageBy10 +	ld hl, -10  	add hl, de  	ld e, l  	ld d, h  	ret -Func_3269: ; 3269 (0:3269) -	ld a, [wccc7] +HandleSubstatus2DamageReduction: ; 3269 (0:3269) +	ld a, [wNoDamageOrEffect]  	or a -	jr nz, .asm_32ad -	ld a, $e7 +	jr nz, .noDamage +	ld a, DUELVARS_ARENA_CARD_SUBSTATUS1  	call GetTurnDuelistVariable  	or a -	jr z, .asm_3297 -	cp $f -	jr z, .asm_32ad -	cp $10 -	jr z, .asm_32ad -	cp $11 -	jr z, .asm_32ad -	cp $17 -	jr z, .asm_32ad -	cp $1e -	jr z, .asm_32b1 -	cp $13 -	jr z, .asm_32b8 -	cp $e -	jr z, .asm_32bf -	cp $15 -	jr z, .asm_32ca -.asm_3297 +	jr z, .notAffectedBySubstatus1 +	cp SUBSTATUS1_NO_DAMAGE_F +	jr z, .noDamage +	cp SUBSTATUS1_NO_DAMAGE_10 +	jr z, .noDamage +	cp SUBSTATUS1_NO_DAMAGE_11 +	jr z, .noDamage +	cp SUBSTATUS1_NO_DAMAGE_17 +	jr z, .noDamage +	cp SUBSTATUS1_REDUCE_BY_10 +	jr z, .reduceDamageBy10 +	cp SUBSTATUS1_REDUCE_BY_20 +	jr z, .reduceDamageBy20 +	cp SUBSTATUS1_HARDEN +	jr z, .preventLessThan30Damage +	cp SUBSTATUS1_KABUTO_ARMOR +	jr z, .halveDamage +.notAffectedBySubstatus1  	call Func_34ef  	ret c  	ld a, [wccb1] @@ -5837,33 +5840,33 @@ Func_3269: ; 3269 (0:3269)  	cp $8b  	jr z, .asm_32e9  	ret -.asm_32ad -	ld de, $0000 +.noDamage +	ld de, 0  	ret -.asm_32b1 -	ld hl, $fff6 +.reduceDamageBy10 +	ld hl, -10  	add hl, de  	ld e, l  	ld d, h  	ret -.asm_32b8 -	ld hl, $ffec +.reduceDamageBy20 +	ld hl, -20  	add hl, de  	ld e, l  	ld d, h  	ret -.asm_32bf -	ld bc, $0028 -	call Func_3090 +.preventLessThan30Damage +	ld bc, 40 +	call CompareDEtoBC  	ret nc -	ld de, $0000 +	ld de, 0  	ret -.asm_32ca +.halveDamage  	sla d  	rr e  	bit 0, e  	ret z -	ld hl, $fffb +	ld hl, -5  	add hl, de  	ld e, l  	ld d, h @@ -5873,7 +5876,7 @@ Func_3269: ; 3269 (0:3269)  	cp $4  	ret z  	ld bc, $001e -	call Func_3090 +	call CompareDEtoBC  	ret c  	ld de, $0000  	ret @@ -5891,19 +5894,21 @@ Func_3269: ; 3269 (0:3269)  INCBIN "baserom.gbc",$32f7,$33c1 - $32f7 -CheckIfCantAttackDueToAttackEffect:: ; 33c1 (0:33c1) -	ld a, DUELVARS_CANT_ATTACK_STATUS +; return carry if card is under a condition that makes it unable to attack +; also return in hl the text id to be displayed +HandleCantAttackSubstatus: ; 33c1 (0:33c1) +	ld a, DUELVARS_ARENA_CARD_SUBSTATUS2  	call GetTurnDuelistVariable  	or a  	ret z  	text_hl UnableToAttackDueToTailWagText -	cp $05 +	cp SUBSTATUS2_TAIL_WAG  	jr z, .returnWithCantAttack  	text_hl UnableToAttackDueToLeerText -	cp $06 +	cp SUBSTATUS2_LEER  	jr z, .returnWithCantAttack  	text_hl UnableToAttackDueToBoneAttackText -	cp $0b +	cp SUBSTATUS2_BONE_ATTACK  	jr z, .returnWithCantAttack  	or a  	ret @@ -5911,30 +5916,32 @@ CheckIfCantAttackDueToAttackEffect:: ; 33c1 (0:33c1)  	scf  	ret -Func_33e1: ; 33e1 (0:33e1) -	ld a, DUELVARS_CANT_ATTACK_STATUS +; return carry if card cannot use selected move due to amnesia +HandleAmnesiaSubstatus: ; 33e1 (0:33e1) +	ld a, DUELVARS_ARENA_CARD_SUBSTATUS2  	call GetTurnDuelistVariable  	or a -	jr nz, .asm_33ea +	jr nz, .checkAmnesia  	ret -.asm_33ea -	cp $4 -	jr z, .asm_33f0 -.asm_33ee +.checkAmnesia +	cp SUBSTATUS2_AMNESIA +	jr z, .affectedByAmnesia +.notTheMoveDisabledByAmnesia  	or a  	ret -.asm_33f0 -	ld a, $f2 +.affectedByAmnesia +	ld a, DUELVARS_ARENA_CARD_DISABLED_MOVE_INDEX  	call GetTurnDuelistVariable -	ld a, [wccc6] +	ld a, [wSelectedMoveIndex]  	cp [hl] -	jr nz, .asm_33ee +	jr nz, .notTheMoveDisabledByAmnesia  	text_hl UnableToUseAttackDueToAmnesiaText  	scf  	ret -Func_3400: ; 3400 (0:3400) -	call Func_3414 +; return carry if the attack was unsuccessful due to sand attack or smokescreen effect +HandleSandAttackOrSmokescreenSubstatus: ; 3400 (0:3400) +	call CheckSandAttackOrSmokescreenSubstatus  	ret nc  	call DisplayCoinTossScreen2  	ld [wcc0a], a @@ -5945,46 +5952,50 @@ Func_3400: ; 3400 (0:3400)  	scf  	ret -Func_3414: ; 3414 (0:3414) -	ld a, DUELVARS_CANT_ATTACK_STATUS +; return carry if card is under the effects of sand attack or smokescreen +CheckSandAttackOrSmokescreenSubstatus: ; 3414 (0:3414) +	ld a, DUELVARS_ARENA_CARD_SUBSTATUS2  	call GetTurnDuelistVariable  	or a  	ret z  	text_de SandAttackCheckText -	cp $2 -	jr z, .asm_342b +	cp SUBSTATUS2_SAND_ATTACK +	jr z, .cardIsAffected  	text_de SmokescreenCheckText -	cp $1 -	jr z, .asm_342b +	cp SUBSTATUS2_SMOKESCREEN +	jr z, .cardIsAffected  	or a  	ret -.asm_342b +.cardIsAffected  	ld a, [wcc0a]  	or a  	ret nz  	scf  	ret -Func_3432: ; 3432 (0:3432) +; return carry if card being attacked is under a substatus that prevents +; any damage or effect dealt to it for a turn. +; also return the cause of the substatus at wNoDamageOrEffect +HandleNoDamageOrEffectSubstatus: ; 3432 (0:3432)  	xor a -	ld [wccc7], a +	ld [wNoDamageOrEffect], a  	ld a, [wccb1]  	cp $4  	ret z -	ld a, $e7 +	ld a, DUELVARS_ARENA_CARD_SUBSTATUS1  	call GetTurnDuelistVariable  	ld e, $3  	text_hl NoDamageOrEffectDueToFlyText -	cp $d -	jr z, .asm_346a +	cp SUBSTATUS1_FLY +	jr z, .noDamageOrEffect  	ld e, $2  	text_hl NoDamageOrEffectDueToBarrierText -	cp $14 -	jr z, .asm_346a +	cp SUBSTATUS1_BARRIER +	jr z, .noDamageOrEffect  	ld e, $1  	text_hl NoDamageOrEffectDueToAgilityText -	cp $c -	jr z, .asm_346a +	cp SUBSTATUS1_AGILITY +	jr z, .noDamageOrEffect  	call Func_34ef  	ccf  	ret nc @@ -5993,9 +6004,9 @@ Func_3432: ; 3432 (0:3432)  	jr z, .asm_3470  	or a  	ret -.asm_346a +.noDamageOrEffect  	ld a, e -	ld [wccc7], a +	ld [wNoDamageOrEffect], a  	scf  	ret  .asm_3470 @@ -6011,7 +6022,7 @@ Func_3432: ; 3432 (0:3432)  	ret z  	ld e, $5  	text_hl NoDamageOrEffectDueToNShieldText -	jr .asm_346a +	jr .noDamageOrEffect  Func_348a: ; 348a (0:348a)  	ld a, [wccc4] @@ -6033,7 +6044,7 @@ Func_348a: ; 348a (0:348a)  	call DisplayCoinTossScreen2  	ret nc  	ld a, $4 -	ld [wccc7], a +	ld [wNoDamageOrEffect], a  	text_hl NoDamageOrEffectDueToTransparencyText  	scf  	ret @@ -6136,38 +6147,81 @@ Func_3525: ; 3525 (0:3525)  INCBIN "baserom.gbc",$356a,$35e6 - $356a -Func_35e6: ; 35e6 (0:35e6) -	ld a, $e7 +; if swords dance or focus energy was used this turn, +; mark that the base power of the next turn's attack has to be doubled +HandleSwordsDanceOrFocusEnergySubstatus: ; 35e6 (0:35e6) +	ld a, DUELVARS_ARENA_CARD_SUBSTATUS1  	call GetTurnDuelistVariable  	ld [hl], $0  	or a  	ret z -	cp $19 +	cp SUBSTATUS1_NEXT_TURN_DOUBLE_DAMAGE  	ret nz -	ld a, $eb +	ld a, DUELVARS_ARENA_CARD_SUBSTATUS5  	call GetTurnDuelistVariable -	set 0, [hl] +	set SUBSTATUS5_THIS_TURN_DOUBLE_DAMAGE, [hl]  	ret -Func_35fa: ; 35fa (0:35fa) -	ld a, $eb +; clears the substatus 2 and updates the double damage condition of the turn holder +UpdateSubstatusConditions: ; 35fa (0:35fa) +	ld a, DUELVARS_ARENA_CARD_SUBSTATUS5  	call GetTurnDuelistVariable  	res 1, [hl]  	push hl -	ld a, DUELVARS_CANT_ATTACK_STATUS +	ld a, DUELVARS_ARENA_CARD_SUBSTATUS2  	call GetTurnDuelistVariable  	xor a  	ld [hl], a -	ld a, $e7 +	ld a, DUELVARS_ARENA_CARD_SUBSTATUS1  	call GetTurnDuelistVariable  	pop hl -	cp $19 +	cp SUBSTATUS1_NEXT_TURN_DOUBLE_DAMAGE  	ret z -	res 0, [hl] +	res SUBSTATUS5_THIS_TURN_DOUBLE_DAMAGE, [hl]  	ret  ; 0x3615 -INCBIN "baserom.gbc",$3615,$367b - $3615 +INCBIN "baserom.gbc",$3615,$363b - $3615 + +; if the target card's HP is 0 and the attacking card's HP is not, +; the attacking card faints if it was affected by destiny bond +HandleDestinyBondSubstatus: ; 363b (0:363b) +	ld a, DUELVARS_ARENA_CARD_SUBSTATUS1 +	call GetOpposingTurnDuelistVariable +	cp SUBSTATUS1_DESTINY_BOND +	jr z, .checkHP +	ret + +.checkHP +	ld a, DUELVARS_ARENA_CARD +	call GetOpposingTurnDuelistVariable +	cp $ff +	ret z +	ld a, DUELVARS_ARENA_CARD_HP +	call GetOpposingTurnDuelistVariable +	or a +	ret nz +	ld a, DUELVARS_ARENA_CARD_HP +	call GetTurnDuelistVariable +	or a +	ret z +	ld [hl], $0 +	push hl +	call $4f9d +	call $503a +	pop hl +	ld l, DUELVARS_ARENA_CARD +	ld a, [hl] +	call LoadDeckCardToBuffer2 +	ld hl, wCardBuffer2Name +	ld a, [hli] +	ld h, [hl] +	ld l, a +	call Func_2ebb +	text_hl KnockedOutDueToDestinyBondText +	call DrawWideTextBox_WaitForInput +	ret +; 0x367b  Func_367b: ; 367b (0:367b)  	ld a, [wccc4] @@ -6264,7 +6318,7 @@ Func_36f7: ; 36f7 (0:36f7)  INCBIN "baserom.gbc",$3729,$3730 - $3729  Func_3730: ; 3730 (0:3730) -	ld a, $e9 +	ld a, DUELVARS_ARENA_CARD_SUBSTATUS3  	call GetTurnDuelistVariable  	or a  	ret nz @@ -6278,7 +6332,7 @@ Func_3730: ; 3730 (0:3730)  INCBIN "baserom.gbc",$3743,$374a - $3743  Func_374a: ; 374a (0:374a) -	ld a, $ea +	ld a, DUELVARS_ARENA_CARD_SUBSTATUS4  	call GetTurnDuelistVariable  	or a  	ret nz diff --git a/src/text/text_offsets.asm b/src/text/text_offsets.asm index b906c99..7e7d64b 100755 --- a/src/text/text_offsets.asm +++ b/src/text/text_offsets.asm @@ -2421,7 +2421,7 @@ TextOffsets:: ; 34000 (d:4000)  	text KinglerKind  	text KinglerDescription  	text HorseaName -	text HorseasSmokescreenDescription +	text OpponentAttackMayDoNothingDescription  	text HorseaKind  	text HorseaDescription  	text SeadraName @@ -2624,7 +2624,7 @@ TextOffsets:: ; 34000 (d:4000)  	text GravelerDescription  	text GolemName  	text AvalancheName -	text AvalancheDescription +	text GolemsSelfdestructDescription  	text GolemKind  	text GolemDescription  	text OnixName diff --git a/src/text/texta.asm b/src/text/texta.asm index 48adce3..d9f2281 100644 --- a/src/text/texta.asm +++ b/src/text/texta.asm @@ -1267,7 +1267,7 @@ KinglerDescription: ; 5bed7 (16:7ed7)  HorseaName: ; 5bf43 (16:7f43)  	db TX_START,"Horsea",TX_END -HorseasSmokescreenDescription: ; 5bf4b (16:7f4b) +OpponentAttackMayDoNothingDescription: ; 5bf4b (16:7f4b)  	db TX_START,"If the Defending Pok`mon tries to\n"  	db "attack during your opponent's next\n"  	db "turn, your opponent flips a coin.\n" diff --git a/src/text/textb.asm b/src/text/textb.asm index f7a84da..d03046e 100644 --- a/src/text/textb.asm +++ b/src/text/textb.asm @@ -857,7 +857,7 @@ GolemName: ; 5ef4c (17:6f4c)  AvalancheName: ; 5ef53 (17:6f53)  	db TX_START,"Avalanche",TX_END -AvalancheDescription: ; 5ef5e (17:6f5e) +GolemsSelfdestructDescription: ; 5ef5e (17:6f5e)  	db TX_START,"Does 20 damage to each Pok`mon on\n"  	db "each player's Bench. (Don't apply\n"  	db "Weakness and Resistance for Benched\n" diff --git a/src/wram.asm b/src/wram.asm index 30826db..54c62eb 100755 --- a/src/wram.asm +++ b/src/wram.asm @@ -63,14 +63,22 @@ wPlayerBench4CardHP:: ; c2cc  	ds $1  wPlayerBench5CardHP:: ; c2cd  	ds $1 -	ds $1a +	ds $19 -; The only known use of this is to store when an attack  -; causes a pokemon to not be able to attack the following turn. -; for example: tail wag, leer -wPlayerCantAttackStatus:: ; c2e8 +wPlayerArenaCardSubstatus1:: ; c2e7 +	ds $1 + +wPlayerArenaCardSubstatus2:: ; c2e8 +	ds $1 + +wPlayerArenaCardSubstatus3:: ; c2e9 +	ds $1 + +wPlayerArenaCardSubstatus4:: ; c2ea +	ds $1 + +wPlayerArenaCardSubstatus5:: ; c2eb  	ds $1 -	ds $3  ; Each bit represents a prize (1 = not taken ; 0 = taken)  wPlayerPrizes:: ; c2ec @@ -94,7 +102,11 @@ wPlayerArenaCardStatus:: ; c2f0  ; other - AI controlled  wPlayerDuelistType:: ; c2f1  	ds $1 -	ds $e + +; if under the effects of amnesia, which move (0 or 1) can't be used +wPlayerArenaCardDisabledMoveIndex:: ; c2f2 +	ds $1 +	ds $d  wOpponentDuelVariables:: ; c300 @@ -130,15 +142,22 @@ wOpponentBench4CardHP:: ; c3cc  	ds $1  wOpponentBench5CardHP:: ; c3cd  	ds $1 -	ds $1a +	ds $19 -;The only known use of this is to store -;when an attack causes a pokemon -;to not be able to attack the following turn -;for example: tail wag, leer -wOpponentCantAttackStatus:: ; c3e8 +wOpponentArenaCardSubstatus1:: ; c3e7 +	ds $1 + +wOpponentArenaCardSubstatus2:: ; c3e8 +	ds $1 + +wOpponentArenaCardSubstatus3:: ; c3e9 +	ds $1 + +wOpponentArenaCardSubstatus4:: ; c3ea +	ds $1 + +wOpponentArenaCardSubstatus5:: ; c3eb  	ds $1 -	ds $3  wOpponentPrizes:: ; c3ec  	ds $1 @@ -160,7 +179,10 @@ wOpponentArenaCardStatus:: ; c3f0  ; other - AI controlled  wOpponentDuelistType:: ; c3f1  	ds $1 -	ds $e + +wOpponentArenaCardDisabledMoveIndex:: ; c3f2 +	ds $1 +	ds $d  wPlayerDeck:: ; c400  	ds $80 @@ -169,8 +191,8 @@ wOpponentDeck:: ; c480  	ds $80  	ds $10 -; when the attack menu opens, it stores  -; each move in the order of  +; when the attack menu opens, it stores +; each move in the order of  ; cardNumber, moveNumber, ...  DuelAttackPointerTable:: ; c510  	ds $4f0 @@ -454,10 +476,12 @@ wccc3:: ; ccc3  wccc4:: ; ccc4  	ds $2 -wccc6:: ; ccc6 +; may contain 0 or 1 depending on which move was selected +wSelectedMoveIndex:: ; ccc6  	ds $1 -wccc7:: ; ccc7 +; if affected by a no damage or effect substatus, this flag indicates what the cause was +wNoDamageOrEffect:: ; ccc7  	ds $2  wccc9:: ; ccc9 @@ -590,7 +614,7 @@ wce4a:: ; ce4a  wce4b:: ; ce4b  	ds $3 -	 +  wCoinTossScreenTextId:: ; ce4e  	ds $2 | 
