aboutsummaryrefslogtreecommitdiffstats
path: root/engine/battle
diff options
context:
space:
mode:
authordannye <33dannye@gmail.com>2024-09-25 00:45:00 -0500
committerdannye <33dannye@gmail.com>2024-09-25 00:45:00 -0500
commita02a98ee7ada1a658e28698484058be2796dc0df (patch)
tree945986054565bd8b5212fc755415096050d1d3a8 /engine/battle
parentUse long option flags for rgbgfx, same as tools/gfx (diff)
parentUse `const_skip` (diff)
downloadpokeyellow-a02a98ee7ada1a658e28698484058be2796dc0df.tar.gz
pokeyellow-a02a98ee7ada1a658e28698484058be2796dc0df.tar.xz
pokeyellow-a02a98ee7ada1a658e28698484058be2796dc0df.zip
Merge branch 'master' of https://github.com/pret/pokered
Diffstat (limited to 'engine/battle')
-rw-r--r--engine/battle/animations.asm32
-rw-r--r--engine/battle/battle_transitions.asm24
-rw-r--r--engine/battle/common_text.asm2
-rw-r--r--engine/battle/core.asm152
-rw-r--r--engine/battle/effects.asm12
-rw-r--r--engine/battle/end_of_battle.asm4
-rw-r--r--engine/battle/experience.asm26
-rw-r--r--engine/battle/get_trainer_name.asm8
-rw-r--r--engine/battle/init_battle.asm14
-rw-r--r--engine/battle/misc.asm14
-rw-r--r--engine/battle/move_effects/pay_day.asm6
-rw-r--r--engine/battle/move_effects/transform.asm2
-rw-r--r--engine/battle/print_type.asm2
-rw-r--r--engine/battle/read_trainer_party.asm12
-rw-r--r--engine/battle/safari_zone.asm2
-rw-r--r--engine/battle/save_trainer_name.asm2
-rw-r--r--engine/battle/trainer_ai.asm10
-rw-r--r--engine/battle/wild_encounters.asm12
18 files changed, 172 insertions, 164 deletions
diff --git a/engine/battle/animations.asm b/engine/battle/animations.asm
index da758332..45fbc1d5 100644
--- a/engine/battle/animations.asm
+++ b/engine/battle/animations.asm
@@ -138,13 +138,13 @@ DrawFrameBlock:
ld [de], a ; store tile ID
inc de
ld a, [hli]
- bit 5, a ; is horizontal flip enabled?
+ bit OAM_X_FLIP, a
jr nz, .disableHorizontalFlip
.enableHorizontalFlip
- set 5, a
+ set OAM_X_FLIP, a
jr .storeFlags2
.disableHorizontalFlip
- res 5, a
+ res OAM_X_FLIP, a
.storeFlags2
ld b, a
ld a, [wdef5]
@@ -452,7 +452,7 @@ MoveAnimation:
xor a
vc_hook Stop_reducing_move_anim_flashing_Haze_Hyper_Beam
ld [wSubAnimSubEntryAddr], a
- ld [wUnusedD09B], a
+ ld [wUnusedMoveAnimByte], a
ld [wSubAnimTransform], a
dec a ; NO_MOVE - 1
ld [wAnimSoundID], a
@@ -722,7 +722,7 @@ DoSpecialEffectByAnimationId:
INCLUDE "data/battle_anims/special_effects.asm"
DoBallTossSpecialEffects:
- ld a, [wcf91]
+ ld a, [wCurItem]
cp ULTRA_BALL + 1 ; is it a Master Ball or Ultra Ball?
jr nc, .skipFlashingEffect
.flashingEffect ; do a flashing effect if it's Master Ball or Ultra Ball
@@ -741,7 +741,7 @@ DoBallTossSpecialEffects:
ld a, [wIsInBattle]
cp 2 ; is it a trainer battle?
jr z, .isTrainerBattle
- ld a, [wd11e]
+ ld a, [wPokeBallAnimData]
cp $10 ; is the enemy pokemon the Ghost Marowak?
ret nz
; if the enemy pokemon is the Ghost Marowak, make it dodge during the last 3 frames
@@ -1169,12 +1169,12 @@ AnimationWaterDropletsEverywhere:
ld a, 16
ld [wBaseCoordY], a
ld a, 0
- ld [wUnusedD08A], a
+ ld [wUnusedWaterDropletsByte], a
call _AnimationWaterDroplets
ld a, 24
ld [wBaseCoordY], a
ld a, 32
- ld [wUnusedD08A], a
+ ld [wUnusedWaterDropletsByte], a
call _AnimationWaterDroplets
dec d
jr nz, .loop
@@ -2109,8 +2109,8 @@ HideSubstituteShowMonAnim:
and a
jr nz, .monIsMinimized
ld a, [wBattleMonSpecies]
- ld [wcf91], a
- ld [wd0b5], a
+ ld [wCurPartySpecies], a
+ ld [wCurSpecies], a
call GetMonHeader
predef LoadMonBackPic
ret
@@ -2119,8 +2119,8 @@ HideSubstituteShowMonAnim:
and a
jr nz, .monIsMinimized
ld a, [wEnemyMonSpecies]
- ld [wcf91], a
- ld [wd0b5], a
+ ld [wCurPartySpecies], a
+ ld [wCurSpecies], a
call GetMonHeader
ld de, vFrontPic
jp LoadMonFrontSprite
@@ -2174,8 +2174,8 @@ ChangeMonPic:
and a
jr z, .playerTurn
ld a, [wChangeMonPicEnemyTurnSpecies]
- ld [wcf91], a
- ld [wd0b5], a
+ ld [wCurPartySpecies], a
+ ld [wCurSpecies], a
xor a
ld [wSpriteFlipped], a
call GetMonHeader
@@ -2187,7 +2187,7 @@ ChangeMonPic:
push af
ld a, [wChangeMonPicPlayerTurnSpecies]
ld [wBattleMonSpecies2], a
- ld [wd0b5], a
+ ld [wCurSpecies], a
call GetMonHeader
predef LoadMonBackPic
xor a ; TILEMAP_MON_PIC
@@ -2795,7 +2795,7 @@ TossBallAnimation:
ld hl, .PokeBallAnimations
; choose which toss animation to use
- ld a, [wcf91]
+ ld a, [wCurItem]
cp POKE_BALL
ld b, TOSS_ANIM
jr z, .done
diff --git a/engine/battle/battle_transitions.asm b/engine/battle/battle_transitions.asm
index 77f2ba89..69cc1203 100644
--- a/engine/battle/battle_transitions.asm
+++ b/engine/battle/battle_transitions.asm
@@ -11,7 +11,7 @@ BattleTransition:
; Determine which OAM block is being used by the enemy trainer sprite (if there
; is one).
ld hl, wSpritePlayerStateData1ImageIndex
- ldh a, [hSpriteIndexOrTextID] ; enemy trainer sprite index (0 if wild battle)
+ ldh a, [hSpriteIndex] ; enemy trainer sprite index (0 if wild battle)
ld c, a
ld b, 0
ld de, $10
@@ -64,6 +64,12 @@ BattleTransition:
ld l, a
jp hl
+ const_def
+ const BIT_TRAINER_BATTLE_TRANSITION ; 0
+ const BIT_STRONGER_BATTLE_TRANSITION ; 1
+ const BIT_DUNGEON_BATTLE_TRANSITION ; 2
+DEF NUM_BATTLE_TRANSITION_BITS EQU const_value
+
; the three GetBattleTransitionID functions set the first
; three bits of c, which determines what transition animation
; to play at the beginning of a battle
@@ -71,6 +77,7 @@ BattleTransition:
; bit 1: set if enemy is at least 3 levels higher than player
; bit 2: set if dungeon map
BattleTransitions:
+ table_width 2, BattleTransitions
dw BattleTransition_DoubleCircle ; %000
dw BattleTransition_Spiral ; %001
dw BattleTransition_Circle ; %010
@@ -79,15 +86,16 @@ BattleTransitions:
dw BattleTransition_Shrink ; %101
dw BattleTransition_VerticalStripes ; %110
dw BattleTransition_Split ; %111
+ assert_table_length 1 << NUM_BATTLE_TRANSITION_BITS
GetBattleTransitionID_WildOrTrainer:
ld a, [wCurOpponent]
cp OPP_ID_OFFSET
jr nc, .trainer
- res 0, c
+ res BIT_TRAINER_BATTLE_TRANSITION, c
ret
.trainer
- set 0, c
+ set BIT_TRAINER_BATTLE_TRANSITION, c
ret
GetBattleTransitionID_CompareLevels:
@@ -105,15 +113,15 @@ GetBattleTransitionID_CompareLevels:
ld a, [hl]
add $3
ld e, a
- ld a, [wCurEnemyLVL]
+ ld a, [wCurEnemyLevel]
sub e
jr nc, .highLevelEnemy
- res 1, c
+ res BIT_STRONGER_BATTLE_TRANSITION, c
ld a, 1
ld [wBattleTransitionSpiralDirection], a
ret
.highLevelEnemy
- set 1, c
+ set BIT_STRONGER_BATTLE_TRANSITION, c
xor a
ld [wBattleTransitionSpiralDirection], a
ret
@@ -129,7 +137,7 @@ GetBattleTransitionID_IsDungeonMap:
cp e
jr nz, .loop1
.match
- set 2, c
+ set BIT_DUNGEON_BATTLE_TRANSITION, c
ret
.noMatch1
ld hl, DungeonMaps2
@@ -145,7 +153,7 @@ GetBattleTransitionID_IsDungeonMap:
cp d
jr nc, .match
.noMatch2
- res 2, c
+ res BIT_DUNGEON_BATTLE_TRANSITION, c
ret
INCLUDE "data/maps/dungeon_maps.asm"
diff --git a/engine/battle/common_text.asm b/engine/battle/common_text.asm
index 95c06bf5..a074fff7 100644
--- a/engine/battle/common_text.asm
+++ b/engine/battle/common_text.asm
@@ -48,7 +48,7 @@ PrintBeginningBattleText:
ld b, SILPH_SCOPE
call IsItemInBag
ld a, [wEnemyMonSpecies2]
- ld [wcf91], a
+ ld [wCurPartySpecies], a
cp RESTLESS_SOUL
jr z, .isMarowak
ld a, b
diff --git a/engine/battle/core.asm b/engine/battle/core.asm
index b0f4f13f..926910fc 100644
--- a/engine/battle/core.asm
+++ b/engine/battle/core.asm
@@ -238,7 +238,7 @@ StartBattle:
ld b, 0
add hl, bc
ld a, [hl] ; species
- ld [wcf91], a
+ ld [wCurPartySpecies], a
ld [wBattleMonSpecies2], a
call LoadScreenTilesFromBuffer1
hlcoord 1, 5
@@ -426,7 +426,7 @@ MainInBattleLoop:
jr c, .AIActionUsedEnemyFirst
call ExecuteEnemyMove
ld a, [wEscapedFromBattle]
- and a ; was Teleport, Road, or Whirlwind used to escape from battle?
+ and a ; was Teleport, Roar, or Whirlwind used to escape from battle?
ret nz ; if so, return
ld a, b
and a
@@ -437,7 +437,7 @@ MainInBattleLoop:
call DrawHUDsAndHPBars
call ExecutePlayerMove
ld a, [wEscapedFromBattle]
- and a ; was Teleport, Road, or Whirlwind used to escape from battle?
+ and a ; was Teleport, Roar, or Whirlwind used to escape from battle?
ret nz ; if so, return
ld a, b
and a
@@ -450,7 +450,7 @@ MainInBattleLoop:
.playerMovesFirst
call ExecutePlayerMove
ld a, [wEscapedFromBattle]
- and a ; was Teleport, Road, or Whirlwind used to escape from battle?
+ and a ; was Teleport, Roar, or Whirlwind used to escape from battle?
ret nz ; if so, return
ld a, b
and a
@@ -464,7 +464,7 @@ MainInBattleLoop:
jr c, .AIActionUsedPlayerFirst
call ExecuteEnemyMove
ld a, [wEscapedFromBattle]
- and a ; was Teleport, Road, or Whirlwind used to escape from battle?
+ and a ; was Teleport, Roar, or Whirlwind used to escape from battle?
ret nz ; if so, return
ld a, b
and a
@@ -853,7 +853,7 @@ FaintEnemyPokemon:
; the player has exp all
; now, set the gain exp flag for every party member
; half of the total stat exp and normal exp will divided evenly amongst every party member
- ld a, $1
+ ld a, TRUE
ld [wBoostExpByExpAll], a
ld a, [wPartyCount]
ld b, 0
@@ -938,8 +938,8 @@ TrainerBattleVictory:
cp RIVAL3 ; final battle against rival
jr nz, .notrival
ld b, MUSIC_DEFEATED_GYM_LEADER
- ld hl, wFlags_D733
- set 1, [hl]
+ ld hl, wStatusFlags7
+ set BIT_NO_MAP_MUSIC, [hl]
.notrival
ld a, [wLinkState]
cp LINK_STATE_BATTLING
@@ -1019,12 +1019,12 @@ RemoveFaintedPlayerMon:
ld b, FLAG_RESET
predef FlagActionPredef ; clear gain exp flag for fainted mon
ld hl, wEnemyBattleStatus1
- res 2, [hl] ; reset "attacking multiple times" flag
+ res ATTACKING_MULTIPLE_TIMES, [hl]
ld a, [wLowHealthAlarm]
- bit 7, a ; skip sound flag (red bar (?))
+ bit BIT_LOW_HEALTH_ALARM, a
jr z, .skipWaitForSound
- ld a, $ff
- ld [wLowHealthAlarm], a ;disable low health alarm
+ ld a, DISABLE_LOW_HEALTH_ALARM
+ ld [wLowHealthAlarm], a
call WaitForSoundToFinish
xor a
.skipWaitForSound
@@ -1196,9 +1196,9 @@ HandlePlayerBlackOut:
ld hl, LinkBattleLostText
.noLinkBattle
call PrintText
- ld a, [wd732]
- res 5, a
- ld [wd732], a
+ ld a, [wStatusFlags6]
+ res BIT_ALWAYS_ON_BIKE, a
+ ld [wStatusFlags6], a
call ClearScreen
scf
ret
@@ -1218,10 +1218,10 @@ LinkBattleLostText:
; slides pic of fainted mon downwards until it disappears
; bug: when this is called, [hAutoBGTransferEnabled] is non-zero, so there is screen tearing
SlideDownFaintedMonPic:
- ld a, [wd730]
+ ld a, [wStatusFlags5]
push af
- set 6, a
- ld [wd730], a
+ set BIT_NO_TEXT_DELAY, a
+ ld [wStatusFlags5], a
ld b, 7 ; number of times to slide
.slideStepLoop ; each iteration, the mon is slid down one row
push bc
@@ -1260,7 +1260,7 @@ SlideDownFaintedMonPic:
dec b
jr nz, .slideStepLoop
pop af
- ld [wd730], a
+ ld [wStatusFlags5], a
ret
SevenSpacesText:
@@ -1344,7 +1344,7 @@ EnemySendOutFirstMon:
dec a
ld [wAICount], a
ld hl, wPlayerBattleStatus1
- res 5, [hl]
+ res USING_TRAPPING_MOVE, [hl]
hlcoord 18, 0
ld a, 8
call SlideTrainerPicOffScreen
@@ -1383,7 +1383,7 @@ EnemySendOutFirstMon:
ld bc, wEnemyMon2 - wEnemyMon1
call AddNTimes
ld a, [hl]
- ld [wCurEnemyLVL], a
+ ld [wCurEnemyLevel], a
ld a, [wWhichPokemon]
inc a
ld hl, wEnemyPartyCount
@@ -1392,7 +1392,7 @@ EnemySendOutFirstMon:
add hl, bc
ld a, [hl]
ld [wEnemyMonSpecies2], a
- ld [wcf91], a
+ ld [wCurPartySpecies], a
call LoadEnemyMonData
ld hl, wEnemyMonHP
ld a, [hli]
@@ -1459,8 +1459,8 @@ EnemySendOutFirstMon:
ld hl, TrainerSentOutText
call PrintText
ld a, [wEnemyMonSpecies2]
- ld [wcf91], a
- ld [wd0b5], a
+ ld [wCurPartySpecies], a
+ ld [wCurSpecies], a
call GetMonHeader
ld de, vFrontPic
call LoadMonFrontSprite
@@ -1683,7 +1683,7 @@ LoadBattleMonFromParty:
ld bc, wBattleMonPP - wBattleMonLevel
call CopyData
ld a, [wBattleMonSpecies2]
- ld [wd0b5], a
+ ld [wCurSpecies], a
call GetMonHeader
ld hl, wPartyMonNicks
ld a, [wPlayerMonNumber]
@@ -1727,7 +1727,7 @@ LoadEnemyMonFromParty:
ld bc, wEnemyMonPP - wEnemyMonLevel
call CopyData
ld a, [wEnemyMonSpecies]
- ld [wd0b5], a
+ ld [wCurSpecies], a
call GetMonHeader
ld hl, wEnemyMonNicks
ld a, [wWhichPokemon]
@@ -1817,7 +1817,7 @@ SendOutMon:
callfar PlayPikachuSoundClip
jr .done
.playRegularCry
- ld a, [wcf91]
+ ld a, [wCurPartySpecies]
call PlayCry
.done
call PrintEmptyString
@@ -1916,7 +1916,7 @@ DrawPlayerHUDAndHPBar:
call PrintLevel
.doNotPrintLevel
ld a, [wLoadedMonSpecies]
- ld [wcf91], a
+ ld [wCurPartySpecies], a
hlcoord 10, 9
predef DrawHP
ld a, $1
@@ -1935,15 +1935,15 @@ DrawPlayerHUDAndHPBar:
jr z, .setLowHealthAlarm
.fainted
ld hl, wLowHealthAlarm
- bit 7, [hl] ;low health alarm enabled?
- ld [hl], $0
+ bit BIT_LOW_HEALTH_ALARM, [hl]
+ ld [hl], 0
ret z
xor a
ld [wChannelSoundIDs + CHAN5], a
ret
.setLowHealthAlarm
ld hl, wLowHealthAlarm
- set 7, [hl] ;enable low health alarm
+ set BIT_LOW_HEALTH_ALARM, [hl]
ret
DrawEnemyHUDAndHPBar:
@@ -2208,7 +2208,7 @@ DisplayBattleMenu::
ld a, D_LEFT | A_BUTTON
ld [hli], a ; wMenuWatchedKeys
call HandleMenuInput
- bit 5, a ; check if left was pressed
+ bit BIT_D_LEFT, a
jr nz, .leftColumn ; if left was pressed, jump
ld a, [wCurrentMenuItem]
add $2 ; if we're in the right column, the actual id is +2
@@ -2249,7 +2249,7 @@ DisplayBattleMenu::
jp LoadScreenTilesFromBuffer1 ; restore saved screen and return
.throwSafariBallWasSelected
ld a, SAFARI_BALL
- ld [wcf91], a
+ ld [wCurItem], a
jp UseBagItem
.handleUnusedBattle
ld a, [wCurrentMenuItem]
@@ -2285,7 +2285,7 @@ DisplayBattleMenu::
; bait was selected
ld a, SAFARI_BAIT
- ld [wcf91], a
+ ld [wCurItem], a
jr UseBagItem
BagWasSelected:
@@ -2341,8 +2341,8 @@ DisplayBagMenu:
UseBagItem:
; either use an item from the bag or use a safari zone item
- ld a, [wcf91]
- ld [wd11e], a
+ ld a, [wCurItem]
+ ld [wNamedObjectIndex], a
call GetItemName
call CopyToStringBuffer
xor a
@@ -2410,7 +2410,7 @@ PartyMenuOrRockOrRun:
jr nz, .partyMenuWasSelected
; safari battle
ld a, SAFARI_ROCK
- ld [wcf91], a
+ ld [wCurItem], a
jp UseBagItem
.partyMenuWasSelected
call LoadScreenTilesFromBuffer1
@@ -2486,8 +2486,8 @@ PartyMenuOrRockOrRun:
jr nz, .doEnemyMonAnimation
; enemy mon is not minimised
ld a, [wEnemyMonSpecies]
- ld [wcf91], a
- ld [wd0b5], a
+ ld [wCurPartySpecies], a
+ ld [wCurSpecies], a
call GetMonHeader
ld de, vFrontPic
call LoadMonFrontSprite
@@ -2580,11 +2580,11 @@ MoveSelectionMenu:
.writemoves
ld de, wMovesString
ldh a, [hUILayoutFlags]
- set 2, a
+ set BIT_SINGLE_SPACED_LINES, a
ldh [hUILayoutFlags], a
call PlaceString
ldh a, [hUILayoutFlags]
- res 2, a
+ res BIT_SINGLE_SPACED_LINES, a
ldh [hUILayoutFlags], a
ret
@@ -2660,7 +2660,7 @@ MoveSelectionMenu:
cp LINK_STATE_BATTLING
jr z, .matchedkeyspicked
; Disable left, right, and START buttons in regular battles.
- ld a, [wFlags_D733]
+ ld a, [wStatusFlags7]
bit BIT_TEST_BATTLE, a
ld b, D_UP | D_DOWN | A_BUTTON | B_BUTTON | SELECT
jr z, .matchedkeyspicked
@@ -2689,7 +2689,7 @@ SelectMenuItem:
jr .select
.battleselect
; Hide move swap cursor in TestBattle.
- ld a, [wFlags_D733]
+ ld a, [wStatusFlags7]
bit BIT_TEST_BATTLE, a
; This causes PrintMenuItem to not run in TestBattle.
; MoveSelectionMenu still draws part of its window, an issue
@@ -2706,10 +2706,10 @@ SelectMenuItem:
ld [hl], "▷"
.select
ld hl, hUILayoutFlags
- set 1, [hl]
+ set BIT_DOUBLE_SPACED_MENU, [hl]
call HandleMenuInput
ld hl, hUILayoutFlags
- res 1, [hl]
+ res BIT_DOUBLE_SPACED_MENU, [hl]
bit BIT_D_UP, a
jp nz, SelectMenuItem_CursorUp
bit BIT_D_DOWN, a
@@ -2762,7 +2762,7 @@ ENDC
cp c
jr z, .disabled
ld a, [wPlayerBattleStatus3]
- bit 3, a ; transformed
+ bit TRANSFORMED, a
jr nz, .transformedMoveSelected
.transformedMoveSelected ; pointless
; Allow moves copied by Transform to be used.
@@ -2863,7 +2863,7 @@ Func_3d536:
ret z
cp STRUGGLE
ret nc
- ld [wd11e], a
+ ld [wNamedObjectIndex], a
call GetMoveName
hlcoord 13, 17
jp PlaceString
@@ -2920,7 +2920,7 @@ NoMovesLeftText:
SwapMovesInMenu:
IF DEF(_DEBUG)
- ld a, [wFlags_D733]
+ ld a, [wStatusFlags7]
bit BIT_TEST_BATTLE, a
jp nz, Func_3d4f5
ENDC
@@ -3047,7 +3047,7 @@ PrintMenuItem:
add hl, bc
ld a, [hl]
and $3f
- ld [wcd6d], a
+ ld [wBattleMenuCurrentPP], a
; print TYPE/<type> and <curPP>/<maxPP>
hlcoord 1, 9
ld de, TypeText
@@ -3057,7 +3057,7 @@ PrintMenuItem:
hlcoord 5, 9
ld [hl], "/"
hlcoord 5, 11
- ld de, wcd6d
+ ld de, wBattleMenuCurrentPP
lb bc, 1, 2
call PrintNumber
hlcoord 8, 11
@@ -3733,7 +3733,7 @@ CheckPlayerStatusConditions:
bit USING_RAGE, a ; is mon using rage?
jp z, .checkPlayerStatusConditionsDone ; if we made it this far, mon can move normally this turn
ld a, RAGE
- ld [wd11e], a
+ ld [wNamedObjectIndex], a
call GetMoveName
call CopyToStringBuffer
xor a
@@ -3823,7 +3823,7 @@ PrintMoveIsDisabledText:
res CHARGING_UP, a ; end the pokemon's
ld [de], a
ld a, [hl]
- ld [wd11e], a
+ ld [wNamedObjectIndex], a
call GetMoveName
ld hl, MoveIsDisabledText
jp PrintText
@@ -3897,13 +3897,13 @@ MonName1Text:
ld hl, wEnemyUsedMove
.playerTurn
ld [hl], a
- ld [wd11e], a
+ ld [wMoveGrammar], a
call DetermineExclamationPointTextNum
ld a, [wMonIsDisobedient]
and a
ld hl, Used2Text
ret nz
- ld a, [wd11e]
+ ld a, [wMoveGrammar]
cp 3
ld hl, Used2Text
ret c
@@ -3940,7 +3940,7 @@ _PrintMoveName:
text_far _MoveNameText
text_asm
ld hl, ExclamationPointPointerTable
- ld a, [wd11e] ; exclamation point num
+ ld a, [wMoveGrammar]
add a
push bc
ld b, $0
@@ -3988,7 +3988,7 @@ ExclamationPoint5Text:
; but the functionality didn't get removed
DetermineExclamationPointTextNum:
push bc
- ld a, [wd11e] ; move ID
+ ld a, [wMoveGrammar] ; move ID
ld c, a
ld b, $0
ld hl, ExclamationPointMoveSets
@@ -4004,7 +4004,7 @@ DetermineExclamationPointTextNum:
jr .loop
.done
ld a, b
- ld [wd11e], a ; exclamation point num
+ ld [wMoveGrammar], a
pop bc
ret
@@ -4019,7 +4019,7 @@ PrintMoveFailureText:
.playersTurn
ld hl, DoesntAffectMonText
ld a, [wDamageMultipliers]
- and $7f
+ and EFFECTIVENESS_MASK
jr z, .gotTextToPrint
ld hl, AttackMissedText
ld a, [wCriticalHitOrOHKO]
@@ -4573,9 +4573,9 @@ GetEnemyMonStat:
ret
.notLinkBattle
ld a, [wEnemyMonLevel]
- ld [wCurEnemyLVL], a
+ ld [wCurEnemyLevel], a
ld a, [wEnemyMonSpecies]
- ld [wd0b5], a
+ ld [wCurSpecies], a
call GetMonHeader
ld hl, wEnemyMonDVs
ld de, wLoadedMonSpeedExp
@@ -4779,7 +4779,7 @@ CriticalHitTest:
jr nz, .handleEnemy
ld a, [wBattleMonSpecies]
.handleEnemy
- ld [wd0b5], a
+ ld [wCurSpecies], a
call GetMonHeader
ld a, [wMonHBaseSpeed]
ld b, a
@@ -5289,7 +5289,7 @@ MirrorMoveFailedText:
; function used to reload move data for moves like Mirror Move and Metronome
ReloadMoveData:
- ld [wd11e], a
+ ld [wNamedObjectIndex], a
dec a
ld hl, Moves
ld bc, MOVE_LENGTH
@@ -5417,7 +5417,7 @@ AdjustDamageForMoveType:
ld a, l
ld [wDamage + 1], a
ld hl, wDamageMultipliers
- set 7, [hl]
+ set BIT_STAB_DAMAGE, [hl]
.skipSameTypeAttackBonus
ld a, [wMoveType]
ld b, a
@@ -5440,7 +5440,7 @@ AdjustDamageForMoveType:
push bc
inc hl
ld a, [wDamageMultipliers]
- and $80
+ and 1 << BIT_STAB_DAMAGE
ld b, a
ld a, [hl] ; a = damage multiplier
ldh [hMultiplier], a
@@ -5805,13 +5805,13 @@ EnemyCanExecuteChargingMove:
res CHARGING_UP, [hl] ; no longer charging up for attack
res INVULNERABLE, [hl] ; no longer invulnerable to typical attacks
ld a, [wEnemyMoveNum]
- ld [wd0b5], a
+ ld [wNameListIndex], a
ld a, BANK(MoveNames)
ld [wPredefBank], a
ld a, MOVE_NAME
ld [wNameListType], a
call GetName
- ld de, wcd6d
+ ld de, wNameBuffer
call CopyToStringBuffer
EnemyCanExecuteMove:
xor a
@@ -6247,7 +6247,7 @@ CheckEnemyStatusConditions:
bit USING_RAGE, a ; is mon using rage?
jp z, .checkEnemyStatusConditionsDone ; if we made it this far, mon can move normally this turn
ld a, RAGE
- ld [wd11e], a
+ ld [wNamedObjectIndex], a
call GetMoveName
call CopyToStringBuffer
xor a
@@ -6272,13 +6272,13 @@ GetCurrentMove:
.player
ld de, wPlayerMoveNum
; Apply InitBattleVariables to TestBattle.
- ld a, [wFlags_D733]
+ ld a, [wStatusFlags7]
bit BIT_TEST_BATTLE, a
ld a, [wTestBattlePlayerSelectedMove]
jr nz, .selected
ld a, [wPlayerSelectedMove]
.selected
- ld [wd0b5], a
+ ld [wNameListIndex], a
dec a
ld hl, Moves
ld bc, MOVE_LENGTH
@@ -6291,7 +6291,7 @@ GetCurrentMove:
ld a, MOVE_NAME
ld [wNameListType], a
call GetName
- ld de, wcd6d
+ ld de, wNameBuffer
jp CopyToStringBuffer
LoadEnemyMonData:
@@ -6300,7 +6300,7 @@ LoadEnemyMonData:
jp z, LoadEnemyMonFromParty
ld a, [wEnemyMonSpecies2]
ld [wEnemyMonSpecies], a
- ld [wd0b5], a
+ ld [wCurSpecies], a
call GetMonHeader
ld a, [wEnemyBattleStatus3]
bit TRANSFORMED, a ; is enemy mon transformed?
@@ -6323,7 +6323,7 @@ LoadEnemyMonData:
ld [hli], a
ld [hl], b
ld de, wEnemyMonLevel
- ld a, [wCurEnemyLVL]
+ ld a, [wCurEnemyLevel]
ld [de], a
inc de
ld b, $0
@@ -6425,16 +6425,16 @@ LoadEnemyMonData:
ld a, [hl] ; base exp
ld [de], a
ld a, [wEnemyMonSpecies2]
- ld [wd11e], a
+ ld [wNamedObjectIndex], a
call GetMonName
- ld hl, wcd6d
+ ld hl, wNameBuffer
ld de, wEnemyMonNick
ld bc, NAME_LENGTH
call CopyData
ld a, [wEnemyMonSpecies2]
- ld [wd11e], a
+ ld [wPokedexNum], a
predef IndexToPokedex
- ld a, [wd11e]
+ ld a, [wPokedexNum]
dec a
ld c, a
ld b, FLAG_SET
diff --git a/engine/battle/effects.asm b/engine/battle/effects.asm
index 51dc1d37..1feebb21 100644
--- a/engine/battle/effects.asm
+++ b/engine/battle/effects.asm
@@ -204,7 +204,7 @@ ExplodeEffect:
FreezeBurnParalyzeEffect:
xor a
ld [wAnimationType], a
- call CheckTargetSubstitute ; test bit 4 of d063/d068 flags [target has substitute flag]
+ call CheckTargetSubstitute
ret nz ; return if they have a substitute, can't effect them
ldh a, [hWhoseTurn]
and a
@@ -848,7 +848,7 @@ SwitchAndTeleportEffect:
ld a, [wIsInBattle]
dec a
jr nz, .notWildBattle1
- ld a, [wCurEnemyLVL]
+ ld a, [wCurEnemyLevel]
ld b, a
ld a, [wBattleMonLevel]
cp b ; is the player's level greater than the enemy's level?
@@ -892,7 +892,7 @@ SwitchAndTeleportEffect:
jr nz, .notWildBattle2
ld a, [wBattleMonLevel]
ld b, a
- ld a, [wCurEnemyLVL]
+ ld a, [wCurEnemyLevel]
cp b
jr nc, .enemyMoveWasSuccessful
add b
@@ -1318,7 +1318,7 @@ MimicEffect:
add hl, bc
ld a, d
ld [hl], a
- ld [wd11e], a
+ ld [wNamedObjectIndex], a
call GetMoveName
call PlayCurrentMoveAnimation
ld hl, MimicLearnedMoveText
@@ -1365,7 +1365,7 @@ DisableEffect:
pop hl
and a
jr z, .pickMoveToDisable ; loop until a non-00 move slot is found
- ld [wd11e], a ; store move number
+ ld [wNamedObjectIndex], a ; store move number
push hl
ldh a, [hWhoseTurn]
and a
@@ -1410,7 +1410,7 @@ DisableEffect:
jr nz, .printDisableText
inc hl ; wEnemyDisabledMoveNumber
.printDisableText
- ld a, [wd11e] ; move number
+ ld a, [wNamedObjectIndex] ; move number
ld [hl], a
call GetMoveName
ld hl, MoveWasDisabledText
diff --git a/engine/battle/end_of_battle.asm b/engine/battle/end_of_battle.asm
index e07c243e..53946250 100644
--- a/engine/battle/end_of_battle.asm
+++ b/engine/battle/end_of_battle.asm
@@ -70,8 +70,8 @@ EndOfBattle:
ld [hli], a
dec b
jr nz, .loop
- ld hl, wd72c
- set 0, [hl]
+ ld hl, wStatusFlags2
+ set BIT_WILD_ENCOUNTER_COOLDOWN, [hl]
call WaitForSoundToFinish
call GBPalWhiteOut
ld a, $ff
diff --git a/engine/battle/experience.asm b/engine/battle/experience.asm
index 61fbdfa3..35f9f1a4 100644
--- a/engine/battle/experience.asm
+++ b/engine/battle/experience.asm
@@ -113,8 +113,8 @@ GainExperience:
ld b, 0
ld hl, wPartySpecies
add hl, bc
- ld a, [hl] ; species
- ld [wd0b5], a
+ ld a, [hl]
+ ld [wCurSpecies], a
call GetMonHeader
ld d, MAX_LEVEL
callfar CalcExperience ; get max exp
@@ -160,17 +160,17 @@ GainExperience:
ld a, [hl] ; current level
cp d
jp z, .nextMon ; if level didn't change, go to next mon
- ld a, [wCurEnemyLVL]
+ ld a, [wCurEnemyLevel]
push af
push hl
ld a, d
- ld [wCurEnemyLVL], a
+ ld [wCurEnemyLevel], a
ld [hl], a
ld bc, wPartyMon1Species - wPartyMon1Level
add hl, bc
- ld a, [hl] ; species
- ld [wd0b5], a
- ld [wd11e], a
+ ld a, [hl]
+ ld [wCurSpecies], a
+ ld [wPokedexNum], a
call GetMonHeader
ld bc, (wPartyMon1MaxHP + 1) - wPartyMon1Species
add hl, bc
@@ -224,7 +224,7 @@ GainExperience:
call CopyData
pop hl
ld a, [wPlayerBattleStatus3]
- bit 3, a ; is the mon transformed?
+ bit TRANSFORMED, a
jr nz, .recalcStatChanges
; the mon is not transformed, so update the unmodified stats
ld de, wPlayerMonUnmodifiedLevel
@@ -257,8 +257,8 @@ GainExperience:
call LoadScreenTilesFromBuffer1
xor a ; PLAYER_PARTY_DATA
ld [wMonDataLocation], a
- ld a, [wd0b5]
- ld [wd11e], a
+ ld a, [wCurSpecies]
+ ld [wPokedexNum], a
predef LearnMoveFromLevelUp
ld hl, wCanEvolveFlags
ld a, [wWhichPokemon]
@@ -267,7 +267,7 @@ GainExperience:
predef FlagActionPredef
pop hl
pop af
- ld [wCurEnemyLVL], a
+ ld [wCurEnemyLevel], a
.nextMon
ld a, [wPartyCount]
@@ -312,7 +312,7 @@ DivideExpDataByNumMonsGainingExp:
jr nz, .countSetBitsLoop
cp $2
ret c ; return if only one mon is gaining exp
- ld [wd11e], a ; store number of mons gaining exp
+ ld [wTempByteValue], a ; store number of mons gaining exp
ld hl, wEnemyMonBaseStats
ld c, wEnemyMonBaseExp + 1 - wEnemyMonBaseStats
.divideLoop
@@ -320,7 +320,7 @@ DivideExpDataByNumMonsGainingExp:
ldh [hDividend], a
ld a, [hl]
ldh [hDividend + 1], a
- ld a, [wd11e]
+ ld a, [wTempByteValue]
ldh [hDivisor], a
ld b, $2
call Divide ; divide value by number of mons gaining exp
diff --git a/engine/battle/get_trainer_name.asm b/engine/battle/get_trainer_name.asm
index b2daebfe..a0e869fc 100644
--- a/engine/battle/get_trainer_name.asm
+++ b/engine/battle/get_trainer_name.asm
@@ -1,5 +1,5 @@
GetTrainerName_::
- ld hl, wGrassRate
+ ld hl, wLinkEnemyTrainerName
ld a, [wLinkState]
and a
jr nz, .foundName
@@ -11,14 +11,14 @@ GetTrainerName_::
jr z, .foundName
cp RIVAL3
jr z, .foundName
- ld [wd0b5], a
+ ld [wNameListIndex], a
ld a, TRAINER_NAME
ld [wNameListType], a
ld a, BANK(TrainerNames)
ld [wPredefBank], a
call GetName
- ld hl, wcd6d
+ ld hl, wNameBuffer
.foundName
ld de, wTrainerName
- ld bc, $d
+ ld bc, ITEM_NAME_LENGTH
jp CopyData
diff --git a/engine/battle/init_battle.asm b/engine/battle/init_battle.asm
index d23df283..58e18a3f 100644
--- a/engine/battle/init_battle.asm
+++ b/engine/battle/init_battle.asm
@@ -5,12 +5,12 @@ InitBattle::
InitOpponent:
ld a, [wCurOpponent]
- ld [wcf91], a
+ ld [wCurPartySpecies], a
ld [wEnemyMonSpecies2], a
jr InitBattleCommon
DetermineWildOpponent:
- ld a, [wd732]
+ ld a, [wStatusFlags6]
bit BIT_DEBUG_MODE, a
jr z, .notDebugMode
ldh a, [hJoyHeld]
@@ -28,7 +28,7 @@ InitBattleCommon:
ld hl, wLetterPrintingDelayFlags
ld a, [hl]
push af
- res 1, [hl]
+ res BIT_TEXT_DELAY, [hl] ; no delay
call InitBattleVariables
ld a, [wEnemyMonSpecies2]
sub OPP_ID_OFFSET
@@ -87,14 +87,14 @@ InitWildBattle:
ld a, "T"
ld [hli], a
ld [hl], "@"
- ld a, [wcf91]
+ ld a, [wCurPartySpecies]
push af
ld a, MON_GHOST
- ld [wcf91], a
+ ld [wCurPartySpecies], a
ld de, vFrontPic
call LoadMonFrontSprite ; load ghost sprite
pop af
- ld [wcf91], a
+ ld [wCurPartySpecies], a
jr .spriteLoaded
.isNoGhost
ld de, vFrontPic
@@ -171,7 +171,7 @@ LoadMonBackPic:
; Assumes the monster's attributes have
; been loaded with GetMonHeader.
ld a, [wBattleMonSpecies2]
- ld [wcf91], a
+ ld [wCurPartySpecies], a
hlcoord 1, 5
lb bc, 7, 8
call ClearScreenArea
diff --git a/engine/battle/misc.asm b/engine/battle/misc.asm
index df9145f2..b8ee4c2f 100644
--- a/engine/battle/misc.asm
+++ b/engine/battle/misc.asm
@@ -8,16 +8,16 @@ FormatMovesString:
and a ; end of move list?
jr z, .printDashLoop ; print dashes when no moves are left
push hl
- ld [wd0b5], a
+ ld [wNameListIndex], a
ld a, BANK(MoveNames)
ld [wPredefBank], a
ld a, MOVE_NAME
ld [wNameListType], a
call GetName
- ld hl, wcd6d
+ ld hl, wNameBuffer
.copyNameLoop
ld a, [hli]
- cp $50
+ cp "@"
jr z, .doneCopyingName
ld [de], a
inc de
@@ -26,7 +26,7 @@ FormatMovesString:
ld a, b
ld [wNumMovesMinusOne], a
inc b
- ld a, $4e ; line break
+ ld a, "<NEXT>"
ld [de], a
inc de
pop hl
@@ -42,7 +42,7 @@ FormatMovesString:
ld a, b
cp NUM_MOVES
jr z, .done
- ld a, $4e ; line break
+ ld a, "<NEXT>"
ld [de], a
inc de
jr .printDashLoop
@@ -92,9 +92,9 @@ InitList:
ld a, h
ld [wListPointer + 1], a
ld a, e
- ld [wUnusedCF8D], a
+ ld [wUnusedNamePointer], a
ld a, d
- ld [wUnusedCF8D + 1], a
+ ld [wUnusedNamePointer + 1], a
ld bc, ItemPrices
ld a, c
ld [wItemPrices], a
diff --git a/engine/battle/move_effects/pay_day.asm b/engine/battle/move_effects/pay_day.asm
index fa373038..9aab3feb 100644
--- a/engine/battle/move_effects/pay_day.asm
+++ b/engine/battle/move_effects/pay_day.asm
@@ -1,6 +1,6 @@
PayDayEffect_:
xor a
- ld hl, wcd6d
+ ld hl, wPayDayMoney
ld [hli], a
ldh a, [hWhoseTurn]
and a
@@ -21,7 +21,7 @@ PayDayEffect_:
ld b, $4
call Divide
ldh a, [hQuotient + 3]
- ld [hli], a
+ ld [hli], a ; wPayDayMoney + 1
ldh a, [hRemainder]
ldh [hDividend + 3], a
ld a, 10
@@ -33,7 +33,7 @@ PayDayEffect_:
ld b, a
ldh a, [hRemainder]
add b
- ld [hl], a
+ ld [hl], a ; wPayDayMoney + 2
ld de, wTotalPayDayMoney + 2
ld c, $3
predef AddBCDPredef
diff --git a/engine/battle/move_effects/transform.asm b/engine/battle/move_effects/transform.asm
index af47ae1b..775816c7 100644
--- a/engine/battle/move_effects/transform.asm
+++ b/engine/battle/move_effects/transform.asm
@@ -109,7 +109,7 @@ TransformEffect_:
; original (unmodified) stats and stat mods
pop hl
ld a, [hl]
- ld [wd11e], a
+ ld [wNamedObjectIndex], a
call GetMonName
ld hl, wEnemyMonUnmodifiedAttack
ld de, wPlayerMonUnmodifiedAttack
diff --git a/engine/battle/print_type.asm b/engine/battle/print_type.asm
index 7da0dc8c..e7c6729c 100644
--- a/engine/battle/print_type.asm
+++ b/engine/battle/print_type.asm
@@ -1,4 +1,4 @@
-; [wd0b5] = pokemon ID
+; [wCurSpecies] = pokemon ID
; hl = dest addr
PrintMonType:
call GetPredefRegisters
diff --git a/engine/battle/read_trainer_party.asm b/engine/battle/read_trainer_party.asm
index 8fa323b5..344d7ce8 100644
--- a/engine/battle/read_trainer_party.asm
+++ b/engine/battle/read_trainer_party.asm
@@ -49,12 +49,12 @@ ReadTrainer:
ld a, [hli]
cp $FF ; is the trainer special?
jr z, .SpecialTrainer ; if so, check for special moves
- ld [wCurEnemyLVL], a
+ ld [wCurEnemyLevel], a
.LoopTrainerData
ld a, [hli]
and a ; have we reached the end of the trainer data?
jp z, .AddAdditionalMoveData
- ld [wcf91], a ; write species somewhere (XXX why?)
+ ld [wCurPartySpecies], a
ld a, ENEMY_PARTY_DATA
ld [wMonDataLocation], a
push hl
@@ -69,9 +69,9 @@ ReadTrainer:
ld a, [hli]
and a ; have we reached the end of the trainer data?
jr z, .AddAdditionalMoveData
- ld [wCurEnemyLVL], a
+ ld [wCurEnemyLevel], a
ld a, [hli]
- ld [wcf91], a
+ ld [wCurPartySpecies], a
ld a, ENEMY_PARTY_DATA
ld [wMonDataLocation], a
push hl
@@ -129,7 +129,7 @@ ReadTrainer:
ld [de], a
inc de
ld [de], a
- ld a, [wCurEnemyLVL]
+ ld a, [wCurEnemyLevel]
ld b, a
.LastLoop
; update wAmountMoneyWon addresses (money to win) based on enemy's level
@@ -141,5 +141,5 @@ ReadTrainer:
inc de
inc de
dec b
- jr nz, .LastLoop ; repeat wCurEnemyLVL times
+ jr nz, .LastLoop ; repeat wCurEnemyLevel times
ret
diff --git a/engine/battle/safari_zone.asm b/engine/battle/safari_zone.asm
index a61f402f..ca3ff8a2 100644
--- a/engine/battle/safari_zone.asm
+++ b/engine/battle/safari_zone.asm
@@ -16,7 +16,7 @@ PrintSafariZoneBattleText:
jr nz, .done
push hl
ld a, [wEnemyMonSpecies]
- ld [wd0b5], a
+ ld [wCurSpecies], a
call GetMonHeader
ld a, [wMonHCatchRate]
ld [wEnemyMonActualCatchRate], a
diff --git a/engine/battle/save_trainer_name.asm b/engine/battle/save_trainer_name.asm
index 4d40fd82..b25d5a11 100644
--- a/engine/battle/save_trainer_name.asm
+++ b/engine/battle/save_trainer_name.asm
@@ -9,7 +9,7 @@ SaveTrainerName::
ld a, [hli]
ld h, [hl]
ld l, a
- ld de, wcd6d
+ ld de, wNameBuffer
.CopyCharacter
ld a, [hli]
ld [de], a
diff --git a/engine/battle/trainer_ai.asm b/engine/battle/trainer_ai.asm
index 41325ce7..d714109d 100644
--- a/engine/battle/trainer_ai.asm
+++ b/engine/battle/trainer_ai.asm
@@ -641,27 +641,27 @@ AICureStatus:
ld [hl], a ; clear status in enemy team roster
ld [wEnemyMonStatus], a ; clear status of active enemy
ld hl, wEnemyBattleStatus3
- res 0, [hl]
+ res BADLY_POISONED, [hl]
ret
AIUseXAccuracy: ; unused
call AIPlayRestoringSFX
ld hl, wEnemyBattleStatus2
- set 0, [hl]
+ set USING_X_ACCURACY, [hl]
ld a, X_ACCURACY
jp AIPrintItemUse
AIUseGuardSpec:
call AIPlayRestoringSFX
ld hl, wEnemyBattleStatus2
- set 1, [hl]
+ set PROTECTED_BY_MIST, [hl]
ld a, GUARD_SPEC
jp AIPrintItemUse
AIUseDireHit: ; unused
call AIPlayRestoringSFX
ld hl, wEnemyBattleStatus2
- set 2, [hl]
+ set GETTING_PUMPED, [hl]
ld a, DIRE_HIT
jp AIPrintItemUse
@@ -741,7 +741,7 @@ AIPrintItemUse:
AIPrintItemUse_:
; print "x used [wAIItem] on z!"
ld a, [wAIItem]
- ld [wd11e], a
+ ld [wNamedObjectIndex], a
call GetItemName
ld hl, AIBattleUseItemText
jp PrintText
diff --git a/engine/battle/wild_encounters.asm b/engine/battle/wild_encounters.asm
index d16c6515..9fe0c96c 100644
--- a/engine/battle/wild_encounters.asm
+++ b/engine/battle/wild_encounters.asm
@@ -4,8 +4,8 @@ TryDoWildEncounter:
ld a, [wNPCMovementScriptPointerTableNum]
and a
ret nz
- ld a, [wd736]
- and a
+ ld a, [wMovementFlags]
+ and a ; is player exiting a door, jumping over a ledge, or fishing?
ret nz
callfar IsPlayerStandingOnDoorTileOrWarpTile
jr nc, .notStandingOnDoorOrWarpTile
@@ -73,23 +73,23 @@ TryDoWildEncounter:
ld b, 0
add hl, bc
ld a, [hli]
- ld [wCurEnemyLVL], a
+ ld [wCurEnemyLevel], a
ld a, [hl]
- ld [wcf91], a
+ ld [wCurPartySpecies], a
ld [wEnemyMonSpecies2], a
ld a, [wRepelRemainingSteps]
and a
jr z, .willEncounter
ld a, [wPartyMon1Level]
ld b, a
- ld a, [wCurEnemyLVL]
+ ld a, [wCurEnemyLevel]
cp b
jr c, .CantEncounter2 ; repel prevents encounters if the leading party mon's level is higher than the wild mon
jr .willEncounter
.lastRepelStep
ld [wRepelRemainingSteps], a
ld a, TEXT_REPEL_WORE_OFF
- ldh [hSpriteIndexOrTextID], a
+ ldh [hTextID], a
call EnableAutoTextBoxDrawing
call DisplayTextID
.CantEncounter2