aboutsummaryrefslogtreecommitdiffstats
path: root/engine/battle
diff options
context:
space:
mode:
authorNarishma-gb <194818981+Narishma-gb@users.noreply.github.com>2025-11-27 19:39:25 +0100
committerGitHub <noreply@github.com>2025-11-27 13:39:25 -0500
commit3a4382c6055e21da72357dd18638947a2acbbda9 (patch)
treecb383fbd6a0dc57e3b0f9e9483c2a3f898f42f96 /engine/battle
parentAvoid magic numbers for most `CopyData` calls (#542) (diff)
downloadpokeyellow-3a4382c6055e21da72357dd18638947a2acbbda9.tar.gz
pokeyellow-3a4382c6055e21da72357dd18638947a2acbbda9.tar.xz
pokeyellow-3a4382c6055e21da72357dd18638947a2acbbda9.zip
Use more Pokemon data constants, create MOVE_NAME_LENGTH (#543)
Diffstat (limited to 'engine/battle')
-rw-r--r--engine/battle/battle_transitions.asm4
-rw-r--r--engine/battle/core.asm52
-rw-r--r--engine/battle/decrement_pp.asm2
-rw-r--r--engine/battle/draw_hud_pokeball_gfx.asm2
-rw-r--r--engine/battle/effects.asm4
-rw-r--r--engine/battle/end_of_battle.asm6
-rw-r--r--engine/battle/experience.asm26
-rw-r--r--engine/battle/read_trainer_party.asm2
-rw-r--r--engine/battle/trainer_ai.asm6
9 files changed, 52 insertions, 52 deletions
diff --git a/engine/battle/battle_transitions.asm b/engine/battle/battle_transitions.asm
index 3670cddc..a37a5054 100644
--- a/engine/battle/battle_transitions.asm
+++ b/engine/battle/battle_transitions.asm
@@ -104,11 +104,11 @@ GetBattleTransitionID_CompareLevels:
ld a, [hli]
or [hl]
jr nz, .notFainted
- ld de, wPartyMon2 - (wPartyMon1 + 1)
+ ld de, PARTYMON_STRUCT_LENGTH - 1
add hl, de
jr .faintedLoop
.notFainted
- ld de, wPartyMon1Level - (wPartyMon1HP + 1)
+ ld de, MON_LEVEL - (MON_HP + 1)
add hl, de
ld a, [hl]
add $3
diff --git a/engine/battle/core.asm b/engine/battle/core.asm
index 4c25373a..44fd9a70 100644
--- a/engine/battle/core.asm
+++ b/engine/battle/core.asm
@@ -137,7 +137,7 @@ StartBattle:
inc a
ld [wFirstMonsNotOutYet], a
ld hl, wEnemyMon1HP
- ld bc, wEnemyMon2 - wEnemyMon1 - 1
+ ld bc, PARTYMON_STRUCT_LENGTH - 1
ld d, $3
.findFirstAliveEnemyMonLoop
inc d
@@ -736,7 +736,7 @@ FaintEnemyPokemon:
jr z, .wild
ld a, [wEnemyMonPartyPos]
ld hl, wEnemyMon1HP
- ld bc, wEnemyMon2 - wEnemyMon1
+ ld bc, PARTYMON_STRUCT_LENGTH
call AddNTimes
xor a
ld [hli], a
@@ -876,7 +876,7 @@ AnyEnemyPokemonAliveCheck:
ld b, a
xor a
ld hl, wEnemyMon1HP
- ld de, wEnemyMon2 - wEnemyMon1
+ ld de, PARTYMON_STRUCT_LENGTH
.nextPokemon
or [hl]
inc hl
@@ -1330,7 +1330,7 @@ EnemySendOutFirstMon:
ld a, b
ld [wWhichPokemon], a
push bc
- ld bc, wEnemyMon2 - wEnemyMon1
+ ld bc, PARTYMON_STRUCT_LENGTH
call AddNTimes
pop bc
inc hl
@@ -1342,7 +1342,7 @@ EnemySendOutFirstMon:
.next3
ld a, [wWhichPokemon]
ld hl, wEnemyMon1Level
- ld bc, wEnemyMon2 - wEnemyMon1
+ ld bc, PARTYMON_STRUCT_LENGTH
call AddNTimes
ld a, [hl]
ld [wCurEnemyLevel], a
@@ -1457,7 +1457,7 @@ AnyPartyAlive::
ld e, a
xor a
ld hl, wPartyMon1HP
- ld bc, wPartyMon2 - wPartyMon1 - 1
+ ld bc, PARTYMON_STRUCT_LENGTH - 1
.partyMonsLoop
or [hl]
inc hl
@@ -1473,7 +1473,7 @@ AnyPartyAlive::
HasMonFainted:
ld a, [wWhichPokemon]
ld hl, wPartyMon1HP
- ld bc, wPartyMon2 - wPartyMon1
+ ld bc, PARTYMON_STRUCT_LENGTH
call AddNTimes
ld a, [hli]
or [hl]
@@ -1625,16 +1625,16 @@ GotAwayText:
; copies from party data to battle mon data when sending out a new player mon
LoadBattleMonFromParty:
ld a, [wWhichPokemon]
- ld bc, wPartyMon2 - wPartyMon1
+ ld bc, PARTYMON_STRUCT_LENGTH
ld hl, wPartyMon1Species
call AddNTimes
ld de, wBattleMonSpecies
ld bc, wBattleMonDVs - wBattleMonSpecies
call CopyData
- ld bc, wPartyMon1DVs - wPartyMon1OTID
+ ld bc, MON_DVS - MON_OTID
add hl, bc
ld de, wBattleMonDVs
- ld bc, wPartyMon1PP - wPartyMon1DVs
+ ld bc, MON_PP - MON_DVS
call CopyData
ld de, wBattleMonPP
ld bc, NUM_MOVES
@@ -1669,16 +1669,16 @@ LoadBattleMonFromParty:
; copies from enemy party data to current enemy mon data when sending out a new enemy mon
LoadEnemyMonFromParty:
ld a, [wWhichPokemon]
- ld bc, wEnemyMon2 - wEnemyMon1
+ ld bc, PARTYMON_STRUCT_LENGTH
ld hl, wEnemyMons
call AddNTimes
ld de, wEnemyMonSpecies
ld bc, wEnemyMonDVs - wEnemyMonSpecies
call CopyData
- ld bc, wEnemyMon1DVs - wEnemyMon1OTID
+ ld bc, MON_DVS - MON_OTID
add hl, bc
ld de, wEnemyMonDVs
- ld bc, wEnemyMon1PP - wEnemyMon1DVs
+ ld bc, MON_PP - MON_DVS
call CopyData
ld de, wEnemyMonPP
ld bc, NUM_MOVES
@@ -1800,7 +1800,7 @@ AnimateRetreatingPlayerMon:
ReadPlayerMonCurHPAndStatus:
ld a, [wPlayerMonNumber]
ld hl, wPartyMon1HP
- ld bc, wPartyMon2 - wPartyMon1
+ ld bc, PARTYMON_STRUCT_LENGTH
call AddNTimes
ld d, h
ld e, l
@@ -2520,7 +2520,7 @@ MoveSelectionMenu:
.relearnmenu
ld a, [wWhichPokemon]
ld hl, wPartyMon1Moves
- ld bc, wPartyMon2 - wPartyMon1
+ ld bc, PARTYMON_STRUCT_LENGTH
call AddNTimes
call .loadmoves
hlcoord 4, 7
@@ -2798,12 +2798,12 @@ SwapMovesInMenu:
.swapMovesInPartyMon
ld hl, wPartyMon1Moves
ld a, [wPlayerMonNumber]
- ld bc, wPartyMon2 - wPartyMon1
+ ld bc, PARTYMON_STRUCT_LENGTH
call AddNTimes
push hl
call .swapBytes ; swap moves
pop hl
- ld bc, wPartyMon1PP - wPartyMon1Moves
+ ld bc, MON_PP - MON_MOVES
add hl, bc
call .swapBytes ; swap move PP
xor a
@@ -3451,7 +3451,7 @@ CheckPlayerStatusConditions:
bit PAR, [hl]
jr z, .BideCheck
call BattleRandom
- cp $3F ; 25% to be fully paralyzed
+ cp 25 percent ; chance to be fully paralyzed
jr nc, .BideCheck
ld hl, FullyParalyzedText
call PrintText
@@ -3970,7 +3970,7 @@ CheckForDisobedience:
; compare the mon's original trainer ID with the player's ID to see if it was traded
.checkIfMonIsTraded
ld hl, wPartyMon1OTID
- ld bc, wPartyMon2 - wPartyMon1
+ ld bc, PARTYMON_STRUCT_LENGTH
ld a, [wPlayerMonNumber]
call AddNTimes
ld a, [wPlayerID]
@@ -4197,7 +4197,7 @@ GetDamageVarsForPlayerAttack:
push bc
ld hl, wPartyMon1Attack
ld a, [wPlayerMonNumber]
- ld bc, wPartyMon2 - wPartyMon1
+ ld bc, PARTYMON_STRUCT_LENGTH
call AddNTimes
pop bc
jr .scaleStats
@@ -4229,7 +4229,7 @@ GetDamageVarsForPlayerAttack:
push bc
ld hl, wPartyMon1Special
ld a, [wPlayerMonNumber]
- ld bc, wPartyMon2 - wPartyMon1
+ ld bc, PARTYMON_STRUCT_LENGTH
call AddNTimes
pop bc
; if either the offensive or defensive stat is too large to store in a byte, scale both stats by dividing them by 4
@@ -4303,7 +4303,7 @@ GetDamageVarsForEnemyAttack:
; in the case of a critical hit, reset the player's defense and the enemy's attack to their base values
ld hl, wPartyMon1Defense
ld a, [wPlayerMonNumber]
- ld bc, wPartyMon2 - wPartyMon1
+ ld bc, PARTYMON_STRUCT_LENGTH
call AddNTimes
ld a, [hli]
ld b, a
@@ -4335,7 +4335,7 @@ GetDamageVarsForEnemyAttack:
; in the case of a critical hit, reset the player's and enemy's specials to their base values
ld hl, wPartyMon1Special
ld a, [wPlayerMonNumber]
- ld bc, wPartyMon2 - wPartyMon1
+ ld bc, PARTYMON_STRUCT_LENGTH
call AddNTimes
ld a, [hli]
ld b, a
@@ -4398,7 +4398,7 @@ GetEnemyMonStat:
ld b, $0
add hl, bc
ld a, [wEnemyMonPartyPos]
- ld bc, wEnemyMon2 - wEnemyMon1
+ ld bc, PARTYMON_STRUCT_LENGTH
call AddNTimes
ld a, [hli]
ldh [hMultiplicand + 1], a
@@ -5197,7 +5197,7 @@ IncrementMovePP:
jr z, .updatePP
ld a, [wEnemyMonPartyPos] ; value for enemy turn
.updatePP
- ld bc, wEnemyMon2 - wEnemyMon1
+ ld bc, PARTYMON_STRUCT_LENGTH
call AddNTimes
inc [hl] ; increment PP in the party memory location
ret
@@ -6206,7 +6206,7 @@ LoadEnemyMonData:
; if it's a trainer battle, copy moves from enemy party data
ld hl, wEnemyMon1Moves
ld a, [wWhichPokemon]
- ld bc, wEnemyMon2 - wEnemyMon1
+ ld bc, PARTYMON_STRUCT_LENGTH
call AddNTimes
ld bc, NUM_MOVES
call CopyData
diff --git a/engine/battle/decrement_pp.asm b/engine/battle/decrement_pp.asm
index 441bbb81..93515224 100644
--- a/engine/battle/decrement_pp.asm
+++ b/engine/battle/decrement_pp.asm
@@ -31,7 +31,7 @@ DecrementPP:
ld hl, wPartyMon1PP ; PP of first move (in party)
ld a, [wPlayerMonNumber] ; which mon in party is active
- ld bc, wPartyMon2 - wPartyMon1
+ ld bc, PARTYMON_STRUCT_LENGTH
call AddNTimes ; calculate address of the mon to modify
.DecrementPP:
ld a, [wPlayerMoveListIndex] ; which move (0, 1, 2, 3) did we use?
diff --git a/engine/battle/draw_hud_pokeball_gfx.asm b/engine/battle/draw_hud_pokeball_gfx.asm
index 011b4b33..768a6e20 100644
--- a/engine/battle/draw_hud_pokeball_gfx.asm
+++ b/engine/battle/draw_hud_pokeball_gfx.asm
@@ -90,7 +90,7 @@ PickPokeball:
.done
ld a, b
ld [de], a
- ld bc, wPartyMon2 - wPartyMon1Status
+ ld bc, PARTYMON_STRUCT_LENGTH - MON_STATUS
add hl, bc ; next mon struct
ret
diff --git a/engine/battle/effects.asm b/engine/battle/effects.asm
index 003592aa..2cef2521 100644
--- a/engine/battle/effects.asm
+++ b/engine/battle/effects.asm
@@ -323,7 +323,7 @@ CheckDefrost:
ld [wEnemyMonStatus], a ; set opponent status to 00 ["defrost" a frozen monster]
ld hl, wEnemyMon1Status
ld a, [wEnemyMonPartyPos]
- ld bc, wEnemyMon2 - wEnemyMon1
+ ld bc, PARTYMON_STRUCT_LENGTH
call AddNTimes
xor a
ld [hl], a ; clear status in roster
@@ -336,7 +336,7 @@ CheckDefrost:
ld [wBattleMonStatus], a
ld hl, wPartyMon1Status
ld a, [wPlayerMonNumber]
- ld bc, wPartyMon2 - wPartyMon1
+ ld bc, PARTYMON_STRUCT_LENGTH
call AddNTimes
xor a
ld [hl], a
diff --git a/engine/battle/end_of_battle.asm b/engine/battle/end_of_battle.asm
index 80fdf002..2feb50bd 100644
--- a/engine/battle/end_of_battle.asm
+++ b/engine/battle/end_of_battle.asm
@@ -5,7 +5,7 @@ EndOfBattle:
; link battle
ld a, [wEnemyMonPartyPos]
ld hl, wEnemyMon1Status
- ld bc, wEnemyMon2 - wEnemyMon1
+ ld bc, PARTYMON_STRUCT_LENGTH
call AddNTimes
ld a, [wEnemyMonStatus]
ld [hl], a
@@ -60,8 +60,8 @@ EndOfBattle:
ld [hli], a
ld [hl], a
ld [wListScrollOffset], a
- ld hl, wPlayerStatsToDouble
- ld b, $18
+ ld hl, wBattleStatusData
+ ld b, wBattleStatusDataEnd - wBattleStatusData
.loop
ld [hli], a
dec b
diff --git a/engine/battle/experience.asm b/engine/battle/experience.asm
index a8ee6747..4e44643c 100644
--- a/engine/battle/experience.asm
+++ b/engine/battle/experience.asm
@@ -21,7 +21,7 @@ GainExperience:
and a ; is mon's gain exp flag set?
pop hl
jp z, .nextMon ; if mon's gain exp flag not set, go to next mon
- ld de, (wPartyMon1HPExp + 1) - (wPartyMon1HP + 1)
+ ld de, (MON_HP_EXP + 1) - (MON_HP + 1)
add hl, de
ld d, h
ld e, l
@@ -66,9 +66,9 @@ GainExperience:
ldh [hDivisor], a
ld b, 4
call Divide
- ld hl, wPartyMon1OTID - (wPartyMon1DVs - 1)
+ ld hl, MON_OTID - (MON_DVS - 1)
add hl, de
- ld b, [hl] ; party mon OTID
+ ld b, [hl] ; wPartyMon*OTID
inc hl
ld a, [wPlayerID]
cp b
@@ -152,7 +152,7 @@ GainExperience:
ld [wMonDataLocation], a
call LoadMonData
pop hl
- ld bc, wPartyMon1Level - wPartyMon1Exp
+ ld bc, MON_LEVEL - MON_EXP
add hl, bc
push hl
farcall CalcLevelFromExperience
@@ -166,13 +166,13 @@ GainExperience:
ld a, d
ld [wCurEnemyLevel], a
ld [hl], a
- ld bc, wPartyMon1Species - wPartyMon1Level
+ ld bc, MON_SPECIES - MON_LEVEL
add hl, bc
ld a, [hl]
ld [wCurSpecies], a
ld [wPokedexNum], a
call GetMonHeader
- ld bc, (wPartyMon1MaxHP + 1) - wPartyMon1Species
+ ld bc, (MON_MAXHP + 1) - MON_SPECIES
add hl, bc
push hl
ld a, [hld]
@@ -181,7 +181,7 @@ GainExperience:
push bc ; push max HP (from before levelling up)
ld d, h
ld e, l
- ld bc, (wPartyMon1HPExp - 1) - wPartyMon1MaxHP
+ ld bc, (MON_HP_EXP - 1) - MON_MAXHP
add hl, bc
ld b, $1 ; consider stat exp when calculating stats
call CalcStats
@@ -193,15 +193,15 @@ GainExperience:
ld a, [hl]
sbc b
ld b, a ; bc = difference between old max HP and new max HP after levelling
- ld de, (wPartyMon1HP + 1) - wPartyMon1MaxHP
+ ld de, (MON_HP + 1) - MON_MAXHP
add hl, de
; add to the current HP the amount of max HP gained when levelling
- ld a, [hl] ; wPartyMon1HP + 1
+ ld a, [hl] ; wPartyMon*HP + 1
add c
ld [hld], a
- ld a, [hl] ; wPartyMon1HP + 1
+ ld a, [hl] ; wPartyMon*HP + 1
adc b
- ld [hl], a ; wPartyMon1HP
+ ld [hl], a ; wPartyMon*HP
ld a, [wPlayerMonNumber]
ld b, a
ld a, [wWhichPokemon]
@@ -216,7 +216,7 @@ GainExperience:
ld a, [hl]
ld [de], a
; copy other stats from party mon to battle mon
- ld bc, wPartyMon1Level - (wPartyMon1HP + 1)
+ ld bc, MON_LEVEL - (MON_HP + 1)
add hl, bc
push hl
ld de, wBattleMonLevel
@@ -271,7 +271,7 @@ GainExperience:
cp b
jr z, .done
ld [wWhichPokemon], a
- ld bc, wPartyMon2 - wPartyMon1
+ ld bc, PARTYMON_STRUCT_LENGTH
ld hl, wPartyMon1
call AddNTimes
jp .partyMonLoop
diff --git a/engine/battle/read_trainer_party.asm b/engine/battle/read_trainer_party.asm
index df1132ea..1e173690 100644
--- a/engine/battle/read_trainer_party.asm
+++ b/engine/battle/read_trainer_party.asm
@@ -92,7 +92,7 @@ ReadTrainer:
ld a, [hli]
ld d, [hl]
ld hl, wEnemyMon1Moves + 2
- ld bc, wEnemyMon2 - wEnemyMon1
+ ld bc, PARTYMON_STRUCT_LENGTH
call AddNTimes
ld [hl], d
jr .FinishUp
diff --git a/engine/battle/trainer_ai.asm b/engine/battle/trainer_ai.asm
index 546dd60e..b9447779 100644
--- a/engine/battle/trainer_ai.asm
+++ b/engine/battle/trainer_ai.asm
@@ -569,7 +569,7 @@ AISwitchIfEnoughMons:
inc d
.Fainted
push bc
- ld bc, wEnemyMon2 - wEnemyMon1
+ ld bc, PARTYMON_STRUCT_LENGTH
add hl, bc
pop bc
dec c
@@ -587,7 +587,7 @@ SwitchEnemyMon:
ld a, [wEnemyMonPartyPos]
ld hl, wEnemyMon1HP
- ld bc, wEnemyMon2 - wEnemyMon1
+ ld bc, PARTYMON_STRUCT_LENGTH
call AddNTimes
ld d, h
ld e, l
@@ -626,7 +626,7 @@ AICureStatus:
; cures the status of enemy's active pokemon
ld a, [wEnemyMonPartyPos]
ld hl, wEnemyMon1Status
- ld bc, wEnemyMon2 - wEnemyMon1
+ ld bc, PARTYMON_STRUCT_LENGTH
call AddNTimes
xor a
ld [hl], a ; clear status in enemy team roster