summaryrefslogtreecommitdiff
path: root/engine/items
diff options
context:
space:
mode:
Diffstat (limited to 'engine/items')
-rwxr-xr-xengine/items/itemfinder.asm34
-rwxr-xr-xengine/items/items.asm517
-rwxr-xr-xengine/items/tm_prices.asm11
-rwxr-xr-xengine/items/tms.asm2
4 files changed, 276 insertions, 288 deletions
diff --git a/engine/items/itemfinder.asm b/engine/items/itemfinder.asm
index d7e5b3ce..5da72388 100755
--- a/engine/items/itemfinder.asm
+++ b/engine/items/itemfinder.asm
@@ -1,16 +1,16 @@
HiddenItemNear: ; 7481f (1d:481f)
ld hl, HiddenItemCoords
- ld b, $0
-.asm_74824
- ld de, $0003
+ ld b, 0
+.loop
+ ld de, 3
ld a, [W_CURMAP]
call IsInRestOfArray
ret nc ; return if current map has no hidden items
push bc
push hl
- ld hl, wd6f0
+ ld hl, wObtainedHiddenItemsFlags
ld c, b
- ld b, $2
+ ld b, FLAG_TEST
predef FlagActionPredef
ld a, c
pop hl
@@ -22,28 +22,30 @@ HiddenItemNear: ; 7481f (1d:481f)
inc hl
ld e, [hl]
inc hl
- jr nz, .asm_74824 ; 0x74845 $dd
+ jr nz, .loop ; if the item has already been obtained
+; check if the item is within 4-5 tiles (depending on the direction of item)
ld a, [W_YCOORD]
- call Func_7486b
+ call Sub5ClampTo0
cp d
- jr nc, .asm_74824 ; 0x7484e $d4
+ jr nc, .loop
ld a, [W_YCOORD]
- add $4
+ add 4
cp d
- jr c, .asm_74824 ; 0x74856 $cc
+ jr c, .loop
ld a, [W_XCOORD]
- call Func_7486b
+ call Sub5ClampTo0
cp e
- jr nc, .asm_74824 ; 0x7485f $c3
+ jr nc, .loop
ld a, [W_XCOORD]
- add $5
+ add 5
cp e
- jr c, .asm_74824 ; 0x74867 $bb
+ jr c, .loop
scf
ret
-Func_7486b: ; 7486b (1d:486b)
- sub $5
+Sub5ClampTo0: ; 7486b (1d:486b)
+; subtract 5 but clamp to 0
+ sub 5
cp $f0
ret c
xor a
diff --git a/engine/items/items.asm b/engine/items/items.asm
index 7d939ae6..29289fd9 100755
--- a/engine/items/items.asm
+++ b/engine/items/items.asm
@@ -1,6 +1,6 @@
UseItem_: ; d5c7 (3:55c7)
ld a,1
- ld [wcd6a],a
+ ld [wActionResultOrTookBattleTurn],a ; initialise to success value
ld a,[wcf91] ;contains item_ID
cp a,HM_01
jp nc,ItemUseTMHM
@@ -91,9 +91,9 @@ ItemUsePtrTable: ; d5e1 (3:55e1)
dw ItemUsePokeflute ; POKE_FLUTE
dw UnusableItem ; LIFT_KEY
dw UnusableItem ; EXP__ALL
- dw OldRodCode ; OLD_ROD
- dw GoodRodCode ; GOOD_ROD
- dw SuperRodCode ; SUPER_ROD
+ dw ItemUseOldRod ; OLD_ROD
+ dw ItemUseGoodRod ; GOOD_ROD
+ dw ItemUseSuperRod ; SUPER_ROD
dw ItemUsePPUp ; PP_UP (real one)
dw ItemUsePPRestore ; ETHER
dw ItemUsePPRestore ; MAX_ETHER
@@ -115,10 +115,10 @@ ItemUseBall: ; d687 (3:5687)
ld a,[W_NUMINBOX] ;is Box full?
cp a,MONS_PER_BOX
jp z,BoxFullCannotThrowBall
-.UseBall ;$56a7
+.UseBall
;ok, you can use a ball
xor a
- ld [wd11c],a
+ ld [wCapturedMonSpecies],a
ld a,[W_BATTLETYPE]
cp a,2 ;SafariBattle
jr nz,.skipSafariZoneCode
@@ -126,8 +126,8 @@ ItemUseBall: ; d687 (3:5687)
; remove a Safari Ball from inventory
ld hl,W_NUMSAFARIBALLS
dec [hl]
-.skipSafariZoneCode ;$56b6
- call GoPAL_SET_CF1C
+.skipSafariZoneCode
+ call RunDefaultPaletteCommand
ld a,$43
ld [wd11e],a
call LoadScreenTilesFromBuffer1 ;restore screenBuffer from Backup
@@ -142,10 +142,10 @@ ItemUseBall: ; d687 (3:5687)
.oldManBattle
ld hl,W_GRASSRATE
ld de,wPlayerName
- ld bc,11
+ ld bc,NAME_LENGTH
call CopyData ; save the player's name in the Wild Monster data (part of the Cinnabar Island Missingno glitch)
- jp .BallSuccess ;$578b
-.notOldManBattle ;$56e9
+ jp .BallSuccess
+.notOldManBattle
ld a,[W_CURMAP]
cp a,POKEMONTOWER_6
jr nz,.loop
@@ -155,13 +155,13 @@ ItemUseBall: ; d687 (3:5687)
jp z,.next12
; if not fighting ghost Marowak, loop until a random number in the current
; pokeball's allowed range is found
-.loop ;$56fa
+.loop
call Random
ld b,a
ld hl,wcf91
ld a,[hl]
cp a,MASTER_BALL
- jp z,.BallSuccess ;$578b
+ jp z,.BallSuccess
cp a,POKE_BALL
jr z,.checkForAilments
ld a,200
@@ -173,7 +173,7 @@ ItemUseBall: ; d687 (3:5687)
ld a,150 ;get only numbers <= 150 for Ultra Ball
cp b
jr c,.loop
-.checkForAilments ;$571a
+.checkForAilments
; pokemon can be caught more easily with any (primary) status ailment
; Frozen/Asleep pokemon are relatively even easier to catch
; for Frozen/Asleep pokemon, any random number from 0-24 ensures a catch.
@@ -185,12 +185,12 @@ ItemUseBall: ; d687 (3:5687)
ld c,12
jr z,.notFrozenOrAsleep
ld c,25
-.notFrozenOrAsleep ;$5728
+.notFrozenOrAsleep
ld a,b
sub c
- jp c,.BallSuccess ;$578b
+ jp c,.BallSuccess
ld b,a
-.noAilments ;$572e
+.noAilments
push bc ;save RANDOM number
xor a
ld [H_MULTIPLICAND],a
@@ -207,7 +207,7 @@ ItemUseBall: ; d687 (3:5687)
ld a,12 ;any other BallFactor
jr nz,.next7
ld a,8
-.next7 ;$574d
+.next7
ld [H_DIVISOR],a
ld b,4 ; number of bytes in dividend
call Divide
@@ -226,7 +226,7 @@ ItemUseBall: ; d687 (3:5687)
and a
jr nz,.next8
inc a
-.next8 ;$5766
+.next8
ld [H_DIVISOR],a
ld b,4
call Divide ; ((MaxHP * 255) / BallFactor) / (CurHP / 4)
@@ -235,7 +235,7 @@ ItemUseBall: ; d687 (3:5687)
jr z,.next9
ld a,255
ld [H_QUOTIENT + 3],a
-.next9 ;$5776
+.next9
pop bc
ld a,[wEnemyMonCatchRate] ;enemy: Catch Rate
cp b
@@ -248,9 +248,9 @@ ItemUseBall: ; d687 (3:5687)
ld a,[H_QUOTIENT + 3]
cp b
jr c,.next10
-.BallSuccess ;$578b
+.BallSuccess
jr .BallSuccess2
-.next10 ;$578d
+.next10
ld a,[H_QUOTIENT + 3]
ld [wd11e],a
xor a
@@ -271,7 +271,7 @@ ItemUseBall: ; d687 (3:5687)
ld b,150
cp a,ULTRA_BALL
jr z,.next11
-.next11 ;$57b8
+.next11
ld a,b
ld [H_DIVISOR],a
ld b,4
@@ -294,11 +294,11 @@ ItemUseBall: ; d687 (3:5687)
ld b,5
jr z,.next14
ld b,10
-.next14 ;$57e6
+.next14
ld a,[H_QUOTIENT + 3]
add b
ld [H_QUOTIENT + 3],a
-.next13 ;$57eb
+.next13
ld a,[H_QUOTIENT + 3]
cp a,10
ld b,$20
@@ -310,16 +310,16 @@ ItemUseBall: ; d687 (3:5687)
ld b,$62
jr c,.next12
ld b,$63
-.next12 ;$5801
+.next12
ld a,b
- ld [wd11e],a
-.BallSuccess2 ;$5805
+ ld [wPokeBallAnimData],a
+.BallSuccess2
ld c,20
call DelayFrames
ld a,TOSS_ANIM
ld [W_ANIMATIONID],a
xor a
- ld [$fff3],a
+ ld [H_WHOSETURN],a
ld [wAnimationType],a
ld [wDamageMultipliers],a
ld a,[wWhichPokemon]
@@ -331,7 +331,7 @@ ItemUseBall: ; d687 (3:5687)
ld [wcf91],a
pop af
ld [wWhichPokemon],a
- ld a,[wd11e]
+ ld a,[wPokeBallAnimData]
cp a,$10
ld hl,ItemUseBallText00
jp z,.printText0
@@ -362,14 +362,14 @@ ItemUseBall: ; d687 (3:5687)
ld a,$4c
ld [wEnemyMonSpecies2],a
jr .next16
-.next15 ;$5871
+.next15
set Transformed,[hl]
- ld hl,wcceb
+ ld hl,wTransformedEnemyMonOriginalDVs
ld a,[wEnemyMonDVs]
ld [hli],a
ld a,[wEnemyMonDVs + 1]
ld [hl],a
-.next16 ;$587e
+.next16
ld a,[wcf91]
push af
ld a,[wEnemyMonSpecies2]
@@ -388,7 +388,7 @@ ItemUseBall: ; d687 (3:5687)
pop af
ld [hl],a
ld a,[wEnemyMonSpecies] ;enemy
- ld [wd11c],a
+ ld [wCapturedMonSpecies],a
ld [wcf91],a
ld [wd11e],a
ld a,[W_BATTLETYPE]
@@ -400,15 +400,15 @@ ItemUseBall: ; d687 (3:5687)
ld a,[wd11e]
dec a
ld c,a
- ld b,2
- ld hl,wPokedexOwned ;Dex_own_flags (pokemon)
+ ld b,FLAG_TEST
+ ld hl,wPokedexOwned
predef FlagActionPredef
ld a,c
push af
ld a,[wd11e]
dec a
ld c,a
- ld b,1
+ ld b,FLAG_SET
predef FlagActionPredef
pop af
and a
@@ -419,39 +419,38 @@ ItemUseBall: ; d687 (3:5687)
ld a,[wEnemyMonSpecies] ;caught mon_ID
ld [wd11e],a
predef ShowPokedexData
-.checkParty ;$58f4
+.checkParty
ld a,[wPartyCount]
cp a,PARTY_LENGTH ;is party full?
jr z,.sendToBox
- xor a
- ld [wcc49],a
+ xor a ; PLAYER_PARTY_DATA
+ ld [wMonDataLocation],a
call ClearSprites
call AddPartyMon ;add mon to Party
jr .End
-.sendToBox ;$5907
+.sendToBox
call ClearSprites
call SendNewMonToBox
ld hl,ItemUseBallText07
- ld a,[wd7f1]
- bit 0,a ;already met Bill?
+ CheckEvent EVENT_MET_BILL
jr nz,.sendToBox2
ld hl,ItemUseBallText08
-.sendToBox2 ;$591a
+.sendToBox2
call PrintText
jr .End
-.printText1 ;$591f
+.printText1
ld hl,ItemUseBallText05
-.printText0 ;$5922
+.printText0
call PrintText
call ClearSprites
-.End ;$5928
+.End
ld a,[W_BATTLETYPE]
and a
ret nz
ld hl,wNumBagItems
inc a
- ld [wcf96],a
- jp RemoveItemFromInventory ;remove ITEM (XXX)
+ ld [wItemQuantity],a
+ jp RemoveItemFromInventory
ItemUseBallText00: ; d937 (3:5937)
;"It dodged the thrown ball!"
;"This pokemon can't be caught"
@@ -499,9 +498,7 @@ ItemUseTownMap: ; d968 (3:5968)
ld a,[W_ISINBATTLE]
and a
jp nz,ItemUseNotTime
- ld b, BANK(DisplayTownMap)
- ld hl, DisplayTownMap
- jp Bankswitch ; display Town Map
+ jpba DisplayTownMap
ItemUseBicycle: ; d977 (3:5977)
ld a,[W_ISINBATTLE]
@@ -556,11 +553,11 @@ ItemUseSurfboard: ; d9b4 (3:59b4)
jp PrintText
.tryToStopSurfing
xor a
- ld [$ff8c],a
+ ld [hSpriteIndexOrTextID],a
ld d,16 ; talking range in pixels (normal range)
call IsSpriteInFrontOfPlayer2
res 7,[hl]
- ld a,[$ff8c]
+ ld a,[hSpriteIndexOrTextID]
and a ; is there a sprite in the way?
jr nz,.cannotStopSurfing
ld hl,TilePairCollisionsWater
@@ -593,14 +590,14 @@ ItemUseSurfboard: ; d9b4 (3:59b4)
jp LoadWalkingPlayerSpriteGraphics
; uses a simulated button press to make the player move forward
.makePlayerMoveForward
- ld a,[wd52a] ; direction the player is going
- bit 3,a
+ ld a,[wPlayerDirection] ; direction the player is going
+ bit PLAYER_DIR_BIT_UP,a
ld b,D_UP
jr nz,.storeSimulatedButtonPress
- bit 2,a
+ bit PLAYER_DIR_BIT_DOWN,a
ld b,D_DOWN
jr nz,.storeSimulatedButtonPress
- bit 1,a
+ bit PLAYER_DIR_BIT_LEFT,a
ld b,D_LEFT
jr nz,.storeSimulatedButtonPress
ld b,D_RIGHT
@@ -631,10 +628,10 @@ ItemUseEvoStone: ; da5b (3:5a5b)
ld a,[wWhichPokemon]
push af
ld a,[wcf91]
- ld [wd156],a
+ ld [wEvoStoneItemID],a
push af
- ld a,$05 ; evolution stone party menu
- ld [wd07d],a
+ ld a,EVO_STONE_PARTY_MENU
+ ld [wPartyMenuTypeOrMessageID],a
ld a,$ff
ld [wUpdateSpritesEnabled],a
call DisplayPartyMenu
@@ -643,25 +640,25 @@ ItemUseEvoStone: ; da5b (3:5a5b)
ld a,b
ld [wcf91],a
ld a,$01
- ld [wccd4],a
- ld a,(SFX_02_3e - SFX_Headers_02) / 3
- call PlaySoundWaitForCurrent ; play sound
- call WaitForSoundToFinish ; wait for sound to end
+ ld [wForceEvolution],a
+ ld a,SFX_HEAL_AILMENT
+ call PlaySoundWaitForCurrent
+ call WaitForSoundToFinish
callab TryEvolvingMon ; try to evolve pokemon
- ld a,[wd121]
+ ld a,[wEvolutionOccurred]
and a
jr z,.noEffect
pop af
ld [wWhichPokemon],a
ld hl,wNumBagItems
ld a,1 ; remove 1 stone
- ld [wcf96],a
+ ld [wItemQuantity],a
jp RemoveItemFromInventory
.noEffect
call ItemUseNoEffect
.canceledItemUse
xor a
- ld [wcd6a],a
+ ld [wActionResultOrTookBattleTurn],a ; item not used
pop af
ret
@@ -678,11 +675,11 @@ ItemUseMedicine: ; dabb (3:5abb)
push af
ld a,[wcf91]
push af
- ld a,$01
- ld [wd07d],a ; item use party menu
+ ld a,USE_ITEM_PARTY_MENU
+ ld [wPartyMenuTypeOrMessageID],a
ld a,$ff
ld [wUpdateSpritesEnabled],a
- ld a,[wd152]
+ ld a,[wPseudoItemID]
and a ; using Softboiled?
jr z,.notUsingSoftboiled
; if using softboiled
@@ -691,7 +688,7 @@ ItemUseMedicine: ; dabb (3:5abb)
.emptyParty
ld hl,.emptyPartyText
xor a
- ld [wcd6a],a ; item use failed
+ ld [wActionResultOrTookBattleTurn],a ; item use failed
jp PrintText
.emptyPartyText
text "You don't have"
@@ -706,7 +703,7 @@ ItemUseMedicine: ; dabb (3:5abb)
ld a,[wWhichPokemon]
call AddNTimes
ld a,[wWhichPokemon]
- ld [wcf06],a
+ ld [wUsedItemOnWhichPokemon],a
ld d,a
ld a,[wcf91]
ld e,a
@@ -715,7 +712,7 @@ ItemUseMedicine: ; dabb (3:5abb)
ld [wcf91],a
pop af
ld [wWhichPokemon],a
- ld a,[wd152]
+ ld a,[wPseudoItemID]
and a ; using Softboiled?
jr z,.checkItemType
; if using softboiled
@@ -737,22 +734,22 @@ ItemUseMedicine: ; dabb (3:5abb)
ld bc,4
add hl,bc ; hl now points to status
ld a,[wcf91]
- ld bc,$f008
+ lb bc, ANTIDOTE_MSG, 1 << PSN
cp a,ANTIDOTE
jr z,.checkMonStatus
- ld bc,$f110
+ lb bc, BURN_HEAL_MSG, 1 << BRN
cp a,BURN_HEAL
jr z,.checkMonStatus
- ld bc,$f220
+ lb bc, ICE_HEAL_MSG, 1 << FRZ
cp a,ICE_HEAL
jr z,.checkMonStatus
- ld bc,$f307
+ lb bc, AWAKENING_MSG, SLP
cp a,AWAKENING
jr z,.checkMonStatus
- ld bc,$f440
+ lb bc, PARALYZ_HEAL_MSG, 1 << PAR
cp a,PARLYZ_HEAL
jr z,.checkMonStatus
- ld bc,$f6ff ; Full Heal
+ lb bc, FULL_HEAL_MSG, $ff ; Full Heal
.checkMonStatus
ld a,[hl] ; pokemon's status
and c ; does the pokemon have a status ailment the item can cure?
@@ -761,7 +758,7 @@ ItemUseMedicine: ; dabb (3:5abb)
xor a
ld [hl],a ; remove the status ailment in the party data
ld a,b
- ld [wd07d],a ; the message to display for the item used
+ ld [wPartyMenuTypeOrMessageID],a ; the message to display for the item used
ld a,[wPlayerMonNumber]
cp d ; is pokemon the item was used on active in battle?
jp nz,.doneHealing
@@ -803,18 +800,18 @@ ItemUseMedicine: ; dabb (3:5abb)
push hl
push de
push bc
- ld a,[wcf06]
+ ld a,[wUsedItemOnWhichPokemon]
ld c,a
ld hl,wPartyFoughtCurrentEnemyFlags
- ld b,$02
+ ld b,FLAG_TEST
predef FlagActionPredef
ld a,c
and a
jr z,.next
- ld a,[wcf06]
+ ld a,[wUsedItemOnWhichPokemon]
ld c,a
ld hl,wPartyGainExpFlags
- ld b,$01
+ ld b,FLAG_SET
predef FlagActionPredef
.next
pop bc
@@ -859,7 +856,7 @@ ItemUseMedicine: ; dabb (3:5abb)
.notFullHP ; if the pokemon's current HP doesn't equal its max HP
xor a
ld [wLowHealthAlarm],a ;disable low health alarm
- ld [wc02a],a
+ ld [wChannelSoundIDs + CH4],a
push hl
push de
ld bc,32
@@ -868,7 +865,7 @@ ItemUseMedicine: ; dabb (3:5abb)
ld [wHPBarMaxHP+1],a
ld a,[hl]
ld [wHPBarMaxHP],a ; max HP stored at wHPBarMaxHP (2 bytes, big-endian)
- ld a,[wd152]
+ ld a,[wPseudoItemID]
and a ; using Softboiled?
jp z,.notUsingSoftboiled2
; if using softboiled
@@ -913,12 +910,12 @@ ItemUseMedicine: ; dabb (3:5abb)
sbc b
ld [hl],a
ld [wHPBarNewHP+1],a
- hlCoord 4, 1
+ coord hl, 4, 1
ld a,[wWhichPokemon]
- ld bc,2 * 20
+ ld bc,2 * SCREEN_WIDTH
call AddNTimes ; calculate coordinates of HP bar of pokemon that used Softboiled
- ld a,(SFX_02_3d - SFX_Headers_02) / 3
- call PlaySoundWaitForCurrent ; play sound
+ ld a,SFX_HEAL_HP
+ call PlaySoundWaitForCurrent
ld a,[hFlags_0xFFF6]
set 0,a
ld [hFlags_0xFFF6],a
@@ -1055,7 +1052,7 @@ ItemUseMedicine: ; dabb (3:5abb)
call ItemUseNoEffect
jp .done
.doneHealing
- ld a,[wd152]
+ ld a,[wPseudoItemID]
and a ; using Softboiled?
jr nz,.skipRemovingItem ; no item to remove if using Softboiled
push hl
@@ -1067,8 +1064,8 @@ ItemUseMedicine: ; dabb (3:5abb)
jr c,.playStatusAilmentCuringSound
cp a,FULL_HEAL
jr z,.playStatusAilmentCuringSound
- ld a,(SFX_02_3d - SFX_Headers_02) / 3 ; HP healing sound
- call PlaySoundWaitForCurrent ; play sound
+ ld a,SFX_HEAL_HP
+ call PlaySoundWaitForCurrent
ld a,[hFlags_0xFFF6]
set 0,a
ld [hFlags_0xFFF6],a
@@ -1078,18 +1075,18 @@ ItemUseMedicine: ; dabb (3:5abb)
ld a,[hFlags_0xFFF6]
res 0,a
ld [hFlags_0xFFF6],a
- ld a,$f7 ; revived message
- ld [wd07d],a
+ ld a,REVIVE_MSG
+ ld [wPartyMenuTypeOrMessageID],a
ld a,[wcf91]
cp a,REVIVE
jr z,.showHealingItemMessage
cp a,MAX_REVIVE
jr z,.showHealingItemMessage
- ld a,$f5 ; standard HP healed message
- ld [wd07d],a
+ ld a,POTION_MSG
+ ld [wPartyMenuTypeOrMessageID],a
jr .showHealingItemMessage
.playStatusAilmentCuringSound
- ld a,(SFX_02_3e - SFX_Headers_02) / 3 ; status ailment curing sound
+ ld a,SFX_HEAL_AILMENT
call PlaySoundWaitForCurrent
.showHealingItemMessage
xor a
@@ -1106,15 +1103,15 @@ ItemUseMedicine: ; dabb (3:5abb)
jr .done
.canceledItemUse
xor a
- ld [wcd6a],a ; item use failed
+ ld [wActionResultOrTookBattleTurn],a ; item use failed
pop af
pop af
.done
- ld a,[wd152]
+ ld a,[wPseudoItemID]
and a ; using Softboiled?
ret nz ; if so, return
call GBPalWhiteOut
- call z,GoPAL_SET_CF1C
+ call z,RunDefaultPaletteCommand
ld a,[W_ISINBATTLE]
and a
ret nz
@@ -1178,8 +1175,8 @@ ItemUseMedicine: ; dabb (3:5abb)
ld de,wcf4b
ld bc,10
call CopyData ; copy the stat's name to wcf4b
- ld a,(SFX_02_3e - SFX_Headers_02) / 3
- call PlaySound ; play sound
+ ld a,SFX_HEAL_AILMENT
+ call PlaySound
ld hl,VitaminStatRoseText
call PrintText
jp RemoveUsedItem
@@ -1216,11 +1213,11 @@ ItemUseMedicine: ; dabb (3:5abb)
ld bc,-19
add hl,bc ; hl now points to experience
; update experience to minimum for new level
- ld a,[$ff96]
+ ld a,[hExperience]
ld [hli],a
- ld a,[$ff97]
+ ld a,[hExperience + 1]
ld [hli],a
- ld a,[$ff98]
+ ld a,[hExperience + 2]
ld [hl],a
pop hl
ld a,[wWhichPokemon]
@@ -1257,25 +1254,25 @@ ItemUseMedicine: ; dabb (3:5abb)
ld a,[hl]
adc b
ld [hl],a
- ld a,$f8 ; level up message
- ld [wd07d],a
+ ld a,RARE_CANDY_MSG
+ ld [wPartyMenuTypeOrMessageID],a
call RedrawPartyMenu
pop de
ld a,d
ld [wWhichPokemon],a
ld a,e
ld [wd11e],a
- xor a
- ld [wcc49],a ; load from player's party
+ xor a ; PLAYER_PARTY_DATA
+ ld [wMonDataLocation],a
call LoadMonData
ld d,$01
callab PrintStatsBox ; display new stats text box
call WaitForTextScrollButtonPress ; wait for button press
- xor a
- ld [wcc49],a
+ xor a ; PLAYER_PARTY_DATA
+ ld [wMonDataLocation],a
predef LearnMoveFromLevelUp ; learn level up move, if any
xor a
- ld [wccd4],a
+ ld [wForceEvolution],a
callab TryEvolvingMon ; evolve pokemon, if appropriate
ld a,$01
ld [wUpdateSpritesEnabled],a
@@ -1327,7 +1324,7 @@ ItemUseRock: ; df67 (3:5f67)
BaitRockCommon: ; df7f (3:5f7f)
ld [W_ANIMATIONID],a
xor a
- ld [wcc5b],a
+ ld [wAnimationType],a
ld [H_WHOSETURN],a
ld [de],a ; zero escape factor (for bait), zero bait factor (for rock)
.randomLoop ; loop until a random number less than 5 is generated
@@ -1377,15 +1374,14 @@ ItemUseEscapeRope: ; dfaf (3:5faf)
set 6,[hl]
ld hl,wd72e
res 4,[hl]
- ld hl,wd790
- res 7,[hl] ; unset Safari Zone bit
+ ResetEvent EVENT_IN_SAFARI_ZONE
xor a
ld [W_NUMSAFARIBALLS],a
ld [W_SAFARIZONEENTRANCECURSCRIPT],a
inc a
ld [wEscapedFromBattle],a
- ld [wcd6a],a ; item used
- ld a,[wd152]
+ ld [wActionResultOrTookBattleTurn],a ; item used
+ ld a,[wPseudoItemID]
and a ; using Dig?
ret nz ; if so, return
call ItemUseReloadOverworldData
@@ -1423,7 +1419,7 @@ ItemUseXAccuracy: ; e013 (3:6013)
; The Card Key is handled in a different way.
ItemUseCardKey: ; e022 (3:6022)
xor a
- ld [wd71f],a
+ ld [wUnusedD71F],a
call GetTileAndCoordsInFrontOfPlayer
ld a,[GetTileAndCoordsInFrontOfPlayer] ; $4586
cp a,$18
@@ -1455,7 +1451,7 @@ ItemUseCardKey: ; e022 (3:6022)
cp e
jr nz,.nextEntry3
ld a,[hl]
- ld [wd71f],a
+ ld [wUnusedD71F],a
jr .done
.nextEntry1
inc hl
@@ -1550,7 +1546,7 @@ ItemUseXStat: ; e104 (3:6104)
jr nz,.inBattle
call ItemUseNotTime
ld a,2
- ld [wcd6a],a ; item not used
+ ld [wActionResultOrTookBattleTurn],a ; item not used
ret
.inBattle
ld hl,W_PLAYERMOVENUM
@@ -1586,8 +1582,7 @@ ItemUsePokeflute: ; e140 (3:6140)
ld a,[W_CURMAP]
cp a,ROUTE_12
jr nz,.notRoute12
- ld a,[wd7d8]
- bit 7,a ; has the player beaten Route 12 Snorlax yet?
+ CheckEvent EVENT_BEAT_ROUTE12_SNORLAX
jr nz,.noSnorlaxToWakeUp
; if the player hasn't beaten Route 12 Snorlax
ld hl,Route12SnorlaxFluteCoords
@@ -1595,14 +1590,12 @@ ItemUsePokeflute: ; e140 (3:6140)
jr nc,.noSnorlaxToWakeUp
ld hl,PlayedFluteHadEffectText
call PrintText
- ld hl,wd7d8
- set 6,[hl] ; trigger Snorlax fight (handled by map script)
+ SetEvent EVENT_FIGHT_ROUTE12_SNORLAX
ret
.notRoute12
cp a,ROUTE_16
jr nz,.noSnorlaxToWakeUp
- ld a,[wd7e0]
- bit 1,a ; has the player beaten Route 16 Snorlax yet?
+ CheckEvent EVENT_BEAT_ROUTE16_SNORLAX
jr nz,.noSnorlaxToWakeUp
; if the player hasn't beaten Route 16 Snorlax
ld hl,Route16SnorlaxFluteCoords
@@ -1610,16 +1603,15 @@ ItemUsePokeflute: ; e140 (3:6140)
jr nc,.noSnorlaxToWakeUp
ld hl,PlayedFluteHadEffectText
call PrintText
- ld hl,wd7e0
- set 0,[hl] ; trigger Snorlax fight (handled by map script)
+ SetEvent EVENT_FIGHT_ROUTE16_SNORLAX
ret
.noSnorlaxToWakeUp
ld hl,PlayedFluteNoEffectText
jp PrintText
.inBattle
xor a
- ld [wWhichTrade],a ; initialize variable that indicates if any pokemon were woken up to zero
- ld b,~SLP & $FF
+ ld [wWereAnyMonsAsleep],a
+ ld b,~SLP & $ff
ld hl,wPartyMon1Status
call WakeUpEntireParty
ld a,[W_ISINBATTLE]
@@ -1638,7 +1630,7 @@ ItemUsePokeflute: ; e140 (3:6140)
and b ; remove Sleep status
ld [hl],a
call LoadScreenTilesFromBuffer2 ; restore saved screen
- ld a,[wWhichTrade]
+ ld a,[wWereAnyMonsAsleep]
and a ; were any pokemon asleep before playing the flute?
ld hl,PlayedFluteNoEffectText
jp z,PrintText ; if no pokemon were asleep
@@ -1651,7 +1643,7 @@ ItemUsePokeflute: ; e140 (3:6140)
call WaitForSoundToFinish ; wait for sound to end
callba Music_PokeFluteInBattle ; play in-battle pokeflute music
.musicWaitLoop ; wait for music to finish playing
- ld a,[wc02c]
+ ld a,[wChannelSoundIDs + CH6]
and a ; music off?
jr nz,.musicWaitLoop
.skipMusic
@@ -1662,9 +1654,9 @@ ItemUsePokeflute: ; e140 (3:6140)
; INPUT:
; hl must point to status of first pokemon in party (player's or enemy's)
; b must equal ~SLP
-; [wWhichTrade] should be initialized to 0
+; [wWereAnyMonsAsleep] should be initialized to 0
; OUTPUT:
-; [wWhichTrade]: set to 1 if any pokemon were asleep
+; [wWereAnyMonsAsleep]: set to 1 if any pokemon were asleep
WakeUpEntireParty: ; e1e5 (3:61e5)
ld de,44
ld c,6
@@ -1674,7 +1666,7 @@ WakeUpEntireParty: ; e1e5 (3:61e5)
and a,SLP ; is pokemon asleep?
jr z,.notAsleep
ld a,1
- ld [wWhichTrade],a ; indicate that a pokemon had to be woken up
+ ld [wWereAnyMonsAsleep],a ; indicate that a pokemon had to be woken up
.notAsleep
pop af
and b ; remove Sleep status
@@ -1713,19 +1705,19 @@ FluteWokeUpText: ; e210 (3:6210)
PlayedFluteHadEffectText: ; e215 (3:6215)
TX_FAR _PlayedFluteHadEffectText
db $06
- db $08
+ TX_ASM
ld a,[W_ISINBATTLE]
and a
jr nz,.done
; play out-of-battle pokeflute music
ld a,$ff
call PlaySound ; turn off music
- ld a, (SFX_02_5e - SFX_Headers_02) / 3
- ld c, BANK(SFX_02_5e)
- call PlayMusic ; play music
+ ld a, SFX_POKEFLUE
+ ld c, BANK(SFX_Pokeflute)
+ call PlayMusic
.musicWaitLoop ; wait for music to finish playing
- ld a,[wc028]
- cp a,$b8
+ ld a,[wChannelSoundIDs + CH2]
+ cp a, SFX_POKEFLUE
jr z,.musicWaitLoop
call PlayDefaultMusic ; start playing normal music again
.done
@@ -1742,14 +1734,14 @@ CoinCaseNumCoinsText: ; e247 (3:6247)
TX_FAR _CoinCaseNumCoinsText
db "@"
-OldRodCode: ; e24c (3:624c)
+ItemUseOldRod: ; e24c (3:624c)
call FishingInit
jp c, ItemUseNotTime
- ld bc, (5 << 8) | MAGIKARP
+ lb bc, 5, MAGIKARP
ld a, $1 ; set bite
- jr RodResponse ; 0xe257 $34
+ jr RodResponse
-GoodRodCode: ; e259 (3:6259)
+ItemUseGoodRod: ; e259 (3:6259)
call FishingInit
jp c,ItemUseNotTime
.RandomLoop
@@ -1777,13 +1769,13 @@ GoodRodCode: ; e259 (3:6259)
INCLUDE "data/good_rod.asm"
-SuperRodCode: ; e283 (3:6283)
+ItemUseSuperRod: ; e283 (3:6283)
call FishingInit
jp c, ItemUseNotTime
- call ReadSuperRodData ; 0xe8ea
+ call ReadSuperRodData
ld a, e
RodResponse: ; e28d (3:628d)
- ld [wWhichTrade], a
+ ld [wRodResponse], a
dec a ; is there a bite?
jr nz, .next
@@ -1801,7 +1793,7 @@ RodResponse: ; e28d (3:628d)
push af
push hl
ld [hl], 0
- callba Func_707b6
+ callba FishingAnim
pop hl
pop af
ld [hl], a
@@ -1824,8 +1816,8 @@ FishingInit: ; e2b4 (3:62b4)
call ItemUseReloadOverworldData
ld hl,ItemUseText00
call PrintText
- ld a,(SFX_02_3e - SFX_Headers_02) / 3
- call PlaySound ; play sound
+ ld a,SFX_HEAL_AILMENT
+ call PlaySound
ld c,80
call DelayFrames
and a
@@ -1847,10 +1839,10 @@ ItemUseItemfinder: ; e2e1 (3:62e1)
jr nc,.printText ; if no hidden items
ld c,4
.loop
- ld a,(SFX_02_4a - SFX_Headers_02) / 3
- call PlaySoundWaitForCurrent ; play sound
- ld a,(SFX_02_5a - SFX_Headers_02) / 3
- call PlaySoundWaitForCurrent ; play sound
+ ld a,SFX_HEALING_MACHINE
+ call PlaySoundWaitForCurrent
+ ld a,SFX_PURCHASE
+ call PlaySoundWaitForCurrent
dec c
jr nz,.loop
ld hl,ItemfinderFoundItemText
@@ -1874,23 +1866,23 @@ ItemUsePPRestore: ; e31e (3:631e)
ld a,[wWhichPokemon]
push af
ld a,[wcf91]
- ld [wWhichTrade],a
+ ld [wPPRestoreItem],a
.chooseMon
xor a
ld [wUpdateSpritesEnabled],a
- ld a,$01 ; item use party menu
- ld [wd07d],a
+ ld a,USE_ITEM_PARTY_MENU
+ ld [wPartyMenuTypeOrMessageID],a
call DisplayPartyMenu
jr nc,.chooseMove
jp .itemNotUsed
.chooseMove
- ld a,[wWhichTrade]
+ ld a,[wPPRestoreItem]
cp a,ELIXER
jp nc,.useElixir ; if Elixir or Max Elixir
ld a,$02
ld [wMoveMenuType],a
ld hl,RaisePPWhichTechniqueText
- ld a,[wWhichTrade]
+ ld a,[wPPRestoreItem]
cp a,ETHER ; is it a PP Up?
jr c,.printWhichTechniqueMessage ; if so, print the raise PP message
ld hl,RestorePPWhichTechniqueText ; otherwise, print the restore PP message
@@ -1903,7 +1895,7 @@ ItemUsePPRestore: ; e31e (3:631e)
ld [wPlayerMoveListIndex],a
jr nz,.chooseMon
ld hl,wPartyMon1Moves
- ld bc,44
+ ld bc, wPartyMon2 - wPartyMon1
call GetSelectedMoveOffset
push hl
ld a,[hl]
@@ -1911,7 +1903,7 @@ ItemUsePPRestore: ; e31e (3:631e)
call GetMoveName
call CopyStringToCF4B ; copy name to wcf4b
pop hl
- ld a,[wWhichTrade]
+ ld a,[wPPRestoreItem]
cp a,ETHER
jr nc,.useEther ; if Ether or Max Ether
.usePPUp
@@ -1936,7 +1928,7 @@ ItemUsePPRestore: ; e31e (3:631e)
pop af
ld [wWhichPokemon],a
call GBPalWhiteOut
- call GoPAL_SET_CF1C
+ call RunDefaultPaletteCommand
jp RemoveUsedItem
.afterRestoringPP ; after using a (Max) Ether/Elixir
ld a,[wWhichPokemon]
@@ -1945,13 +1937,13 @@ ItemUsePPRestore: ; e31e (3:631e)
cp b ; is the pokemon whose PP was restored active in battle?
jr nz,.skipUpdatingInBattleData
ld hl,wPartyMon1PP
- ld bc,44
+ ld bc, wPartyMon2 - wPartyMon1
call AddNTimes
ld de,wBattleMonPP
ld bc,4
call CopyData ; copy party data to in-battle data
.skipUpdatingInBattleData
- ld a,(SFX_02_3e - SFX_Headers_02) / 3
+ ld a,SFX_HEAL_AILMENT
call PlaySound
ld hl,PPRestoredText
call PrintText
@@ -1963,17 +1955,17 @@ ItemUsePPRestore: ; e31e (3:631e)
; unsets zero flag if PP was restored, sets zero flag if not
; however, this is bugged for Max Ethers and Max Elixirs (see below)
.restorePP
- xor a
- ld [wcc49],a ; party pokemon
+ xor a ; PLAYER_PARTY_DATA
+ ld [wMonDataLocation],a
call GetMaxPP
ld hl,wPartyMon1Moves
- ld bc,44
+ ld bc, wPartyMon2 - wPartyMon1
call GetSelectedMoveOffset
- ld bc,21
+ ld bc, wPartyMon1PP - wPartyMon1Moves
add hl,bc ; hl now points to move's PP
- ld a,[wd11e]
- ld b,a ; b = max PP
- ld a,[wWhichTrade]
+ ld a,[wMaxPP]
+ ld b,a
+ ld a,[wPPRestoreItem]
cp a,MAX_ETHER
jr z,.fullyRestorePP
ld a,[hl] ; move PP
@@ -2005,7 +1997,7 @@ ItemUsePPRestore: ; e31e (3:631e)
jr .storeNewAmount
.useElixir
; decrement the item ID so that ELIXER becomes ETHER and MAX_ELIXER becomes MAX_ETHER
- ld hl,wWhichTrade
+ ld hl,wPPRestoreItem
dec [hl]
dec [hl]
xor a
@@ -2017,7 +2009,7 @@ ItemUsePPRestore: ; e31e (3:631e)
.elixirLoop
push bc
ld hl,wPartyMon1Moves
- ld bc,44
+ ld bc, wPartyMon2 - wPartyMon1
call GetSelectedMoveOffset
ld a,[hl]
and a ; does the current slot have a move?
@@ -2040,10 +2032,10 @@ ItemUsePPRestore: ; e31e (3:631e)
call ItemUseNoEffect
.itemNotUsed
call GBPalWhiteOut
- call GoPAL_SET_CF1C
+ call RunDefaultPaletteCommand
pop af
xor a
- ld [wcd6a],a ; item use failed
+ ld [wActionResultOrTookBattleTurn],a ; item use failed
ret
RaisePPWhichTechniqueText: ; e45d (3:645d)
@@ -2095,8 +2087,8 @@ ItemUseTMHM: ; e479 (3:6479)
call PrintText
ld hl,TeachMachineMoveText
call PrintText
- hlCoord 14, 7
- ld bc,$080f
+ coord hl, 14, 7
+ lb bc, 8, 15
ld a,TWO_OPTION_MENU
ld [wTextBoxID],a
call DisplayTextBoxID ; yes/no menu
@@ -2104,7 +2096,7 @@ ItemUseTMHM: ; e479 (3:6479)
and a
jr z,.useMachine
ld a,2
- ld [wcd6a],a ; item not used
+ ld [wActionResultOrTookBattleTurn],a ; item not used
ret
.useMachine
ld a,[wWhichPokemon]
@@ -2113,16 +2105,16 @@ ItemUseTMHM: ; e479 (3:6479)
push af
.chooseMon
ld hl,wcf4b
- ld de,wd036
+ ld de,wTempMoveNameBuffer
ld bc,14
- call CopyData
+ call CopyData ; save the move name because DisplayPartyMenu will overwrite it
ld a,$ff
ld [wUpdateSpritesEnabled],a
- ld a,$03 ; teach TM/HM party menu
- ld [wd07d],a
+ ld a,TMHM_PARTY_MENU
+ ld [wPartyMenuTypeOrMessageID],a
call DisplayPartyMenu
push af
- ld hl,wd036
+ ld hl,wTempMoveNameBuffer
ld de,wcf4b
ld bc,14
call CopyData
@@ -2133,7 +2125,7 @@ ItemUseTMHM: ; e479 (3:6479)
pop af
call GBPalWhiteOutWithDelay3
call ClearSprites
- call GoPAL_SET_CF1C
+ call RunDefaultPaletteCommand
jp LoadScreenTilesFromBuffer1 ; restore saved screen
.checkIfAbleToLearnMove
predef CanLearnTM ; check if the pokemon can learn the move
@@ -2146,8 +2138,8 @@ ItemUseTMHM: ; e479 (3:6479)
and a ; can the pokemon learn the move?
jr nz,.checkIfAlreadyLearnedMove
; if the pokemon can't learn the move
- ld a,(SFX_02_51 - SFX_Headers_02) / 3
- call PlaySoundWaitForCurrent ; play sound
+ ld a,SFX_DENIED
+ call PlaySoundWaitForCurrent
ld hl,MonCannotLearnMachineMoveText
call PrintText
jr .chooseMon
@@ -2186,14 +2178,14 @@ MonCannotLearnMachineMoveText: ; e55e (3:655e)
PrintItemUseTextAndRemoveItem: ; e563 (3:6563)
ld hl,ItemUseText00
call PrintText
- ld a,(SFX_02_3e - SFX_Headers_02) / 3
- call PlaySound ; play sound
+ ld a,SFX_HEAL_AILMENT
+ call PlaySound
call WaitForTextScrollButtonPress ; wait for button press
RemoveUsedItem: ; e571 (3:6571)
ld hl,wNumBagItems
ld a,1 ; one item
- ld [wcf96],a ; store quantity
+ ld [wItemQuantity],a
jp RemoveItemFromInventory
ItemUseNoEffect: ; e57c (3:657c)
@@ -2209,7 +2201,7 @@ ItemUseNotYoursToUse: ; e586 (3:6586)
jr ItemUseFailed
ThrowBallAtTrainerMon: ; e58b (3:658b)
- call GoPAL_SET_CF1C
+ call RunDefaultPaletteCommand
call LoadScreenTilesFromBuffer1 ; restore saved screen
call Delay3
ld a,TOSS_ANIM
@@ -2234,7 +2226,7 @@ SurfingAttemptFailed: ; e5b6 (3:65b6)
ItemUseFailed: ; e5b9 (3:65b9)
xor a
- ld [wcd6a],a ; item use failed
+ ld [wActionResultOrTookBattleTurn],a ; item use failed
jp PrintText
ItemUseNotTimeText: ; e5c0 (3:65c0)
@@ -2291,23 +2283,20 @@ GotOffBicycleText: ; e5fc (3:65fc)
; also, when a PP Up is used, it increases the current PP by one PP Up bonus
; INPUT:
; [wWhichPokemon] = index of pokemon in party
-; [wd11e] = mode
-; 0: Pokemon Center healing
-; 1: using a PP Up
; [wCurrentMenuItem] = index of move (when using a PP Up)
RestoreBonusPP: ; e606 (3:6606)
ld hl,wPartyMon1Moves
- ld bc,44
+ ld bc, wPartyMon2 - wPartyMon1
ld a,[wWhichPokemon]
call AddNTimes
push hl
- ld de,wcd78 - 1
- predef LoadMovePPs ; loads the normal max PP of each of the pokemon's moves to wcd78
+ ld de,wNormalMaxPPList - 1
+ predef LoadMovePPs ; loads the normal max PP of each of the pokemon's moves to wNormalMaxPPList
pop hl
- ld c,21
+ ld c, wPartyMon1PP - wPartyMon1Moves
ld b,0
add hl,bc ; hl now points to move 1 PP
- ld de,wcd78
+ ld de,wNormalMaxPPList
ld b,0 ; initialize move counter to zero
; loop through the pokemon's moves
.loop
@@ -2315,7 +2304,7 @@ RestoreBonusPP: ; e606 (3:6606)
ld a,b
cp a,5 ; reached the end of the pokemon's moves?
ret z ; if so, return
- ld a,[wd11e]
+ ld a,[wUsingPPUp]
dec a ; using a PP Up?
jr nz,.skipMenuItemIDCheck
; if using a PP Up, check if this is the move it's being used on
@@ -2337,8 +2326,6 @@ RestoreBonusPP: ; e606 (3:6606)
; INPUT:
; [de] = normal max PP
; [hl] = move PP
-; [wd11e] = max number of times to add bonus
-; set to 1 when using a PP Up, set to 255 otherwise
AddBonusPP: ; e642 (3:6642)
push bc
ld a,[de] ; normal max PP of move
@@ -2366,9 +2353,9 @@ AddBonusPP: ; e642 (3:6642)
.addAmount
add b
ld b,a
- ld a,[wd11e]
- dec a
- jr z,.done
+ ld a,[wUsingPPUp]
+ dec a ; is the player using a PP Up right now?
+ jr z,.done ; if so, only add the bonus once
dec c
jr nz,.loop
.done
@@ -2379,7 +2366,7 @@ AddBonusPP: ; e642 (3:6642)
; gets max PP of a pokemon's move (including PP from PP Ups)
; INPUT:
; [wWhichPokemon] = index of pokemon within party/box
-; [wcc49] = pokemon source
+; [wMonDataLocation] = pokemon source
; 00: player's party
; 01: enemy's party
; 02: current box
@@ -2387,9 +2374,9 @@ AddBonusPP: ; e642 (3:6642)
; 04: player's in-battle pokemon
; [wCurrentMenuItem] = move index
; OUTPUT:
-; [wd11e] = max PP
+; [wMaxPP] = max PP
GetMaxPP: ; e677 (3:6677)
- ld a,[wcc49]
+ ld a,[wMonDataLocation]
and a
ld hl,wPartyMon1Moves
ld bc,wPartyMon2 - wPartyMon1
@@ -2415,21 +2402,21 @@ GetMaxPP: ; e677 (3:6677)
dec a
push hl
ld hl,Moves
- ld bc,6
+ ld bc,MoveEnd - Moves
call AddNTimes
ld de,wcd6d
ld a,BANK(Moves)
call FarCopyData
- ld de,wcd72
+ ld de,wcd6d + 5 ; PP is byte 5 of move data
ld a,[de]
ld b,a ; b = normal max PP
pop hl
push bc
- ld bc,21 ; PP offset if not player's in-battle pokemon data
- ld a,[wcc49]
+ ld bc,wPartyMon1PP - wPartyMon1Moves ; PP offset if not player's in-battle pokemon data
+ ld a,[wMonDataLocation]
cp a,4 ; player's in-battle pokemon?
jr nz,.addPPOffset
- ld bc,17 ; PP offset if player's in-battle pokemon data
+ ld bc,wBattleMonPP - wBattleMonMoves ; PP offset if player's in-battle pokemon data
.addPPOffset
add hl,bc
ld a,[hl] ; a = current PP
@@ -2440,12 +2427,12 @@ GetMaxPP: ; e677 (3:6677)
ld l,e
inc hl ; hl = wcd73
ld [hl],a
- xor a
- ld [wd11e],a ; no limit on PP Up amount
+ xor a ; add the bonus for the existing PP Up count
+ ld [wUsingPPUp],a
call AddBonusPP ; add bonus PP from PP Ups
ld a,[hl]
and a,%00111111 ; mask out the PP Up count
- ld [wd11e],a ; store max PP
+ ld [wMaxPP],a ; store max PP
ret
GetSelectedMoveOffset: ; e6e3 (3:66e3)
@@ -2464,7 +2451,7 @@ GetSelectedMoveOffset2: ; e6e9 (3:66e9)
; hl = address of inventory (either wNumBagItems or wNumBoxItems)
; [wcf91] = item ID
; [wWhichPokemon] = index of item within inventory
-; [wcf96] = quantity to toss
+; [wItemQuantity] = quantity to toss
; OUTPUT:
; clears carry flag if the item is tossed, sets carry flag if not
TossItem_: ; e6f1 (3:66f1)
@@ -2475,7 +2462,7 @@ TossItem_: ; e6f1 (3:66f1)
jr c,.tooImportantToToss
push hl
call IsKeyItem_
- ld a,[wd124]
+ ld a,[wIsKeyItem]
pop hl
and a
jr nz,.tooImportantToToss
@@ -2486,16 +2473,16 @@ TossItem_: ; e6f1 (3:66f1)
call CopyStringToCF4B ; copy name to wcf4b
ld hl,IsItOKToTossItemText
call PrintText
- hlCoord 14, 7
- ld bc,$080f
+ coord hl, 14, 7
+ lb bc, 8, 15
ld a,TWO_OPTION_MENU
ld [wTextBoxID],a
call DisplayTextBoxID ; yes/no menu
- ld a,[wd12e]
- cp a,2
+ ld a,[wMenuExitMethod]
+ cp a,CHOSE_SECOND_ITEM
pop hl
scf
- ret z
+ ret z ; return if the player chose No
; if the player chose Yes
push hl
ld a,[wWhichPokemon]
@@ -2533,27 +2520,27 @@ TooImportantToTossText: ; e75f (3:675f)
; INPUT:
; [wcf91] = item ID
; OUTPUT:
-; [wd124] = result
+; [wIsKeyItem] = result
; 00: item is not key item
; 01: item is key item
IsKeyItem_: ; e764 (3:6764)
ld a,$01
- ld [wd124],a
+ ld [wIsKeyItem],a
ld a,[wcf91]
cp a,HM_01 ; is the item an HM or TM?
jr nc,.checkIfItemIsHM
; if the item is not an HM or TM
push af
ld hl,KeyItemBitfield
- ld de,wHPBarMaxHP
+ ld de,wBuffer
ld bc,15 ; only 11 bytes are actually used
call CopyData
pop af
dec a
ld c,a
- ld hl,wHPBarMaxHP
- ld b,$02 ; test bit
- predef FlagActionPredef ; bitfield operation function
+ ld hl,wBuffer
+ ld b,FLAG_TEST
+ predef FlagActionPredef
ld a,c
and a
ret nz
@@ -2562,13 +2549,13 @@ IsKeyItem_: ; e764 (3:6764)
call IsItemHM
ret c
xor a
- ld [wd124],a
+ ld [wIsKeyItem],a
ret
INCLUDE "data/key_items.asm"
SendNewMonToBox: ; e7a4 (3:67a4)
- ld de, W_NUMINBOX ; wda80
+ ld de, W_NUMINBOX
ld a, [de]
inc a
ld [de], a
@@ -2586,74 +2573,74 @@ SendNewMonToBox: ; e7a4 (3:67a4)
jr nz, .asm_e7b1
call GetMonHeader
ld hl, wBoxMonOT
- ld bc, $b
- ld a, [W_NUMINBOX] ; wda80
+ ld bc, NAME_LENGTH
+ ld a, [W_NUMINBOX]
dec a
jr z, .asm_e7ee
dec a
call AddNTimes
push hl
- ld bc, $b
+ ld bc, NAME_LENGTH
add hl, bc
ld d, h
ld e, l
pop hl
- ld a, [W_NUMINBOX] ; wda80
+ ld a, [W_NUMINBOX]
dec a
ld b, a
.asm_e7db
push bc
push hl
- ld bc, $b
+ ld bc, NAME_LENGTH
call CopyData
pop hl
ld d, h
ld e, l
- ld bc, $fff5
+ ld bc, -NAME_LENGTH
add hl, bc
pop bc
dec b
jr nz, .asm_e7db
.asm_e7ee
- ld hl, wPlayerName ; wd158
+ ld hl, wPlayerName
ld de, wBoxMonOT
- ld bc, $b
+ ld bc, NAME_LENGTH
call CopyData
- ld a, [W_NUMINBOX] ; wda80
+ ld a, [W_NUMINBOX]
dec a
jr z, .asm_e82a
ld hl, wBoxMonNicks
- ld bc, $b
+ ld bc, NAME_LENGTH
dec a
call AddNTimes
push hl
- ld bc, $b
+ ld bc, NAME_LENGTH
add hl, bc
ld d, h
ld e, l
pop hl
- ld a, [W_NUMINBOX] ; wda80
+ ld a, [W_NUMINBOX]
dec a
ld b, a
.asm_e817
push bc
push hl
- ld bc, $b
+ ld bc, NAME_LENGTH
call CopyData
pop hl
ld d, h
ld e, l
- ld bc, $fff5
+ ld bc, -NAME_LENGTH
add hl, bc
pop bc
dec b
jr nz, .asm_e817
.asm_e82a
ld hl, wBoxMonNicks
- ld a, $2
- ld [wd07d], a
+ ld a, NAME_MON_SCREEN
+ ld [wNamingScreenType], a
predef AskName
- ld a, [W_NUMINBOX] ; wda80
+ ld a, [W_NUMINBOX]
dec a
jr z, .asm_e867
ld hl, wBoxMons
@@ -2666,7 +2653,7 @@ SendNewMonToBox: ; e7a4 (3:67a4)
ld d, h
ld e, l
pop hl
- ld a, [W_NUMINBOX] ; wda80
+ ld a, [W_NUMINBOX]
dec a
ld b, a
.asm_e854
@@ -2677,19 +2664,19 @@ SendNewMonToBox: ; e7a4 (3:67a4)
pop hl
ld d, h
ld e, l
- ld bc, $ffdf
+ ld bc, wBoxMon1 - wBoxMon2
add hl, bc
pop bc
dec b
jr nz, .asm_e854
.asm_e867
- ld a, [wEnemyMonLevel] ; wEnemyMonLevel
+ ld a, [wEnemyMonLevel]
ld [wEnemyMonBoxLevel], a
ld hl, wEnemyMon
ld de, wBoxMon1
- ld bc, $c
+ ld bc, wEnemyMonDVs - wEnemyMon
call CopyData
- ld hl, wPlayerID ; wPlayerID
+ ld hl, wPlayerID
ld a, [hli]
ld [de], a
inc de
@@ -2697,21 +2684,21 @@ SendNewMonToBox: ; e7a4 (3:67a4)
ld [de], a
inc de
push de
- ld a, [W_CURENEMYLVL] ; W_CURENEMYLVL
+ ld a, [W_CURENEMYLVL]
ld d, a
callab CalcExperience
pop de
- ld a, [H_NUMTOPRINT] ; $ff96 (aliases: H_MULTIPLICAND)
+ ld a, [hExperience]
ld [de], a
inc de
- ld a, [$ff97]
+ ld a, [hExperience + 1]
ld [de], a
inc de
- ld a, [$ff98]
+ ld a, [hExperience + 2]
ld [de], a
inc de
xor a
- ld b, $a
+ ld b, NUM_STATS * 2
.asm_e89f
ld [de], a
inc de
@@ -2723,8 +2710,8 @@ SendNewMonToBox: ; e7a4 (3:67a4)
inc de
ld a, [hli]
ld [de], a
- ld hl, wEnemyMonPP ; wcffe
- ld b, $4
+ ld hl, wEnemyMonPP
+ ld b, NUM_MOVES
.asm_e8b1
ld a, [hli]
inc de
@@ -2781,7 +2768,7 @@ ReadSuperRodData: ; e8ea (3:68ea)
ld e, $2 ; $2 if no fishing groups found
ret
-.ReadFishingGroup ; 0xe8f6
+.ReadFishingGroup
; hl points to the fishing group entry in the index
inc hl ; skip map id
@@ -2794,7 +2781,7 @@ ReadSuperRodData: ; e8ea (3:68ea)
inc hl ; point to data
ld e, $0 ; no bite yet
-.RandomLoop ; 0xe90c
+.RandomLoop
call Random
srl a
ret c ; 50% chance of no battle
diff --git a/engine/items/tm_prices.asm b/engine/items/tm_prices.asm
index ccc5fc5a..a3a8c608 100755
--- a/engine/items/tm_prices.asm
+++ b/engine/items/tm_prices.asm
@@ -1,12 +1,11 @@
GetMachinePrice: ; f65d4 (3d:65d4)
; Input: [wcf91] = Item Id of a TM
-; Output: Stores the 2-byte TM price in [H_DOWNARROWBLINKCNT1] and [H_DOWNARROWBLINKCNT2]
-; as a BCD
+; Output: Stores the TM price at hItemPrice
ld a, [wcf91] ; a contains TM item id
sub TM_01
ret c
ld d, a
- ld hl, TechnicalMachinePrices ; $7fa7
+ ld hl, TechnicalMachinePrices
srl a
ld c, a
ld b, 0
@@ -17,10 +16,10 @@ GetMachinePrice: ; f65d4 (3d:65d4)
swap a
.highNybbleIsPrice
and $f0
- ld [H_DOWNARROWBLINKCNT2], a ; $ff8c
+ ld [hItemPrice + 1], a
xor a
- ld [H_DOWNARROWBLINKCNT1], a ; $ff8b
- ld [$ff8d], a
+ ld [hItemPrice], a
+ ld [hItemPrice + 2], a
ret
INCLUDE "data/tm_prices.asm"
diff --git a/engine/items/tms.asm b/engine/items/tms.asm
index 511aab5b..23912b34 100755
--- a/engine/items/tms.asm
+++ b/engine/items/tms.asm
@@ -17,7 +17,7 @@ CanLearnTM: ; 1373e (4:773e)
jr .findTMloop
.TMfoundLoop
pop hl
- ld b, $2 ; read corresponding bit from TM compatibility array
+ ld b, FLAG_TEST
predef_jump FlagActionPredef
; converts TM/HM number in wd11e into move number