effect command cleanup

-weather and badge type boosts
This commit is contained in:
yenatch 2013-04-19 03:50:45 -04:00
parent f125f14e98
commit 7503f9074c
2 changed files with 313 additions and 71 deletions

View File

@ -376,7 +376,7 @@ CantMove: ; 341f0
and $ec and $ec
ld [hl], a ld [hl], a
call Function0x377be call ResetFuryCutterCount
ld a, BATTLE_VARS_MOVE_ANIM ld a, BATTLE_VARS_MOVE_ANIM
call CleanGetBattleVarPair call CleanGetBattleVarPair
@ -1394,9 +1394,10 @@ BattleCommand07: ; 346d2
ld a, [hli] ld a, [hli]
ld d, a ld d, a
ld e, [hl] ld e, [hl]
ld a, [hBattleTurn] ld a, [hBattleTurn]
and a and a
jr z, .asm_346f7 jr z, .go
ld hl, EnemyMonType1 ld hl, EnemyMonType1
ld a, [hli] ld a, [hli]
@ -1407,7 +1408,7 @@ BattleCommand07: ; 346d2
ld d, a ld d, a
ld e, [hl] ld e, [hl]
.asm_346f7 .go
ld a, BATTLE_VARS_MOVE_TYPE ld a, BATTLE_VARS_MOVE_TYPE
call GetBattleVarPair call GetBattleVarPair
ld [$d265], a ld [$d265], a
@ -1415,69 +1416,77 @@ BattleCommand07: ; 346d2
push hl push hl
push de push de
push bc push bc
ld a, $3e callba DoWeatherModifiers
ld hl, $7da4
rst FarCall
pop bc pop bc
pop de pop de
pop hl pop hl
push de push de
push bc push bc
ld a, $3e callba DoBadgeTypeBoosts
ld hl, $7e24
rst FarCall
pop bc pop bc
pop de pop de
ld a, [$d265] ld a, [$d265]
cp b cp b
jr z, .asm_34720 jr z, .stab
cp c cp c
jr z, .asm_34720 jr z, .stab
jr .asm_3473a jr .asm_3473a
.asm_34720 .stab
ld hl, CurDamage + 1 ld hl, CurDamage + 1
ld a, [hld] ld a, [hld]
ld h, [hl] ld h, [hl]
ld l, a ld l, a
ld b, h ld b, h
ld c, l ld c, l
srl b srl b
rr c rr c
add hl, bc add hl, bc
ld a, h ld a, h
ld [CurDamage], a ld [CurDamage], a
ld a, l ld a, l
ld [CurDamage + 1], a ld [CurDamage + 1], a
ld hl, TypeModifier ld hl, TypeModifier
set 7, [hl] set 7, [hl]
.asm_3473a .asm_3473a
ld a, BATTLE_VARS_MOVE_TYPE ld a, BATTLE_VARS_MOVE_TYPE
call CleanGetBattleVarPair call CleanGetBattleVarPair
ld b, a ld b, a
ld hl, TypeMatchup ld hl, TypeMatchup
.asm_34743 .asm_34743
ld a, [hli] ld a, [hli]
cp $ff cp $ff
jr z, .asm_347b7 ; 34746 $6f jr z, .end
; foresight
cp $fe cp $fe
jr nz, .asm_34757 ; 3474a $b jr nz, .asm_34757
ld a, BATTLE_VARS_SUBSTATUS1_OPP ld a, BATTLE_VARS_SUBSTATUS1_OPP
call CleanGetBattleVarPair call CleanGetBattleVarPair
bit 3, a bit 3, a
jr nz, .asm_347b7 ; 34753 $62 jr nz, .end
jr .asm_34743 ; 34755 $ec
jr .asm_34743
.asm_34757 .asm_34757
cp b cp b
jr nz, .asm_347b3 ; 34758 $59 jr nz, .asm_347b3
ld a, [hl] ld a, [hl]
cp d cp d
jr z, .asm_34763 ; 3475c $5 jr z, .asm_34763
cp e cp e
jr z, .asm_34763 ; 3475f $2 jr z, .asm_34763
jr .asm_347b3 ; 34761 $50 jr .asm_347b3
.asm_34763 .asm_34763
push hl push hl
push bc push bc
@ -1487,7 +1496,7 @@ BattleCommand07: ; 346d2
ld b, a ld b, a
ld a, [hl] ld a, [hl]
and a and a
jr nz, .asm_34775 ; 3476e $5 jr nz, .asm_34775
inc a inc a
ld [AttackMissed], a ld [AttackMissed], a
xor a xor a
@ -1495,14 +1504,18 @@ BattleCommand07: ; 346d2
ld [$ffb7], a ld [$ffb7], a
add b add b
ld [TypeModifier], a ld [TypeModifier], a
xor a xor a
ld [$ffb4], a ld [$ffb4], a
ld hl, CurDamage ld hl, CurDamage
ld a, [hli] ld a, [hli]
ld [$ffb5], a ld [$ffb5], a
ld a, [hld] ld a, [hld]
ld [$ffb6], a ld [$ffb6], a
call $3119 call $3119
ld a, [$ffb4] ld a, [$ffb4]
ld b, a ld b, a
ld a, [$ffb5] ld a, [$ffb5]
@ -1510,7 +1523,8 @@ BattleCommand07: ; 346d2
ld b, a ld b, a
ld a, [$ffb6] ld a, [$ffb6]
or b or b
jr z, .asm_347ab ; 34794 $15 jr z, .asm_347ab
ld a, $a ld a, $a
ld [$ffb7], a ld [$ffb7], a
ld b, $4 ld b, $4
@ -1519,9 +1533,11 @@ BattleCommand07: ; 346d2
ld b, a ld b, a
ld a, [$ffb6] ld a, [$ffb6]
or b or b
jr nz, .asm_347ab ; 347a5 $4 jr nz, .asm_347ab
ld a, $1 ld a, $1
ld [$ffb6], a ld [$ffb6], a
.asm_347ab .asm_347ab
ld a, [$ffb5] ld a, [$ffb5]
ld [hli], a ld [hli], a
@ -1529,11 +1545,13 @@ BattleCommand07: ; 346d2
ld [hl], a ld [hl], a
pop bc pop bc
pop hl pop hl
.asm_347b3 .asm_347b3
inc hl inc hl
inc hl inc hl
jr .asm_34743 ; 347b5 $8c jr .asm_34743
.asm_347b7
.end
call Function0x347c8 call Function0x347c8
ld a, [$d265] ld a, [$d265]
ld b, a ld b, a
@ -2780,10 +2798,10 @@ BattleCommand0b: ; 34f60
ld a, [hBattleTurn] ld a, [hBattleTurn]
and a and a
ld de, $c672 ld de, PlayerRolloutCount
ld a, 1 ld a, 1
jr z, .asm_34f76 jr z, .asm_34f76
ld de, $c67a ld de, EnemyRolloutCount
ld a, 4 ld a, 4
.asm_34f76 .asm_34f76
@ -3156,11 +3174,11 @@ BattleCommand0f: ; 35175
BattleCommandae: ; 35197 BattleCommandae: ; 35197
; startloop ; startloop
ld hl, $c672 ld hl, PlayerRolloutCount
ld a, [hBattleTurn] ld a, [hBattleTurn]
and a and a
jr z, .asm_351a2 jr z, .asm_351a2
ld hl, $c67a ld hl, EnemyRolloutCount
.asm_351a2 .asm_351a2
xor a xor a
@ -3473,7 +3491,7 @@ PlayerAttackDamage: ; 352e2
; 3534d ; 3534d
Function0x3534d: ; 3534d= Function0x3534d: ; 3534d
ld a, h ld a, h
or b or b
jr z, .asm_3536b ; 0x3534f $1a jr z, .asm_3536b ; 0x3534f $1a
@ -3726,12 +3744,12 @@ BattleCommanda1: ; 35461
ld c, $14 ld c, $14
call DelayFrames call DelayFrames
xor a xor a
ld [$c672], a ld [PlayerRolloutCount], a
ld [DefaultFlypoint], a ld [DefaultFlypoint], a
ld [$c72d], a ld [$c72d], a
jr .asm_3548d ; 35480 $b jr .asm_3548d ; 35480 $b
.asm_35482 .asm_35482
ld a, [$c672] ld a, [PlayerRolloutCount]
ld b, a ld b, a
ld a, [PartyCount] ld a, [PartyCount]
sub b sub b
@ -3791,13 +3809,13 @@ BattleCommanda1: ; 35461
jr nz, .asm_35502 jr nz, .asm_35502
xor a xor a
ld [$c67a], a ld [EnemyRolloutCount], a
ld [DefaultFlypoint], a ld [DefaultFlypoint], a
ld [$c72d], a ld [$c72d], a
jr .asm_3550d jr .asm_3550d
.asm_35502 .asm_35502
ld a, [$c67a] ld a, [EnemyRolloutCount]
ld b, a ld b, a
ld a, [OTPartyCount] ld a, [OTPartyCount]
sub b sub b
@ -6803,11 +6821,11 @@ BattleCommand21: ; 36671
call CleanGetBattleVarPair call CleanGetBattleVarPair
bit 0, a bit 0, a
ret z ret z
ld hl, $c672 ld hl, PlayerRolloutCount
ld a, [hBattleTurn] ld a, [hBattleTurn]
and a and a
jr z, .asm_36684 ; 3667f $3 jr z, .asm_36684 ; 3667f $3
ld hl, $c67a ld hl, EnemyRolloutCount
.asm_36684 .asm_36684
dec [hl] dec [hl]
jr nz, .asm_366dc ; 36685 $55 jr nz, .asm_366dc ; 36685 $55
@ -6870,12 +6888,12 @@ BattleCommand22: ; 366e5
; unleashenergy ; unleashenergy
ld de, $c682 ld de, $c682
ld bc, $c672 ld bc, PlayerRolloutCount
ld a, [hBattleTurn] ld a, [hBattleTurn]
and a and a
jr z, .asm_366f6 ; 366ee $6 jr z, .asm_366f6 ; 366ee $6
ld de, $c684 ld de, $c684
ld bc, $c67a ld bc, EnemyRolloutCount
.asm_366f6 .asm_366f6
ld a, BATTLE_VARS_SUBSTATUS3 ld a, BATTLE_VARS_SUBSTATUS3
call GetBattleVarPair call GetBattleVarPair
@ -6901,11 +6919,11 @@ BattleCommand22: ; 366e5
BattleCommand3e: ; 3671a BattleCommand3e: ; 3671a
; checkrampage ; checkrampage
ld de, $c672 ld de, PlayerRolloutCount
ld a, [hBattleTurn] ld a, [hBattleTurn]
and a and a
jr z, .asm_36725 ; 36720 $3 jr z, .asm_36725 ; 36720 $3
ld de, $c67a ld de, EnemyRolloutCount
.asm_36725 .asm_36725
ld a, BATTLE_VARS_SUBSTATUS3 ld a, BATTLE_VARS_SUBSTATUS3
call GetBattleVarPair call GetBattleVarPair
@ -6944,11 +6962,11 @@ BattleCommand3d: ; 36751
and 7 and 7
ret nz ret nz
ld de, $c672 ld de, PlayerRolloutCount
ld a, [hBattleTurn] ld a, [hBattleTurn]
and a and a
jr z, .asm_36764 ; 3675f $3 jr z, .asm_36764 ; 3675f $3
ld de, $c67a ld de, EnemyRolloutCount
.asm_36764 .asm_36764
ld a, BATTLE_VARS_SUBSTATUS3 ld a, BATTLE_VARS_SUBSTATUS3
call GetBattleVarPair call GetBattleVarPair
@ -6957,7 +6975,7 @@ BattleCommand3d: ; 36751
and $1 and $1
inc a inc a
ld [de], a ld [de], a
ld a, $1 ld a, 1
ld [$c73e], a ld [$c73e], a
ret ret
; 36778 ; 36778
@ -7310,12 +7328,12 @@ BattleCommand24: ; 369b6
; Loop back to the command before 'critical'. ; Loop back to the command before 'critical'.
ld de, $c672 ld de, PlayerRolloutCount
ld bc, $c682 ld bc, $c682
ld a, [hBattleTurn] ld a, [hBattleTurn]
and a and a
jr z, .asm_369c7 jr z, .asm_369c7
ld de, $c67a ld de, EnemyRolloutCount
ld bc, $c684 ld bc, $c684
.asm_369c7 .asm_369c7
@ -9562,11 +9580,11 @@ BattleCommand59: ; 376f8
BattleCommand5b: ; 37718 BattleCommand5b: ; 37718
; checkcurl ; checkcurl
ld de, $c672 ld de, PlayerRolloutCount
ld a, [hBattleTurn] ld a, [hBattleTurn]
and a and a
jr z, .asm_37723 ; 3771e $3 jr z, .asm_37723 ; 3771e $3
ld de, $c67a ld de, EnemyRolloutCount
.asm_37723 .asm_37723
ld a, BATTLE_VARS_SUBSTATUS1 ld a, BATTLE_VARS_SUBSTATUS1
call CleanGetBattleVarPair call CleanGetBattleVarPair
@ -9588,28 +9606,33 @@ BattleCommand5c: ; 37734
ld a, BATTLE_VARS_STATUS ld a, BATTLE_VARS_STATUS
call CleanGetBattleVarPair call CleanGetBattleVarPair
and $7 and 7
ret nz ret nz
ld hl, $c672
ld hl, PlayerRolloutCount
ld a, [hBattleTurn] ld a, [hBattleTurn]
and a and a
jr z, .asm_37747 ; 37742 $3 jr z, .asm_37747
ld hl, $c67a ld hl, EnemyRolloutCount
.asm_37747 .asm_37747
ld a, [hl] ld a, [hl]
and a and a
jr nz, .asm_37750 ; 37749 $5 jr nz, .asm_37750
ld a, $1 ld a, 1
ld [$c73e], a ld [$c73e], a
.asm_37750 .asm_37750
ld a, [AttackMissed] ld a, [AttackMissed]
and a and a
jr z, .asm_3775e ; 37754 $8 jr z, .hit
ld a, BATTLE_VARS_SUBSTATUS1 ld a, BATTLE_VARS_SUBSTATUS1
call GetBattleVarPair call GetBattleVarPair
res 6, [hl] res 6, [hl]
ret ret
.asm_3775e
.hit
inc [hl] inc [hl]
ld a, [hl] ld a, [hl]
ld b, a ld b, a
@ -9619,10 +9642,12 @@ BattleCommand5c: ; 37734
call GetBattleVarPair call GetBattleVarPair
res 6, [hl] res 6, [hl]
jr .asm_37775 ; 3776c $7 jr .asm_37775 ; 3776c $7
.asm_3776e .asm_3776e
ld a, BATTLE_VARS_SUBSTATUS1 ld a, BATTLE_VARS_SUBSTATUS1
call GetBattleVarPair call GetBattleVarPair
set 6, [hl] set 6, [hl]
.asm_37775 .asm_37775
ld a, BATTLE_VARS_SUBSTATUS2 ld a, BATTLE_VARS_SUBSTATUS2
call CleanGetBattleVarPair call CleanGetBattleVarPair
@ -9654,29 +9679,38 @@ BattleCommand5d: ; 37791
BattleCommand5e: ; 37792 BattleCommand5e: ; 37792
; furycutter ; furycutter
ld hl, $c678 ld hl, PlayerFuryCutterCount
ld a, [hBattleTurn] ld a, [hBattleTurn]
and a and a
jr z, .asm_3779d ; 37798 $3 jr z, .go
ld hl, $c680 ld hl, EnemyFuryCutterCount
.asm_3779d
.go
ld a, [AttackMissed] ld a, [AttackMissed]
and a and a
jp nz, Function0x377be jp nz, ResetFuryCutterCount
inc [hl] inc [hl]
; Damage capped at 5 turns' worth (16x).
ld a, [hl] ld a, [hl]
ld b, a ld b, a
cp $6 cp 6
jr c, .asm_377ad ; 377a9 $2 jr c, .checkdouble
ld b, $5 ld b, 5
.asm_377ad
.checkdouble
dec b dec b
ret z ret z
; Double the damage
ld hl, CurDamage + 1 ld hl, CurDamage + 1
sla [hl] sla [hl]
dec hl dec hl
rl [hl] rl [hl]
jr nc, .asm_377ad ; 377b7 $f4 jr nc, .checkdouble
; No overflow
ld a, $ff ld a, $ff
ld [hli], a ld [hli], a
ld [hl], a ld [hl], a
@ -9684,16 +9718,17 @@ BattleCommand5e: ; 37792
; 377be ; 377be
Function0x377be: ; 377be ResetFuryCutterCount: ; 377be
push hl push hl
ld hl, $c678 ld hl, PlayerFuryCutterCount
ld a, [hBattleTurn] ld a, [hBattleTurn]
and a and a
jr z, .asm_377ca jr z, .reset
ld hl, $c680 ld hl, EnemyFuryCutterCount
.asm_377ca .reset
xor a xor a
ld [hl], a ld [hl], a

209
main.asm
View File

@ -14457,7 +14457,214 @@ INCBIN "baserom.gbc", $f8ea3, $fbbfc - $f8ea3
INCLUDE "battle/magikarp_length.asm" INCLUDE "battle/magikarp_length.asm"
INCBIN "baserom.gbc", $fbccf, $fbe91 - $fbccf INCBIN "baserom.gbc", $fbccf, $fbda4 - $fbccf
DoWeatherModifiers: ; fbda4
ld de, .WeatherTypeModifiers
ld a, [Weather]
ld b, a
ld a, [$d265] ; move type
ld c, a
.CheckWeatherType
ld a, [de]
inc de
cp $ff
jr z, .asm_fbdc0
cp b
jr nz, .NextWeatherType
ld a, [de]
cp c
jr z, .ApplyModifier
.NextWeatherType
inc de
inc de
jr .CheckWeatherType
.asm_fbdc0
ld de, .WeatherMoveModifiers
ld a, BATTLE_VARS_MOVE_EFFECT
call CleanGetBattleVarPair
ld c, a
.CheckWeatherMove
ld a, [de]
inc de
cp $ff
jr z, .done
cp b
jr nz, .NextWeatherMove
ld a, [de]
cp c
jr z, .ApplyModifier
.NextWeatherMove
inc de
inc de
jr .CheckWeatherMove
.ApplyModifier
xor a
ld [$ffb4], a
ld hl, CurDamage
ld a, [hli]
ld [$ffb5], a
ld a, [hl]
ld [$ffb6], a
inc de
ld a, [de]
ld [$ffb7], a
call Multiply
ld a, 10
ld [$ffb7], a
ld b, $4
call Divide
ld a, [$ffb4]
and a
ld bc, $ffff
jr nz, .Update
ld a, [$ffb5]
ld b, a
ld a, [$ffb6]
ld c, a
or b
jr nz, .Update
ld bc, 1
.Update
ld a, b
ld [CurDamage], a
ld a, c
ld [CurDamage + 1], a
.done
ret
.WeatherTypeModifiers
db WEATHER_RAIN, WATER, 15
db WEATHER_RAIN, FIRE, 05
db WEATHER_SUN, FIRE, 15
db WEATHER_SUN, WATER, 05
db $ff
.WeatherMoveModifiers
db WEATHER_RAIN, $97, 05 ; Solarbeam
db $ff
; fbe24
DoBadgeTypeBoosts: ; fbe24
ld a, [InLinkBattle]
and a
ret nz
ld a, [$cfc0]
and a
ret nz
ld a, [hBattleTurn]
and a
ret nz
push de
push bc
ld hl, .BadgeTypes
ld a, [KantoBadges]
ld b, a
ld a, [JohtoBadges]
ld c, a
.CheckBadge
ld a, [hl]
cp $ff
jr z, .done
srl b
rr c
jr nc, .NextBadge
ld a, [$d265] ; move type
cp [hl]
jr z, .ApplyBoost
.NextBadge
inc hl
jr .CheckBadge
.ApplyBoost
ld a, [CurDamage]
ld h, a
ld d, a
ld a, [CurDamage + 1]
ld l, a
ld e, a
srl d
rr e
srl d
rr e
srl d
rr e
ld a, e
or d
jr nz, .asm_fbe6f
ld e, 1
.asm_fbe6f
add hl, de
jr nc, .Update
ld hl, $ffff
.Update
ld a, h
ld [CurDamage], a
ld a, l
ld [$d257], a
.done
pop bc
pop de
ret
.BadgeTypes
db FLYING ; zephyrbadge
db BUG ; hivebadge
db NORMAL ; plainbadge
db GHOST ; fogbadge
db STEEL ; mineralbadge
db FIGHTING ; stormbadge
db ICE ; glacierbadge
db DRAGON ; risingbadge
db ROCK ; boulderbadge
db WATER ; cascadebadge
db ELECTRIC ; thunderbadge
db GRASS ; rainbowbadge
db POISON ; soulbadge
db PSYCHIC ; marshbadge
db FIRE ; volcanobadge
db GROUND ; earthbadge
db $ff
; fbe91
SECTION "bank3F",DATA,BANK[$3F] SECTION "bank3F",DATA,BANK[$3F]