summaryrefslogtreecommitdiff
path: root/engine/battle
diff options
context:
space:
mode:
Diffstat (limited to 'engine/battle')
-rw-r--r--engine/battle/ai/items.asm8
-rw-r--r--engine/battle/battle_transition.asm36
-rw-r--r--engine/battle/core.asm60
-rw-r--r--engine/battle/effect_commands.asm19
-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, 77 insertions, 76 deletions
diff --git a/engine/battle/ai/items.asm b/engine/battle/ai/items.asm
index b375b54c..16e9ef20 100644
--- a/engine/battle/ai/items.asm
+++ b/engine/battle/ai/items.asm
@@ -25,7 +25,7 @@ AI_SwitchOrTryItem:
ld hl, TrainerClassAttributes + TRNATTR_AI_ITEM_SWITCH
ld bc, NUM_TRAINER_ATTRIBUTES
call AddNTimes
-.ok
+
bit SWITCH_OFTEN_F, [hl]
jp nz, SwitchOften
bit SWITCH_RARELY_F, [hl]
@@ -141,7 +141,7 @@ SwitchSometimes:
ld [wEnemySwitchMonIndex], a
jp AI_TrySwitch
-CheckSubstatusCantRun:
+CheckSubstatusCantRun: ; unreferenced
ld a, [wEnemySubStatus5]
bit SUBSTATUS_CANT_RUN, a
ret
@@ -204,7 +204,7 @@ AI_TryItem:
inc hl
jr c, .loop
-.used_item
+; used item
xor a
ld [de], a
inc a
@@ -247,7 +247,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 105248f0..f5b4effe 100644
--- a/engine/battle/battle_transition.asm
+++ b/engine/battle/battle_transition.asm
@@ -208,7 +208,7 @@ StartTrainerBattle_NextScene:
StartTrainerBattle_SetUpBGMap:
call StartTrainerBattle_NextScene
xor a
- ld [wce64], a
+ ld [wBattleTransitionCounter], a
ldh [hBGMapMode], a
ret
@@ -222,7 +222,7 @@ StartTrainerBattle_Flash:
ld a, [wTimeOfDayPalset]
cp DARKNESS_PALSET
jr z, .done
- ld hl, wce64
+ ld hl, wBattleTransitionCounter
ld a, [hl]
inc [hl]
srl a
@@ -240,7 +240,7 @@ StartTrainerBattle_Flash:
.done
xor a
- ld [wce64], a
+ ld [wBattleTransitionCounter], a
scf
ret
@@ -271,12 +271,12 @@ StartTrainerBattle_SetUpForWavyOutro:
ld a, $90
ldh [hLYOverrideEnd], a
xor a
- ld [wce64], a
- ld [wce65], a
+ ld [wBattleTransitionCounter], a
+ ld [wBattleTransitionSineWaveOffset], a
ret
StartTrainerBattle_SineWave:
- ld a, [wce64]
+ ld a, [wBattleTransitionCounter]
cp $60
jr nc, .end
call .DoSineWave
@@ -288,10 +288,10 @@ StartTrainerBattle_SineWave:
ret
.DoSineWave:
- ld hl, wce65
+ ld hl, wBattleTransitionSineWaveOffset
ld a, [hl]
inc [hl]
- ld hl, wce64
+ ld hl, wBattleTransitionCounter
ld d, [hl]
add [hl]
ld [hl], a
@@ -319,13 +319,13 @@ StartTrainerBattle_SetUpForSpinOutro:
farcall RespawnPlayerAndOpponent
call StartTrainerBattle_NextScene
xor a
- ld [wce64], a
+ ld [wBattleTransitionCounter], a
ret
StartTrainerBattle_SpinToBlack:
xor a
ldh [hBGMapMode], a
- ld a, [wce64]
+ ld a, [wBattleTransitionCounter]
ld e, a
ld d, 0
ld hl, .spin_quadrants
@@ -335,13 +335,13 @@ endr
ld a, [hli]
cp -1
jr z, .end
- ld [wce65], a
+ ld [wBattleTransitionSpinQuadrant], a
call .load
ld a, 1
ldh [hBGMapMode], a
call DelayFrame
call DelayFrame
- ld hl, wce64
+ ld hl, wBattleTransitionCounter
inc [hl]
ret
@@ -396,7 +396,7 @@ ENDM
spin_quadrant LOWER_LEFT, .wedge1, 1, 11
db -1
-.load
+.load:
ld a, [hli]
ld e, a
ld a, [hli]
@@ -411,7 +411,7 @@ ENDM
inc de
.loop1
ld [hl], BATTLETRANSITION_BLACK
- ld a, [wce65]
+ ld a, [wBattleTransitionSpinQuadrant]
bit RIGHT_QUADRANT_F, a
jr z, .leftside
inc hl
@@ -422,7 +422,7 @@ ENDM
dec c
jr nz, .loop1
pop hl
- ld a, [wce65]
+ ld a, [wBattleTransitionSpinQuadrant]
bit LOWER_QUADRANT_F, a
ld bc, SCREEN_WIDTH
jr z, .upper
@@ -437,7 +437,7 @@ ENDM
jr z, .loop
ld c, a
.loop2
- ld a, [wce65]
+ ld a, [wBattleTransitionSpinQuadrant]
bit RIGHT_QUADRANT_F, a
jr z, .leftside2
dec hl
@@ -459,13 +459,13 @@ StartTrainerBattle_SetUpForRandomScatterOutro:
farcall RespawnPlayerAndOpponent
call StartTrainerBattle_NextScene
ld a, $10
- ld [wce64], a
+ ld [wBattleTransitionCounter], a
ld a, 1
ldh [hBGMapMode], a
ret
StartTrainerBattle_SpeckleToBlack:
- ld hl, wce64
+ ld hl, wBattleTransitionCounter
ld a, [hl]
and a
jr z, .done
diff --git a/engine/battle/core.asm b/engine/battle/core.asm
index 4a580aca..0587c750 100644
--- a/engine/battle/core.asm
+++ b/engine/battle/core.asm
@@ -1644,7 +1644,7 @@ HandleWeather:
cp USING_EXTERNAL_CLOCK
jr z, .enemy_first
-.player_first
+; player first
call SetPlayerTurn
call .SandstormDamage
call SetEnemyTurn
@@ -2609,7 +2609,7 @@ AskUseNextPokemon:
ForcePlayerMonChoice:
call EmptyBattleTextbox
call LoadStandardMenuHeader
- call SetUpBattlePartyMenu_NoLoop
+ call SetUpBattlePartyMenu
call ForcePickPartyMonInBattle
ld a, [wLinkMode]
cp LINK_COLOSSEUM
@@ -2681,9 +2681,8 @@ PlayerPartyMonEntrance:
call SetPlayerTurn
jp SpikesDamage
-SetUpBattlePartyMenu_NoLoop:
+SetUpBattlePartyMenu:
call ClearBGPalettes
-SetUpBattlePartyMenu: ; switch to fullscreen menu?
farcall LoadPartyMenuGFX
farcall InitPartyMenuWithCancel
farcall InitPartyMenuGFX
@@ -2818,10 +2817,11 @@ PlayerMonFaintedAnimation:
jp MonFaintedAnimation
MonFaintedAnimation:
- ld a, [wd8ba]
+ ld a, [wJoypadDisable]
push af
- set 6, a
- ld [wd8ba], a
+ set JOYPAD_DISABLE_MON_FAINT_F, a
+ ld [wJoypadDisable], a
+
ld b, 7
.OuterLoop:
@@ -2864,7 +2864,7 @@ MonFaintedAnimation:
jr nz, .OuterLoop
pop af
- ld [wd8ba], a
+ ld [wJoypadDisable], a
ret
.Spaces:
@@ -3296,7 +3296,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]
@@ -4404,7 +4404,7 @@ CheckDanger:
PrintPlayerHUD:
ld de, wBattleMonNick
hlcoord 10, 7
- call ret_3df99
+ call Battle_DummyFunction
call PlaceString
push bc
@@ -4490,7 +4490,7 @@ DrawEnemyHUD:
call GetBaseData
ld de, wEnemyMonNick
hlcoord 1, 0
- call ret_3df99
+ call Battle_DummyFunction
call PlaceString
ld h, b
ld l, c
@@ -4619,7 +4619,8 @@ UpdateHPPal:
ret z
jp FinishBattleAnim
-ret_3df99:
+Battle_DummyFunction:
+; called before placing either battler's nickname in the HUD
ret
BattleMenu:
@@ -7167,13 +7168,13 @@ AnimateExpBar:
jp z, .finish
ldh a, [hProduct + 3]
- ld [wceef], a
+ ld [wExperienceGained + 2], a
push af
ldh a, [hProduct + 2]
- ld [wceee], a
+ ld [wExperienceGained + 1], a
push af
xor a
- ld [wceed], a
+ ld [wExperienceGained], a
xor a ; PARTYMON
ld [wMonType], a
predef CopyMonToTempMon
@@ -7185,10 +7186,10 @@ AnimateExpBar:
call CalcExpBar
push bc
ld hl, wTempMonExp + 2
- ld a, [wceef]
+ ld a, [wExperienceGained + 2]
add [hl]
ld [hld], a
- ld a, [wceee]
+ ld a, [wExperienceGained + 1]
adc [hl]
ld [hld], a
jr nc, .NoOverflow
@@ -7487,7 +7488,8 @@ HandleSafariAngerEatingStatus: ; unreferenced
jr .finish
.angry
- dec hl ; wSafariMonAngerCount
+ dec hl
+ assert wSafariMonEating - 1 == wSafariMonAngerCount
ld a, [hl]
and a
ret z
@@ -8005,7 +8007,7 @@ CheckPayDay:
call StdBattleTextbox
ret
-PlayerPickedUpPayDayMoney:
+PlayerPickedUpPayDayMoney: ; unreferenced
text_far _PlayerPickedUpPayDayMoney
text_end
@@ -8180,7 +8182,6 @@ ReadAndPrintLinkBattleRecord:
lb bc, 2, 4
call PrintNum
-.quit
ret
.PrintZerosIfNoSaveFileExists:
@@ -8392,7 +8393,7 @@ AddLastLinkBattleToLinkRecord:
.FindOpponentAndAppendRecord:
ld b, NUM_LINK_BATTLE_RECORDS
ld hl, sLinkBattleRecord1End - 1
- ld de, wceed
+ ld de, wLinkBattleRecordBuffer
.loop3
push bc
push de
@@ -8421,16 +8422,16 @@ AddLastLinkBattleToLinkRecord:
add b
add b
ld e, a
- ld d, $0
- ld hl, wceed
+ 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, wceed
+ ld d, 0
+ ld hl, wLinkBattleRecordBuffer
add hl, de
ld d, h
ld e, l
@@ -8462,7 +8463,7 @@ AddLastLinkBattleToLinkRecord:
ld hl, sLinkBattleRecord
call AddNTimes
push hl
- ld de, wceed
+ ld de, wLinkBattleRecordBuffer
ld bc, LINK_BATTLE_RECORD_LENGTH
call CopyBytes
pop hl
@@ -8476,7 +8477,7 @@ AddLastLinkBattleToLinkRecord:
push hl
ld bc, LINK_BATTLE_RECORD_LENGTH
call CopyBytes
- ld hl, wceed
+ ld hl, wLinkBattleRecordBuffer
ld bc, LINK_BATTLE_RECORD_LENGTH
pop de
call CopyBytes
@@ -8556,14 +8557,15 @@ InitBattleDisplay:
call OpenSRAM
ld hl, sDecompressScratch
- ld bc, sScratchAttrmap - sDecompressScratch
+ ld bc, BG_MAP_WIDTH * BG_MAP_HEIGHT
ld a, " "
call ByteFill
ld de, sDecompressScratch
hlbgcoord 0, 0
- lb bc, BANK(.BlankBGMap), $40
+ lb bc, BANK(@), (BG_MAP_WIDTH * BG_MAP_HEIGHT) / LEN_2BPP_TILE
call Request2bpp
+
call CloseSRAM
ret
diff --git a/engine/battle/effect_commands.asm b/engine/battle/effect_commands.asm
index a5ae950f..12f7a101 100644
--- a/engine/battle/effect_commands.asm
+++ b/engine/battle/effect_commands.asm
@@ -145,7 +145,7 @@ BattleCommand_CheckTurn:
and a
jp nz, CheckEnemyTurn
-CheckPlayerTurn:
+; check player turn
ld hl, wPlayerSubStatus4
bit SUBSTATUS_RECHARGE, [hl]
jr z, .no_recharge
@@ -2592,7 +2592,7 @@ PlayerAttackDamage:
cp SPECIAL
jr nc, .special
-.physical
+; physical
ld hl, wEnemyMonDefense
ld a, [hli]
ld b, a
@@ -2660,7 +2660,6 @@ PlayerAttackDamage:
ret
TruncateHL_BC:
-.loop
; Truncate 16-bit values hl and bc to 8-bit values b and c respectively.
; b = hl, c = bc
@@ -2821,9 +2820,9 @@ EnemyAttackDamage:
ld a, [hl]
cp SPECIAL
- jr nc, .Special
+ jr nc, .special
-.physical
+; physical
ld hl, wBattleMonDefense
ld a, [hli]
ld b, a
@@ -2847,7 +2846,7 @@ EnemyAttackDamage:
ld hl, wEnemyAttack
jr .thickclub
-.Special:
+.special
ld hl, wBattleMonSpclDef
ld a, [hli]
ld b, a
@@ -5669,7 +5668,7 @@ BattleCommand_Charge:
text_far _BattleDugText
text_end
-BattleCommand3c:
+BattleCommand_Unused3C:
; unused
ret
@@ -6075,7 +6074,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
@@ -6098,7 +6097,7 @@ BattleCommand_ResetStats:
jp StdBattleTextbox
.Fill:
- ld b, wPlayerStatLevelsEnd - wPlayerStatLevels
+ ld b, NUM_LEVEL_STATS
.next
ld [hli], a
dec b
@@ -6440,7 +6439,7 @@ INCLUDE "engine/battle/move_effects/sandstorm.asm"
INCLUDE "engine/battle/move_effects/rollout.asm"
-BattleCommand5d:
+BattleCommand_Unused5D:
; unused
ret
diff --git a/engine/battle/menu.asm b/engine/battle/menu.asm
index 6a942f6c..e9a7e593 100644
--- a/engine/battle/menu.asm
+++ b/engine/battle/menu.asm
@@ -3,8 +3,7 @@ LoadBattleMenu:
call LoadMenuHeader
jr CommonBattleMenu
-SafariBattleMenu:
-; untranslated
+SafariBattleMenu: ; unreferenced
ld hl, SafariBattleMenuHeader
call LoadMenuHeader
jr CommonBattleMenu
@@ -12,7 +11,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 bf9e3235..236acc82 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 8546c37d..32e0112c 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 [wceed], 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 [wceed], a
+ ld [wCurBeatUpPartyMon], a
.got_mon
- ld a, [wceed]
+ 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, [wceed]
+ 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 [wceed], 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 [wceed], a
+ ld [wCurBeatUpPartyMon], a
.enemy_got_mon
ld a, [wBattleMode]
@@ -108,7 +108,7 @@ BattleCommand_BeatUp:
and a
jr nz, .linked
- ld a, [wceed]
+ ld a, [wCurBeatUpPartyMon]
ld c, a
ld b, 0
ld hl, wOTPartySpecies
@@ -119,7 +119,7 @@ BattleCommand_BeatUp:
jr .got_enemy_nick
.linked
- ld a, [wceed]
+ ld a, [wCurBeatUpPartyMon]
ld hl, wOTPartyMonNicknames
ld bc, NAME_LENGTH
call AddNTimes
@@ -133,7 +133,7 @@ BattleCommand_BeatUp:
or [hl]
jp z, .beatup_fail
- ld a, [wceed]
+ ld a, [wCurBeatUpPartyMon]
ld b, a
ld a, [wCurOTMon]
cp b
@@ -213,7 +213,7 @@ GetBeatupMonLocation:
ld hl, wOTPartyMon1Species
.got_species
- ld a, [wceed]
+ 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 33e172fb..0577e76b 100644
--- a/engine/battle/move_effects/present.asm
+++ b/engine/battle/move_effects/present.asm
@@ -67,7 +67,7 @@ BattleCommand_Present:
add a
jr nc, .do_animation
call AnimateFailedMove
- ld hl, CantReceiveGiftText
+ ld hl, PresentFailedText
call StdBattleTextbox
.do_animation
jp EndMoveEffect