pokecrystal-board/engine/battle/misc.asm

229 lines
2.8 KiB
NASM
Raw Normal View History

2015-11-09 13:41:09 -08:00
_DisappearUser: ; fbd54
xor a
ld [hBGMapMode], a
ld a, [hBattleTurn]
and a
2015-11-09 13:41:09 -08:00
jr z, .player
call GetEnemyFrontpicCoords
jr .okay
.player
call GetPlayerBackpicCoords
.okay
call ClearBox
2015-11-09 13:41:09 -08:00
jr FinishAppearDisappearUser
2015-11-09 13:41:09 -08:00
_AppearUserRaiseSub: ; fbd69 (3e:7d69)
2017-12-24 09:47:30 -08:00
farcall BattleCommand_RaiseSubNoAnim
2015-11-09 13:41:09 -08:00
jr AppearUser
2015-11-09 13:41:09 -08:00
_AppearUserLowerSub: ; fbd71 (3e:7d71)
2017-12-24 09:47:30 -08:00
farcall BattleCommand_LowerSubNoAnim
2015-11-09 13:41:09 -08:00
AppearUser: ; fbd77 (3e:7d77)
xor a
ld [hBGMapMode], a
ld a, [hBattleTurn]
and a
2015-11-09 13:41:09 -08:00
jr z, .player
call GetEnemyFrontpicCoords
xor a
2015-11-09 13:41:09 -08:00
jr .okay
.player
call GetPlayerBackpicCoords
ld a, $31
2015-11-09 13:41:09 -08:00
.okay
2016-01-12 09:46:18 -08:00
ld [hGraphicStartTile], a
predef PlaceGraphic
2015-11-09 13:41:09 -08:00
FinishAppearDisappearUser: ; fbd91 (3e:7d91)
ld a, $1
ld [hBGMapMode], a
ret
2015-11-09 13:41:09 -08:00
GetEnemyFrontpicCoords: ; fbd96 (3e:7d96)
hlcoord 12, 0
lb bc, 7, 7
ret
2015-11-09 13:41:09 -08:00
GetPlayerBackpicCoords: ; fbd9d (3e:7d9d)
hlcoord 2, 6
lb bc, 6, 6
ret
DoWeatherModifiers: ; fbda4
2018-01-25 18:34:42 -08:00
ld de, WeatherTypeModifiers
ld a, [wBattleWeather]
ld b, a
ld a, [wd265] ; move type
ld c, a
.CheckWeatherType:
ld a, [de]
inc de
cp $ff
2015-11-09 13:41:09 -08:00
jr z, .done_weather_types
cp b
jr nz, .NextWeatherType
ld a, [de]
cp c
jr z, .ApplyModifier
.NextWeatherType:
inc de
inc de
jr .CheckWeatherType
2015-11-09 13:41:09 -08:00
.done_weather_types
2018-01-25 18:34:42 -08:00
ld de, WeatherMoveModifiers
ld a, BATTLE_VARS_MOVE_EFFECT
call GetBattleVar
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 [hMultiplicand + 0], a
2018-01-23 14:39:09 -08:00
ld hl, wCurDamage
ld a, [hli]
ld [hMultiplicand + 1], a
ld a, [hl]
ld [hMultiplicand + 2], a
inc de
ld a, [de]
ld [hMultiplier], a
call Multiply
ld a, 10
ld [hDivisor], a
ld b, $4
call Divide
ld a, [hQuotient + 0]
and a
ld bc, -1
jr nz, .Update
ld a, [hQuotient + 1]
ld b, a
ld a, [hQuotient + 2]
ld c, a
or b
jr nz, .Update
ld bc, 1
.Update:
ld a, b
2018-01-23 14:39:09 -08:00
ld [wCurDamage], a
ld a, c
2018-01-23 14:39:09 -08:00
ld [wCurDamage + 1], a
.done
ret
2018-01-25 18:34:42 -08:00
INCLUDE "data/battle/weather_modifiers.asm"
DoBadgeTypeBoosts: ; fbe24
ld a, [wLinkMode]
and a
ret nz
2018-01-23 14:39:09 -08:00
ld a, [wInBattleTowerBattle]
and a
ret nz
ld a, [hBattleTurn]
and a
ret nz
push de
push bc
2018-01-25 18:34:42 -08:00
ld hl, BadgeTypeBoosts
ld a, [wKantoBadges]
ld b, a
ld a, [wJohtoBadges]
ld c, a
.CheckBadge:
ld a, [hl]
2018-01-10 19:53:42 -08:00
cp -1
jr z, .done
srl b
rr c
jr nc, .NextBadge
ld a, [wd265] ; move type
cp [hl]
jr z, .ApplyBoost
.NextBadge:
inc hl
jr .CheckBadge
.ApplyBoost:
2018-01-23 14:39:09 -08:00
ld a, [wCurDamage]
ld h, a
ld d, a
2018-01-23 14:39:09 -08:00
ld a, [wCurDamage + 1]
ld l, a
ld e, a
srl d
rr e
srl d
rr e
srl d
rr e
ld a, e
or d
2015-11-09 13:41:09 -08:00
jr nz, .done_min
ld e, 1
2015-11-09 13:41:09 -08:00
.done_min
add hl, de
jr nc, .Update
ld hl, $ffff
.Update:
ld a, h
2018-01-23 14:39:09 -08:00
ld [wCurDamage], a
ld a, l
2018-01-23 14:39:09 -08:00
ld [wCurDamage + 1], a
.done
pop bc
pop de
ret
INCLUDE "data/types/badge_type_boosts.asm"