aboutsummaryrefslogtreecommitdiffstats
path: root/engine/pokemon
diff options
context:
space:
mode:
authordannye <33dannye@gmail.com>2026-01-17 22:38:33 -0600
committerdannye <33dannye@gmail.com>2026-01-17 22:38:33 -0600
commitbc2354dd6626ce28bb9561547ed2107cfa56c18e (patch)
tree5902d4c3389253c76b7c3351e0d7dfecb551c28d /engine/pokemon
parentIdentify characters in `_OakSpeechText2B` and `Printer_GetMonStats.IDNo` (#144) (diff)
parentUse macros for `WildMonEncounterSlotChances` (#562) (diff)
downloadpokeyellow-bc2354dd6626ce28bb9561547ed2107cfa56c18e.tar.gz
pokeyellow-bc2354dd6626ce28bb9561547ed2107cfa56c18e.tar.xz
pokeyellow-bc2354dd6626ce28bb9561547ed2107cfa56c18e.zip
Merge branch 'master' of https://github.com/pret/pokered
Diffstat (limited to 'engine/pokemon')
-rw-r--r--engine/pokemon/add_mon.asm39
-rw-r--r--engine/pokemon/bills_pc.asm4
-rw-r--r--engine/pokemon/evos_moves.asm10
-rw-r--r--engine/pokemon/learn_move.asm6
-rw-r--r--engine/pokemon/load_mon_data.asm8
-rw-r--r--engine/pokemon/remove_mon.asm70
-rw-r--r--engine/pokemon/set_types.asm2
-rw-r--r--engine/pokemon/status_ailments.asm30
-rw-r--r--engine/pokemon/status_screen.asm72
9 files changed, 114 insertions, 127 deletions
diff --git a/engine/pokemon/add_mon.asm b/engine/pokemon/add_mon.asm
index a0b1ef0a..24d360b2 100644
--- a/engine/pokemon/add_mon.asm
+++ b/engine/pokemon/add_mon.asm
@@ -59,7 +59,7 @@ _AddPartyMon::
.next3
ldh a, [hNewPartyLength]
dec a
- ld bc, wPartyMon2 - wPartyMon1
+ ld bc, PARTYMON_STRUCT_LENGTH
call AddNTimes
ld e, l
ld d, h
@@ -117,12 +117,12 @@ _AddPartyMon::
.next4
push bc
- ld bc, wPartyMon1DVs - wPartyMon1
+ ld bc, MON_DVS
add hl, bc
pop bc
ld [hli], a
ld [hl], b ; write IVs
- ld bc, (wPartyMon1HPExp - 1) - (wPartyMon1DVs + 1)
+ ld bc, (MON_HP_EXP - 1) - (MON_DVS + 1)
add hl, bc
ld a, 1
ld c, a
@@ -142,7 +142,7 @@ _AddPartyMon::
inc de
jr .copyMonTypesAndMoves
.copyEnemyMonData
- ld bc, wEnemyMon1DVs - wEnemyMon1
+ ld bc, MON_DVS
add hl, bc
ld a, [wEnemyMonDVs] ; copy IVs from cur enemy mon
ld [hli], a
@@ -237,13 +237,13 @@ _AddPartyMon::
dec a
jr nz, .calcFreshStats
ld hl, wEnemyMonMaxHP
- ld bc, $a
+ ld bc, NUM_STATS * 2
call CopyData ; copy stats of cur enemy mon
pop hl
jr .done
.calcFreshStats
pop hl
- ld bc, wPartyMon1HPExp - 1 - wPartyMon1
+ ld bc, MON_HP_EXP - 1
add hl, bc
ld b, $0
call CalcStats ; calculate fresh set of stats
@@ -300,7 +300,7 @@ _AddEnemyMonToPlayerParty::
ld hl, wPartyMons
ld a, [wPartyCount]
dec a
- ld bc, wPartyMon2 - wPartyMon1
+ ld bc, PARTYMON_STRUCT_LENGTH
call AddNTimes
ld e, l
ld d, h
@@ -381,16 +381,16 @@ _MoveMon::
.copySpecies
ld [hli], a ; write new mon ID
ld [hl], $ff ; write new sentinel
-.findMonDataDest
+; find mon data dest
ld a, [wMoveMonType]
dec a
ld hl, wPartyMons
- ld bc, wPartyMon2 - wPartyMon1 ; $2c
+ ld bc, PARTYMON_STRUCT_LENGTH
ld a, [wPartyCount]
jr nz, .addMonOffset
; if it's PARTY_TO_BOX
ld hl, wBoxMons
- ld bc, wBoxMon2 - wBoxMon1 ; $21
+ ld bc, BOXMON_STRUCT_LENGTH
ld a, [wBoxCount]
.addMonOffset
dec a
@@ -402,20 +402,20 @@ _MoveMon::
ld a, [wMoveMonType]
and a
ld hl, wBoxMons
- ld bc, wBoxMon2 - wBoxMon1 ; $21
+ ld bc, BOXMON_STRUCT_LENGTH
jr z, .addMonOffset2
cp DAYCARE_TO_PARTY
ld hl, wDayCareMon
jr z, .copyMonData
ld hl, wPartyMons
- ld bc, wPartyMon2 - wPartyMon1 ; $2c
+ ld bc, PARTYMON_STRUCT_LENGTH
.addMonOffset2
ld a, [wWhichPokemon]
call AddNTimes
.copyMonData
push hl
push de
- ld bc, wBoxMon2 - wBoxMon1
+ ld bc, BOXMON_STRUCT_LENGTH
call CopyData
pop de
pop hl
@@ -424,7 +424,7 @@ _MoveMon::
jr z, .findOTdest
cp DAYCARE_TO_PARTY
jr z, .findOTdest
- ld bc, wBoxMon2 - wBoxMon1
+ ld bc, BOXMON_STRUCT_LENGTH
add hl, bc
ld a, [hl] ; hl = Level
inc de
@@ -463,7 +463,7 @@ _MoveMon::
ld bc, NAME_LENGTH
call CopyData
ld a, [wMoveMonType]
-.findNickDest
+; find nick dest
cp PARTY_TO_DAYCARE
ld de, wDayCareMonName
jr z, .findNickSrc
@@ -499,6 +499,7 @@ _MoveMon::
jr z, .done
cp PARTY_TO_DAYCARE
jr z, .done
+ ; returning mon to party, compute level and stats
push hl
srl a
add $2
@@ -508,13 +509,13 @@ _MoveMon::
ld a, d
ld [wCurEnemyLevel], a
pop hl
- ld bc, wBoxMon2 - wBoxMon1
- add hl, bc
+ ld bc, BOXMON_STRUCT_LENGTH
+ add hl, bc ; hl = wPartyMon*Level
ld [hli], a
ld d, h
ld e, l
- ld bc, -18
- add hl, bc
+ ld bc, (MON_HP_EXP - 1) - MON_STATS
+ add hl, bc ; hl = wPartyMon*HPExp - 1
ld b, $1
call CalcStats
.done
diff --git a/engine/pokemon/bills_pc.asm b/engine/pokemon/bills_pc.asm
index e82b41b0..c8f24560 100644
--- a/engine/pokemon/bills_pc.asm
+++ b/engine/pokemon/bills_pc.asm
@@ -393,11 +393,11 @@ BoxNoPCText:
KnowsHMMove::
; returns whether mon with party index [wWhichPokemon] knows an HM move
ld hl, wPartyMon1Moves
- ld bc, wPartyMon2 - wPartyMon1
+ ld bc, PARTYMON_STRUCT_LENGTH
jr .next
; unreachable
ld hl, wBoxMon1Moves
- ld bc, wBoxMon2 - wBoxMon1
+ ld bc, BOXMON_STRUCT_LENGTH
.next
ld a, [wWhichPokemon]
call AddNTimes
diff --git a/engine/pokemon/evos_moves.asm b/engine/pokemon/evos_moves.asm
index 1f0d265f..f4d5039a 100644
--- a/engine/pokemon/evos_moves.asm
+++ b/engine/pokemon/evos_moves.asm
@@ -179,13 +179,13 @@ Evolution_PartyMonLoop: ; loop over party mons
call CalcStats
ld a, [wWhichPokemon]
ld hl, wPartyMon1
- ld bc, wPartyMon2 - wPartyMon1
+ ld bc, PARTYMON_STRUCT_LENGTH
call AddNTimes
ld e, l
ld d, h
push hl
push bc
- ld bc, wPartyMon1MaxHP - wPartyMon1
+ ld bc, MON_MAXHP
add hl, bc
ld a, [hli]
ld b, a
@@ -345,7 +345,7 @@ LearnMoveFromLevelUp:
; If it is not 0, this function will not work properly.
ld hl, wPartyMon1Moves
ld a, [wWhichPokemon]
- ld bc, wPartyMon2 - wPartyMon1
+ ld bc, PARTYMON_STRUCT_LENGTH
call AddNTimes
.next
ld b, NUM_MOVES
@@ -559,7 +559,7 @@ WriteMonMoves:
; shift PP as well if learning moves from day care
push de
- ld bc, wPartyMon1PP - (wPartyMon1Moves + 3)
+ ld bc, MON_PP - (MON_MOVES + 3)
add hl, bc
ld d, h
ld e, l
@@ -578,7 +578,7 @@ WriteMonMoves:
; write move PP value if learning moves from day care
push hl
ld a, [hl]
- ld hl, wPartyMon1PP - wPartyMon1Moves
+ ld hl, MON_PP - MON_MOVES
add hl, de
push hl
dec a
diff --git a/engine/pokemon/learn_move.asm b/engine/pokemon/learn_move.asm
index e40b3573..7843cc59 100644
--- a/engine/pokemon/learn_move.asm
+++ b/engine/pokemon/learn_move.asm
@@ -10,7 +10,7 @@ LearnMove:
DontAbandonLearning:
ld hl, wPartyMon1Moves
- ld bc, wPartyMon2Moves - wPartyMon1Moves
+ ld bc, PARTYMON_STRUCT_LENGTH
ld a, [wWhichPokemon]
call AddNTimes
ld d, h
@@ -38,7 +38,7 @@ DontAbandonLearning:
.next
ld a, [wMoveNum]
ld [hl], a
- ld bc, wPartyMon1PP - wPartyMon1Moves
+ ld bc, MON_PP - MON_MOVES
add hl, bc
push hl
push de
@@ -66,7 +66,7 @@ DontAbandonLearning:
ld de, wBattleMonMoves
ld bc, NUM_MOVES
call CopyData
- ld bc, wPartyMon1PP - wPartyMon1OTID
+ ld bc, MON_PP - MON_OTID
add hl, bc
ld de, wBattleMonPP
ld bc, NUM_MOVES
diff --git a/engine/pokemon/load_mon_data.asm b/engine/pokemon/load_mon_data.asm
index 964db2e4..e46dc2db 100644
--- a/engine/pokemon/load_mon_data.asm
+++ b/engine/pokemon/load_mon_data.asm
@@ -23,7 +23,7 @@ LoadMonData_::
call GetMonHeader
ld hl, wPartyMons
- ld bc, wPartyMon2 - wPartyMon1
+ ld bc, PARTYMON_STRUCT_LENGTH
ld a, [wMonDataLocation]
cp ENEMY_PARTY_DATA
jr c, .getMonEntry
@@ -31,9 +31,9 @@ LoadMonData_::
ld hl, wEnemyMons
jr z, .getMonEntry
- cp 2
+ cp BOX_DATA
ld hl, wBoxMons
- ld bc, wBoxMon2 - wBoxMon1
+ ld bc, BOXMON_STRUCT_LENGTH
jr z, .getMonEntry
ld hl, wDayCareMon
@@ -45,7 +45,7 @@ LoadMonData_::
.copyMonData
ld de, wLoadedMon
- ld bc, wPartyMon2 - wPartyMon1
+ ld bc, PARTYMON_STRUCT_LENGTH
jp CopyData
; get species of mon e in list [wMonDataLocation] for LoadMonData
diff --git a/engine/pokemon/remove_mon.asm b/engine/pokemon/remove_mon.asm
index 60ec8c27..ee47f0c8 100644
--- a/engine/pokemon/remove_mon.asm
+++ b/engine/pokemon/remove_mon.asm
@@ -2,15 +2,16 @@ _RemovePokemon::
ld hl, wPartyCount
ld a, [wRemoveMonFromBox]
and a
- jr z, .usePartyCount
+ jr z, .gotCount
ld hl, wBoxCount
-.usePartyCount
+.gotCount
ld a, [hl]
dec a
ld [hli], a
+
ld a, [wWhichPokemon]
ld c, a
- ld b, $0
+ ld b, 0
add hl, bc
ld e, l
ld d, h
@@ -21,21 +22,27 @@ _RemovePokemon::
ld [hli], a
inc a ; reached terminator?
jr nz, .shiftMonSpeciesLoop ; if not, continue shifting species
+
ld hl, wPartyMonOT
ld d, PARTY_LENGTH - 1 ; max number of pokemon to shift
ld a, [wRemoveMonFromBox]
and a
- jr z, .usePartyMonOTs
+ jr z, .gotOTsPointer
ld hl, wBoxMonOT
ld d, MONS_PER_BOX - 1
-.usePartyMonOTs
+.gotOTsPointer
ld a, [wWhichPokemon]
call SkipFixedLengthTextEntries
ld a, [wWhichPokemon]
cp d ; are we removing the last pokemon?
jr nz, .notRemovingLastMon ; if not, shift the pokemon below
- ld [hl], $ff ; else, write the terminator and return
+
+ ; bug: to erase a string, this should be ld [hl], '@'
+ ; This is not needed, as wBoxSpecies/wPartySpecies determine if a slot is used.
+ ; Besides, existing mon nick is left untouched
+ ld [hl], $ff
ret
+
.notRemovingLastMon
ld d, h
ld e, l
@@ -44,44 +51,49 @@ _RemovePokemon::
ld bc, wPartyMonNicks
ld a, [wRemoveMonFromBox]
and a
- jr z, .usePartyMonNicks
+ jr z, .gotNicksPointer
ld bc, wBoxMonNicks
-.usePartyMonNicks
+.gotNicksPointer
call CopyDataUntil
+
ld hl, wPartyMons
- ld bc, wPartyMon2 - wPartyMon1
+ ld bc, PARTYMON_STRUCT_LENGTH
ld a, [wRemoveMonFromBox]
and a
- jr z, .usePartyMonStructs
+ jr z, .gotMonStructs
ld hl, wBoxMons
- ld bc, wBoxMon2 - wBoxMon1
-.usePartyMonStructs
+ ld bc, BOXMON_STRUCT_LENGTH
+.gotMonStructs
ld a, [wWhichPokemon]
call AddNTimes ; get address of the pokemon removed
- ld d, h ; store in de for CopyDataUntil
+
+ ld d, h ; de = start address for CopyDataUntil
ld e, l
ld a, [wRemoveMonFromBox]
and a
- jr z, .copyUntilPartyMonOTs
- ld bc, wBoxMon2 - wBoxMon1
- add hl, bc ; get address of pokemon after the pokemon removed
- ld bc, wBoxMonOT ; address of when to stop copying
- jr .continue
-.copyUntilPartyMonOTs
- ld bc, wPartyMon2 - wPartyMon1
- add hl, bc ; get address of pokemon after the pokemon removed
- ld bc, wPartyMonOT ; address of when to stop copying
-.continue
- call CopyDataUntil ; shift all pokemon data after the removed mon to the removed mon's location
+ jr z, .copyUntilPartyMonOT
+; copy until wBoxMonOT
+ ld bc, BOXMON_STRUCT_LENGTH
+ add hl, bc ; get address of next slot
+ ld bc, wBoxMonOT
+ jr .shiftOTs
+.copyUntilPartyMonOT
+ ld bc, PARTYMON_STRUCT_LENGTH
+ add hl, bc ; get address of next slot
+ ld bc, wPartyMonOT
+.shiftOTs
+ call CopyDataUntil ; shift all pokemon data up one slot
+
ld hl, wPartyMonNicks
ld a, [wRemoveMonFromBox]
and a
- jr z, .usePartyMonNicks2
+ jr z, .gotNicksPointer2
ld hl, wBoxMonNicks
-.usePartyMonNicks2
+.gotNicksPointer2
ld bc, NAME_LENGTH
ld a, [wWhichPokemon]
call AddNTimes
+
ld d, h
ld e, l
ld bc, NAME_LENGTH
@@ -89,7 +101,7 @@ _RemovePokemon::
ld bc, wPartyMonNicksEnd
ld a, [wRemoveMonFromBox]
and a
- jr z, .copyUntilPartyMonNicksEnd
+ jr z, .shiftMonNicks
ld bc, wBoxMonNicksEnd
-.copyUntilPartyMonNicksEnd
- jp CopyDataUntil
+.shiftMonNicks
+ jp CopyDataUntil ; shift all pokemon nicknames up one slot
diff --git a/engine/pokemon/set_types.asm b/engine/pokemon/set_types.asm
index 2cf8f14c..d42c3cf3 100644
--- a/engine/pokemon/set_types.asm
+++ b/engine/pokemon/set_types.asm
@@ -1,7 +1,7 @@
; updates the types of a party mon (pointed to in hl) to the ones of the mon specified in [wPokedexNum]
SetPartyMonTypes:
call GetPredefRegisters
- ld bc, wPartyMon1Type - wPartyMon1 ; $5
+ ld bc, MON_TYPE
add hl, bc
ld a, [wPokedexNum]
ld [wCurSpecies], a
diff --git a/engine/pokemon/status_ailments.asm b/engine/pokemon/status_ailments.asm
index 2c5b3bcd..3cc2d490 100644
--- a/engine/pokemon/status_ailments.asm
+++ b/engine/pokemon/status_ailments.asm
@@ -10,37 +10,17 @@ PrintStatusAilment::
jr nz, .par
and SLP_MASK
ret z
- ld a, 'S'
- ld [hli], a
- ld a, 'L'
- ld [hli], a
- ld [hl], 'P'
+ ld_hli_a_string "SLP"
ret
.psn
- ld a, 'P'
- ld [hli], a
- ld a, 'S'
- ld [hli], a
- ld [hl], 'N'
+ ld_hli_a_string "PSN"
ret
.brn
- ld a, 'B'
- ld [hli], a
- ld a, 'R'
- ld [hli], a
- ld [hl], 'N'
+ ld_hli_a_string "BRN"
ret
.frz
- ld a, 'F'
- ld [hli], a
- ld a, 'R'
- ld [hli], a
- ld [hl], 'Z'
+ ld_hli_a_string "FRZ"
ret
.par
- ld a, 'P'
- ld [hli], a
- ld a, 'A'
- ld [hli], a
- ld [hl], 'R'
+ ld_hli_a_string "PAR"
ret
diff --git a/engine/pokemon/status_screen.asm b/engine/pokemon/status_screen.asm
index 638f4c41..7e8ad615 100644
--- a/engine/pokemon/status_screen.asm
+++ b/engine/pokemon/status_screen.asm
@@ -61,8 +61,6 @@ DrawHP_:
pop de
ret
-
-; Predef 0x37
StatusScreen:
call LoadMonData
ld a, [wMonDataLocation]
@@ -75,7 +73,7 @@ StatusScreen:
ld hl, wLoadedMonHPExp - 1
ld de, wLoadedMonStats
ld b, $1
- call CalcStats ; Recalculate stats
+ call CalcStats
.DontRecalculate
ld hl, wStatusFlags2
set BIT_NO_AUDIO_FADE_OUT, [hl]
@@ -117,8 +115,8 @@ StatusScreen:
lb bc, 8, 6
call DrawLineBox ; Draws the box around types, ID No. and OT
hlcoord 10, 9
- ld de, Type1Text
- call PlaceString ; "TYPE1/"
+ ld de, TypesIDNoOTText
+ call PlaceString
hlcoord 11, 3
predef DrawHP
ld hl, wStatusScreenHPBarColor
@@ -137,7 +135,7 @@ StatusScreen:
ld de, StatusText
call PlaceString ; "STATUS/"
hlcoord 14, 2
- call PrintLevel ; Pokémon level
+ call PrintLevel
ld a, [wMonHIndex]
ld [wPokedexNum], a
ld [wCurSpecies], a
@@ -164,7 +162,7 @@ StatusScreen:
ld de, wLoadedMonOTID
lb bc, LEADING_ZEROES | 2, 5
call PrintNumber ; ID Number
- ld d, $0
+ ld d, STATUS_SCREEN_STATS_BOX
call PrintStatsBox
call Delay3
call GBPalNormal
@@ -221,20 +219,11 @@ NamePointers2:
dw wBoxMonNicks
dw wDayCareMonName
-Type1Text:
+TypesIDNoOTText:
db "TYPE1/"
- next ""
- ; fallthrough
-Type2Text:
- db "TYPE2/"
- next ""
- ; fallthrough
-IDNoText:
- db "<ID>№/"
- next ""
- ; fallthrough
-OTText:
- db "OT/"
+ next "TYPE2/"
+ next "<ID>№/"
+ next "OT/"
next "@"
StatusText:
@@ -265,38 +254,40 @@ PTile: INCBIN "gfx/font/P.1bpp"
PrintStatsBox:
ld a, d
- and a ; a is 0 from the status screen
- jr nz, .DifferentBox
+ ASSERT STATUS_SCREEN_STATS_BOX == 0
+ and a
+ jr nz, .LevelUpStatsBox ; battle or Rare Candy
hlcoord 0, 8
lb bc, 8, 8
- call TextBoxBorder ; Draws the box
- hlcoord 1, 9 ; Start printing stats from here
- ld bc, $19 ; Number offset
+ call TextBoxBorder
+ hlcoord 1, 9
+ ld bc, SCREEN_WIDTH + 5 ; one row down and 5 columns right
jr .PrintStats
-.DifferentBox
+.LevelUpStatsBox
hlcoord 9, 2
lb bc, 8, 9
call TextBoxBorder
hlcoord 11, 3
- ld bc, $18
+ ld bc, SCREEN_WIDTH + 4 ; one row down and 4 columns right
.PrintStats
push bc
push hl
- ld de, StatsText
+ ld de, .StatsText
call PlaceString
pop hl
pop bc
add hl, bc
ld de, wLoadedMonAttack
lb bc, 2, 3
- call PrintStat
+ call .PrintStat
ld de, wLoadedMonDefense
- call PrintStat
+ call .PrintStat
ld de, wLoadedMonSpeed
- call PrintStat
+ call .PrintStat
ld de, wLoadedMonSpecial
jp PrintNumber
-PrintStat:
+
+.PrintStat:
push hl
call PrintNumber
pop hl
@@ -304,7 +295,7 @@ PrintStat:
add hl, de
ret
-StatsText:
+.StatsText:
db "ATTACK"
next "DEFENSE"
next "SPEED"
@@ -337,10 +328,10 @@ StatusScreen2:
call PlaceString ; Print moves
ld a, [wNumMovesMinusOne]
inc a
- ld c, a
- ld a, $4
+ ld c, a ; number of known moves
+ ld a, NUM_MOVES
sub c
- ld b, a ; Number of moves ?
+ ld b, a ; number of blank moves
hlcoord 11, 10
ld de, SCREEN_WIDTH * 2
ld a, '<BOLD_P>'
@@ -375,7 +366,7 @@ StatusScreen2:
pop de
pop hl
push hl
- ld bc, wPartyMon1PP - wPartyMon1Moves - 1
+ ld bc, MON_PP - MON_MOVES - 1
add hl, bc
ld a, [hl]
and PP_MASK
@@ -400,7 +391,7 @@ StatusScreen2:
pop bc
inc b
ld a, b
- cp $4
+ cp NUM_MOVES
jr nz, .PrintPP
.PPDone
hlcoord 9, 3
@@ -429,8 +420,11 @@ StatusScreen2:
hlcoord 7, 6
lb bc, 3, 7
call PrintNumber ; exp needed to level up
+
+ ; unneeded, this clears the diacritic characters in JPN versions
hlcoord 9, 0
call StatusScreen_ClearName
+
hlcoord 9, 1
call StatusScreen_ClearName
ld a, [wMonHIndex]
@@ -482,7 +476,7 @@ StatusScreenExpText:
next "LEVEL UP@"
StatusScreen_ClearName:
- ld bc, 10
+ ld bc, NAME_LENGTH - 1
ld a, ' '
jp FillMemory