aboutsummaryrefslogtreecommitdiffstats
path: root/engine/items
diff options
context:
space:
mode:
Diffstat (limited to 'engine/items')
-rw-r--r--engine/items/inventory.asm1
-rw-r--r--engine/items/item_effects.asm168
-rw-r--r--engine/items/tmhm.asm2
-rw-r--r--engine/items/town_map.asm14
4 files changed, 98 insertions, 87 deletions
diff --git a/engine/items/inventory.asm b/engine/items/inventory.asm
index 758c81d7..caa9dd22 100644
--- a/engine/items/inventory.asm
+++ b/engine/items/inventory.asm
@@ -119,7 +119,6 @@ RemoveItemFromInventory_::
jr nz, .skipMovingUpSlots
; if the remaining quantity is 0,
; remove the emptied item slot and move up all the following item slots
-.moveSlotsUp
ld e, l
ld d, h
inc de
diff --git a/engine/items/item_effects.asm b/engine/items/item_effects.asm
index 31684719..0cbb0c48 100644
--- a/engine/items/item_effects.asm
+++ b/engine/items/item_effects.asm
@@ -669,7 +669,7 @@ ItemUseBicycle:
jp z, ItemUseNotTime
dec a ; is player already bicycling?
jr nz, .tryToGetOnBike
-.getOffBike
+; get off bike
call ItemUseReloadOverworldData
xor a
ld [wWalkBikeSurfState], a ; change player state to walking
@@ -702,13 +702,13 @@ ItemUseSurfboard:
ld [wWalkBikeSurfStateCopy], a
cp 2 ; is the player already surfing?
jr z, .tryToStopSurfing
-.tryToSurf
+; try to Surf
call IsNextTileShoreOrWater
jp nc, SurfingAttemptFailed
ld hl, TilePairCollisionsWater
call CheckForTilePairCollisions
jp c, SurfingAttemptFailed
-.surf
+; surfing
call .makePlayerMoveForward
ld hl, wStatusFlags5
set BIT_SCRIPTED_MOVEMENT_STATE, [hl]
@@ -923,7 +923,7 @@ ItemUseMedicine:
.getPartyMonDataAddress
jp c, .canceledItemUse
ld hl, wPartyMons
- ld bc, wPartyMon2 - wPartyMon1
+ ld bc, PARTYMON_STRUCT_LENGTH
ld a, [wWhichPokemon]
call AddNTimes
ld a, [wWhichPokemon]
@@ -965,7 +965,7 @@ ItemUseMedicine:
jr nc, .healHP ; if it's a Full Restore or one of the potions
; fall through if it's one of the status-specific healing items
.cureStatusAilment
- ld bc, wPartyMon1Status - wPartyMon1
+ ld bc, MON_STATUS
add hl, bc ; hl now points to status
ld a, [wCurItem]
lb bc, ANTIDOTE_MSG, 1 << PSN
@@ -1003,7 +1003,7 @@ ItemUseMedicine:
ld hl, wPlayerBattleStatus3
res BADLY_POISONED, [hl] ; heal Toxic status
pop hl
- ld bc, wPartyMon1Stats - wPartyMon1Status
+ ld bc, MON_STATS - MON_STATUS
add hl, bc ; hl now points to party stats
ld de, wBattleMonStats
ld bc, NUM_STATS * 2
@@ -1021,7 +1021,7 @@ ItemUseMedicine:
ld [wHPBarOldHP], a ; current HP stored at wHPBarOldHP (2 bytes, big-endian)
or b
jr nz, .notFainted
-.fainted
+; fainted
ld a, [wCurItem]
cp REVIVE
jr z, .updateInBattleFaintedData
@@ -1078,7 +1078,7 @@ ItemUseMedicine:
.compareCurrentHPToMaxHP
push hl
push bc
- ld bc, wPartyMon1MaxHP - (wPartyMon1HP + 1)
+ ld bc, MON_MAXHP - (MON_HP + 1)
add hl, bc ; hl now points to max HP
pop bc
ld a, [hli]
@@ -1089,7 +1089,7 @@ ItemUseMedicine:
.skipComparingLSB
pop hl
jr nz, .notFullHP
-.fullHP ; if the pokemon's current HP equals its max HP
+; if the pokemon's current HP equals its max HP
ld a, [wCurItem]
cp FULL_RESTORE
jp nz, .healingItemNoEffect
@@ -1111,7 +1111,7 @@ ItemUseMedicine:
ld [wChannelSoundIDs + CHAN5], a
push hl
push de
- ld bc, wPartyMon1MaxHP - (wPartyMon1HP + 1)
+ ld bc, MON_MAXHP - (MON_HP + 1)
add hl, bc ; hl now points to max HP
ld a, [hli]
ld [wHPBarMaxHP+1], a
@@ -1132,7 +1132,7 @@ ItemUseMedicine:
push af
ld hl, wPartyMon1MaxHP
ld a, [wWhichPokemon]
- ld bc, wPartyMon2 - wPartyMon1
+ ld bc, PARTYMON_STRUCT_LENGTH
call AddNTimes
ld a, [hli]
ld [wHPBarMaxHP + 1], a
@@ -1144,7 +1144,7 @@ ItemUseMedicine:
ldh [hDivisor], a
ld b, 2 ; number of bytes
call Divide ; get 1/5 of max HP of pokemon that used Softboiled
- ld bc, (wPartyMon1HP + 1) - (wPartyMon1MaxHP + 1)
+ ld bc, (MON_HP + 1) - (MON_MAXHP + 1)
add hl, bc ; hl now points to LSB of current HP of pokemon that used Softboiled
; subtract 1/5 of max HP from current HP of pokemon that used Softboiled
ldh a, [hQuotient + 3]
@@ -1224,7 +1224,7 @@ ItemUseMedicine:
inc hl
ld d, h
ld e, l ; de now points to current HP
- ld hl, (wPartyMon1MaxHP + 1) - (wPartyMon1HP + 1)
+ ld hl, (MON_MAXHP + 1) - (MON_HP + 1)
add hl, de ; hl now points to max HP
ld a, [wCurItem]
cp REVIVE
@@ -1273,7 +1273,7 @@ ItemUseMedicine:
ld a, [wCurItem]
cp FULL_RESTORE
jr nz, .updateInBattleData
- ld bc, wPartyMon1Status - (wPartyMon1MaxHP + 1)
+ ld bc, MON_STATUS - (MON_MAXHP + 1)
add hl, bc
xor a
ld [hl], a ; remove the status ailment in the party data
@@ -1381,7 +1381,7 @@ ItemUseMedicine:
ld a, [hl]
ld [wCurSpecies], a
ld [wPokedexNum], a
- ld bc, wPartyMon1Level - wPartyMon1
+ ld bc, MON_LEVEL
add hl, bc ; hl now points to level
ld a, [hl] ; a = level
ld [wCurEnemyLevel], a ; store level
@@ -1398,7 +1398,7 @@ ItemUseMedicine:
push hl
sub HP_UP
add a
- ld bc, wPartyMon1HPExp - wPartyMon1
+ ld bc, MON_HP_EXP
add hl, bc
add l
ld l, a
@@ -1427,14 +1427,14 @@ ItemUseMedicine:
.statNameInnerLoop
ld a, [hli]
ld b, a
- ld a, $50
+ ld a, '@'
cp b
jr nz, .statNameInnerLoop
jr .statNameLoop
.gotStatName
ld de, wStringBuffer
- ld bc, 10
+ ld bc, STAT_NAME_LENGTH
call CopyData ; copy the stat's name to wStringBuffer
ld a, SFX_HEAL_AILMENT
call PlaySound
@@ -1449,17 +1449,17 @@ ItemUseMedicine:
jp GBPalWhiteOut
.recalculateStats
- ld bc, wPartyMon1Stats - wPartyMon1
+ ld bc, MON_STATS
add hl, bc
ld d, h
ld e, l ; de now points to stats
- ld bc, (wPartyMon1Exp + 2) - wPartyMon1Stats
+ ld bc, (MON_EXP + 2) - MON_STATS
add hl, bc ; hl now points to LSB of experience
ld b, 1
jp CalcStats ; recalculate stats
.useRareCandy
push hl
- ld bc, wPartyMon1Level - wPartyMon1
+ ld bc, MON_LEVEL
add hl, bc ; hl now points to level
ld a, [hl] ; a = level
cp MAX_LEVEL
@@ -1473,7 +1473,7 @@ ItemUseMedicine:
callfar CalcExperience ; calculate experience for next level and store it at hExperience
pop de
pop hl
- ld bc, wPartyMon1Exp - wPartyMon1Level
+ ld bc, MON_EXP - MON_LEVEL
add hl, bc ; hl now points to MSB of experience
; update experience to minimum for new level
ldh a, [hExperience]
@@ -1489,7 +1489,7 @@ ItemUseMedicine:
push af
push de
push hl
- ld bc, wPartyMon1MaxHP - wPartyMon1
+ ld bc, MON_MAXHP
add hl, bc ; hl now points to MSB of max HP
ld a, [hli]
ld b, a
@@ -1499,7 +1499,7 @@ ItemUseMedicine:
push hl
call .recalculateStats
pop hl
- ld bc, (wPartyMon1MaxHP + 1) - wPartyMon1
+ ld bc, (MON_MAXHP + 1)
add hl, bc ; hl now points to LSB of max HP
pop bc
ld a, [hld]
@@ -1509,7 +1509,7 @@ ItemUseMedicine:
sbc b
ld b, a ; bc = the amount of max HP gained from leveling up
; add the amount gained to the current HP
- ld de, (wPartyMon1HP + 1) - wPartyMon1MaxHP
+ ld de, (MON_HP + 1) - MON_MAXHP
add hl, de ; hl now points to LSB of current HP
ld a, [hl]
add c
@@ -1528,12 +1528,12 @@ ItemUseMedicine:
xor a ; PLAYER_PARTY_DATA
ld [wMonDataLocation], a
call LoadMonData
- ld d, $01
- callfar PrintStatsBox ; display new stats text box
- call WaitForTextScrollButtonPress ; wait for button press
+ ld d, LEVEL_UP_STATS_BOX
+ callfar PrintStatsBox
+ call WaitForTextScrollButtonPress
xor a ; PLAYER_PARTY_DATA
ld [wMonDataLocation], a
- predef LearnMoveFromLevelUp ; learn level up move, if any
+ predef LearnMoveFromLevelUp
xor a
ld [wForceEvolution], a
@@ -1542,7 +1542,7 @@ ItemUseMedicine:
push af
ld a, [wUsedItemOnWhichPokemon]
ld [wWhichPokemon], a
- callfar RespawnOverworldPikachu ; evolve pokemon, if appropriate
+ callfar RespawnOverworldPikachu
pop af
ld [wWhichPokemon], a
@@ -1571,11 +1571,11 @@ INCLUDE "data/battle/stat_names.asm"
ItemUseBait:
ld hl, ThrewBaitText
call PrintText
- ld hl, wEnemyMonActualCatchRate ; catch rate
+ ld hl, wEnemyMonActualCatchRate
srl [hl] ; halve catch rate
ld a, BAIT_ANIM
- ld hl, wSafariBaitFactor ; bait factor
- ld de, wSafariEscapeFactor ; escape factor
+ ld hl, wSafariBaitFactor
+ ld de, wSafariEscapeFactor
jr BaitRockCommon
; for CASCADEBADGE when used from the
@@ -1584,7 +1584,7 @@ ItemUseBait:
ItemUseRock:
ld hl, ThrewRockText
call PrintText
- ld hl, wEnemyMonActualCatchRate ; catch rate
+ ld hl, wEnemyMonActualCatchRate
ld a, [hl]
add a ; double catch rate
jr nc, .noCarry
@@ -1592,8 +1592,8 @@ ItemUseRock:
.noCarry
ld [hl], a
ld a, ROCK_ANIM
- ld hl, wSafariEscapeFactor ; escape factor
- ld de, wSafariBaitFactor ; bait factor
+ ld hl, wSafariEscapeFactor
+ ld de, wSafariBaitFactor
BaitRockCommon:
ld [wAnimationID], a
@@ -1954,8 +1954,8 @@ ItemUsePokeFlute:
; OUTPUT:
; [wWereAnyMonsAsleep]: set to 1 if any pokemon were asleep
WakeUpEntireParty:
- ld de, 44
- ld c, 6
+ ld de, PARTYMON_STRUCT_LENGTH
+ ld c, PARTY_LENGTH
.loop
ld a, [hl]
push af
@@ -2221,7 +2221,7 @@ ItemUsePPRestore:
ld [wPlayerMoveListIndex], a
jr nz, .chooseMon
ld hl, wPartyMon1Moves
- ld bc, wPartyMon2 - wPartyMon1
+ ld bc, PARTYMON_STRUCT_LENGTH
call GetSelectedMoveOffset
push hl
ld a, [hl]
@@ -2232,8 +2232,8 @@ ItemUsePPRestore:
ld a, [wPPRestoreItem]
cp ETHER
jr nc, .useEther ; if Ether or Max Ether
-.usePPUp
- ld bc, wPartyMon1PP - wPartyMon1Moves
+; use PP Up
+ ld bc, MON_PP - MON_MOVES
add hl, bc
ld a, [hl] ; move PP
cp 3 << 6 ; have 3 PP Ups already been used?
@@ -2267,10 +2267,10 @@ ItemUsePPRestore:
cp b ; is the pokemon whose PP was restored active in battle?
jr nz, .skipUpdatingInBattleData
ld hl, wPartyMon1PP
- ld bc, wPartyMon2 - wPartyMon1
+ ld bc, PARTYMON_STRUCT_LENGTH
call AddNTimes
ld de, wBattleMonPP
- ld bc, 4
+ ld bc, NUM_MOVES
call CopyData ; copy party data to in-battle data
.skipUpdatingInBattleData
ld a, SFX_HEAL_AILMENT
@@ -2291,9 +2291,9 @@ ItemUsePPRestore:
ld [wMonDataLocation], a
call GetMaxPP
ld hl, wPartyMon1Moves
- ld bc, wPartyMon2 - wPartyMon1
+ ld bc, PARTYMON_STRUCT_LENGTH
call GetSelectedMoveOffset
- ld bc, wPartyMon1PP - wPartyMon1Moves
+ ld bc, MON_PP - MON_MOVES
add hl, bc ; hl now points to move's PP
ld a, [wMaxPP]
ld b, a
@@ -2343,7 +2343,7 @@ ItemUsePPRestore:
.elixirLoop
push bc
ld hl, wPartyMon1Moves
- ld bc, wPartyMon2 - wPartyMon1
+ ld bc, PARTYMON_STRUCT_LENGTH
call GetSelectedMoveOffset
ld a, [hl]
and a ; does the current slot have a move?
@@ -2441,7 +2441,7 @@ ItemUseTMHM:
.chooseMon
ld hl, wStringBuffer
ld de, wTempMoveNameBuffer
- ld bc, ITEM_NAME_LENGTH + 1
+ ld bc, MOVE_NAME_LENGTH
call CopyData ; save the move name because DisplayPartyMenu will overwrite it
ld a, $ff
ld [wUpdateSpritesEnabled], a
@@ -2451,7 +2451,7 @@ ItemUseTMHM:
push af
ld hl, wTempMoveNameBuffer
ld de, wStringBuffer
- ld bc, ITEM_NAME_LENGTH + 1
+ ld bc, MOVE_NAME_LENGTH
call CopyData
pop af
jr nc, .checkIfAbleToLearnMove
@@ -2656,14 +2656,14 @@ GotOffBicycleText:
; [wCurrentMenuItem] = index of move (when using a PP Up)
RestoreBonusPP:
ld hl, wPartyMon1Moves
- ld bc, wPartyMon2 - wPartyMon1
+ ld bc, PARTYMON_STRUCT_LENGTH
ld a, [wWhichPokemon]
call AddNTimes
push hl
ld de, wNormalMaxPPList - 1
predef LoadMovePPs ; loads the normal max PP of each of the pokemon's moves to wNormalMaxPPList
pop hl
- ld c, wPartyMon1PP - wPartyMon1Moves
+ ld c, MON_PP - MON_MOVES
ld b, 0
add hl, bc ; hl now points to move 1 PP
ld de, wNormalMaxPPList
@@ -2749,13 +2749,13 @@ GetMaxPP:
ld a, [wMonDataLocation]
and a
ld hl, wPartyMon1Moves
- ld bc, wPartyMon2 - wPartyMon1
+ ld bc, PARTYMON_STRUCT_LENGTH
jr z, .sourceWithMultipleMon
ld hl, wEnemyMon1Moves
dec a
jr z, .sourceWithMultipleMon
ld hl, wBoxMon1Moves
- ld bc, wBoxMon2 - wBoxMon1
+ ld bc, BOXMON_STRUCT_LENGTH
dec a
jr z, .sourceWithMultipleMon
ld hl, wDayCareMonMoves
@@ -2783,7 +2783,7 @@ GetMaxPP:
ld b, a ; b = normal max PP
pop hl
push bc
- ld bc, wPartyMon1PP - wPartyMon1Moves ; PP offset if not player's in-battle pokemon data
+ ld bc, MON_PP - MON_MOVES ; PP offset if not player's in-battle pokemon data
ld a, [wMonDataLocation]
cp 4 ; player's in-battle pokemon?
jr nz, .addPPOffset
@@ -2928,29 +2928,33 @@ IsKeyItem_::
INCLUDE "data/items/key_items.asm"
+; store the new mon in the first slot, shifting all existing box data down
SendNewMonToBox:
ld de, wBoxCount
ld a, [de]
inc a
ld [de], a
+
ld a, [wCurPartySpecies]
ld [wCurSpecies], a
ld c, a
-.loop
+.shiftSpeciesLoop
inc de
ld a, [de]
ld b, a
ld a, c
ld c, b
ld [de], a
- cp $ff
- jr nz, .loop
+ cp -1
+ jr nz, .shiftSpeciesLoop
+
call GetMonHeader
ld hl, wBoxMonOT
ld bc, NAME_LENGTH
ld a, [wBoxCount]
dec a
- jr z, .skip
+ jr z, .skipOTshift ; if the box was empty, there is nothing to shift
+
dec a
call AddNTimes
push hl
@@ -2962,7 +2966,7 @@ SendNewMonToBox:
ld a, [wBoxCount]
dec a
ld b, a
-.loop2
+.shiftMonOTLoop
push bc
push hl
ld bc, NAME_LENGTH
@@ -2974,15 +2978,18 @@ SendNewMonToBox:
add hl, bc
pop bc
dec b
- jr nz, .loop2
-.skip
+ jr nz, .shiftMonOTLoop
+
+.skipOTshift
ld hl, wPlayerName
- ld de, wBoxMonOT
+ ld de, wBoxMon1OT
ld bc, NAME_LENGTH
call CopyData
+
ld a, [wBoxCount]
dec a
- jr z, .skip2
+ jr z, .skipNickShift
+
ld hl, wBoxMonNicks
ld bc, NAME_LENGTH
dec a
@@ -2996,7 +3003,7 @@ SendNewMonToBox:
ld a, [wBoxCount]
dec a
ld b, a
-.loop3
+.shiftNickLoop
push bc
push hl
ld bc, NAME_LENGTH
@@ -3008,21 +3015,24 @@ SendNewMonToBox:
add hl, bc
pop bc
dec b
- jr nz, .loop3
-.skip2
- ld hl, wBoxMonNicks
+ jr nz, .shiftNickLoop
+
+.skipNickShift
+ ld hl, wBoxMon1Nick
ld a, NAME_MON_SCREEN
ld [wNamingScreenType], a
predef AskName
+
ld a, [wBoxCount]
dec a
- jr z, .skip3
+ jr z, .skipMonDataShift
+
ld hl, wBoxMons
- ld bc, wBoxMon2 - wBoxMon1
+ ld bc, BOXMON_STRUCT_LENGTH
dec a
call AddNTimes
push hl
- ld bc, wBoxMon2 - wBoxMon1
+ ld bc, BOXMON_STRUCT_LENGTH
add hl, bc
ld d, h
ld e, l
@@ -3030,20 +3040,21 @@ SendNewMonToBox:
ld a, [wBoxCount]
dec a
ld b, a
-.loop4
+.shiftMonDataLoop
push bc
push hl
- ld bc, wBoxMon2 - wBoxMon1
+ ld bc, BOXMON_STRUCT_LENGTH
call CopyData
pop hl
ld d, h
ld e, l
- ld bc, wBoxMon1 - wBoxMon2
+ ld bc, -BOXMON_STRUCT_LENGTH
add hl, bc
pop bc
dec b
- jr nz, .loop4
-.skip3
+ jr nz, .shiftMonDataLoop
+
+.skipMonDataShift
ld a, [wEnemyMonLevel]
ld [wEnemyMonBoxLevel], a
ld hl, wEnemyMon
@@ -3073,11 +3084,12 @@ SendNewMonToBox:
inc de
xor a
ld b, NUM_STATS * 2
-.loop5
+.statLoop
ld [de], a
inc de
dec b
- jr nz, .loop5
+ jr nz, .statLoop
+
ld hl, wEnemyMonDVs
ld a, [hli]
ld [de], a
@@ -3086,12 +3098,12 @@ SendNewMonToBox:
ld [de], a
ld hl, wEnemyMonPP
ld b, NUM_MOVES
-.loop6
+.movePPLoop
ld a, [hli]
inc de
ld [de], a
dec b
- jr nz, .loop6
+ jr nz, .movePPLoop
ld a, [wCurPartySpecies]
cp KADABRA
jr nz, .notKadabra
diff --git a/engine/items/tmhm.asm b/engine/items/tmhm.asm
index a11cd736..bac92f5d 100644
--- a/engine/items/tmhm.asm
+++ b/engine/items/tmhm.asm
@@ -2,7 +2,7 @@
CheckIfMoveIsKnown:
ld a, [wWhichPokemon]
ld hl, wPartyMon1Moves
- ld bc, wPartyMon2 - wPartyMon1
+ ld bc, PARTYMON_STRUCT_LENGTH
call AddNTimes
ld a, [wMoveNum]
ld b, a
diff --git a/engine/items/town_map.asm b/engine/items/town_map.asm
index a7093cfc..fe274579 100644
--- a/engine/items/town_map.asm
+++ b/engine/items/town_map.asm
@@ -20,11 +20,11 @@ DisplayTownMap:
call PlaceString
ld hl, wShadowOAMSprite00
ld de, wShadowOAMBackupSprite00
- ld bc, 4 * 4
+ ld bc, OBJ_SIZE * 4
call CopyData
ld hl, vSprites tile BIRD_BASE_TILE
ld de, TownMapCursor
- lb bc, BANK(TownMapCursor), (TownMapCursorEnd - TownMapCursor) / $8
+ lb bc, BANK(TownMapCursor), (TownMapCursorEnd - TownMapCursor) / TILE_1BPP_SIZE
call CopyVideoDataDouble
xor a
ld [wWhichTownMapLocation], a
@@ -64,7 +64,7 @@ DisplayTownMap:
call PlaceString
ld hl, wShadowOAMSprite04
ld de, wShadowOAMBackupSprite04
- ld bc, 4 * 4
+ ld bc, OBJ_SIZE * 4
call CopyData
.inputLoop
call TownMapSpriteBlinkingAnimation
@@ -159,7 +159,7 @@ LoadTownMap_Fly::
call CopyVideoData
ld de, TownMapUpArrow
ld hl, vChars1 tile $6d
- lb bc, BANK(TownMapUpArrow), (TownMapUpArrowEnd - TownMapUpArrow) / $8
+ lb bc, BANK(TownMapUpArrow), (TownMapUpArrowEnd - TownMapUpArrow) / TILE_1BPP_SIZE
call CopyVideoDataDouble
call BuildFlyLocationsList
ld hl, wUpdateSpritesEnabled
@@ -618,11 +618,11 @@ TownMapSpriteBlinkingAnimation::
xor a
jr .done
.hideSprites
- ld hl, wShadowOAM
+ ld hl, wShadowOAMSprite00YCoord
ld b, OAM_COUNT - 4
- ld de, $4
+ ld de, OBJ_SIZE
.hideSpritesLoop
- ld [hl], $a0
+ ld [hl], SCREEN_HEIGHT_PX + OAM_Y_OFS
add hl, de
dec b
jr nz, .hideSpritesLoop