summaryrefslogtreecommitdiff
path: root/engine/battle
diff options
context:
space:
mode:
Diffstat (limited to 'engine/battle')
-rw-r--r--engine/battle/ai/items.asm12
-rw-r--r--engine/battle/battle_transition.asm36
-rw-r--r--engine/battle/core.asm59
-rw-r--r--engine/battle/effect_commands.asm20
-rw-r--r--engine/battle/menu.asm6
-rw-r--r--engine/battle/move_effects/baton_pass.asm2
-rw-r--r--engine/battle/move_effects/beat_up.asm20
-rw-r--r--engine/battle/move_effects/present.asm2
8 files changed, 80 insertions, 77 deletions
diff --git a/engine/battle/ai/items.asm b/engine/battle/ai/items.asm
index 4de82d153..62adaca77 100644
--- a/engine/battle/ai/items.asm
+++ b/engine/battle/ai/items.asm
@@ -20,8 +20,9 @@ AI_SwitchOrTryItem:
and a
jr nz, DontSwitch
+ ; always load the first trainer class in wTrainerClass for Battle Tower trainers
ld hl, TrainerClassAttributes + TRNATTR_AI_ITEM_SWITCH
- ld a, [wInBattleTowerBattle] ; always load the first trainer class in wTrainerClass for BattleTower-Trainers
+ ld a, [wInBattleTowerBattle]
and a
jr nz, .ok
@@ -29,6 +30,7 @@ AI_SwitchOrTryItem:
dec a
ld bc, NUM_TRAINER_ATTRIBUTES
call AddNTimes
+
.ok
bit SWITCH_OFTEN_F, [hl]
jp nz, SwitchOften
@@ -145,13 +147,13 @@ SwitchSometimes:
ld [wEnemySwitchMonIndex], a
jp AI_TrySwitch
-CheckSubstatusCantRun:
+CheckSubstatusCantRun: ; unreferenced
ld a, [wEnemySubStatus5]
bit SUBSTATUS_CANT_RUN, a
ret
AI_TryItem:
- ; items are not allowed in the BattleTower
+ ; items are not allowed in the Battle Tower
ld a, [wInBattleTowerBattle]
and a
ret nz
@@ -213,7 +215,7 @@ AI_TryItem:
inc hl
jr c, .loop
-.used_item
+; used item
xor a
ld [de], a
inc a
@@ -259,7 +261,7 @@ AI_TryItem:
cp e
jr nc, .yes
-.no
+.no ; unreferenced
and a
ret
diff --git a/engine/battle/battle_transition.asm b/engine/battle/battle_transition.asm
index a1cdd239d..12932ede5 100644
--- a/engine/battle/battle_transition.asm
+++ b/engine/battle/battle_transition.asm
@@ -258,7 +258,7 @@ StartTrainerBattle_NextScene:
StartTrainerBattle_SetUpBGMap:
call StartTrainerBattle_NextScene
xor a
- ld [wcf64], a
+ ld [wBattleTransitionCounter], a
ldh [hBGMapMode], a
ret
@@ -272,7 +272,7 @@ StartTrainerBattle_Flash:
ld a, [wTimeOfDayPalset]
cp DARKNESS_PALSET
jr z, .done
- ld hl, wcf64
+ ld hl, wBattleTransitionCounter
ld a, [hl]
inc [hl]
srl a
@@ -290,7 +290,7 @@ StartTrainerBattle_Flash:
.done
xor a
- ld [wcf64], a
+ ld [wBattleTransitionCounter], a
scf
ret
@@ -322,12 +322,12 @@ StartTrainerBattle_SetUpForWavyOutro:
ld a, $90
ldh [hLYOverrideEnd], a
xor a
- ld [wcf64], a
- ld [wcf65], a
+ ld [wBattleTransitionCounter], a
+ ld [wBattleTransitionSineWaveOffset], a
ret
StartTrainerBattle_SineWave:
- ld a, [wcf64]
+ ld a, [wBattleTransitionCounter]
cp $60
jr nc, .end
call .DoSineWave
@@ -339,10 +339,10 @@ StartTrainerBattle_SineWave:
ret
.DoSineWave:
- ld hl, wcf65
+ ld hl, wBattleTransitionSineWaveOffset
ld a, [hl]
inc [hl]
- ld hl, wcf64
+ ld hl, wBattleTransitionCounter
ld d, [hl]
add [hl]
ld [hl], a
@@ -372,13 +372,13 @@ StartTrainerBattle_SetUpForSpinOutro:
ldh [rSVBK], a
call StartTrainerBattle_NextScene
xor a
- ld [wcf64], a
+ ld [wBattleTransitionCounter], a
ret
StartTrainerBattle_SpinToBlack:
xor a
ldh [hBGMapMode], a
- ld a, [wcf64]
+ ld a, [wBattleTransitionCounter]
ld e, a
ld d, 0
ld hl, .spin_quadrants
@@ -388,13 +388,13 @@ endr
ld a, [hli]
cp -1
jr z, .end
- ld [wcf65], a
+ ld [wBattleTransitionSineWaveOffset], a
call .load
ld a, 1
ldh [hBGMapMode], a
call DelayFrame
call DelayFrame
- ld hl, wcf64
+ ld hl, wBattleTransitionCounter
inc [hl]
ret
@@ -449,7 +449,7 @@ ENDM
spin_quadrant LOWER_LEFT, .wedge1, 1, 11
db -1
-.load
+.load:
ld a, [hli]
ld e, a
ld a, [hli]
@@ -464,7 +464,7 @@ ENDM
inc de
.loop1
ld [hl], BATTLETRANSITION_BLACK
- ld a, [wcf65]
+ ld a, [wBattleTransitionSineWaveOffset]
bit RIGHT_QUADRANT_F, a
jr z, .leftside
inc hl
@@ -475,7 +475,7 @@ ENDM
dec c
jr nz, .loop1
pop hl
- ld a, [wcf65]
+ ld a, [wBattleTransitionSineWaveOffset]
bit LOWER_QUADRANT_F, a
ld bc, SCREEN_WIDTH
jr z, .upper
@@ -490,7 +490,7 @@ ENDM
jr z, .loop
ld c, a
.loop2
- ld a, [wcf65]
+ ld a, [wBattleTransitionSineWaveOffset]
bit RIGHT_QUADRANT_F, a
jr z, .leftside2
dec hl
@@ -514,13 +514,13 @@ StartTrainerBattle_SetUpForRandomScatterOutro:
ldh [rSVBK], a
call StartTrainerBattle_NextScene
ld a, $10
- ld [wcf64], a
+ ld [wBattleTransitionCounter], a
ld a, 1
ldh [hBGMapMode], a
ret
StartTrainerBattle_SpeckleToBlack:
- ld hl, wcf64
+ ld hl, wBattleTransitionCounter
ld a, [hl]
and a
jr z, .done
diff --git a/engine/battle/core.asm b/engine/battle/core.asm
index 85cba5f85..f84864a95 100644
--- a/engine/battle/core.asm
+++ b/engine/battle/core.asm
@@ -1697,7 +1697,7 @@ HandleWeather:
cp USING_EXTERNAL_CLOCK
jr z, .enemy_first
-.player_first
+; player first
call SetPlayerTurn
call .SandstormDamage
call SetEnemyTurn
@@ -2711,7 +2711,7 @@ AskUseNextPokemon:
ForcePlayerMonChoice:
call EmptyBattleTextbox
call LoadStandardMenuHeader
- call SetUpBattlePartyMenu_NoLoop
+ call SetUpBattlePartyMenu
call ForcePickPartyMonInBattle
ld a, [wLinkMode]
and a
@@ -2810,9 +2810,9 @@ IsMobileBattle:
cp LINK_MOBILE
ret
-SetUpBattlePartyMenu_NoLoop:
+SetUpBattlePartyMenu:
call ClearBGPalettes
-SetUpBattlePartyMenu: ; switch to fullscreen menu?
+SetUpBattlePartyMenu_Loop: ; switch to fullscreen menu?
farcall LoadPartyMenuGFX
farcall InitPartyMenuWithCancel
farcall InitPartyMenuBGPal7
@@ -3006,10 +3006,11 @@ PlayerMonFaintedAnimation:
jp MonFaintedAnimation
MonFaintedAnimation:
- ld a, [wcfbe]
+ ld a, [wJoypadDisable]
push af
- set 6, a
- ld [wcfbe], a
+ set JOYPAD_DISABLE_MON_FAINT_F, a
+ ld [wJoypadDisable], a
+
ld b, 7
.OuterLoop:
@@ -3052,7 +3053,7 @@ MonFaintedAnimation:
jr nz, .OuterLoop
pop af
- ld [wcfbe], a
+ ld [wJoypadDisable], a
ret
.Spaces:
@@ -3486,7 +3487,7 @@ OfferSwitch:
ld a, [wMenuCursorY]
dec a
jr nz, .said_no
- call SetUpBattlePartyMenu_NoLoop
+ call SetUpBattlePartyMenu
call PickSwitchMonInBattle
jr c, .canceled_switch
ld a, [wCurBattleMon]
@@ -4639,7 +4640,7 @@ CheckDanger:
PrintPlayerHUD:
ld de, wBattleMonNick
hlcoord 10, 7
- call ret_3e138
+ call Battle_DummyFunction
call PlaceString
push bc
@@ -4725,7 +4726,7 @@ DrawEnemyHUD:
call GetBaseData
ld de, wEnemyMonNick
hlcoord 1, 0
- call ret_3e138
+ call Battle_DummyFunction
call PlaceString
ld h, b
ld l, c
@@ -4854,7 +4855,8 @@ UpdateHPPal:
ret z
jp FinishBattleAnim
-ret_3e138:
+Battle_DummyFunction:
+; called before placing either battler's nickname in the HUD
ret
BattleMenu:
@@ -5043,7 +5045,7 @@ BattleMenuPKMN_ReturnFromStats:
call LoadStandardMenuHeader
call ClearBGPalettes
BattleMenuPKMN_Loop:
- call SetUpBattlePartyMenu
+ call SetUpBattlePartyMenu_Loop
xor a
ld [wPartyMenuActionText], a
call JumpToPartyMenuAndPrintText
@@ -7436,13 +7438,13 @@ AnimateExpBar:
jp nc, .finish
ldh a, [hProduct + 3]
- ld [wd004], a
+ ld [wExperienceGained + 2], a
push af
ldh a, [hProduct + 2]
- ld [wd003], a
+ ld [wExperienceGained + 1], a
push af
xor a
- ld [wd002], a
+ ld [wExperienceGained], a
xor a ; PARTYMON
ld [wMonType], a
predef CopyMonToTempMon
@@ -7454,10 +7456,10 @@ AnimateExpBar:
call CalcExpBar
push bc
ld hl, wTempMonExp + 2
- ld a, [wd004]
+ ld a, [wExperienceGained + 2]
add [hl]
ld [hld], a
- ld a, [wd003]
+ ld a, [wExperienceGained + 1]
adc [hl]
ld [hld], a
jr nc, .NoOverflow
@@ -7781,7 +7783,8 @@ HandleSafariAngerEatingStatus: ; unreferenced
jr .finish
.angry
- dec hl ; wSafariMonAngerCount
+ dec hl
+ assert wSafariMonEating - 1 == wSafariMonAngerCount
ld a, [hl]
and a
ret z
@@ -8785,7 +8788,7 @@ AddLastLinkBattleToLinkRecord:
.FindOpponentAndAppendRecord:
ld b, NUM_LINK_BATTLE_RECORDS
ld hl, sLinkBattleRecord1End - 1
- ld de, wd002
+ ld de, wLinkBattleRecordBuffer
.loop3
push bc
push de
@@ -8814,16 +8817,16 @@ AddLastLinkBattleToLinkRecord:
add b
add b
ld e, a
- ld d, $0
- ld hl, wd002
+ ld d, 0
+ ld hl, wLinkBattleRecordBuffer
add hl, de
push hl
ld a, c
add c
add c
ld e, a
- ld d, $0
- ld hl, wd002
+ ld d, 0
+ ld hl, wLinkBattleRecordBuffer
add hl, de
ld d, h
ld e, l
@@ -8855,7 +8858,7 @@ AddLastLinkBattleToLinkRecord:
ld hl, sLinkBattleRecord
call AddNTimes
push hl
- ld de, wd002
+ ld de, wLinkBattleRecordBuffer
ld bc, LINK_BATTLE_RECORD_LENGTH
call CopyBytes
pop hl
@@ -8869,7 +8872,7 @@ AddLastLinkBattleToLinkRecord:
push hl
ld bc, LINK_BATTLE_RECORD_LENGTH
call CopyBytes
- ld hl, wd002
+ ld hl, wLinkBattleRecordBuffer
ld bc, LINK_BATTLE_RECORD_LENGTH
pop de
call CopyBytes
@@ -8952,13 +8955,13 @@ InitBattleDisplay:
ldh [rSVBK], a
ld hl, wDecompressScratch
- ld bc, wScratchAttrmap - wDecompressScratch
+ ld bc, BG_MAP_WIDTH * BG_MAP_HEIGHT
ld a, " "
call ByteFill
ld de, wDecompressScratch
hlbgcoord 0, 0
- lb bc, BANK(.BlankBGMap), $40
+ lb bc, BANK(@), (BG_MAP_WIDTH * BG_MAP_HEIGHT) / LEN_2BPP_TILE
call Request2bpp
pop af
diff --git a/engine/battle/effect_commands.asm b/engine/battle/effect_commands.asm
index 4d670b4b1..14f1afd82 100644
--- a/engine/battle/effect_commands.asm
+++ b/engine/battle/effect_commands.asm
@@ -134,7 +134,7 @@ BattleCommand_CheckTurn:
and a
jp nz, CheckEnemyTurn
-CheckPlayerTurn:
+; check player turn
ld hl, wPlayerSubStatus4
bit SUBSTATUS_RECHARGE, [hl]
jr z, .no_recharge
@@ -2586,7 +2586,7 @@ PlayerAttackDamage:
cp SPECIAL
jr nc, .special
-.physical
+; physical
ld hl, wEnemyMonDefense
ld a, [hli]
ld b, a
@@ -2826,9 +2826,9 @@ EnemyAttackDamage:
ld a, [hl]
cp SPECIAL
- jr nc, .Special
+ jr nc, .special
-.physical
+; physical
ld hl, wBattleMonDefense
ld a, [hli]
ld b, a
@@ -2852,7 +2852,7 @@ EnemyAttackDamage:
ld hl, wEnemyAttack
jr .thickclub
-.Special:
+.special
ld hl, wBattleMonSpclDef
ld a, [hli]
ld b, a
@@ -5714,8 +5714,7 @@ BattleCommand_Charge:
text_far _BattleDugText
text_end
-BattleCommand3c:
-; unused
+BattleCommand_Unused3C: ; unreferenced
ret
BattleCommand_TrapTarget:
@@ -6124,7 +6123,7 @@ INCLUDE "engine/battle/move_effects/conversion.asm"
BattleCommand_ResetStats:
; resetstats
- ld a, 7 ; neutral
+ ld a, BASE_STAT_LEVEL
ld hl, wPlayerStatLevels
call .Fill
ld hl, wEnemyStatLevels
@@ -6147,7 +6146,7 @@ BattleCommand_ResetStats:
jp StdBattleTextbox
.Fill:
- ld b, wPlayerStatLevelsEnd - wPlayerStatLevels
+ ld b, NUM_LEVEL_STATS
.next
ld [hli], a
dec b
@@ -6489,8 +6488,7 @@ INCLUDE "engine/battle/move_effects/sandstorm.asm"
INCLUDE "engine/battle/move_effects/rollout.asm"
-BattleCommand5d:
-; unused
+BattleCommand_Unused5D: ; unreferenced
ret
INCLUDE "engine/battle/move_effects/fury_cutter.asm"
diff --git a/engine/battle/menu.asm b/engine/battle/menu.asm
index a4955ec6a..e29bff48b 100644
--- a/engine/battle/menu.asm
+++ b/engine/battle/menu.asm
@@ -9,8 +9,7 @@ LoadBattleMenu:
call ExitMenu
ret
-SafariBattleMenu:
-; untranslated
+SafariBattleMenu: ; unreferenced
ld hl, SafariBattleMenuHeader
call LoadMenuHeader
jr CommonBattleMenu
@@ -18,7 +17,8 @@ SafariBattleMenu:
ContestBattleMenu:
ld hl, ContestBattleMenuHeader
call LoadMenuHeader
-; fallthrough
+ ; fallthrough
+
CommonBattleMenu:
ld a, [wBattleMenuCursorBuffer]
ld [wMenuCursorBuffer], a
diff --git a/engine/battle/move_effects/baton_pass.asm b/engine/battle/move_effects/baton_pass.asm
index 46baeb75f..bafe33866 100644
--- a/engine/battle/move_effects/baton_pass.asm
+++ b/engine/battle/move_effects/baton_pass.asm
@@ -17,7 +17,7 @@ BattleCommand_BatonPass:
; Transition into switchmon menu
call LoadStandardMenuHeader
- farcall SetUpBattlePartyMenu_NoLoop
+ farcall SetUpBattlePartyMenu
farcall ForcePickSwitchMonInBattle
diff --git a/engine/battle/move_effects/beat_up.asm b/engine/battle/move_effects/beat_up.asm
index 73bbb2e42..f1cc7a5c2 100644
--- a/engine/battle/move_effects/beat_up.asm
+++ b/engine/battle/move_effects/beat_up.asm
@@ -14,7 +14,7 @@ BattleCommand_BeatUp:
call DelayFrames
xor a
ld [wPlayerRolloutCount], a
- ld [wd002], a
+ ld [wCurBeatUpPartyMon], a
ld [wBeatUpHitAtLeastOnce], a
jr .got_mon
@@ -23,10 +23,10 @@ BattleCommand_BeatUp:
ld b, a
ld a, [wPartyCount]
sub b
- ld [wd002], a
+ ld [wCurBeatUpPartyMon], a
.got_mon
- ld a, [wd002]
+ ld a, [wCurBeatUpPartyMon]
ld hl, wPartyMonNicknames
call GetNick
ld a, MON_HP
@@ -34,7 +34,7 @@ BattleCommand_BeatUp:
ld a, [hli]
or [hl]
jp z, .beatup_fail ; fainted
- ld a, [wd002]
+ ld a, [wCurBeatUpPartyMon]
ld c, a
ld a, [wCurBattleMon]
; BUG: this can desynchronize link battles
@@ -88,7 +88,7 @@ BattleCommand_BeatUp:
xor a
ld [wEnemyRolloutCount], a
- ld [wd002], a
+ ld [wCurBeatUpPartyMon], a
ld [wBeatUpHitAtLeastOnce], a
jr .enemy_got_mon
@@ -97,7 +97,7 @@ BattleCommand_BeatUp:
ld b, a
ld a, [wOTPartyCount]
sub b
- ld [wd002], a
+ ld [wCurBeatUpPartyMon], a
.enemy_got_mon
ld a, [wBattleMode]
@@ -112,7 +112,7 @@ BattleCommand_BeatUp:
and a
jr nz, .link_or_tower
- ld a, [wd002]
+ ld a, [wCurBeatUpPartyMon]
ld c, a
ld b, 0
ld hl, wOTPartySpecies
@@ -123,7 +123,7 @@ BattleCommand_BeatUp:
jr .got_enemy_nick
.link_or_tower
- ld a, [wd002]
+ ld a, [wCurBeatUpPartyMon]
ld hl, wOTPartyMonNicknames
ld bc, NAME_LENGTH
call AddNTimes
@@ -137,7 +137,7 @@ BattleCommand_BeatUp:
or [hl]
jp z, .beatup_fail
- ld a, [wd002]
+ ld a, [wCurBeatUpPartyMon]
ld b, a
ld a, [wCurOTMon]
cp b
@@ -217,7 +217,7 @@ GetBeatupMonLocation:
ld hl, wOTPartyMon1Species
.got_species
- ld a, [wd002]
+ ld a, [wCurBeatUpPartyMon]
add hl, bc
call GetPartyLocation
pop bc
diff --git a/engine/battle/move_effects/present.asm b/engine/battle/move_effects/present.asm
index 8d7461fa1..6aa35acbf 100644
--- a/engine/battle/move_effects/present.asm
+++ b/engine/battle/move_effects/present.asm
@@ -80,7 +80,7 @@ BattleCommand_Present:
call _CheckBattleScene
jr nc, .do_animation
call AnimateFailedMove
- ld hl, RefusedGiftText
+ ld hl, PresentFailedText
call StdBattleTextbox
.do_animation
jp EndMoveEffect