2016-06-12 00:24:04 +00:00
|
|
|
UseItem_:
|
2014-05-22 22:13:20 +00:00
|
|
|
ld a,1
|
2015-07-15 06:16:06 +00:00
|
|
|
ld [wActionResultOrTookBattleTurn],a ; initialise to success value
|
2016-07-28 03:33:48 +00:00
|
|
|
ld a,[wcf91] ;contains item_ID
|
2014-05-22 22:13:20 +00:00
|
|
|
cp a,HM_01
|
|
|
|
jp nc,ItemUseTMHM
|
|
|
|
ld hl,ItemUsePtrTable
|
|
|
|
dec a
|
|
|
|
add a
|
|
|
|
ld c,a
|
|
|
|
ld b,0
|
|
|
|
add hl,bc
|
|
|
|
ld a,[hli]
|
|
|
|
ld h,[hl]
|
|
|
|
ld l,a
|
|
|
|
jp [hl]
|
|
|
|
|
2016-06-12 00:24:04 +00:00
|
|
|
ItemUsePtrTable:
|
2014-05-22 22:13:20 +00:00
|
|
|
dw ItemUseBall ; MASTER_BALL
|
|
|
|
dw ItemUseBall ; ULTRA_BALL
|
|
|
|
dw ItemUseBall ; GREAT_BALL
|
|
|
|
dw ItemUseBall ; POKE_BALL
|
|
|
|
dw ItemUseTownMap ; TOWN_MAP
|
|
|
|
dw ItemUseBicycle ; BICYCLE
|
|
|
|
dw ItemUseSurfboard ; out-of-battle Surf effect
|
|
|
|
dw ItemUseBall ; SAFARI_BALL
|
|
|
|
dw ItemUsePokedex ; POKEDEX
|
|
|
|
dw ItemUseEvoStone ; MOON_STONE
|
|
|
|
dw ItemUseMedicine ; ANTIDOTE
|
|
|
|
dw ItemUseMedicine ; BURN_HEAL
|
|
|
|
dw ItemUseMedicine ; ICE_HEAL
|
|
|
|
dw ItemUseMedicine ; AWAKENING
|
|
|
|
dw ItemUseMedicine ; PARLYZ_HEAL
|
|
|
|
dw ItemUseMedicine ; FULL_RESTORE
|
|
|
|
dw ItemUseMedicine ; MAX_POTION
|
|
|
|
dw ItemUseMedicine ; HYPER_POTION
|
|
|
|
dw ItemUseMedicine ; SUPER_POTION
|
|
|
|
dw ItemUseMedicine ; POTION
|
|
|
|
dw ItemUseBait ; BOULDERBADGE
|
|
|
|
dw ItemUseRock ; CASCADEBADGE
|
|
|
|
dw UnusableItem ; THUNDERBADGE
|
|
|
|
dw UnusableItem ; RAINBOWBADGE
|
|
|
|
dw UnusableItem ; SOULBADGE
|
|
|
|
dw UnusableItem ; MARSHBADGE
|
|
|
|
dw UnusableItem ; VOLCANOBADGE
|
|
|
|
dw UnusableItem ; EARTHBADGE
|
|
|
|
dw ItemUseEscapeRope ; ESCAPE_ROPE
|
|
|
|
dw ItemUseRepel ; REPEL
|
|
|
|
dw UnusableItem ; OLD_AMBER
|
|
|
|
dw ItemUseEvoStone ; FIRE_STONE
|
|
|
|
dw ItemUseEvoStone ; THUNDER_STONE
|
|
|
|
dw ItemUseEvoStone ; WATER_STONE
|
|
|
|
dw ItemUseVitamin ; HP_UP
|
|
|
|
dw ItemUseVitamin ; PROTEIN
|
|
|
|
dw ItemUseVitamin ; IRON
|
|
|
|
dw ItemUseVitamin ; CARBOS
|
|
|
|
dw ItemUseVitamin ; CALCIUM
|
|
|
|
dw ItemUseVitamin ; RARE_CANDY
|
|
|
|
dw UnusableItem ; DOME_FOSSIL
|
|
|
|
dw UnusableItem ; HELIX_FOSSIL
|
|
|
|
dw UnusableItem ; SECRET_KEY
|
|
|
|
dw UnusableItem
|
|
|
|
dw UnusableItem ; BIKE_VOUCHER
|
|
|
|
dw ItemUseXAccuracy ; X_ACCURACY
|
|
|
|
dw ItemUseEvoStone ; LEAF_STONE
|
|
|
|
dw ItemUseCardKey ; CARD_KEY
|
|
|
|
dw UnusableItem ; NUGGET
|
|
|
|
dw UnusableItem ; ??? PP_UP
|
|
|
|
dw ItemUsePokedoll ; POKE_DOLL
|
|
|
|
dw ItemUseMedicine ; FULL_HEAL
|
|
|
|
dw ItemUseMedicine ; REVIVE
|
|
|
|
dw ItemUseMedicine ; MAX_REVIVE
|
2015-12-15 04:09:30 +00:00
|
|
|
dw ItemUseGuardSpec ; GUARD_SPEC
|
2014-05-22 22:13:20 +00:00
|
|
|
dw ItemUseSuperRepel ; SUPER_REPL
|
|
|
|
dw ItemUseMaxRepel ; MAX_REPEL
|
|
|
|
dw ItemUseDireHit ; DIRE_HIT
|
|
|
|
dw UnusableItem ; COIN
|
|
|
|
dw ItemUseMedicine ; FRESH_WATER
|
|
|
|
dw ItemUseMedicine ; SODA_POP
|
|
|
|
dw ItemUseMedicine ; LEMONADE
|
2015-12-15 04:09:30 +00:00
|
|
|
dw UnusableItem ; S_S_TICKET
|
2014-05-22 22:13:20 +00:00
|
|
|
dw UnusableItem ; GOLD_TEETH
|
|
|
|
dw ItemUseXStat ; X_ATTACK
|
|
|
|
dw ItemUseXStat ; X_DEFEND
|
|
|
|
dw ItemUseXStat ; X_SPEED
|
|
|
|
dw ItemUseXStat ; X_SPECIAL
|
|
|
|
dw ItemUseCoinCase ; COIN_CASE
|
|
|
|
dw ItemUseOaksParcel ; OAKS_PARCEL
|
|
|
|
dw ItemUseItemfinder ; ITEMFINDER
|
|
|
|
dw UnusableItem ; SILPH_SCOPE
|
|
|
|
dw ItemUsePokeflute ; POKE_FLUTE
|
|
|
|
dw UnusableItem ; LIFT_KEY
|
2015-12-15 04:09:30 +00:00
|
|
|
dw UnusableItem ; EXP_ALL
|
2015-08-05 14:33:32 +00:00
|
|
|
dw ItemUseOldRod ; OLD_ROD
|
|
|
|
dw ItemUseGoodRod ; GOOD_ROD
|
|
|
|
dw ItemUseSuperRod ; SUPER_ROD
|
2014-05-22 22:13:20 +00:00
|
|
|
dw ItemUsePPUp ; PP_UP (real one)
|
|
|
|
dw ItemUsePPRestore ; ETHER
|
|
|
|
dw ItemUsePPRestore ; MAX_ETHER
|
|
|
|
dw ItemUsePPRestore ; ELIXER
|
|
|
|
dw ItemUsePPRestore ; MAX_ELIXER
|
|
|
|
|
2016-06-12 00:24:04 +00:00
|
|
|
ItemUseBall:
|
2015-08-30 06:21:54 +00:00
|
|
|
|
|
|
|
; Balls can't be used out of battle.
|
2015-08-31 02:38:41 +00:00
|
|
|
ld a,[wIsInBattle]
|
2014-05-22 22:13:20 +00:00
|
|
|
and a
|
2015-08-30 06:21:54 +00:00
|
|
|
jp z,ItemUseNotTime
|
|
|
|
|
|
|
|
; Balls can't catch trainers' Pokémon.
|
2014-05-22 22:13:20 +00:00
|
|
|
dec a
|
|
|
|
jp nz,ThrowBallAtTrainerMon
|
2015-08-30 06:21:54 +00:00
|
|
|
|
|
|
|
; If this is for the old man battle, skip checking if the party & box are full.
|
2015-08-31 02:38:41 +00:00
|
|
|
ld a,[wBattleType]
|
2014-05-22 22:13:20 +00:00
|
|
|
dec a
|
2015-08-30 06:21:54 +00:00
|
|
|
jr z,.canUseBall
|
|
|
|
|
|
|
|
ld a,[wPartyCount] ; is party full?
|
2014-08-23 06:17:47 +00:00
|
|
|
cp a,PARTY_LENGTH
|
2015-08-30 06:21:54 +00:00
|
|
|
jr nz,.canUseBall
|
2015-08-31 02:38:41 +00:00
|
|
|
ld a,[wNumInBox] ; is box full?
|
2014-08-23 06:17:47 +00:00
|
|
|
cp a,MONS_PER_BOX
|
2014-05-22 22:13:20 +00:00
|
|
|
jp z,BoxFullCannotThrowBall
|
2015-08-30 06:21:54 +00:00
|
|
|
|
|
|
|
.canUseBall
|
2014-05-22 22:13:20 +00:00
|
|
|
xor a
|
2015-07-25 03:27:59 +00:00
|
|
|
ld [wCapturedMonSpecies],a
|
2015-08-30 06:21:54 +00:00
|
|
|
|
2015-08-31 02:38:41 +00:00
|
|
|
ld a,[wBattleType]
|
2015-08-30 06:21:54 +00:00
|
|
|
cp a,BATTLE_TYPE_SAFARI
|
2014-05-22 22:13:20 +00:00
|
|
|
jr nz,.skipSafariZoneCode
|
2015-08-30 06:21:54 +00:00
|
|
|
|
2014-05-22 22:13:20 +00:00
|
|
|
.safariZone
|
2015-08-31 02:38:41 +00:00
|
|
|
ld hl,wNumSafariBalls
|
2015-08-30 06:21:54 +00:00
|
|
|
dec [hl] ; remove a Safari Ball
|
|
|
|
|
2015-07-03 19:37:53 +00:00
|
|
|
.skipSafariZoneCode
|
2015-08-12 09:16:56 +00:00
|
|
|
call RunDefaultPaletteCommand
|
2015-08-30 06:21:54 +00:00
|
|
|
|
|
|
|
ld a,$43 ; successful capture value
|
|
|
|
ld [wPokeBallAnimData],a
|
|
|
|
|
|
|
|
call LoadScreenTilesFromBuffer1
|
2014-05-22 22:13:20 +00:00
|
|
|
ld hl,ItemUseText00
|
|
|
|
call PrintText
|
2015-08-30 06:21:54 +00:00
|
|
|
|
|
|
|
; If the player is fighting an unidentified ghost, set the value that indicates
|
|
|
|
; the Pokémon can't be caught and skip the capture calculations.
|
2014-05-22 22:13:20 +00:00
|
|
|
callab IsGhostBattle
|
2015-08-30 06:21:54 +00:00
|
|
|
ld b,$10 ; can't be caught value
|
|
|
|
jp z,.setAnimData
|
|
|
|
|
2015-08-31 02:38:41 +00:00
|
|
|
ld a,[wBattleType]
|
2014-05-22 22:13:20 +00:00
|
|
|
dec a
|
|
|
|
jr nz,.notOldManBattle
|
2015-08-30 06:21:54 +00:00
|
|
|
|
2014-05-22 22:13:20 +00:00
|
|
|
.oldManBattle
|
2015-08-31 02:38:41 +00:00
|
|
|
ld hl,wGrassRate
|
2014-06-14 11:12:40 +00:00
|
|
|
ld de,wPlayerName
|
2015-08-11 04:51:20 +00:00
|
|
|
ld bc,NAME_LENGTH
|
2015-08-30 06:21:54 +00:00
|
|
|
call CopyData ; save the player's name in the Wild Monster data (part of the Cinnabar Island Missingno. glitch)
|
|
|
|
jp .captured
|
|
|
|
|
2015-07-03 19:37:53 +00:00
|
|
|
.notOldManBattle
|
2015-08-30 06:21:54 +00:00
|
|
|
; If the player is fighting the ghost Marowak, set the value that indicates the
|
|
|
|
; Pokémon can't be caught and skip the capture calculations.
|
2015-08-31 02:38:41 +00:00
|
|
|
ld a,[wCurMap]
|
2014-05-22 22:13:20 +00:00
|
|
|
cp a,POKEMONTOWER_6
|
|
|
|
jr nz,.loop
|
2014-06-14 11:12:40 +00:00
|
|
|
ld a,[wEnemyMonSpecies2]
|
2014-05-22 22:13:20 +00:00
|
|
|
cp a,MAROWAK
|
2015-08-30 06:21:54 +00:00
|
|
|
ld b,$10 ; can't be caught value
|
|
|
|
jp z,.setAnimData
|
|
|
|
|
|
|
|
; Get the first random number. Let it be called Rand1.
|
|
|
|
; Rand1 must be within a certain range according the kind of ball being thrown.
|
|
|
|
; The ranges are as follows.
|
|
|
|
; Poké Ball: [0, 255]
|
|
|
|
; Great Ball: [0, 200]
|
|
|
|
; Ultra/Safari Ball: [0, 150]
|
|
|
|
; Loop until an acceptable number is found.
|
|
|
|
|
2015-07-03 19:37:53 +00:00
|
|
|
.loop
|
2014-05-24 18:40:38 +00:00
|
|
|
call Random
|
2014-05-22 22:13:20 +00:00
|
|
|
ld b,a
|
2015-08-30 06:21:54 +00:00
|
|
|
|
|
|
|
; Get the item ID.
|
2014-05-26 21:04:56 +00:00
|
|
|
ld hl,wcf91
|
2014-05-22 22:13:20 +00:00
|
|
|
ld a,[hl]
|
2015-08-30 06:21:54 +00:00
|
|
|
|
|
|
|
; The Master Ball always succeeds.
|
2014-05-22 22:13:20 +00:00
|
|
|
cp a,MASTER_BALL
|
2015-08-30 06:21:54 +00:00
|
|
|
jp z,.captured
|
|
|
|
|
|
|
|
; Anything will do for the basic Poké Ball.
|
2014-05-22 22:13:20 +00:00
|
|
|
cp a,POKE_BALL
|
|
|
|
jr z,.checkForAilments
|
2015-08-30 06:21:54 +00:00
|
|
|
|
|
|
|
; If it's a Great/Ultra/Safari Ball and Rand1 is greater than 200, try again.
|
2014-05-22 22:13:20 +00:00
|
|
|
ld a,200
|
|
|
|
cp b
|
2015-08-30 06:21:54 +00:00
|
|
|
jr c,.loop
|
|
|
|
|
|
|
|
; Less than or equal to 200 is good enough for a Great Ball.
|
2014-05-22 22:13:20 +00:00
|
|
|
ld a,[hl]
|
|
|
|
cp a,GREAT_BALL
|
|
|
|
jr z,.checkForAilments
|
2015-08-30 06:21:54 +00:00
|
|
|
|
|
|
|
; If it's an Ultra/Safari Ball and Rand1 is greater than 150, try again.
|
|
|
|
ld a,150
|
2014-05-22 22:13:20 +00:00
|
|
|
cp b
|
|
|
|
jr c,.loop
|
2015-08-30 06:21:54 +00:00
|
|
|
|
2015-07-03 19:37:53 +00:00
|
|
|
.checkForAilments
|
2015-08-30 06:21:54 +00:00
|
|
|
; Pokémon can be caught more easily with a status ailment.
|
|
|
|
; Depending on the status ailment, a certain value will be subtracted from
|
|
|
|
; Rand1. Let this value be called Status.
|
|
|
|
; The larger Status is, the more easily the Pokémon can be caught.
|
|
|
|
; no status ailment: Status = 0
|
|
|
|
; Burn/Paralysis/Poison: Status = 12
|
|
|
|
; Freeze/Sleep: Status = 25
|
|
|
|
; If Status is greater than Rand1, the Pokémon will be caught for sure.
|
|
|
|
ld a,[wEnemyMonStatus]
|
2014-05-22 22:13:20 +00:00
|
|
|
and a
|
2015-08-30 06:21:54 +00:00
|
|
|
jr z,.skipAilmentValueSubtraction ; no ailments
|
|
|
|
and a, 1 << FRZ | SLP
|
2014-05-22 22:13:20 +00:00
|
|
|
ld c,12
|
|
|
|
jr z,.notFrozenOrAsleep
|
|
|
|
ld c,25
|
2015-07-03 19:37:53 +00:00
|
|
|
.notFrozenOrAsleep
|
2014-05-22 22:13:20 +00:00
|
|
|
ld a,b
|
|
|
|
sub c
|
2015-08-30 06:21:54 +00:00
|
|
|
jp c,.captured
|
2014-05-22 22:13:20 +00:00
|
|
|
ld b,a
|
2015-08-30 06:21:54 +00:00
|
|
|
|
|
|
|
.skipAilmentValueSubtraction
|
2016-07-28 03:33:48 +00:00
|
|
|
push bc ; save (Rand1 - Status)
|
2015-08-30 06:21:54 +00:00
|
|
|
|
|
|
|
; Calculate MaxHP * 255.
|
2014-05-22 22:13:20 +00:00
|
|
|
xor a
|
|
|
|
ld [H_MULTIPLICAND],a
|
2014-06-14 11:12:40 +00:00
|
|
|
ld hl,wEnemyMonMaxHP
|
2014-05-22 22:13:20 +00:00
|
|
|
ld a,[hli]
|
|
|
|
ld [H_MULTIPLICAND + 1],a
|
|
|
|
ld a,[hl]
|
|
|
|
ld [H_MULTIPLICAND + 2],a
|
|
|
|
ld a,255
|
|
|
|
ld [H_MULTIPLIER],a
|
2015-08-30 06:21:54 +00:00
|
|
|
call Multiply
|
|
|
|
|
|
|
|
; Determine BallFactor. It's 8 for Great Balls and 12 for the others.
|
2014-05-26 21:04:56 +00:00
|
|
|
ld a,[wcf91]
|
2014-05-22 22:13:20 +00:00
|
|
|
cp a,GREAT_BALL
|
2015-08-30 06:21:54 +00:00
|
|
|
ld a,12
|
2015-08-30 07:15:59 +00:00
|
|
|
jr nz,.skip1
|
2014-05-22 22:13:20 +00:00
|
|
|
ld a,8
|
2015-08-30 06:21:54 +00:00
|
|
|
|
2015-08-30 07:15:59 +00:00
|
|
|
.skip1
|
2015-08-30 06:21:54 +00:00
|
|
|
; Note that the results of all division operations are floored.
|
|
|
|
|
|
|
|
; Calculate (MaxHP * 255) / BallFactor.
|
2014-05-22 22:13:20 +00:00
|
|
|
ld [H_DIVISOR],a
|
2015-08-30 06:21:54 +00:00
|
|
|
ld b,4 ; number of bytes in dividend
|
2014-05-22 22:13:20 +00:00
|
|
|
call Divide
|
2015-08-30 06:21:54 +00:00
|
|
|
|
|
|
|
; Divide the enemy's current HP by 4. HP is not supposed to exceed 999 so
|
|
|
|
; the result should fit in a. If the division results in a quotient of 0,
|
|
|
|
; change it to 1.
|
2014-06-14 11:12:40 +00:00
|
|
|
ld hl,wEnemyMonHP
|
2014-05-22 22:13:20 +00:00
|
|
|
ld a,[hli]
|
|
|
|
ld b,a
|
|
|
|
ld a,[hl]
|
|
|
|
srl b
|
|
|
|
rr a
|
|
|
|
srl b
|
2015-08-30 06:21:54 +00:00
|
|
|
rr a
|
2014-05-22 22:13:20 +00:00
|
|
|
and a
|
2015-08-30 07:15:59 +00:00
|
|
|
jr nz,.skip2
|
2014-05-22 22:13:20 +00:00
|
|
|
inc a
|
2015-08-30 06:21:54 +00:00
|
|
|
|
2015-08-30 07:15:59 +00:00
|
|
|
.skip2
|
2015-08-30 06:21:54 +00:00
|
|
|
; Let W = ((MaxHP * 255) / BallFactor) / max(HP / 4, 1). Calculate W.
|
2014-05-22 22:13:20 +00:00
|
|
|
ld [H_DIVISOR],a
|
|
|
|
ld b,4
|
2015-08-30 06:21:54 +00:00
|
|
|
call Divide
|
|
|
|
|
|
|
|
; If W > 255, store 255 in [H_QUOTIENT + 3].
|
|
|
|
; Let X = min(W, 255) = [H_QUOTIENT + 3].
|
2014-05-22 22:13:20 +00:00
|
|
|
ld a,[H_QUOTIENT + 2]
|
|
|
|
and a
|
2015-08-30 07:15:59 +00:00
|
|
|
jr z,.skip3
|
2014-05-22 22:13:20 +00:00
|
|
|
ld a,255
|
|
|
|
ld [H_QUOTIENT + 3],a
|
2015-08-30 06:21:54 +00:00
|
|
|
|
2015-08-30 07:15:59 +00:00
|
|
|
.skip3
|
2015-08-30 06:21:54 +00:00
|
|
|
pop bc ; b = Rand1 - Status
|
|
|
|
|
|
|
|
; If Rand1 - Status > CatchRate, the ball fails to capture the Pokémon.
|
|
|
|
ld a,[wEnemyMonCatchRate]
|
2014-05-22 22:13:20 +00:00
|
|
|
cp b
|
2015-08-30 06:21:54 +00:00
|
|
|
jr c,.failedToCapture
|
|
|
|
|
|
|
|
; If W > 255, the ball captures the Pokémon.
|
2014-05-22 22:13:20 +00:00
|
|
|
ld a,[H_QUOTIENT + 2]
|
|
|
|
and a
|
2015-08-30 06:21:54 +00:00
|
|
|
jr nz,.captured
|
|
|
|
|
|
|
|
call Random ; Let this random number be called Rand2.
|
|
|
|
|
|
|
|
; If Rand2 > X, the ball fails to capture the Pokémon.
|
2014-05-22 22:13:20 +00:00
|
|
|
ld b,a
|
|
|
|
ld a,[H_QUOTIENT + 3]
|
|
|
|
cp b
|
2015-08-30 06:21:54 +00:00
|
|
|
jr c,.failedToCapture
|
|
|
|
|
|
|
|
.captured
|
|
|
|
jr .skipShakeCalculations
|
|
|
|
|
|
|
|
.failedToCapture
|
2014-05-22 22:13:20 +00:00
|
|
|
ld a,[H_QUOTIENT + 3]
|
2015-08-30 06:21:54 +00:00
|
|
|
ld [wPokeBallCaptureCalcTemp],a ; Save X.
|
|
|
|
|
|
|
|
; Calculate CatchRate * 100.
|
2014-05-22 22:13:20 +00:00
|
|
|
xor a
|
|
|
|
ld [H_MULTIPLICAND],a
|
|
|
|
ld [H_MULTIPLICAND + 1],a
|
2015-08-30 06:21:54 +00:00
|
|
|
ld a,[wEnemyMonCatchRate]
|
2014-05-22 22:13:20 +00:00
|
|
|
ld [H_MULTIPLICAND + 2],a
|
|
|
|
ld a,100
|
|
|
|
ld [H_MULTIPLIER],a
|
2015-08-30 06:21:54 +00:00
|
|
|
call Multiply
|
|
|
|
|
|
|
|
; Determine BallFactor2.
|
|
|
|
; Poké Ball: BallFactor2 = 255
|
|
|
|
; Great Ball: BallFactor2 = 200
|
|
|
|
; Ultra/Safari Ball: BallFactor2 = 150
|
2014-05-26 21:04:56 +00:00
|
|
|
ld a,[wcf91]
|
2014-05-22 22:13:20 +00:00
|
|
|
ld b,255
|
|
|
|
cp a,POKE_BALL
|
2015-08-30 07:15:59 +00:00
|
|
|
jr z,.skip4
|
2014-05-22 22:13:20 +00:00
|
|
|
ld b,200
|
|
|
|
cp a,GREAT_BALL
|
2015-08-30 07:15:59 +00:00
|
|
|
jr z,.skip4
|
2014-05-22 22:13:20 +00:00
|
|
|
ld b,150
|
|
|
|
cp a,ULTRA_BALL
|
2015-08-30 07:15:59 +00:00
|
|
|
jr z,.skip4
|
2015-08-30 06:21:54 +00:00
|
|
|
|
2015-08-30 07:15:59 +00:00
|
|
|
.skip4
|
2015-08-30 06:21:54 +00:00
|
|
|
; Let Y = (CatchRate * 100) / BallFactor2. Calculate Y.
|
2014-05-22 22:13:20 +00:00
|
|
|
ld a,b
|
|
|
|
ld [H_DIVISOR],a
|
|
|
|
ld b,4
|
|
|
|
call Divide
|
2015-08-30 06:21:54 +00:00
|
|
|
|
|
|
|
; If Y > 255, there are 3 shakes.
|
|
|
|
; Note that this shouldn't be possible.
|
|
|
|
; The maximum value of Y is (255 * 100) / 150 = 170.
|
2014-05-22 22:13:20 +00:00
|
|
|
ld a,[H_QUOTIENT + 2]
|
|
|
|
and a
|
2015-08-30 06:21:54 +00:00
|
|
|
ld b,$63 ; 3 shakes
|
|
|
|
jr nz,.setAnimData
|
|
|
|
|
|
|
|
; Calculate X * Y.
|
|
|
|
ld a,[wPokeBallCaptureCalcTemp]
|
2014-05-22 22:13:20 +00:00
|
|
|
ld [H_MULTIPLIER],a
|
|
|
|
call Multiply
|
2015-08-30 06:21:54 +00:00
|
|
|
|
|
|
|
; Calculate (X * Y) / 255.
|
2014-05-22 22:13:20 +00:00
|
|
|
ld a,255
|
|
|
|
ld [H_DIVISOR],a
|
|
|
|
ld b,4
|
|
|
|
call Divide
|
2015-08-30 06:21:54 +00:00
|
|
|
|
|
|
|
; Determine Status2.
|
|
|
|
; no status ailment: Status2 = 0
|
|
|
|
; Burn/Paralysis/Poison: Status2 = 5
|
|
|
|
; Freeze/Sleep: Status2 = 10
|
|
|
|
ld a,[wEnemyMonStatus]
|
2014-05-22 22:13:20 +00:00
|
|
|
and a
|
2015-08-30 07:15:59 +00:00
|
|
|
jr z,.skip5
|
2014-05-22 22:13:20 +00:00
|
|
|
and a, 1 << FRZ | SLP
|
|
|
|
ld b,5
|
2015-08-30 07:15:59 +00:00
|
|
|
jr z,.addAilmentValue
|
2014-05-22 22:13:20 +00:00
|
|
|
ld b,10
|
2015-08-30 06:21:54 +00:00
|
|
|
|
2015-08-30 07:15:59 +00:00
|
|
|
.addAilmentValue
|
2015-08-30 06:21:54 +00:00
|
|
|
; If the Pokémon has a status ailment, add Status2.
|
2014-05-22 22:13:20 +00:00
|
|
|
ld a,[H_QUOTIENT + 3]
|
|
|
|
add b
|
|
|
|
ld [H_QUOTIENT + 3],a
|
2015-08-30 06:21:54 +00:00
|
|
|
|
2015-08-30 07:15:59 +00:00
|
|
|
.skip5
|
2015-08-30 06:21:54 +00:00
|
|
|
; Finally determine the number of shakes.
|
2015-08-30 07:15:59 +00:00
|
|
|
; Let Z = ((X * Y) / 255) + Status2 = [H_QUOTIENT + 3].
|
2015-08-30 06:21:54 +00:00
|
|
|
; The number of shakes depend on the range Z is in.
|
|
|
|
; 0 ≤ Z < 10: 0 shakes (the ball misses)
|
|
|
|
; 10 ≤ Z < 30: 1 shake
|
|
|
|
; 30 ≤ Z < 70: 2 shakes
|
|
|
|
; 70 ≤ Z: 3 shakes
|
2014-05-22 22:13:20 +00:00
|
|
|
ld a,[H_QUOTIENT + 3]
|
|
|
|
cp a,10
|
|
|
|
ld b,$20
|
2015-08-30 06:21:54 +00:00
|
|
|
jr c,.setAnimData
|
2014-05-22 22:13:20 +00:00
|
|
|
cp a,30
|
|
|
|
ld b,$61
|
2015-08-30 06:21:54 +00:00
|
|
|
jr c,.setAnimData
|
2014-05-22 22:13:20 +00:00
|
|
|
cp a,70
|
|
|
|
ld b,$62
|
2015-08-30 06:21:54 +00:00
|
|
|
jr c,.setAnimData
|
2014-05-22 22:13:20 +00:00
|
|
|
ld b,$63
|
2015-08-30 06:21:54 +00:00
|
|
|
|
|
|
|
.setAnimData
|
2014-05-22 22:13:20 +00:00
|
|
|
ld a,b
|
2015-08-07 12:20:37 +00:00
|
|
|
ld [wPokeBallAnimData],a
|
2015-08-30 06:21:54 +00:00
|
|
|
|
|
|
|
.skipShakeCalculations
|
2014-05-22 22:13:20 +00:00
|
|
|
ld c,20
|
|
|
|
call DelayFrames
|
2015-08-30 06:21:54 +00:00
|
|
|
|
|
|
|
; Do the animation.
|
2014-05-22 22:13:20 +00:00
|
|
|
ld a,TOSS_ANIM
|
2015-08-31 02:38:41 +00:00
|
|
|
ld [wAnimationID],a
|
2014-05-22 22:13:20 +00:00
|
|
|
xor a
|
2015-07-24 21:39:45 +00:00
|
|
|
ld [H_WHOSETURN],a
|
2015-03-31 19:09:43 +00:00
|
|
|
ld [wAnimationType],a
|
2015-03-31 18:28:42 +00:00
|
|
|
ld [wDamageMultipliers],a
|
2014-05-22 22:13:20 +00:00
|
|
|
ld a,[wWhichPokemon]
|
|
|
|
push af
|
2014-05-26 21:04:56 +00:00
|
|
|
ld a,[wcf91]
|
2014-05-22 22:13:20 +00:00
|
|
|
push af
|
2014-06-16 20:57:26 +00:00
|
|
|
predef MoveAnimation
|
2014-05-22 22:13:20 +00:00
|
|
|
pop af
|
2014-05-26 21:04:56 +00:00
|
|
|
ld [wcf91],a
|
2014-05-22 22:13:20 +00:00
|
|
|
pop af
|
|
|
|
ld [wWhichPokemon],a
|
2015-08-30 06:21:54 +00:00
|
|
|
|
|
|
|
; Determine the message to display from the animation.
|
2015-08-07 12:20:37 +00:00
|
|
|
ld a,[wPokeBallAnimData]
|
2014-05-22 22:13:20 +00:00
|
|
|
cp a,$10
|
|
|
|
ld hl,ItemUseBallText00
|
2015-08-30 06:21:54 +00:00
|
|
|
jp z,.printMessage
|
2014-05-22 22:13:20 +00:00
|
|
|
cp a,$20
|
|
|
|
ld hl,ItemUseBallText01
|
2015-08-30 06:21:54 +00:00
|
|
|
jp z,.printMessage
|
2014-05-22 22:13:20 +00:00
|
|
|
cp a,$61
|
|
|
|
ld hl,ItemUseBallText02
|
2015-08-30 06:21:54 +00:00
|
|
|
jp z,.printMessage
|
2014-05-22 22:13:20 +00:00
|
|
|
cp a,$62
|
|
|
|
ld hl,ItemUseBallText03
|
2015-08-30 06:21:54 +00:00
|
|
|
jp z,.printMessage
|
2014-05-22 22:13:20 +00:00
|
|
|
cp a,$63
|
|
|
|
ld hl,ItemUseBallText04
|
2015-08-30 06:21:54 +00:00
|
|
|
jp z,.printMessage
|
|
|
|
|
|
|
|
; Save current HP.
|
|
|
|
ld hl,wEnemyMonHP
|
2014-05-22 22:13:20 +00:00
|
|
|
ld a,[hli]
|
|
|
|
push af
|
|
|
|
ld a,[hli]
|
2015-08-30 06:21:54 +00:00
|
|
|
push af
|
|
|
|
|
|
|
|
; Save status ailment.
|
2014-05-22 22:13:20 +00:00
|
|
|
inc hl
|
|
|
|
ld a,[hl]
|
2015-08-30 06:21:54 +00:00
|
|
|
push af
|
|
|
|
|
2014-05-22 22:13:20 +00:00
|
|
|
push hl
|
2015-08-30 06:21:54 +00:00
|
|
|
|
|
|
|
; If the Pokémon is transformed, the Pokémon is assumed to be a Ditto.
|
|
|
|
; This is a bug because a wild Pokémon could have used Transform via
|
|
|
|
; Mirror Move even though the only wild Pokémon that knows Transform is Ditto.
|
2015-08-31 02:38:41 +00:00
|
|
|
ld hl,wEnemyBattleStatus3
|
2015-02-03 19:51:53 +00:00
|
|
|
bit Transformed,[hl]
|
2015-08-30 06:21:54 +00:00
|
|
|
jr z,.notTransformed
|
|
|
|
ld a,DITTO
|
2014-06-14 11:12:40 +00:00
|
|
|
ld [wEnemyMonSpecies2],a
|
2015-08-30 07:15:59 +00:00
|
|
|
jr .skip6
|
2015-08-30 06:21:54 +00:00
|
|
|
|
|
|
|
.notTransformed
|
|
|
|
; If the Pokémon is not transformed, set the transformed bit and copy the
|
|
|
|
; DVs to wTransformedEnemyMonOriginalDVs so that LoadEnemyMonData won't generate
|
|
|
|
; new DVs.
|
2015-02-03 19:51:53 +00:00
|
|
|
set Transformed,[hl]
|
2015-08-14 07:36:06 +00:00
|
|
|
ld hl,wTransformedEnemyMonOriginalDVs
|
2014-06-14 11:12:40 +00:00
|
|
|
ld a,[wEnemyMonDVs]
|
2014-05-22 22:13:20 +00:00
|
|
|
ld [hli],a
|
2014-06-14 11:12:40 +00:00
|
|
|
ld a,[wEnemyMonDVs + 1]
|
2014-05-22 22:13:20 +00:00
|
|
|
ld [hl],a
|
2015-08-30 06:21:54 +00:00
|
|
|
|
2015-08-30 07:15:59 +00:00
|
|
|
.skip6
|
2014-05-26 21:04:56 +00:00
|
|
|
ld a,[wcf91]
|
2014-05-22 22:13:20 +00:00
|
|
|
push af
|
2014-06-14 11:12:40 +00:00
|
|
|
ld a,[wEnemyMonSpecies2]
|
2014-05-26 21:04:56 +00:00
|
|
|
ld [wcf91],a
|
2014-06-14 11:12:40 +00:00
|
|
|
ld a,[wEnemyMonLevel]
|
2015-08-31 02:38:41 +00:00
|
|
|
ld [wCurEnemyLVL],a
|
2014-08-09 05:39:13 +00:00
|
|
|
callab LoadEnemyMonData
|
2014-05-22 22:13:20 +00:00
|
|
|
pop af
|
2014-05-26 21:04:56 +00:00
|
|
|
ld [wcf91],a
|
2014-05-22 22:13:20 +00:00
|
|
|
pop hl
|
|
|
|
pop af
|
|
|
|
ld [hld],a
|
|
|
|
dec hl
|
|
|
|
pop af
|
|
|
|
ld [hld],a
|
|
|
|
pop af
|
|
|
|
ld [hl],a
|
2015-08-30 06:21:54 +00:00
|
|
|
ld a,[wEnemyMonSpecies]
|
2015-07-25 03:27:59 +00:00
|
|
|
ld [wCapturedMonSpecies],a
|
2014-05-26 21:04:56 +00:00
|
|
|
ld [wcf91],a
|
|
|
|
ld [wd11e],a
|
2015-08-31 02:38:41 +00:00
|
|
|
ld a,[wBattleType]
|
2015-08-30 06:21:54 +00:00
|
|
|
dec a ; is this the old man battle?
|
|
|
|
jr z,.oldManCaughtMon ; if so, don't give the player the caught Pokémon
|
|
|
|
|
2014-05-22 22:13:20 +00:00
|
|
|
ld hl,ItemUseBallText05
|
|
|
|
call PrintText
|
2015-08-30 06:21:54 +00:00
|
|
|
|
|
|
|
; Add the caught Pokémon to the Pokédex.
|
2014-06-16 20:57:26 +00:00
|
|
|
predef IndexToPokedex
|
2014-05-26 21:04:56 +00:00
|
|
|
ld a,[wd11e]
|
2014-05-22 22:13:20 +00:00
|
|
|
dec a
|
|
|
|
ld c,a
|
2015-07-20 03:45:34 +00:00
|
|
|
ld b,FLAG_TEST
|
|
|
|
ld hl,wPokedexOwned
|
2014-06-16 20:57:26 +00:00
|
|
|
predef FlagActionPredef
|
2014-05-22 22:13:20 +00:00
|
|
|
ld a,c
|
|
|
|
push af
|
2014-05-26 21:04:56 +00:00
|
|
|
ld a,[wd11e]
|
2014-05-22 22:13:20 +00:00
|
|
|
dec a
|
|
|
|
ld c,a
|
2015-07-20 03:45:34 +00:00
|
|
|
ld b,FLAG_SET
|
2014-06-16 20:57:26 +00:00
|
|
|
predef FlagActionPredef
|
2014-05-22 22:13:20 +00:00
|
|
|
pop af
|
2015-08-30 06:21:54 +00:00
|
|
|
|
|
|
|
and a ; was the Pokémon already in the Pokédex?
|
|
|
|
jr nz,.skipShowingPokedexData ; if so, don't show the Pokédex data
|
|
|
|
|
2014-05-22 22:13:20 +00:00
|
|
|
ld hl,ItemUseBallText06
|
|
|
|
call PrintText
|
2014-05-23 22:34:35 +00:00
|
|
|
call ClearSprites
|
2015-08-30 06:21:54 +00:00
|
|
|
ld a,[wEnemyMonSpecies]
|
2014-05-26 21:04:56 +00:00
|
|
|
ld [wd11e],a
|
2014-06-16 20:57:26 +00:00
|
|
|
predef ShowPokedexData
|
2015-08-30 06:21:54 +00:00
|
|
|
|
|
|
|
.skipShowingPokedexData
|
2014-06-14 11:12:40 +00:00
|
|
|
ld a,[wPartyCount]
|
2015-08-30 06:21:54 +00:00
|
|
|
cp a,PARTY_LENGTH ; is party full?
|
2014-05-22 22:13:20 +00:00
|
|
|
jr z,.sendToBox
|
2015-07-16 03:04:58 +00:00
|
|
|
xor a ; PLAYER_PARTY_DATA
|
|
|
|
ld [wMonDataLocation],a
|
2014-05-23 22:34:35 +00:00
|
|
|
call ClearSprites
|
2015-08-30 06:21:54 +00:00
|
|
|
call AddPartyMon
|
|
|
|
jr .done
|
|
|
|
|
2015-07-03 19:37:53 +00:00
|
|
|
.sendToBox
|
2014-05-23 22:34:35 +00:00
|
|
|
call ClearSprites
|
2015-02-08 06:18:42 +00:00
|
|
|
call SendNewMonToBox
|
2014-05-22 22:13:20 +00:00
|
|
|
ld hl,ItemUseBallText07
|
2015-07-21 17:36:03 +00:00
|
|
|
CheckEvent EVENT_MET_BILL
|
2015-08-30 06:21:54 +00:00
|
|
|
jr nz,.printTransferredToPCText
|
2014-05-22 22:13:20 +00:00
|
|
|
ld hl,ItemUseBallText08
|
2015-08-30 06:21:54 +00:00
|
|
|
.printTransferredToPCText
|
2014-05-22 22:13:20 +00:00
|
|
|
call PrintText
|
2015-08-30 06:21:54 +00:00
|
|
|
jr .done
|
|
|
|
|
|
|
|
.oldManCaughtMon
|
2014-05-22 22:13:20 +00:00
|
|
|
ld hl,ItemUseBallText05
|
2015-08-30 06:21:54 +00:00
|
|
|
|
|
|
|
.printMessage
|
2014-05-22 22:13:20 +00:00
|
|
|
call PrintText
|
2014-05-23 22:34:35 +00:00
|
|
|
call ClearSprites
|
2015-08-30 06:21:54 +00:00
|
|
|
|
|
|
|
.done
|
2015-08-31 02:38:41 +00:00
|
|
|
ld a,[wBattleType]
|
2015-08-30 06:21:54 +00:00
|
|
|
and a ; is this the old man battle?
|
|
|
|
ret nz ; if so, don't remove a ball from the bag
|
|
|
|
|
|
|
|
; Remove a ball from the bag.
|
2014-05-26 21:04:56 +00:00
|
|
|
ld hl,wNumBagItems
|
2014-05-22 22:13:20 +00:00
|
|
|
inc a
|
2015-07-13 06:00:48 +00:00
|
|
|
ld [wItemQuantity],a
|
2015-07-03 19:37:53 +00:00
|
|
|
jp RemoveItemFromInventory
|
2015-08-30 06:21:54 +00:00
|
|
|
|
2016-06-12 00:24:04 +00:00
|
|
|
ItemUseBallText00:
|
2014-05-22 22:13:20 +00:00
|
|
|
;"It dodged the thrown ball!"
|
|
|
|
;"This pokemon can't be caught"
|
|
|
|
TX_FAR _ItemUseBallText00
|
|
|
|
db "@"
|
2016-06-12 00:24:04 +00:00
|
|
|
ItemUseBallText01:
|
2014-05-22 22:13:20 +00:00
|
|
|
;"You missed the pokemon!"
|
|
|
|
TX_FAR _ItemUseBallText01
|
|
|
|
db "@"
|
2016-06-12 00:24:04 +00:00
|
|
|
ItemUseBallText02:
|
2014-05-22 22:13:20 +00:00
|
|
|
;"Darn! The pokemon broke free!"
|
|
|
|
TX_FAR _ItemUseBallText02
|
|
|
|
db "@"
|
2016-06-12 00:24:04 +00:00
|
|
|
ItemUseBallText03:
|
2014-05-22 22:13:20 +00:00
|
|
|
;"Aww! It appeared to be caught!"
|
|
|
|
TX_FAR _ItemUseBallText03
|
|
|
|
db "@"
|
2016-06-12 00:24:04 +00:00
|
|
|
ItemUseBallText04:
|
2014-05-22 22:13:20 +00:00
|
|
|
;"Shoot! It was so close too!"
|
|
|
|
TX_FAR _ItemUseBallText04
|
|
|
|
db "@"
|
2016-06-12 00:24:04 +00:00
|
|
|
ItemUseBallText05:
|
2014-05-22 22:13:20 +00:00
|
|
|
;"All right! {MonName} was caught!"
|
|
|
|
;play sound
|
|
|
|
TX_FAR _ItemUseBallText05
|
2016-07-18 06:17:03 +00:00
|
|
|
TX_SFX_CAUGHT_MON
|
|
|
|
TX_BLINK
|
2014-05-22 22:13:20 +00:00
|
|
|
db "@"
|
2016-06-12 00:24:04 +00:00
|
|
|
ItemUseBallText07:
|
2014-05-22 22:13:20 +00:00
|
|
|
;"X was transferred to Bill's PC"
|
|
|
|
TX_FAR _ItemUseBallText07
|
|
|
|
db "@"
|
2016-06-12 00:24:04 +00:00
|
|
|
ItemUseBallText08:
|
2014-05-22 22:13:20 +00:00
|
|
|
;"X was transferred to someone's PC"
|
|
|
|
TX_FAR _ItemUseBallText08
|
|
|
|
db "@"
|
|
|
|
|
2016-06-12 00:24:04 +00:00
|
|
|
ItemUseBallText06:
|
2014-05-22 22:13:20 +00:00
|
|
|
;"New DEX data will be added..."
|
|
|
|
;play sound
|
|
|
|
TX_FAR _ItemUseBallText06
|
2016-07-18 06:17:03 +00:00
|
|
|
TX_SFX_DEX_PAGE_ADDED
|
|
|
|
TX_BLINK
|
2014-05-22 22:13:20 +00:00
|
|
|
db "@"
|
|
|
|
|
2016-06-12 00:24:04 +00:00
|
|
|
ItemUseTownMap:
|
2015-08-31 02:38:41 +00:00
|
|
|
ld a,[wIsInBattle]
|
2014-05-22 22:13:20 +00:00
|
|
|
and a
|
|
|
|
jp nz,ItemUseNotTime
|
2015-07-19 18:56:13 +00:00
|
|
|
jpba DisplayTownMap
|
2014-05-22 22:13:20 +00:00
|
|
|
|
2016-06-12 00:24:04 +00:00
|
|
|
ItemUseBicycle:
|
2015-08-31 02:38:41 +00:00
|
|
|
ld a,[wIsInBattle]
|
2014-05-22 22:13:20 +00:00
|
|
|
and a
|
|
|
|
jp nz,ItemUseNotTime
|
2014-09-13 07:50:56 +00:00
|
|
|
ld a,[wWalkBikeSurfState]
|
|
|
|
ld [wWalkBikeSurfStateCopy],a
|
2014-05-22 22:13:20 +00:00
|
|
|
cp a,2 ; is the player surfing?
|
|
|
|
jp z,ItemUseNotTime
|
|
|
|
dec a ; is player already bicycling?
|
|
|
|
jr nz,.tryToGetOnBike
|
|
|
|
.getOffBike
|
|
|
|
call ItemUseReloadOverworldData
|
|
|
|
xor a
|
2014-09-13 07:50:56 +00:00
|
|
|
ld [wWalkBikeSurfState],a ; change player state to walking
|
2014-09-10 03:55:19 +00:00
|
|
|
call PlayDefaultMusic ; play walking music
|
2014-05-22 22:13:20 +00:00
|
|
|
ld hl,GotOffBicycleText
|
|
|
|
jr .printText
|
|
|
|
.tryToGetOnBike
|
|
|
|
call IsBikeRidingAllowed
|
|
|
|
jp nc,NoCyclingAllowedHere
|
|
|
|
call ItemUseReloadOverworldData
|
|
|
|
xor a ; no keys pressed
|
2014-05-25 17:51:53 +00:00
|
|
|
ld [hJoyHeld],a ; current joypad state
|
2014-05-22 22:13:20 +00:00
|
|
|
inc a
|
2014-09-13 07:50:56 +00:00
|
|
|
ld [wWalkBikeSurfState],a ; change player state to bicycling
|
2014-05-22 22:13:20 +00:00
|
|
|
ld hl,GotOnBicycleText
|
2014-09-10 03:55:19 +00:00
|
|
|
call PlayDefaultMusic ; play bike riding music
|
2014-05-22 22:13:20 +00:00
|
|
|
.printText
|
|
|
|
jp PrintText
|
|
|
|
|
|
|
|
; used for Surf out-of-battle effect
|
2016-06-12 00:24:04 +00:00
|
|
|
ItemUseSurfboard:
|
2014-09-13 07:50:56 +00:00
|
|
|
ld a,[wWalkBikeSurfState]
|
|
|
|
ld [wWalkBikeSurfStateCopy],a
|
2014-05-22 22:13:20 +00:00
|
|
|
cp a,2 ; is the player already surfing?
|
|
|
|
jr z,.tryToStopSurfing
|
|
|
|
.tryToSurf
|
|
|
|
call IsNextTileShoreOrWater
|
|
|
|
jp c,SurfingAttemptFailed
|
|
|
|
ld hl,TilePairCollisionsWater
|
|
|
|
call CheckForTilePairCollisions
|
|
|
|
jp c,SurfingAttemptFailed
|
|
|
|
.surf
|
|
|
|
call .makePlayerMoveForward
|
2014-05-26 21:04:56 +00:00
|
|
|
ld hl,wd730
|
2014-05-22 22:13:20 +00:00
|
|
|
set 7,[hl]
|
|
|
|
ld a,2
|
2014-09-13 07:50:56 +00:00
|
|
|
ld [wWalkBikeSurfState],a ; change player state to surfing
|
2014-09-10 03:55:19 +00:00
|
|
|
call PlayDefaultMusic ; play surfing music
|
2014-05-22 22:13:20 +00:00
|
|
|
ld hl,SurfingGotOnText
|
|
|
|
jp PrintText
|
|
|
|
.tryToStopSurfing
|
|
|
|
xor a
|
2015-07-18 15:17:29 +00:00
|
|
|
ld [hSpriteIndexOrTextID],a
|
2014-05-22 22:13:20 +00:00
|
|
|
ld d,16 ; talking range in pixels (normal range)
|
|
|
|
call IsSpriteInFrontOfPlayer2
|
|
|
|
res 7,[hl]
|
2015-07-18 15:17:29 +00:00
|
|
|
ld a,[hSpriteIndexOrTextID]
|
2014-05-22 22:13:20 +00:00
|
|
|
and a ; is there a sprite in the way?
|
|
|
|
jr nz,.cannotStopSurfing
|
|
|
|
ld hl,TilePairCollisionsWater
|
|
|
|
call CheckForTilePairCollisions
|
|
|
|
jr c,.cannotStopSurfing
|
2016-06-12 08:06:27 +00:00
|
|
|
ld hl,wTilesetCollisionPtr ; pointer to list of passable tiles
|
2014-05-22 22:13:20 +00:00
|
|
|
ld a,[hli]
|
|
|
|
ld h,[hl]
|
|
|
|
ld l,a ; hl now points to passable tiles
|
2014-09-13 07:50:56 +00:00
|
|
|
ld a,[wTileInFrontOfPlayer] ; tile in front of the player
|
2014-05-22 22:13:20 +00:00
|
|
|
ld b,a
|
|
|
|
.passableTileLoop
|
|
|
|
ld a,[hli]
|
|
|
|
cp b
|
|
|
|
jr z,.stopSurfing
|
|
|
|
cp a,$ff
|
|
|
|
jr nz,.passableTileLoop
|
|
|
|
.cannotStopSurfing
|
|
|
|
ld hl,SurfingNoPlaceToGetOffText
|
|
|
|
jp PrintText
|
|
|
|
.stopSurfing
|
|
|
|
call .makePlayerMoveForward
|
2014-05-26 21:04:56 +00:00
|
|
|
ld hl,wd730
|
2014-05-22 22:13:20 +00:00
|
|
|
set 7,[hl]
|
|
|
|
xor a
|
2014-09-13 07:50:56 +00:00
|
|
|
ld [wWalkBikeSurfState],a ; change player state to walking
|
2014-05-22 22:13:20 +00:00
|
|
|
dec a
|
2014-05-25 17:51:53 +00:00
|
|
|
ld [wJoyIgnore],a
|
2014-09-10 03:55:19 +00:00
|
|
|
call PlayDefaultMusic ; play walking music
|
2014-05-22 22:13:20 +00:00
|
|
|
jp LoadWalkingPlayerSpriteGraphics
|
|
|
|
; uses a simulated button press to make the player move forward
|
|
|
|
.makePlayerMoveForward
|
2015-07-20 00:52:26 +00:00
|
|
|
ld a,[wPlayerDirection] ; direction the player is going
|
|
|
|
bit PLAYER_DIR_BIT_UP,a
|
2014-09-10 03:55:19 +00:00
|
|
|
ld b,D_UP
|
2014-05-22 22:13:20 +00:00
|
|
|
jr nz,.storeSimulatedButtonPress
|
2015-07-20 00:52:26 +00:00
|
|
|
bit PLAYER_DIR_BIT_DOWN,a
|
2014-09-10 03:55:19 +00:00
|
|
|
ld b,D_DOWN
|
2014-05-22 22:13:20 +00:00
|
|
|
jr nz,.storeSimulatedButtonPress
|
2015-07-20 00:52:26 +00:00
|
|
|
bit PLAYER_DIR_BIT_LEFT,a
|
2014-09-10 03:55:19 +00:00
|
|
|
ld b,D_LEFT
|
2014-05-22 22:13:20 +00:00
|
|
|
jr nz,.storeSimulatedButtonPress
|
2014-09-10 03:55:19 +00:00
|
|
|
ld b,D_RIGHT
|
2014-05-22 22:13:20 +00:00
|
|
|
.storeSimulatedButtonPress
|
|
|
|
ld a,b
|
2014-09-10 03:55:19 +00:00
|
|
|
ld [wSimulatedJoypadStatesEnd],a
|
2014-05-22 22:13:20 +00:00
|
|
|
xor a
|
2014-09-10 03:55:19 +00:00
|
|
|
ld [wWastedByteCD39],a
|
2014-05-22 22:13:20 +00:00
|
|
|
inc a
|
2014-09-10 03:55:19 +00:00
|
|
|
ld [wSimulatedJoypadStatesIndex],a
|
2014-05-22 22:13:20 +00:00
|
|
|
ret
|
|
|
|
|
2016-06-12 00:24:04 +00:00
|
|
|
SurfingGotOnText:
|
2014-05-22 22:13:20 +00:00
|
|
|
TX_FAR _SurfingGotOnText
|
|
|
|
db "@"
|
|
|
|
|
2016-06-12 00:24:04 +00:00
|
|
|
SurfingNoPlaceToGetOffText:
|
2014-05-22 22:13:20 +00:00
|
|
|
TX_FAR _SurfingNoPlaceToGetOffText
|
|
|
|
db "@"
|
|
|
|
|
2016-06-12 00:24:04 +00:00
|
|
|
ItemUsePokedex:
|
2014-06-16 20:57:26 +00:00
|
|
|
predef_jump ShowPokedexMenu
|
2014-05-22 22:13:20 +00:00
|
|
|
|
2016-06-12 00:24:04 +00:00
|
|
|
ItemUseEvoStone:
|
2015-08-31 02:38:41 +00:00
|
|
|
ld a,[wIsInBattle]
|
2014-05-22 22:13:20 +00:00
|
|
|
and a
|
|
|
|
jp nz,ItemUseNotTime
|
|
|
|
ld a,[wWhichPokemon]
|
|
|
|
push af
|
2014-05-26 21:04:56 +00:00
|
|
|
ld a,[wcf91]
|
2015-07-26 02:26:54 +00:00
|
|
|
ld [wEvoStoneItemID],a
|
2014-05-22 22:13:20 +00:00
|
|
|
push af
|
2015-07-13 22:40:33 +00:00
|
|
|
ld a,EVO_STONE_PARTY_MENU
|
|
|
|
ld [wPartyMenuTypeOrMessageID],a
|
2014-05-22 22:13:20 +00:00
|
|
|
ld a,$ff
|
2014-09-13 07:50:56 +00:00
|
|
|
ld [wUpdateSpritesEnabled],a
|
2014-05-22 22:13:20 +00:00
|
|
|
call DisplayPartyMenu
|
|
|
|
pop bc
|
|
|
|
jr c,.canceledItemUse
|
|
|
|
ld a,b
|
2014-05-26 21:04:56 +00:00
|
|
|
ld [wcf91],a
|
2014-05-22 22:13:20 +00:00
|
|
|
ld a,$01
|
2015-07-14 08:46:23 +00:00
|
|
|
ld [wForceEvolution],a
|
2015-07-19 08:46:12 +00:00
|
|
|
ld a,SFX_HEAL_AILMENT
|
2015-07-03 19:37:53 +00:00
|
|
|
call PlaySoundWaitForCurrent
|
|
|
|
call WaitForSoundToFinish
|
2014-08-09 05:39:13 +00:00
|
|
|
callab TryEvolvingMon ; try to evolve pokemon
|
2015-07-25 03:27:59 +00:00
|
|
|
ld a,[wEvolutionOccurred]
|
2014-05-22 22:13:20 +00:00
|
|
|
and a
|
|
|
|
jr z,.noEffect
|
|
|
|
pop af
|
|
|
|
ld [wWhichPokemon],a
|
|
|
|
ld hl,wNumBagItems
|
|
|
|
ld a,1 ; remove 1 stone
|
2015-07-13 06:00:48 +00:00
|
|
|
ld [wItemQuantity],a
|
2014-05-22 22:13:20 +00:00
|
|
|
jp RemoveItemFromInventory
|
|
|
|
.noEffect
|
|
|
|
call ItemUseNoEffect
|
|
|
|
.canceledItemUse
|
|
|
|
xor a
|
2015-07-15 06:16:06 +00:00
|
|
|
ld [wActionResultOrTookBattleTurn],a ; item not used
|
2014-05-22 22:13:20 +00:00
|
|
|
pop af
|
|
|
|
ret
|
|
|
|
|
2016-06-12 00:24:04 +00:00
|
|
|
ItemUseVitamin:
|
2015-08-31 02:38:41 +00:00
|
|
|
ld a,[wIsInBattle]
|
2014-05-22 22:13:20 +00:00
|
|
|
and a
|
|
|
|
jp nz,ItemUseNotTime
|
|
|
|
|
2016-06-12 00:24:04 +00:00
|
|
|
ItemUseMedicine:
|
2014-06-14 11:12:40 +00:00
|
|
|
ld a,[wPartyCount]
|
2014-05-22 22:13:20 +00:00
|
|
|
and a
|
|
|
|
jp z,.emptyParty
|
|
|
|
ld a,[wWhichPokemon]
|
|
|
|
push af
|
2014-05-26 21:04:56 +00:00
|
|
|
ld a,[wcf91]
|
2014-05-22 22:13:20 +00:00
|
|
|
push af
|
2015-07-13 22:40:33 +00:00
|
|
|
ld a,USE_ITEM_PARTY_MENU
|
|
|
|
ld [wPartyMenuTypeOrMessageID],a
|
2014-05-22 22:13:20 +00:00
|
|
|
ld a,$ff
|
2014-09-13 07:50:56 +00:00
|
|
|
ld [wUpdateSpritesEnabled],a
|
2015-07-26 02:26:54 +00:00
|
|
|
ld a,[wPseudoItemID]
|
2014-05-22 22:13:20 +00:00
|
|
|
and a ; using Softboiled?
|
|
|
|
jr z,.notUsingSoftboiled
|
|
|
|
; if using softboiled
|
|
|
|
call GoBackToPartyMenu
|
|
|
|
jr .getPartyMonDataAddress
|
|
|
|
.emptyParty
|
|
|
|
ld hl,.emptyPartyText
|
|
|
|
xor a
|
2015-07-15 06:16:06 +00:00
|
|
|
ld [wActionResultOrTookBattleTurn],a ; item use failed
|
2014-05-22 22:13:20 +00:00
|
|
|
jp PrintText
|
|
|
|
.emptyPartyText
|
|
|
|
text "You don't have"
|
|
|
|
line "any #MON!"
|
|
|
|
prompt
|
|
|
|
.notUsingSoftboiled
|
|
|
|
call DisplayPartyMenu
|
|
|
|
.getPartyMonDataAddress
|
|
|
|
jp c,.canceledItemUse
|
2014-06-14 11:12:40 +00:00
|
|
|
ld hl,wPartyMons
|
|
|
|
ld bc,wPartyMon2 - wPartyMon1
|
2014-05-22 22:13:20 +00:00
|
|
|
ld a,[wWhichPokemon]
|
|
|
|
call AddNTimes
|
|
|
|
ld a,[wWhichPokemon]
|
2015-07-15 06:16:06 +00:00
|
|
|
ld [wUsedItemOnWhichPokemon],a
|
2014-05-22 22:13:20 +00:00
|
|
|
ld d,a
|
2014-05-26 21:04:56 +00:00
|
|
|
ld a,[wcf91]
|
2014-05-22 22:13:20 +00:00
|
|
|
ld e,a
|
2014-05-26 21:04:56 +00:00
|
|
|
ld [wd0b5],a
|
2014-05-22 22:13:20 +00:00
|
|
|
pop af
|
2014-05-26 21:04:56 +00:00
|
|
|
ld [wcf91],a
|
2014-05-22 22:13:20 +00:00
|
|
|
pop af
|
|
|
|
ld [wWhichPokemon],a
|
2015-07-26 02:26:54 +00:00
|
|
|
ld a,[wPseudoItemID]
|
2014-05-22 22:13:20 +00:00
|
|
|
and a ; using Softboiled?
|
|
|
|
jr z,.checkItemType
|
|
|
|
; if using softboiled
|
|
|
|
ld a,[wWhichPokemon]
|
|
|
|
cp d ; is the pokemon trying to use softboiled on itself?
|
|
|
|
jr z,ItemUseMedicine ; if so, force another choice
|
|
|
|
.checkItemType
|
2014-05-26 21:04:56 +00:00
|
|
|
ld a,[wcf91]
|
2014-05-22 22:13:20 +00:00
|
|
|
cp a,REVIVE
|
|
|
|
jr nc,.healHP ; if it's a Revive or Max Revive
|
|
|
|
cp a,FULL_HEAL
|
|
|
|
jr z,.cureStatusAilment ; if it's a Full Heal
|
|
|
|
cp a,HP_UP
|
|
|
|
jp nc,.useVitamin ; if it's a vitamin or Rare Candy
|
|
|
|
cp a,FULL_RESTORE
|
|
|
|
jr nc,.healHP ; if it's a Full Restore or one of the potions
|
|
|
|
; fall through if it's one of the status-specifc healing items
|
|
|
|
.cureStatusAilment
|
2016-02-21 20:59:33 +00:00
|
|
|
ld bc,wPartyMon1Status - wPartyMon1
|
2014-05-22 22:13:20 +00:00
|
|
|
add hl,bc ; hl now points to status
|
2014-05-26 21:04:56 +00:00
|
|
|
ld a,[wcf91]
|
2015-08-05 21:20:29 +00:00
|
|
|
lb bc, ANTIDOTE_MSG, 1 << PSN
|
2014-05-22 22:13:20 +00:00
|
|
|
cp a,ANTIDOTE
|
|
|
|
jr z,.checkMonStatus
|
2015-08-05 21:20:29 +00:00
|
|
|
lb bc, BURN_HEAL_MSG, 1 << BRN
|
2014-05-22 22:13:20 +00:00
|
|
|
cp a,BURN_HEAL
|
|
|
|
jr z,.checkMonStatus
|
2015-08-05 21:20:29 +00:00
|
|
|
lb bc, ICE_HEAL_MSG, 1 << FRZ
|
2014-05-22 22:13:20 +00:00
|
|
|
cp a,ICE_HEAL
|
|
|
|
jr z,.checkMonStatus
|
2015-08-05 21:20:29 +00:00
|
|
|
lb bc, AWAKENING_MSG, SLP
|
2014-05-22 22:13:20 +00:00
|
|
|
cp a,AWAKENING
|
|
|
|
jr z,.checkMonStatus
|
2015-08-05 21:20:29 +00:00
|
|
|
lb bc, PARALYZ_HEAL_MSG, 1 << PAR
|
2014-05-22 22:13:20 +00:00
|
|
|
cp a,PARLYZ_HEAL
|
|
|
|
jr z,.checkMonStatus
|
2015-08-05 21:20:29 +00:00
|
|
|
lb bc, FULL_HEAL_MSG, $ff ; Full Heal
|
2014-05-22 22:13:20 +00:00
|
|
|
.checkMonStatus
|
|
|
|
ld a,[hl] ; pokemon's status
|
|
|
|
and c ; does the pokemon have a status ailment the item can cure?
|
|
|
|
jp z,.healingItemNoEffect
|
|
|
|
; if the pokemon has a status the item can heal
|
|
|
|
xor a
|
|
|
|
ld [hl],a ; remove the status ailment in the party data
|
|
|
|
ld a,b
|
2015-07-13 22:40:33 +00:00
|
|
|
ld [wPartyMenuTypeOrMessageID],a ; the message to display for the item used
|
2014-05-22 22:13:20 +00:00
|
|
|
ld a,[wPlayerMonNumber]
|
|
|
|
cp d ; is pokemon the item was used on active in battle?
|
|
|
|
jp nz,.doneHealing
|
|
|
|
; if it is active in battle
|
|
|
|
xor a
|
2014-06-14 11:12:40 +00:00
|
|
|
ld [wBattleMonStatus],a ; remove the status ailment in the in-battle pokemon data
|
2014-05-22 22:13:20 +00:00
|
|
|
push hl
|
2015-08-31 02:38:41 +00:00
|
|
|
ld hl,wPlayerBattleStatus3
|
2015-02-03 19:51:53 +00:00
|
|
|
res BadlyPoisoned,[hl] ; heal Toxic status
|
2014-05-22 22:13:20 +00:00
|
|
|
pop hl
|
2015-08-30 07:44:13 +00:00
|
|
|
ld bc,wPartyMon1Stats - wPartyMon1Status
|
2014-05-22 22:13:20 +00:00
|
|
|
add hl,bc ; hl now points to party stats
|
2015-08-30 07:44:13 +00:00
|
|
|
ld de,wBattleMonStats
|
|
|
|
ld bc,NUM_STATS * 2
|
2014-05-22 22:13:20 +00:00
|
|
|
call CopyData ; copy party stats to in-battle stat data
|
2015-02-08 09:44:41 +00:00
|
|
|
predef DoubleOrHalveSelectedStats
|
2014-05-22 22:13:20 +00:00
|
|
|
jp .doneHealing
|
|
|
|
.healHP
|
|
|
|
inc hl ; hl = address of current HP
|
|
|
|
ld a,[hli]
|
|
|
|
ld b,a
|
|
|
|
ld [wHPBarOldHP+1],a
|
|
|
|
ld a,[hl]
|
|
|
|
ld c,a
|
2014-05-26 21:04:56 +00:00
|
|
|
ld [wHPBarOldHP],a ; current HP stored at wHPBarOldHP (2 bytes, big-endian)
|
2014-05-22 22:13:20 +00:00
|
|
|
or b
|
|
|
|
jr nz,.notFainted
|
|
|
|
.fainted
|
2014-05-26 21:04:56 +00:00
|
|
|
ld a,[wcf91]
|
2014-05-22 22:13:20 +00:00
|
|
|
cp a,REVIVE
|
|
|
|
jr z,.updateInBattleFaintedData
|
|
|
|
cp a,MAX_REVIVE
|
|
|
|
jr z,.updateInBattleFaintedData
|
|
|
|
jp .healingItemNoEffect
|
|
|
|
.updateInBattleFaintedData
|
2015-08-31 02:38:41 +00:00
|
|
|
ld a,[wIsInBattle]
|
2014-05-22 22:13:20 +00:00
|
|
|
and a
|
|
|
|
jr z,.compareCurrentHPToMaxHP
|
|
|
|
push hl
|
|
|
|
push de
|
|
|
|
push bc
|
2015-07-15 06:16:06 +00:00
|
|
|
ld a,[wUsedItemOnWhichPokemon]
|
2014-05-22 22:13:20 +00:00
|
|
|
ld c,a
|
2014-08-09 05:39:13 +00:00
|
|
|
ld hl,wPartyFoughtCurrentEnemyFlags
|
2015-07-20 03:45:34 +00:00
|
|
|
ld b,FLAG_TEST
|
2014-06-16 20:57:26 +00:00
|
|
|
predef FlagActionPredef
|
2014-05-22 22:13:20 +00:00
|
|
|
ld a,c
|
|
|
|
and a
|
|
|
|
jr z,.next
|
2015-07-15 06:16:06 +00:00
|
|
|
ld a,[wUsedItemOnWhichPokemon]
|
2014-05-22 22:13:20 +00:00
|
|
|
ld c,a
|
2014-08-09 05:39:13 +00:00
|
|
|
ld hl,wPartyGainExpFlags
|
2015-07-20 03:45:34 +00:00
|
|
|
ld b,FLAG_SET
|
2014-06-16 20:57:26 +00:00
|
|
|
predef FlagActionPredef
|
2014-05-22 22:13:20 +00:00
|
|
|
.next
|
|
|
|
pop bc
|
|
|
|
pop de
|
|
|
|
pop hl
|
|
|
|
jr .compareCurrentHPToMaxHP
|
|
|
|
.notFainted
|
2014-05-26 21:04:56 +00:00
|
|
|
ld a,[wcf91]
|
2014-05-22 22:13:20 +00:00
|
|
|
cp a,REVIVE
|
|
|
|
jp z,.healingItemNoEffect
|
|
|
|
cp a,MAX_REVIVE
|
|
|
|
jp z,.healingItemNoEffect
|
|
|
|
.compareCurrentHPToMaxHP
|
|
|
|
push hl
|
|
|
|
push bc
|
2015-08-30 07:44:13 +00:00
|
|
|
ld bc,wPartyMon1MaxHP - (wPartyMon1HP + 1)
|
2014-05-22 22:13:20 +00:00
|
|
|
add hl,bc ; hl now points to max HP
|
|
|
|
pop bc
|
|
|
|
ld a,[hli]
|
|
|
|
cp b
|
|
|
|
jr nz,.skipComparingLSB ; no need to compare the LSB's if the MSB's don't match
|
|
|
|
ld a,[hl]
|
|
|
|
cp c
|
|
|
|
.skipComparingLSB
|
|
|
|
pop hl
|
|
|
|
jr nz,.notFullHP
|
|
|
|
.fullHP ; if the pokemon's current HP equals its max HP
|
2014-05-26 21:04:56 +00:00
|
|
|
ld a,[wcf91]
|
2014-05-22 22:13:20 +00:00
|
|
|
cp a,FULL_RESTORE
|
|
|
|
jp nz,.healingItemNoEffect
|
|
|
|
inc hl
|
|
|
|
inc hl
|
|
|
|
ld a,[hld] ; status ailment
|
|
|
|
and a ; does the pokemon have a status ailment?
|
|
|
|
jp z,.healingItemNoEffect
|
|
|
|
ld a,FULL_HEAL
|
2014-05-26 21:04:56 +00:00
|
|
|
ld [wcf91],a
|
2014-05-22 22:13:20 +00:00
|
|
|
dec hl
|
|
|
|
dec hl
|
|
|
|
dec hl
|
|
|
|
jp .cureStatusAilment
|
|
|
|
.notFullHP ; if the pokemon's current HP doesn't equal its max HP
|
|
|
|
xor a
|
2015-03-12 14:49:35 +00:00
|
|
|
ld [wLowHealthAlarm],a ;disable low health alarm
|
2016-07-28 03:08:13 +00:00
|
|
|
ld [wChannelSoundIDs + Ch4],a
|
2014-05-22 22:13:20 +00:00
|
|
|
push hl
|
|
|
|
push de
|
2015-08-30 07:44:13 +00:00
|
|
|
ld bc,wPartyMon1MaxHP - (wPartyMon1HP + 1)
|
2014-05-22 22:13:20 +00:00
|
|
|
add hl,bc ; hl now points to max HP
|
|
|
|
ld a,[hli]
|
|
|
|
ld [wHPBarMaxHP+1],a
|
|
|
|
ld a,[hl]
|
2014-05-26 21:04:56 +00:00
|
|
|
ld [wHPBarMaxHP],a ; max HP stored at wHPBarMaxHP (2 bytes, big-endian)
|
2015-07-26 02:26:54 +00:00
|
|
|
ld a,[wPseudoItemID]
|
2014-05-22 22:13:20 +00:00
|
|
|
and a ; using Softboiled?
|
|
|
|
jp z,.notUsingSoftboiled2
|
|
|
|
; if using softboiled
|
|
|
|
ld hl,wHPBarMaxHP
|
|
|
|
ld a,[hli]
|
|
|
|
push af
|
|
|
|
ld a,[hli]
|
|
|
|
push af
|
|
|
|
ld a,[hli]
|
|
|
|
push af
|
|
|
|
ld a,[hl]
|
|
|
|
push af
|
2014-06-14 11:12:40 +00:00
|
|
|
ld hl,wPartyMon1MaxHP
|
2014-05-22 22:13:20 +00:00
|
|
|
ld a,[wWhichPokemon]
|
2014-06-14 11:12:40 +00:00
|
|
|
ld bc,wPartyMon2 - wPartyMon1
|
2014-05-22 22:13:20 +00:00
|
|
|
call AddNTimes
|
|
|
|
ld a,[hli]
|
2014-05-26 21:04:56 +00:00
|
|
|
ld [wHPBarMaxHP + 1],a
|
2014-05-22 22:13:20 +00:00
|
|
|
ld [H_DIVIDEND],a
|
|
|
|
ld a,[hl]
|
|
|
|
ld [wHPBarMaxHP],a
|
|
|
|
ld [H_DIVIDEND + 1],a
|
|
|
|
ld a,5
|
|
|
|
ld [H_DIVISOR],a
|
|
|
|
ld b,2 ; number of bytes
|
|
|
|
call Divide ; get 1/5 of max HP of pokemon that used Softboiled
|
2015-08-30 07:44:13 +00:00
|
|
|
ld bc,(wPartyMon1HP + 1) - (wPartyMon1MaxHP + 1)
|
2014-05-22 22:13:20 +00:00
|
|
|
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
|
|
|
|
ld a,[H_QUOTIENT + 3]
|
|
|
|
push af
|
|
|
|
ld b,a
|
|
|
|
ld a,[hl]
|
|
|
|
ld [wHPBarOldHP],a
|
|
|
|
sub b
|
|
|
|
ld [hld],a
|
|
|
|
ld [wHPBarNewHP],a
|
|
|
|
ld a,[H_QUOTIENT + 2]
|
|
|
|
ld b,a
|
|
|
|
ld a,[hl]
|
|
|
|
ld [wHPBarOldHP+1],a
|
|
|
|
sbc b
|
|
|
|
ld [hl],a
|
|
|
|
ld [wHPBarNewHP+1],a
|
2015-07-18 20:52:03 +00:00
|
|
|
coord hl, 4, 1
|
2014-05-22 22:13:20 +00:00
|
|
|
ld a,[wWhichPokemon]
|
2015-08-10 04:56:20 +00:00
|
|
|
ld bc,2 * SCREEN_WIDTH
|
2014-05-22 22:13:20 +00:00
|
|
|
call AddNTimes ; calculate coordinates of HP bar of pokemon that used Softboiled
|
2015-07-19 08:46:12 +00:00
|
|
|
ld a,SFX_HEAL_HP
|
2015-07-03 19:37:53 +00:00
|
|
|
call PlaySoundWaitForCurrent
|
2015-02-08 00:24:16 +00:00
|
|
|
ld a,[hFlags_0xFFF6]
|
2014-05-22 22:13:20 +00:00
|
|
|
set 0,a
|
2015-02-08 00:24:16 +00:00
|
|
|
ld [hFlags_0xFFF6],a
|
2014-05-22 22:13:20 +00:00
|
|
|
ld a,$02
|
2015-02-08 06:18:42 +00:00
|
|
|
ld [wHPBarType],a
|
2014-06-16 20:57:26 +00:00
|
|
|
predef UpdateHPBar2 ; animate HP bar decrease of pokemon that used Softboiled
|
2015-02-08 00:24:16 +00:00
|
|
|
ld a,[hFlags_0xFFF6]
|
2014-05-22 22:13:20 +00:00
|
|
|
res 0,a
|
2015-02-08 00:24:16 +00:00
|
|
|
ld [hFlags_0xFFF6],a
|
2014-05-22 22:13:20 +00:00
|
|
|
pop af
|
|
|
|
ld b,a ; store heal amount (1/5 of max HP)
|
2014-05-26 21:04:56 +00:00
|
|
|
ld hl,wHPBarOldHP + 1
|
2014-05-22 22:13:20 +00:00
|
|
|
pop af
|
|
|
|
ld [hld],a
|
|
|
|
pop af
|
|
|
|
ld [hld],a
|
|
|
|
pop af
|
|
|
|
ld [hld],a
|
|
|
|
pop af
|
|
|
|
ld [hl],a
|
|
|
|
jr .addHealAmount
|
|
|
|
.notUsingSoftboiled2
|
2014-05-26 21:04:56 +00:00
|
|
|
ld a,[wcf91]
|
2014-05-22 22:13:20 +00:00
|
|
|
cp a,SODA_POP
|
|
|
|
ld b,60 ; Soda Pop heal amount
|
|
|
|
jr z,.addHealAmount
|
|
|
|
ld b,80 ; Lemonade heal amount
|
|
|
|
jr nc,.addHealAmount
|
|
|
|
cp a,FRESH_WATER
|
|
|
|
ld b,50 ; Fresh Water heal amount
|
|
|
|
jr z,.addHealAmount
|
|
|
|
cp a,SUPER_POTION
|
|
|
|
ld b,200 ; Hyper Potion heal amount
|
|
|
|
jr c,.addHealAmount
|
|
|
|
ld b,50 ; Super Potion heal amount
|
|
|
|
jr z,.addHealAmount
|
|
|
|
ld b,20 ; Potion heal amount
|
|
|
|
.addHealAmount
|
|
|
|
pop de
|
|
|
|
pop hl
|
|
|
|
ld a,[hl]
|
|
|
|
add b
|
|
|
|
ld [hld],a
|
|
|
|
ld [wHPBarNewHP],a
|
|
|
|
ld a,[hl]
|
|
|
|
ld [wHPBarNewHP+1],a
|
|
|
|
jr nc,.noCarry
|
|
|
|
inc [hl]
|
|
|
|
ld a,[hl]
|
2014-05-26 21:04:56 +00:00
|
|
|
ld [wHPBarNewHP + 1],a
|
2014-05-22 22:13:20 +00:00
|
|
|
.noCarry
|
|
|
|
push de
|
|
|
|
inc hl
|
|
|
|
ld d,h
|
|
|
|
ld e,l ; de now points to current HP
|
2015-08-30 07:44:13 +00:00
|
|
|
ld hl,(wPartyMon1MaxHP + 1) - (wPartyMon1HP + 1)
|
2014-05-22 22:13:20 +00:00
|
|
|
add hl,de ; hl now points to max HP
|
2014-05-26 21:04:56 +00:00
|
|
|
ld a,[wcf91]
|
2014-05-22 22:13:20 +00:00
|
|
|
cp a,REVIVE
|
|
|
|
jr z,.setCurrentHPToHalfMaxHP
|
|
|
|
ld a,[hld]
|
|
|
|
ld b,a
|
|
|
|
ld a,[de]
|
|
|
|
sub b
|
|
|
|
dec de
|
|
|
|
ld b,[hl]
|
|
|
|
ld a,[de]
|
|
|
|
sbc b
|
|
|
|
jr nc,.setCurrentHPToMaxHp ; if current HP exceeds max HP after healing
|
2014-05-26 21:04:56 +00:00
|
|
|
ld a,[wcf91]
|
2014-05-22 22:13:20 +00:00
|
|
|
cp a,HYPER_POTION
|
|
|
|
jr c,.setCurrentHPToMaxHp ; if using a Full Restore or Max Potion
|
|
|
|
cp a,MAX_REVIVE
|
|
|
|
jr z,.setCurrentHPToMaxHp ; if using a Max Revive
|
|
|
|
jr .updateInBattleData
|
|
|
|
.setCurrentHPToHalfMaxHP
|
|
|
|
dec hl
|
|
|
|
dec de
|
|
|
|
ld a,[hli]
|
|
|
|
srl a
|
|
|
|
ld [de],a
|
|
|
|
ld [wHPBarNewHP+1],a
|
|
|
|
ld a,[hl]
|
|
|
|
rr a
|
|
|
|
inc de
|
|
|
|
ld [de],a
|
|
|
|
ld [wHPBarNewHP],a
|
|
|
|
dec de
|
|
|
|
jr .doneHealingPartyHP
|
|
|
|
.setCurrentHPToMaxHp
|
|
|
|
ld a,[hli]
|
|
|
|
ld [de],a
|
|
|
|
ld [wHPBarNewHP+1],a
|
|
|
|
inc de
|
|
|
|
ld a,[hl]
|
|
|
|
ld [de],a
|
|
|
|
ld [wHPBarNewHP],a
|
|
|
|
dec de
|
|
|
|
.doneHealingPartyHP ; done updating the pokemon's current HP in the party data structure
|
2014-05-26 21:04:56 +00:00
|
|
|
ld a,[wcf91]
|
2014-05-22 22:13:20 +00:00
|
|
|
cp a,FULL_RESTORE
|
|
|
|
jr nz,.updateInBattleData
|
2015-08-30 07:44:13 +00:00
|
|
|
ld bc,wPartyMon1Status - (wPartyMon1MaxHP + 1)
|
2014-05-22 22:13:20 +00:00
|
|
|
add hl,bc
|
|
|
|
xor a
|
|
|
|
ld [hl],a ; remove the status ailment in the party data
|
|
|
|
.updateInBattleData
|
|
|
|
ld h,d
|
|
|
|
ld l,e
|
|
|
|
pop de
|
|
|
|
ld a,[wPlayerMonNumber]
|
|
|
|
cp d ; is pokemon the item was used on active in battle?
|
|
|
|
jr nz,.calculateHPBarCoords
|
|
|
|
; copy party HP to in-battle HP
|
|
|
|
ld a,[hli]
|
2014-06-14 11:12:40 +00:00
|
|
|
ld [wBattleMonHP],a
|
2014-05-22 22:13:20 +00:00
|
|
|
ld a,[hld]
|
2014-06-14 11:12:40 +00:00
|
|
|
ld [wBattleMonHP + 1],a
|
2014-05-26 21:04:56 +00:00
|
|
|
ld a,[wcf91]
|
2014-05-22 22:13:20 +00:00
|
|
|
cp a,FULL_RESTORE
|
|
|
|
jr nz,.calculateHPBarCoords
|
|
|
|
xor a
|
2014-06-14 11:12:40 +00:00
|
|
|
ld [wBattleMonStatus],a ; remove the status ailment in the in-battle pokemon data
|
2014-05-22 22:13:20 +00:00
|
|
|
.calculateHPBarCoords
|
2014-05-26 21:04:56 +00:00
|
|
|
ld hl,wOAMBuffer + $90
|
2015-08-30 07:44:13 +00:00
|
|
|
ld bc,2 * SCREEN_WIDTH
|
2014-05-22 22:13:20 +00:00
|
|
|
inc d
|
|
|
|
.calculateHPBarCoordsLoop
|
|
|
|
add hl,bc
|
|
|
|
dec d
|
|
|
|
jr nz,.calculateHPBarCoordsLoop
|
|
|
|
jr .doneHealing
|
|
|
|
.healingItemNoEffect
|
|
|
|
call ItemUseNoEffect
|
|
|
|
jp .done
|
|
|
|
.doneHealing
|
2015-07-26 02:26:54 +00:00
|
|
|
ld a,[wPseudoItemID]
|
2014-05-22 22:13:20 +00:00
|
|
|
and a ; using Softboiled?
|
|
|
|
jr nz,.skipRemovingItem ; no item to remove if using Softboiled
|
|
|
|
push hl
|
|
|
|
call RemoveUsedItem
|
|
|
|
pop hl
|
|
|
|
.skipRemovingItem
|
2014-05-26 21:04:56 +00:00
|
|
|
ld a,[wcf91]
|
2014-05-22 22:13:20 +00:00
|
|
|
cp a,FULL_RESTORE
|
|
|
|
jr c,.playStatusAilmentCuringSound
|
|
|
|
cp a,FULL_HEAL
|
|
|
|
jr z,.playStatusAilmentCuringSound
|
2015-07-19 08:46:12 +00:00
|
|
|
ld a,SFX_HEAL_HP
|
2015-07-03 19:37:53 +00:00
|
|
|
call PlaySoundWaitForCurrent
|
2015-02-08 00:24:16 +00:00
|
|
|
ld a,[hFlags_0xFFF6]
|
2014-05-22 22:13:20 +00:00
|
|
|
set 0,a
|
2015-02-08 00:24:16 +00:00
|
|
|
ld [hFlags_0xFFF6],a
|
2014-05-22 22:13:20 +00:00
|
|
|
ld a,$02
|
2015-02-08 06:18:42 +00:00
|
|
|
ld [wHPBarType],a
|
2014-06-16 20:57:26 +00:00
|
|
|
predef UpdateHPBar2 ; animate the HP bar lengthening
|
2015-02-08 00:24:16 +00:00
|
|
|
ld a,[hFlags_0xFFF6]
|
2014-05-22 22:13:20 +00:00
|
|
|
res 0,a
|
2015-02-08 00:24:16 +00:00
|
|
|
ld [hFlags_0xFFF6],a
|
2015-07-13 22:40:33 +00:00
|
|
|
ld a,REVIVE_MSG
|
|
|
|
ld [wPartyMenuTypeOrMessageID],a
|
2014-05-26 21:04:56 +00:00
|
|
|
ld a,[wcf91]
|
2014-05-22 22:13:20 +00:00
|
|
|
cp a,REVIVE
|
|
|
|
jr z,.showHealingItemMessage
|
|
|
|
cp a,MAX_REVIVE
|
|
|
|
jr z,.showHealingItemMessage
|
2015-07-13 22:40:33 +00:00
|
|
|
ld a,POTION_MSG
|
|
|
|
ld [wPartyMenuTypeOrMessageID],a
|
2014-05-22 22:13:20 +00:00
|
|
|
jr .showHealingItemMessage
|
|
|
|
.playStatusAilmentCuringSound
|
2015-07-19 08:46:12 +00:00
|
|
|
ld a,SFX_HEAL_AILMENT
|
2015-02-08 06:18:42 +00:00
|
|
|
call PlaySoundWaitForCurrent
|
2014-05-22 22:13:20 +00:00
|
|
|
.showHealingItemMessage
|
|
|
|
xor a
|
|
|
|
ld [H_AUTOBGTRANSFERENABLED],a
|
|
|
|
call ClearScreen
|
|
|
|
dec a
|
2014-09-13 07:50:56 +00:00
|
|
|
ld [wUpdateSpritesEnabled],a
|
2014-05-22 22:13:20 +00:00
|
|
|
call RedrawPartyMenu ; redraws the party menu and displays the message
|
|
|
|
ld a,1
|
|
|
|
ld [H_AUTOBGTRANSFERENABLED],a
|
|
|
|
ld c,50
|
|
|
|
call DelayFrames
|
2015-02-08 06:18:42 +00:00
|
|
|
call WaitForTextScrollButtonPress
|
2014-05-22 22:13:20 +00:00
|
|
|
jr .done
|
|
|
|
.canceledItemUse
|
|
|
|
xor a
|
2015-07-15 06:16:06 +00:00
|
|
|
ld [wActionResultOrTookBattleTurn],a ; item use failed
|
2014-05-22 22:13:20 +00:00
|
|
|
pop af
|
|
|
|
pop af
|
|
|
|
.done
|
2015-07-26 02:26:54 +00:00
|
|
|
ld a,[wPseudoItemID]
|
2014-05-22 22:13:20 +00:00
|
|
|
and a ; using Softboiled?
|
|
|
|
ret nz ; if so, return
|
|
|
|
call GBPalWhiteOut
|
2015-08-12 09:16:56 +00:00
|
|
|
call z,RunDefaultPaletteCommand
|
2015-08-31 02:38:41 +00:00
|
|
|
ld a,[wIsInBattle]
|
2014-05-22 22:13:20 +00:00
|
|
|
and a
|
|
|
|
ret nz
|
2015-02-08 06:18:42 +00:00
|
|
|
jp ReloadMapData
|
2014-05-22 22:13:20 +00:00
|
|
|
.useVitamin
|
|
|
|
push hl
|
|
|
|
ld a,[hl]
|
2014-05-26 21:04:56 +00:00
|
|
|
ld [wd0b5],a
|
|
|
|
ld [wd11e],a
|
2015-08-30 07:44:13 +00:00
|
|
|
ld bc,wPartyMon1Level - wPartyMon1
|
2014-05-22 22:13:20 +00:00
|
|
|
add hl,bc ; hl now points to level
|
|
|
|
ld a,[hl] ; a = level
|
2015-08-31 02:38:41 +00:00
|
|
|
ld [wCurEnemyLVL],a ; store level
|
2014-05-22 22:13:20 +00:00
|
|
|
call GetMonHeader
|
|
|
|
push de
|
|
|
|
ld a,d
|
2014-06-14 11:12:40 +00:00
|
|
|
ld hl,wPartyMonNicks
|
2014-05-22 22:13:20 +00:00
|
|
|
call GetPartyMonName
|
|
|
|
pop de
|
|
|
|
pop hl
|
2014-05-26 21:04:56 +00:00
|
|
|
ld a,[wcf91]
|
2014-05-22 22:13:20 +00:00
|
|
|
cp a,RARE_CANDY
|
|
|
|
jp z,.useRareCandy
|
|
|
|
push hl
|
|
|
|
sub a,HP_UP
|
|
|
|
add a
|
2015-08-30 07:44:13 +00:00
|
|
|
ld bc,wPartyMon1HPExp - wPartyMon1
|
2014-05-22 22:13:20 +00:00
|
|
|
add hl,bc
|
|
|
|
add l
|
|
|
|
ld l,a
|
|
|
|
jr nc,.noCarry2
|
|
|
|
inc h
|
|
|
|
.noCarry2
|
|
|
|
ld a,10
|
|
|
|
ld b,a
|
|
|
|
ld a,[hl] ; a = MSB of stat experience of the appropriate stat
|
|
|
|
cp a,100 ; is there already at least 25600 (256 * 100) stat experience?
|
|
|
|
jr nc,.vitaminNoEffect ; if so, vitamins can't add any more
|
|
|
|
add b ; add 2560 (256 * 10) stat experience
|
|
|
|
jr nc,.noCarry3 ; a carry should be impossible here, so this will always jump
|
|
|
|
ld a,255
|
|
|
|
.noCarry3
|
|
|
|
ld [hl],a
|
|
|
|
pop hl
|
|
|
|
call .recalculateStats
|
|
|
|
ld hl,VitaminText
|
2014-05-26 21:04:56 +00:00
|
|
|
ld a,[wcf91]
|
2014-05-22 22:13:20 +00:00
|
|
|
sub a,HP_UP - 1
|
|
|
|
ld c,a
|
|
|
|
.statNameLoop ; loop to get the address of the name of the stat the vitamin increases
|
|
|
|
dec c
|
|
|
|
jr z,.gotStatName
|
|
|
|
.statNameInnerLoop
|
|
|
|
ld a,[hli]
|
|
|
|
ld b,a
|
|
|
|
ld a,$50
|
|
|
|
cp b
|
|
|
|
jr nz,.statNameInnerLoop
|
|
|
|
jr .statNameLoop
|
|
|
|
.gotStatName
|
2014-05-26 21:04:56 +00:00
|
|
|
ld de,wcf4b
|
2014-05-22 22:13:20 +00:00
|
|
|
ld bc,10
|
2014-05-26 21:04:56 +00:00
|
|
|
call CopyData ; copy the stat's name to wcf4b
|
2015-07-19 08:46:12 +00:00
|
|
|
ld a,SFX_HEAL_AILMENT
|
2015-07-03 19:37:53 +00:00
|
|
|
call PlaySound
|
2014-05-22 22:13:20 +00:00
|
|
|
ld hl,VitaminStatRoseText
|
|
|
|
call PrintText
|
|
|
|
jp RemoveUsedItem
|
|
|
|
.vitaminNoEffect
|
|
|
|
pop hl
|
|
|
|
ld hl,VitaminNoEffectText
|
|
|
|
call PrintText
|
|
|
|
jp GBPalWhiteOut
|
|
|
|
.recalculateStats
|
2015-08-30 07:44:13 +00:00
|
|
|
ld bc,wPartyMon1Stats - wPartyMon1
|
2014-05-22 22:13:20 +00:00
|
|
|
add hl,bc
|
|
|
|
ld d,h
|
|
|
|
ld e,l ; de now points to stats
|
2015-08-30 07:44:13 +00:00
|
|
|
ld bc,(wPartyMon1Exp + 2) - wPartyMon1Stats
|
|
|
|
add hl,bc ; hl now points to LSB of experience
|
2014-05-22 22:13:20 +00:00
|
|
|
ld b,1
|
|
|
|
jp CalcStats ; recalculate stats
|
|
|
|
.useRareCandy
|
|
|
|
push hl
|
2015-08-30 07:44:13 +00:00
|
|
|
ld bc,wPartyMon1Level - wPartyMon1
|
2014-05-22 22:13:20 +00:00
|
|
|
add hl,bc ; hl now points to level
|
|
|
|
ld a,[hl] ; a = level
|
2014-06-10 21:06:30 +00:00
|
|
|
cp a, MAX_LEVEL
|
2014-05-22 22:13:20 +00:00
|
|
|
jr z,.vitaminNoEffect ; can't raise level above 100
|
|
|
|
inc a
|
|
|
|
ld [hl],a ; store incremented level
|
2015-08-31 02:38:41 +00:00
|
|
|
ld [wCurEnemyLVL],a
|
2014-05-22 22:13:20 +00:00
|
|
|
push hl
|
|
|
|
push de
|
|
|
|
ld d,a
|
|
|
|
callab CalcExperience ; calculate experience for next level and store it at $ff96
|
|
|
|
pop de
|
|
|
|
pop hl
|
2015-08-30 07:44:13 +00:00
|
|
|
ld bc,wPartyMon1Exp - wPartyMon1Level
|
|
|
|
add hl,bc ; hl now points to MSB of experience
|
2014-05-22 22:13:20 +00:00
|
|
|
; update experience to minimum for new level
|
2015-07-19 03:49:52 +00:00
|
|
|
ld a,[hExperience]
|
2014-05-22 22:13:20 +00:00
|
|
|
ld [hli],a
|
2015-07-19 03:49:52 +00:00
|
|
|
ld a,[hExperience + 1]
|
2014-05-22 22:13:20 +00:00
|
|
|
ld [hli],a
|
2015-07-19 03:49:52 +00:00
|
|
|
ld a,[hExperience + 2]
|
2014-05-22 22:13:20 +00:00
|
|
|
ld [hl],a
|
|
|
|
pop hl
|
|
|
|
ld a,[wWhichPokemon]
|
|
|
|
push af
|
2014-05-26 21:04:56 +00:00
|
|
|
ld a,[wcf91]
|
2014-05-22 22:13:20 +00:00
|
|
|
push af
|
|
|
|
push de
|
|
|
|
push hl
|
2015-08-30 07:44:13 +00:00
|
|
|
ld bc,wPartyMon1MaxHP - wPartyMon1
|
2014-05-22 22:13:20 +00:00
|
|
|
add hl,bc ; hl now points to MSB of max HP
|
|
|
|
ld a,[hli]
|
|
|
|
ld b,a
|
|
|
|
ld c,[hl]
|
|
|
|
pop hl
|
|
|
|
push bc
|
|
|
|
push hl
|
|
|
|
call .recalculateStats
|
|
|
|
pop hl
|
2015-08-30 07:44:13 +00:00
|
|
|
ld bc,(wPartyMon1MaxHP + 1) - wPartyMon1
|
|
|
|
add hl,bc ; hl now points to LSB of max HP
|
2014-05-22 22:13:20 +00:00
|
|
|
pop bc
|
|
|
|
ld a,[hld]
|
|
|
|
sub c
|
|
|
|
ld c,a
|
|
|
|
ld a,[hl]
|
|
|
|
sbc b
|
|
|
|
ld b,a ; bc = the amount of max HP gained from leveling up
|
|
|
|
; add the amount gained to the current HP
|
2015-08-30 07:44:13 +00:00
|
|
|
ld de,(wPartyMon1HP + 1) - wPartyMon1MaxHP
|
|
|
|
add hl,de ; hl now points to LSB of current HP
|
2014-05-22 22:13:20 +00:00
|
|
|
ld a,[hl]
|
|
|
|
add c
|
|
|
|
ld [hld],a
|
|
|
|
ld a,[hl]
|
|
|
|
adc b
|
|
|
|
ld [hl],a
|
2015-07-13 22:40:33 +00:00
|
|
|
ld a,RARE_CANDY_MSG
|
|
|
|
ld [wPartyMenuTypeOrMessageID],a
|
2014-05-22 22:13:20 +00:00
|
|
|
call RedrawPartyMenu
|
|
|
|
pop de
|
|
|
|
ld a,d
|
|
|
|
ld [wWhichPokemon],a
|
|
|
|
ld a,e
|
2014-05-26 21:04:56 +00:00
|
|
|
ld [wd11e],a
|
2015-07-16 03:04:58 +00:00
|
|
|
xor a ; PLAYER_PARTY_DATA
|
|
|
|
ld [wMonDataLocation],a
|
2014-05-22 22:13:20 +00:00
|
|
|
call LoadMonData
|
|
|
|
ld d,$01
|
|
|
|
callab PrintStatsBox ; display new stats text box
|
|
|
|
call WaitForTextScrollButtonPress ; wait for button press
|
2015-07-16 03:04:58 +00:00
|
|
|
xor a ; PLAYER_PARTY_DATA
|
|
|
|
ld [wMonDataLocation],a
|
2014-08-09 05:39:13 +00:00
|
|
|
predef LearnMoveFromLevelUp ; learn level up move, if any
|
2014-05-22 22:13:20 +00:00
|
|
|
xor a
|
2015-07-14 08:46:23 +00:00
|
|
|
ld [wForceEvolution],a
|
2014-08-09 05:39:13 +00:00
|
|
|
callab TryEvolvingMon ; evolve pokemon, if appropriate
|
2014-05-22 22:13:20 +00:00
|
|
|
ld a,$01
|
2014-09-13 07:50:56 +00:00
|
|
|
ld [wUpdateSpritesEnabled],a
|
2014-05-22 22:13:20 +00:00
|
|
|
pop af
|
2014-05-26 21:04:56 +00:00
|
|
|
ld [wcf91],a
|
2014-05-22 22:13:20 +00:00
|
|
|
pop af
|
|
|
|
ld [wWhichPokemon],a
|
|
|
|
jp RemoveUsedItem
|
|
|
|
|
2016-06-12 00:24:04 +00:00
|
|
|
VitaminStatRoseText:
|
2014-05-22 22:13:20 +00:00
|
|
|
TX_FAR _VitaminStatRoseText
|
|
|
|
db "@"
|
|
|
|
|
2016-06-12 00:24:04 +00:00
|
|
|
VitaminNoEffectText:
|
2014-05-22 22:13:20 +00:00
|
|
|
TX_FAR _VitaminNoEffectText
|
|
|
|
db "@"
|
|
|
|
|
2016-06-12 00:24:04 +00:00
|
|
|
VitaminText:
|
2014-05-22 22:13:20 +00:00
|
|
|
db "HEALTH@"
|
|
|
|
db "ATTACK@"
|
|
|
|
db "DEFENSE@"
|
|
|
|
db "SPEED@"
|
|
|
|
db "SPECIAL@"
|
|
|
|
|
2016-06-12 00:24:04 +00:00
|
|
|
ItemUseBait:
|
2014-05-22 22:13:20 +00:00
|
|
|
ld hl,ThrewBaitText
|
|
|
|
call PrintText
|
2014-08-09 05:39:13 +00:00
|
|
|
ld hl,wEnemyMonCatchRate ; catch rate
|
2014-05-22 22:13:20 +00:00
|
|
|
srl [hl] ; halve catch rate
|
|
|
|
ld a,BAIT_ANIM
|
2014-08-09 05:39:13 +00:00
|
|
|
ld hl,wSafariBaitFactor ; bait factor
|
|
|
|
ld de,wSafariEscapeFactor ; escape factor
|
2014-05-22 22:13:20 +00:00
|
|
|
jr BaitRockCommon
|
|
|
|
|
2016-06-12 00:24:04 +00:00
|
|
|
ItemUseRock:
|
2014-05-22 22:13:20 +00:00
|
|
|
ld hl,ThrewRockText
|
|
|
|
call PrintText
|
2014-08-09 05:39:13 +00:00
|
|
|
ld hl,wEnemyMonCatchRate ; catch rate
|
2014-05-22 22:13:20 +00:00
|
|
|
ld a,[hl]
|
|
|
|
add a ; double catch rate
|
|
|
|
jr nc,.noCarry
|
|
|
|
ld a,$ff
|
|
|
|
.noCarry
|
|
|
|
ld [hl],a
|
|
|
|
ld a,ROCK_ANIM
|
2014-08-09 05:39:13 +00:00
|
|
|
ld hl,wSafariEscapeFactor ; escape factor
|
|
|
|
ld de,wSafariBaitFactor ; bait factor
|
2014-05-22 22:13:20 +00:00
|
|
|
|
2016-06-12 00:24:04 +00:00
|
|
|
BaitRockCommon:
|
2015-08-31 02:38:41 +00:00
|
|
|
ld [wAnimationID],a
|
2014-05-22 22:13:20 +00:00
|
|
|
xor a
|
2015-08-13 05:14:31 +00:00
|
|
|
ld [wAnimationType],a
|
2014-05-22 22:13:20 +00:00
|
|
|
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
|
2014-05-24 18:40:38 +00:00
|
|
|
call Random
|
2014-05-22 22:13:20 +00:00
|
|
|
and a,7
|
|
|
|
cp a,5
|
|
|
|
jr nc,.randomLoop
|
|
|
|
inc a ; increment the random number, giving a range from 1 to 5 inclusive
|
|
|
|
ld b,a
|
|
|
|
ld a,[hl]
|
|
|
|
add b ; increase bait factor (for bait), increase escape factor (for rock)
|
|
|
|
jr nc,.noCarry
|
|
|
|
ld a,$ff
|
|
|
|
.noCarry
|
|
|
|
ld [hl],a
|
2014-06-16 20:57:26 +00:00
|
|
|
predef MoveAnimation ; do animation
|
2014-05-22 22:13:20 +00:00
|
|
|
ld c,70
|
|
|
|
jp DelayFrames
|
|
|
|
|
2016-06-12 00:24:04 +00:00
|
|
|
ThrewBaitText:
|
2014-05-22 22:13:20 +00:00
|
|
|
TX_FAR _ThrewBaitText
|
|
|
|
db "@"
|
|
|
|
|
2016-06-12 00:24:04 +00:00
|
|
|
ThrewRockText:
|
2014-05-22 22:13:20 +00:00
|
|
|
TX_FAR _ThrewRockText
|
|
|
|
db "@"
|
|
|
|
|
|
|
|
; also used for Dig out-of-battle effect
|
2016-06-12 00:24:04 +00:00
|
|
|
ItemUseEscapeRope:
|
2015-08-31 02:38:41 +00:00
|
|
|
ld a,[wIsInBattle]
|
2014-05-22 22:13:20 +00:00
|
|
|
and a
|
|
|
|
jr nz,.notUsable
|
2015-08-31 02:38:41 +00:00
|
|
|
ld a,[wCurMap]
|
2014-05-22 22:13:20 +00:00
|
|
|
cp a,AGATHAS_ROOM
|
|
|
|
jr z,.notUsable
|
2015-08-31 02:38:41 +00:00
|
|
|
ld a,[wCurMapTileset]
|
2014-05-22 22:13:20 +00:00
|
|
|
ld b,a
|
|
|
|
ld hl,EscapeRopeTilesets
|
|
|
|
.loop
|
|
|
|
ld a,[hli]
|
|
|
|
cp a,$ff
|
|
|
|
jr z,.notUsable
|
|
|
|
cp b
|
|
|
|
jr nz,.loop
|
2014-05-26 21:04:56 +00:00
|
|
|
ld hl,wd732
|
2014-05-22 22:13:20 +00:00
|
|
|
set 3,[hl]
|
|
|
|
set 6,[hl]
|
2014-05-26 21:04:56 +00:00
|
|
|
ld hl,wd72e
|
2014-05-22 22:13:20 +00:00
|
|
|
res 4,[hl]
|
2015-07-21 01:32:02 +00:00
|
|
|
ResetEvent EVENT_IN_SAFARI_ZONE
|
2014-05-22 22:13:20 +00:00
|
|
|
xor a
|
2015-08-31 02:38:41 +00:00
|
|
|
ld [wNumSafariBalls],a
|
|
|
|
ld [wSafariZoneEntranceCurScript],a
|
2014-05-22 22:13:20 +00:00
|
|
|
inc a
|
2014-08-09 05:39:13 +00:00
|
|
|
ld [wEscapedFromBattle],a
|
2015-07-15 06:16:06 +00:00
|
|
|
ld [wActionResultOrTookBattleTurn],a ; item used
|
2015-07-26 02:26:54 +00:00
|
|
|
ld a,[wPseudoItemID]
|
2014-05-22 22:13:20 +00:00
|
|
|
and a ; using Dig?
|
|
|
|
ret nz ; if so, return
|
|
|
|
call ItemUseReloadOverworldData
|
|
|
|
ld c,30
|
|
|
|
call DelayFrames
|
|
|
|
jp RemoveUsedItem
|
|
|
|
.notUsable
|
|
|
|
jp ItemUseNotTime
|
|
|
|
|
2016-06-12 00:24:04 +00:00
|
|
|
EscapeRopeTilesets:
|
2014-05-22 22:13:20 +00:00
|
|
|
db FOREST, CEMETERY, CAVERN, FACILITY, INTERIOR
|
|
|
|
db $ff ; terminator
|
|
|
|
|
2016-06-12 00:24:04 +00:00
|
|
|
ItemUseRepel:
|
2014-05-22 22:13:20 +00:00
|
|
|
ld b,100
|
|
|
|
|
2016-06-12 00:24:04 +00:00
|
|
|
ItemUseRepelCommon:
|
2015-08-31 02:38:41 +00:00
|
|
|
ld a,[wIsInBattle]
|
2014-05-22 22:13:20 +00:00
|
|
|
and a
|
|
|
|
jp nz,ItemUseNotTime
|
|
|
|
ld a,b
|
2015-02-03 19:51:53 +00:00
|
|
|
ld [wRepelRemainingSteps],a
|
2014-05-22 22:13:20 +00:00
|
|
|
jp PrintItemUseTextAndRemoveItem
|
|
|
|
|
|
|
|
; handles X Accuracy item
|
2016-06-12 00:24:04 +00:00
|
|
|
ItemUseXAccuracy:
|
2015-08-31 02:38:41 +00:00
|
|
|
ld a,[wIsInBattle]
|
2014-05-22 22:13:20 +00:00
|
|
|
and a
|
|
|
|
jp z,ItemUseNotTime
|
2015-08-31 02:38:41 +00:00
|
|
|
ld hl,wPlayerBattleStatus2
|
2015-02-03 19:51:53 +00:00
|
|
|
set UsingXAccuracy,[hl] ; X Accuracy bit
|
2014-05-22 22:13:20 +00:00
|
|
|
jp PrintItemUseTextAndRemoveItem
|
|
|
|
|
|
|
|
; This function is bugged and never works. It always jumps to ItemUseNotTime.
|
|
|
|
; The Card Key is handled in a different way.
|
2016-06-12 00:24:04 +00:00
|
|
|
ItemUseCardKey:
|
2014-05-22 22:13:20 +00:00
|
|
|
xor a
|
2015-07-26 02:26:54 +00:00
|
|
|
ld [wUnusedD71F],a
|
2014-09-13 07:50:56 +00:00
|
|
|
call GetTileAndCoordsInFrontOfPlayer
|
2015-08-30 00:15:05 +00:00
|
|
|
ld a,[GetTileAndCoordsInFrontOfPlayer]
|
2014-05-22 22:13:20 +00:00
|
|
|
cp a,$18
|
|
|
|
jr nz,.next0
|
|
|
|
ld hl,CardKeyTable1
|
|
|
|
jr .next1
|
|
|
|
.next0
|
|
|
|
cp a,$24
|
|
|
|
jr nz,.next2
|
|
|
|
ld hl,CardKeyTable2
|
|
|
|
jr .next1
|
|
|
|
.next2
|
|
|
|
cp a,$5e
|
|
|
|
jp nz,ItemUseNotTime
|
|
|
|
ld hl,CardKeyTable3
|
|
|
|
.next1
|
2015-08-31 02:38:41 +00:00
|
|
|
ld a,[wCurMap]
|
2014-05-22 22:13:20 +00:00
|
|
|
ld b,a
|
|
|
|
.loop
|
|
|
|
ld a,[hli]
|
|
|
|
cp a,$ff
|
|
|
|
jp z,ItemUseNotTime
|
|
|
|
cp b
|
|
|
|
jr nz,.nextEntry1
|
|
|
|
ld a,[hli]
|
|
|
|
cp d
|
|
|
|
jr nz,.nextEntry2
|
|
|
|
ld a,[hli]
|
|
|
|
cp e
|
|
|
|
jr nz,.nextEntry3
|
|
|
|
ld a,[hl]
|
2015-07-26 02:26:54 +00:00
|
|
|
ld [wUnusedD71F],a
|
2014-05-22 22:13:20 +00:00
|
|
|
jr .done
|
|
|
|
.nextEntry1
|
|
|
|
inc hl
|
|
|
|
.nextEntry2
|
|
|
|
inc hl
|
|
|
|
.nextEntry3
|
|
|
|
inc hl
|
|
|
|
jr .loop
|
|
|
|
.done
|
|
|
|
ld hl,ItemUseText00
|
|
|
|
call PrintText
|
2014-05-26 21:04:56 +00:00
|
|
|
ld hl,wd728
|
2014-05-22 22:13:20 +00:00
|
|
|
set 7,[hl]
|
|
|
|
ret
|
|
|
|
|
|
|
|
; These tables are probably supposed to be door locations in Silph Co.,
|
|
|
|
; but they are unused.
|
|
|
|
; The reason there are 3 tables is unknown.
|
|
|
|
|
|
|
|
; Format:
|
|
|
|
; 00: Map ID
|
|
|
|
; 01: Y
|
|
|
|
; 02: X
|
|
|
|
; 03: ID?
|
|
|
|
|
2016-06-12 00:24:04 +00:00
|
|
|
CardKeyTable1:
|
2014-05-22 22:13:20 +00:00
|
|
|
db SILPH_CO_2F,$04,$04,$00
|
|
|
|
db SILPH_CO_2F,$04,$05,$01
|
|
|
|
db SILPH_CO_4F,$0C,$04,$02
|
|
|
|
db SILPH_CO_4F,$0C,$05,$03
|
|
|
|
db SILPH_CO_7F,$06,$0A,$04
|
|
|
|
db SILPH_CO_7F,$06,$0B,$05
|
|
|
|
db SILPH_CO_9F,$04,$12,$06
|
|
|
|
db SILPH_CO_9F,$04,$13,$07
|
|
|
|
db SILPH_CO_10F,$08,$0A,$08
|
|
|
|
db SILPH_CO_10F,$08,$0B,$09
|
|
|
|
db $ff
|
|
|
|
|
2016-06-12 00:24:04 +00:00
|
|
|
CardKeyTable2:
|
2014-05-22 22:13:20 +00:00
|
|
|
db SILPH_CO_3F,$08,$09,$0A
|
|
|
|
db SILPH_CO_3F,$09,$09,$0B
|
|
|
|
db SILPH_CO_5F,$04,$07,$0C
|
|
|
|
db SILPH_CO_5F,$05,$07,$0D
|
|
|
|
db SILPH_CO_6F,$0C,$05,$0E
|
|
|
|
db SILPH_CO_6F,$0D,$05,$0F
|
|
|
|
db SILPH_CO_8F,$08,$07,$10
|
|
|
|
db SILPH_CO_8F,$09,$07,$11
|
|
|
|
db SILPH_CO_9F,$08,$03,$12
|
|
|
|
db SILPH_CO_9F,$09,$03,$13
|
|
|
|
db $ff
|
|
|
|
|
2016-06-12 00:24:04 +00:00
|
|
|
CardKeyTable3:
|
2014-05-22 22:13:20 +00:00
|
|
|
db SILPH_CO_11F,$08,$09,$14
|
|
|
|
db SILPH_CO_11F,$09,$09,$15
|
|
|
|
db $ff
|
|
|
|
|
2016-06-12 00:24:04 +00:00
|
|
|
ItemUsePokedoll:
|
2015-08-31 02:38:41 +00:00
|
|
|
ld a,[wIsInBattle]
|
2014-05-22 22:13:20 +00:00
|
|
|
dec a
|
|
|
|
jp nz,ItemUseNotTime
|
|
|
|
ld a,$01
|
2014-08-09 05:39:13 +00:00
|
|
|
ld [wEscapedFromBattle],a
|
2014-05-22 22:13:20 +00:00
|
|
|
jp PrintItemUseTextAndRemoveItem
|
|
|
|
|
2016-06-12 00:24:04 +00:00
|
|
|
ItemUseGuardSpec:
|
2015-08-31 02:38:41 +00:00
|
|
|
ld a,[wIsInBattle]
|
2014-05-22 22:13:20 +00:00
|
|
|
and a
|
|
|
|
jp z,ItemUseNotTime
|
2015-08-31 02:38:41 +00:00
|
|
|
ld hl,wPlayerBattleStatus2
|
2015-02-03 19:51:53 +00:00
|
|
|
set ProtectedByMist,[hl] ; Mist bit
|
2014-05-22 22:13:20 +00:00
|
|
|
jp PrintItemUseTextAndRemoveItem
|
|
|
|
|
2016-06-12 00:24:04 +00:00
|
|
|
ItemUseSuperRepel:
|
2014-05-22 22:13:20 +00:00
|
|
|
ld b,200
|
|
|
|
jp ItemUseRepelCommon
|
|
|
|
|
2016-06-12 00:24:04 +00:00
|
|
|
ItemUseMaxRepel:
|
2014-05-22 22:13:20 +00:00
|
|
|
ld b,250
|
|
|
|
jp ItemUseRepelCommon
|
|
|
|
|
2016-06-12 00:24:04 +00:00
|
|
|
ItemUseDireHit:
|
2015-08-31 02:38:41 +00:00
|
|
|
ld a,[wIsInBattle]
|
2014-05-22 22:13:20 +00:00
|
|
|
and a
|
|
|
|
jp z,ItemUseNotTime
|
2015-08-31 02:38:41 +00:00
|
|
|
ld hl,wPlayerBattleStatus2
|
2015-02-03 19:51:53 +00:00
|
|
|
set GettingPumped,[hl] ; Focus Energy bit
|
2014-05-22 22:13:20 +00:00
|
|
|
jp PrintItemUseTextAndRemoveItem
|
|
|
|
|
2016-06-12 00:24:04 +00:00
|
|
|
ItemUseXStat:
|
2015-08-31 02:38:41 +00:00
|
|
|
ld a,[wIsInBattle]
|
2014-05-22 22:13:20 +00:00
|
|
|
and a
|
|
|
|
jr nz,.inBattle
|
|
|
|
call ItemUseNotTime
|
|
|
|
ld a,2
|
2015-07-15 06:16:06 +00:00
|
|
|
ld [wActionResultOrTookBattleTurn],a ; item not used
|
2014-05-22 22:13:20 +00:00
|
|
|
ret
|
|
|
|
.inBattle
|
2015-08-31 02:38:41 +00:00
|
|
|
ld hl,wPlayerMoveNum
|
2014-05-22 22:13:20 +00:00
|
|
|
ld a,[hli]
|
2015-08-31 02:38:41 +00:00
|
|
|
push af ; save [wPlayerMoveNum]
|
2014-05-22 22:13:20 +00:00
|
|
|
ld a,[hl]
|
2015-08-31 02:38:41 +00:00
|
|
|
push af ; save [wPlayerMoveEffect]
|
2014-05-22 22:13:20 +00:00
|
|
|
push hl
|
2014-05-26 21:04:56 +00:00
|
|
|
ld a,[wcf91]
|
2014-05-22 22:13:20 +00:00
|
|
|
sub a,X_ATTACK - ATTACK_UP1_EFFECT
|
|
|
|
ld [hl],a ; store player move effect
|
|
|
|
call PrintItemUseTextAndRemoveItem
|
|
|
|
ld a,XSTATITEM_ANIM ; X stat item animation ID
|
2015-08-31 02:38:41 +00:00
|
|
|
ld [wPlayerMoveNum],a
|
2014-05-22 22:13:20 +00:00
|
|
|
call LoadScreenTilesFromBuffer1 ; restore saved screen
|
|
|
|
call Delay3
|
|
|
|
xor a
|
|
|
|
ld [H_WHOSETURN],a ; set turn to player's turn
|
|
|
|
callba StatModifierUpEffect ; do stat increase move
|
|
|
|
pop hl
|
|
|
|
pop af
|
2015-08-31 02:38:41 +00:00
|
|
|
ld [hld],a ; restore [wPlayerMoveEffect]
|
2014-05-22 22:13:20 +00:00
|
|
|
pop af
|
2015-08-31 02:38:41 +00:00
|
|
|
ld [hl],a ; restore [wPlayerMoveNum]
|
2014-05-22 22:13:20 +00:00
|
|
|
ret
|
|
|
|
|
2016-06-12 00:24:04 +00:00
|
|
|
ItemUsePokeflute:
|
2015-08-31 02:38:41 +00:00
|
|
|
ld a,[wIsInBattle]
|
2014-05-22 22:13:20 +00:00
|
|
|
and a
|
|
|
|
jr nz,.inBattle
|
|
|
|
; if not in battle
|
|
|
|
call ItemUseReloadOverworldData
|
2015-08-31 02:38:41 +00:00
|
|
|
ld a,[wCurMap]
|
2014-05-22 22:13:20 +00:00
|
|
|
cp a,ROUTE_12
|
|
|
|
jr nz,.notRoute12
|
2015-07-21 01:32:02 +00:00
|
|
|
CheckEvent EVENT_BEAT_ROUTE12_SNORLAX
|
2014-05-22 22:13:20 +00:00
|
|
|
jr nz,.noSnorlaxToWakeUp
|
|
|
|
; if the player hasn't beaten Route 12 Snorlax
|
|
|
|
ld hl,Route12SnorlaxFluteCoords
|
|
|
|
call ArePlayerCoordsInArray
|
|
|
|
jr nc,.noSnorlaxToWakeUp
|
|
|
|
ld hl,PlayedFluteHadEffectText
|
|
|
|
call PrintText
|
2015-07-21 01:32:02 +00:00
|
|
|
SetEvent EVENT_FIGHT_ROUTE12_SNORLAX
|
2014-05-22 22:13:20 +00:00
|
|
|
ret
|
|
|
|
.notRoute12
|
|
|
|
cp a,ROUTE_16
|
|
|
|
jr nz,.noSnorlaxToWakeUp
|
2015-07-21 01:32:02 +00:00
|
|
|
CheckEvent EVENT_BEAT_ROUTE16_SNORLAX
|
2014-05-22 22:13:20 +00:00
|
|
|
jr nz,.noSnorlaxToWakeUp
|
|
|
|
; if the player hasn't beaten Route 16 Snorlax
|
|
|
|
ld hl,Route16SnorlaxFluteCoords
|
|
|
|
call ArePlayerCoordsInArray
|
|
|
|
jr nc,.noSnorlaxToWakeUp
|
|
|
|
ld hl,PlayedFluteHadEffectText
|
|
|
|
call PrintText
|
2015-07-21 01:32:02 +00:00
|
|
|
SetEvent EVENT_FIGHT_ROUTE16_SNORLAX
|
2014-05-22 22:13:20 +00:00
|
|
|
ret
|
|
|
|
.noSnorlaxToWakeUp
|
|
|
|
ld hl,PlayedFluteNoEffectText
|
|
|
|
jp PrintText
|
|
|
|
.inBattle
|
|
|
|
xor a
|
2015-07-19 03:49:52 +00:00
|
|
|
ld [wWereAnyMonsAsleep],a
|
|
|
|
ld b,~SLP & $ff
|
2014-06-14 11:12:40 +00:00
|
|
|
ld hl,wPartyMon1Status
|
2014-05-22 22:13:20 +00:00
|
|
|
call WakeUpEntireParty
|
2015-08-31 02:38:41 +00:00
|
|
|
ld a,[wIsInBattle]
|
2014-05-22 22:13:20 +00:00
|
|
|
dec a ; is it a trainer battle?
|
|
|
|
jr z,.skipWakingUpEnemyParty
|
|
|
|
; if it's a trainer battle
|
2014-06-14 11:12:40 +00:00
|
|
|
ld hl,wEnemyMon1Status
|
2014-05-22 22:13:20 +00:00
|
|
|
call WakeUpEntireParty
|
|
|
|
.skipWakingUpEnemyParty
|
2014-06-14 11:12:40 +00:00
|
|
|
ld hl,wBattleMonStatus
|
2014-05-22 22:13:20 +00:00
|
|
|
ld a,[hl]
|
|
|
|
and b ; remove Sleep status
|
|
|
|
ld [hl],a
|
2014-06-14 11:12:40 +00:00
|
|
|
ld hl,wEnemyMonStatus
|
2014-05-22 22:13:20 +00:00
|
|
|
ld a,[hl]
|
|
|
|
and b ; remove Sleep status
|
|
|
|
ld [hl],a
|
|
|
|
call LoadScreenTilesFromBuffer2 ; restore saved screen
|
2015-07-19 03:49:52 +00:00
|
|
|
ld a,[wWereAnyMonsAsleep]
|
2014-05-22 22:13:20 +00:00
|
|
|
and a ; were any pokemon asleep before playing the flute?
|
|
|
|
ld hl,PlayedFluteNoEffectText
|
|
|
|
jp z,PrintText ; if no pokemon were asleep
|
|
|
|
; if some pokemon were asleep
|
|
|
|
ld hl,PlayedFluteHadEffectText
|
|
|
|
call PrintText
|
2015-03-12 14:49:35 +00:00
|
|
|
ld a,[wLowHealthAlarm]
|
2014-05-22 22:13:20 +00:00
|
|
|
and a,$80
|
|
|
|
jr nz,.skipMusic
|
|
|
|
call WaitForSoundToFinish ; wait for sound to end
|
|
|
|
callba Music_PokeFluteInBattle ; play in-battle pokeflute music
|
|
|
|
.musicWaitLoop ; wait for music to finish playing
|
2016-07-28 03:08:13 +00:00
|
|
|
ld a,[wChannelSoundIDs + Ch6]
|
2014-05-22 22:13:20 +00:00
|
|
|
and a ; music off?
|
|
|
|
jr nz,.musicWaitLoop
|
|
|
|
.skipMusic
|
|
|
|
ld hl,FluteWokeUpText
|
|
|
|
jp PrintText
|
|
|
|
|
|
|
|
; wakes up all party pokemon
|
|
|
|
; INPUT:
|
|
|
|
; hl must point to status of first pokemon in party (player's or enemy's)
|
|
|
|
; b must equal ~SLP
|
2015-07-19 03:49:52 +00:00
|
|
|
; [wWereAnyMonsAsleep] should be initialized to 0
|
2014-05-22 22:13:20 +00:00
|
|
|
; OUTPUT:
|
2015-07-19 03:49:52 +00:00
|
|
|
; [wWereAnyMonsAsleep]: set to 1 if any pokemon were asleep
|
2016-06-12 00:24:04 +00:00
|
|
|
WakeUpEntireParty:
|
2014-05-22 22:13:20 +00:00
|
|
|
ld de,44
|
|
|
|
ld c,6
|
|
|
|
.loop
|
|
|
|
ld a,[hl]
|
|
|
|
push af
|
|
|
|
and a,SLP ; is pokemon asleep?
|
|
|
|
jr z,.notAsleep
|
|
|
|
ld a,1
|
2015-07-19 03:49:52 +00:00
|
|
|
ld [wWereAnyMonsAsleep],a ; indicate that a pokemon had to be woken up
|
2014-05-22 22:13:20 +00:00
|
|
|
.notAsleep
|
|
|
|
pop af
|
|
|
|
and b ; remove Sleep status
|
|
|
|
ld [hl],a
|
|
|
|
add hl,de
|
|
|
|
dec c
|
|
|
|
jr nz,.loop
|
|
|
|
ret
|
|
|
|
|
|
|
|
; Format:
|
|
|
|
; 00: Y
|
|
|
|
; 01: X
|
2016-06-12 00:24:04 +00:00
|
|
|
Route12SnorlaxFluteCoords:
|
2014-05-22 22:13:20 +00:00
|
|
|
db 62,9 ; one space West of Snorlax
|
|
|
|
db 61,10 ; one space North of Snorlax
|
|
|
|
db 63,10 ; one space South of Snorlax
|
|
|
|
db 62,11 ; one space East of Snorlax
|
|
|
|
db $ff ; terminator
|
|
|
|
|
|
|
|
; Format:
|
|
|
|
; 00: Y
|
|
|
|
; 01: X
|
2016-06-12 00:24:04 +00:00
|
|
|
Route16SnorlaxFluteCoords:
|
2014-05-22 22:13:20 +00:00
|
|
|
db 10,27 ; one space East of Snorlax
|
|
|
|
db 10,25 ; one space West of Snorlax
|
|
|
|
db $ff ; terminator
|
|
|
|
|
2016-06-12 00:24:04 +00:00
|
|
|
PlayedFluteNoEffectText:
|
2014-05-22 22:13:20 +00:00
|
|
|
TX_FAR _PlayedFluteNoEffectText
|
|
|
|
db "@"
|
|
|
|
|
2016-06-12 00:24:04 +00:00
|
|
|
FluteWokeUpText:
|
2014-05-22 22:13:20 +00:00
|
|
|
TX_FAR _FluteWokeUpText
|
|
|
|
db "@"
|
|
|
|
|
2016-06-12 00:24:04 +00:00
|
|
|
PlayedFluteHadEffectText:
|
2014-05-22 22:13:20 +00:00
|
|
|
TX_FAR _PlayedFluteHadEffectText
|
2016-07-18 06:17:03 +00:00
|
|
|
TX_BLINK
|
2015-07-19 04:53:43 +00:00
|
|
|
TX_ASM
|
2015-08-31 02:38:41 +00:00
|
|
|
ld a,[wIsInBattle]
|
2014-05-22 22:13:20 +00:00
|
|
|
and a
|
|
|
|
jr nz,.done
|
|
|
|
; play out-of-battle pokeflute music
|
|
|
|
ld a,$ff
|
|
|
|
call PlaySound ; turn off music
|
2015-07-19 08:46:12 +00:00
|
|
|
ld a, SFX_POKEFLUE
|
2015-07-22 14:57:31 +00:00
|
|
|
ld c, BANK(SFX_Pokeflute)
|
2015-07-03 19:37:53 +00:00
|
|
|
call PlayMusic
|
2014-05-22 22:13:20 +00:00
|
|
|
.musicWaitLoop ; wait for music to finish playing
|
2016-07-28 03:08:13 +00:00
|
|
|
ld a,[wChannelSoundIDs + Ch2]
|
2015-08-09 05:32:44 +00:00
|
|
|
cp a, SFX_POKEFLUE
|
2014-05-22 22:13:20 +00:00
|
|
|
jr z,.musicWaitLoop
|
2014-09-10 03:55:19 +00:00
|
|
|
call PlayDefaultMusic ; start playing normal music again
|
2014-05-22 22:13:20 +00:00
|
|
|
.done
|
|
|
|
jp TextScriptEnd ; end text
|
|
|
|
|
2016-06-12 00:24:04 +00:00
|
|
|
ItemUseCoinCase:
|
2015-08-31 02:38:41 +00:00
|
|
|
ld a,[wIsInBattle]
|
2014-05-22 22:13:20 +00:00
|
|
|
and a
|
|
|
|
jp nz,ItemUseNotTime
|
|
|
|
ld hl,CoinCaseNumCoinsText
|
|
|
|
jp PrintText
|
|
|
|
|
2016-06-12 00:24:04 +00:00
|
|
|
CoinCaseNumCoinsText:
|
2014-05-22 22:13:20 +00:00
|
|
|
TX_FAR _CoinCaseNumCoinsText
|
|
|
|
db "@"
|
|
|
|
|
2016-06-12 00:24:04 +00:00
|
|
|
ItemUseOldRod:
|
2014-05-22 22:13:20 +00:00
|
|
|
call FishingInit
|
|
|
|
jp c, ItemUseNotTime
|
2015-08-05 21:20:29 +00:00
|
|
|
lb bc, 5, MAGIKARP
|
2014-05-22 22:13:20 +00:00
|
|
|
ld a, $1 ; set bite
|
2015-07-03 19:37:53 +00:00
|
|
|
jr RodResponse
|
2014-05-22 22:13:20 +00:00
|
|
|
|
2016-06-12 00:24:04 +00:00
|
|
|
ItemUseGoodRod:
|
2014-05-22 22:13:20 +00:00
|
|
|
call FishingInit
|
|
|
|
jp c,ItemUseNotTime
|
|
|
|
.RandomLoop
|
2014-05-24 18:40:38 +00:00
|
|
|
call Random
|
2014-05-22 22:13:20 +00:00
|
|
|
srl a
|
|
|
|
jr c, .SetBite
|
|
|
|
and %11
|
|
|
|
cp 2
|
|
|
|
jr nc, .RandomLoop
|
|
|
|
; choose which monster appears
|
|
|
|
ld hl,GoodRodMons
|
|
|
|
add a,a
|
|
|
|
ld c,a
|
|
|
|
ld b,0
|
|
|
|
add hl,bc
|
|
|
|
ld b,[hl]
|
|
|
|
inc hl
|
|
|
|
ld c,[hl]
|
|
|
|
and a
|
|
|
|
.SetBite
|
|
|
|
ld a,0
|
|
|
|
rla
|
|
|
|
xor 1
|
|
|
|
jr RodResponse
|
|
|
|
|
|
|
|
INCLUDE "data/good_rod.asm"
|
|
|
|
|
2016-06-12 00:24:04 +00:00
|
|
|
ItemUseSuperRod:
|
2014-05-22 22:13:20 +00:00
|
|
|
call FishingInit
|
|
|
|
jp c, ItemUseNotTime
|
2015-07-03 19:37:53 +00:00
|
|
|
call ReadSuperRodData
|
2014-05-22 22:13:20 +00:00
|
|
|
ld a, e
|
2016-06-12 00:24:04 +00:00
|
|
|
RodResponse:
|
2015-07-14 21:32:49 +00:00
|
|
|
ld [wRodResponse], a
|
2014-05-22 22:13:20 +00:00
|
|
|
|
|
|
|
dec a ; is there a bite?
|
|
|
|
jr nz, .next
|
|
|
|
; if yes, store level and species data
|
|
|
|
ld a, 1
|
2015-08-31 02:38:41 +00:00
|
|
|
ld [wMoveMissed], a
|
2014-05-22 22:13:20 +00:00
|
|
|
ld a, b ; level
|
2015-08-31 02:38:41 +00:00
|
|
|
ld [wCurEnemyLVL], a
|
2014-05-22 22:13:20 +00:00
|
|
|
ld a, c ; species
|
2015-08-31 02:38:41 +00:00
|
|
|
ld [wCurOpponent], a
|
2014-05-22 22:13:20 +00:00
|
|
|
|
|
|
|
.next
|
2014-09-13 07:50:56 +00:00
|
|
|
ld hl, wWalkBikeSurfState
|
2014-05-22 22:13:20 +00:00
|
|
|
ld a, [hl] ; store the value in a
|
|
|
|
push af
|
|
|
|
push hl
|
|
|
|
ld [hl], 0
|
2015-07-14 21:32:49 +00:00
|
|
|
callba FishingAnim
|
2014-05-22 22:13:20 +00:00
|
|
|
pop hl
|
|
|
|
pop af
|
|
|
|
ld [hl], a
|
|
|
|
ret
|
|
|
|
|
|
|
|
; checks if fishing is possible and if so, runs initialization code common to all rods
|
|
|
|
; unsets carry if fishing is possible, sets carry if not
|
2016-06-12 00:24:04 +00:00
|
|
|
FishingInit:
|
2015-08-31 02:38:41 +00:00
|
|
|
ld a,[wIsInBattle]
|
2014-05-22 22:13:20 +00:00
|
|
|
and a
|
|
|
|
jr z,.notInBattle
|
|
|
|
scf ; can't fish during battle
|
|
|
|
ret
|
|
|
|
.notInBattle
|
|
|
|
call IsNextTileShoreOrWater
|
|
|
|
ret c
|
2014-09-13 07:50:56 +00:00
|
|
|
ld a,[wWalkBikeSurfState]
|
2014-05-22 22:13:20 +00:00
|
|
|
cp a,2 ; Surfing?
|
|
|
|
jr z,.surfing
|
|
|
|
call ItemUseReloadOverworldData
|
|
|
|
ld hl,ItemUseText00
|
|
|
|
call PrintText
|
2015-07-19 08:46:12 +00:00
|
|
|
ld a,SFX_HEAL_AILMENT
|
2015-07-03 19:37:53 +00:00
|
|
|
call PlaySound
|
2014-05-22 22:13:20 +00:00
|
|
|
ld c,80
|
|
|
|
call DelayFrames
|
|
|
|
and a
|
|
|
|
ret
|
|
|
|
.surfing
|
|
|
|
scf ; can't fish when surfing
|
|
|
|
ret
|
|
|
|
|
2016-06-12 00:24:04 +00:00
|
|
|
ItemUseOaksParcel:
|
2014-05-22 22:13:20 +00:00
|
|
|
jp ItemUseNotYoursToUse
|
|
|
|
|
2016-06-12 00:24:04 +00:00
|
|
|
ItemUseItemfinder:
|
2015-08-31 02:38:41 +00:00
|
|
|
ld a,[wIsInBattle]
|
2014-05-22 22:13:20 +00:00
|
|
|
and a
|
|
|
|
jp nz,ItemUseNotTime
|
|
|
|
call ItemUseReloadOverworldData
|
|
|
|
callba HiddenItemNear ; check for hidden items
|
|
|
|
ld hl,ItemfinderFoundNothingText
|
|
|
|
jr nc,.printText ; if no hidden items
|
|
|
|
ld c,4
|
|
|
|
.loop
|
2015-07-19 08:46:12 +00:00
|
|
|
ld a,SFX_HEALING_MACHINE
|
2015-07-03 19:37:53 +00:00
|
|
|
call PlaySoundWaitForCurrent
|
2015-07-19 08:46:12 +00:00
|
|
|
ld a,SFX_PURCHASE
|
2015-07-03 19:37:53 +00:00
|
|
|
call PlaySoundWaitForCurrent
|
2014-05-22 22:13:20 +00:00
|
|
|
dec c
|
|
|
|
jr nz,.loop
|
|
|
|
ld hl,ItemfinderFoundItemText
|
|
|
|
.printText
|
|
|
|
jp PrintText
|
|
|
|
|
2016-06-12 00:24:04 +00:00
|
|
|
ItemfinderFoundItemText:
|
2014-05-22 22:13:20 +00:00
|
|
|
TX_FAR _ItemfinderFoundItemText
|
|
|
|
db "@"
|
|
|
|
|
2016-06-12 00:24:04 +00:00
|
|
|
ItemfinderFoundNothingText:
|
2014-05-22 22:13:20 +00:00
|
|
|
TX_FAR _ItemfinderFoundNothingText
|
|
|
|
db "@"
|
|
|
|
|
2016-06-12 00:24:04 +00:00
|
|
|
ItemUsePPUp:
|
2015-08-31 02:38:41 +00:00
|
|
|
ld a,[wIsInBattle]
|
2014-05-22 22:13:20 +00:00
|
|
|
and a
|
|
|
|
jp nz,ItemUseNotTime
|
|
|
|
|
2016-06-12 00:24:04 +00:00
|
|
|
ItemUsePPRestore:
|
2014-05-22 22:13:20 +00:00
|
|
|
ld a,[wWhichPokemon]
|
|
|
|
push af
|
2014-05-26 21:04:56 +00:00
|
|
|
ld a,[wcf91]
|
2015-07-19 03:49:52 +00:00
|
|
|
ld [wPPRestoreItem],a
|
2014-05-22 22:13:20 +00:00
|
|
|
.chooseMon
|
|
|
|
xor a
|
2014-09-13 07:50:56 +00:00
|
|
|
ld [wUpdateSpritesEnabled],a
|
2015-07-13 22:40:33 +00:00
|
|
|
ld a,USE_ITEM_PARTY_MENU
|
|
|
|
ld [wPartyMenuTypeOrMessageID],a
|
2014-05-22 22:13:20 +00:00
|
|
|
call DisplayPartyMenu
|
|
|
|
jr nc,.chooseMove
|
|
|
|
jp .itemNotUsed
|
|
|
|
.chooseMove
|
2015-07-19 03:49:52 +00:00
|
|
|
ld a,[wPPRestoreItem]
|
2014-05-22 22:13:20 +00:00
|
|
|
cp a,ELIXER
|
|
|
|
jp nc,.useElixir ; if Elixir or Max Elixir
|
|
|
|
ld a,$02
|
|
|
|
ld [wMoveMenuType],a
|
|
|
|
ld hl,RaisePPWhichTechniqueText
|
2015-07-19 03:49:52 +00:00
|
|
|
ld a,[wPPRestoreItem]
|
2014-05-22 22:13:20 +00:00
|
|
|
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
|
|
|
|
.printWhichTechniqueMessage
|
|
|
|
call PrintText
|
|
|
|
xor a
|
2014-05-26 21:04:56 +00:00
|
|
|
ld [wPlayerMoveListIndex],a
|
2014-05-22 22:13:20 +00:00
|
|
|
callab MoveSelectionMenu ; move selection menu
|
|
|
|
ld a,0
|
2014-05-26 21:04:56 +00:00
|
|
|
ld [wPlayerMoveListIndex],a
|
2014-05-22 22:13:20 +00:00
|
|
|
jr nz,.chooseMon
|
2014-06-14 11:12:40 +00:00
|
|
|
ld hl,wPartyMon1Moves
|
2015-08-07 12:20:37 +00:00
|
|
|
ld bc, wPartyMon2 - wPartyMon1
|
2014-05-22 22:13:20 +00:00
|
|
|
call GetSelectedMoveOffset
|
|
|
|
push hl
|
|
|
|
ld a,[hl]
|
2014-05-26 21:04:56 +00:00
|
|
|
ld [wd11e],a
|
2014-05-22 22:13:20 +00:00
|
|
|
call GetMoveName
|
2014-05-26 21:04:56 +00:00
|
|
|
call CopyStringToCF4B ; copy name to wcf4b
|
2014-05-22 22:13:20 +00:00
|
|
|
pop hl
|
2015-07-19 03:49:52 +00:00
|
|
|
ld a,[wPPRestoreItem]
|
2014-05-22 22:13:20 +00:00
|
|
|
cp a,ETHER
|
|
|
|
jr nc,.useEther ; if Ether or Max Ether
|
|
|
|
.usePPUp
|
2016-02-21 20:59:33 +00:00
|
|
|
ld bc,wPartyMon1PP - wPartyMon1Moves
|
2014-05-22 22:13:20 +00:00
|
|
|
add hl,bc
|
|
|
|
ld a,[hl] ; move PP
|
|
|
|
cp a,3 << 6 ; have 3 PP Ups already been used?
|
|
|
|
jr c,.PPNotMaxedOut
|
|
|
|
ld hl,PPMaxedOutText
|
|
|
|
call PrintText
|
|
|
|
jr .chooseMove
|
|
|
|
.PPNotMaxedOut
|
|
|
|
ld a,[hl]
|
|
|
|
add a,1 << 6 ; increase PP Up count by 1
|
|
|
|
ld [hl],a
|
|
|
|
ld a,1 ; 1 PP Up used
|
2014-05-26 21:04:56 +00:00
|
|
|
ld [wd11e],a
|
2014-05-22 22:13:20 +00:00
|
|
|
call RestoreBonusPP ; add the bonus PP to current PP
|
|
|
|
ld hl,PPIncreasedText
|
|
|
|
call PrintText
|
|
|
|
.done
|
|
|
|
pop af
|
|
|
|
ld [wWhichPokemon],a
|
|
|
|
call GBPalWhiteOut
|
2015-08-12 09:16:56 +00:00
|
|
|
call RunDefaultPaletteCommand
|
2014-05-22 22:13:20 +00:00
|
|
|
jp RemoveUsedItem
|
|
|
|
.afterRestoringPP ; after using a (Max) Ether/Elixir
|
|
|
|
ld a,[wWhichPokemon]
|
|
|
|
ld b,a
|
|
|
|
ld a,[wPlayerMonNumber]
|
|
|
|
cp b ; is the pokemon whose PP was restored active in battle?
|
|
|
|
jr nz,.skipUpdatingInBattleData
|
2014-06-14 11:12:40 +00:00
|
|
|
ld hl,wPartyMon1PP
|
2015-08-07 12:20:37 +00:00
|
|
|
ld bc, wPartyMon2 - wPartyMon1
|
2014-05-22 22:13:20 +00:00
|
|
|
call AddNTimes
|
2014-06-14 11:12:40 +00:00
|
|
|
ld de,wBattleMonPP
|
2014-05-22 22:13:20 +00:00
|
|
|
ld bc,4
|
|
|
|
call CopyData ; copy party data to in-battle data
|
|
|
|
.skipUpdatingInBattleData
|
2015-07-19 08:46:12 +00:00
|
|
|
ld a,SFX_HEAL_AILMENT
|
2014-05-22 22:13:20 +00:00
|
|
|
call PlaySound
|
|
|
|
ld hl,PPRestoredText
|
|
|
|
call PrintText
|
|
|
|
jr .done
|
|
|
|
.useEther
|
|
|
|
call .restorePP
|
|
|
|
jr nz,.afterRestoringPP
|
|
|
|
jp .noEffect
|
|
|
|
; 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
|
2015-07-16 03:04:58 +00:00
|
|
|
xor a ; PLAYER_PARTY_DATA
|
|
|
|
ld [wMonDataLocation],a
|
2014-05-22 22:13:20 +00:00
|
|
|
call GetMaxPP
|
2014-06-14 11:12:40 +00:00
|
|
|
ld hl,wPartyMon1Moves
|
2015-08-07 12:20:37 +00:00
|
|
|
ld bc, wPartyMon2 - wPartyMon1
|
2014-05-22 22:13:20 +00:00
|
|
|
call GetSelectedMoveOffset
|
2015-08-07 12:20:37 +00:00
|
|
|
ld bc, wPartyMon1PP - wPartyMon1Moves
|
2014-05-22 22:13:20 +00:00
|
|
|
add hl,bc ; hl now points to move's PP
|
2015-08-07 12:20:37 +00:00
|
|
|
ld a,[wMaxPP]
|
|
|
|
ld b,a
|
2015-07-19 03:49:52 +00:00
|
|
|
ld a,[wPPRestoreItem]
|
2014-05-22 22:13:20 +00:00
|
|
|
cp a,MAX_ETHER
|
|
|
|
jr z,.fullyRestorePP
|
|
|
|
ld a,[hl] ; move PP
|
|
|
|
and a,%00111111 ; lower 6 bit bits store current PP
|
|
|
|
cp b ; does current PP equal max PP?
|
|
|
|
ret z ; if so, return
|
|
|
|
add a,10 ; increase current PP by 10
|
|
|
|
; b holds the max PP amount and b will hold the new PP amount.
|
|
|
|
; So, if the new amount meets or exceeds the max amount,
|
|
|
|
; cap the amount to the max amount by leaving b unchanged.
|
|
|
|
; Otherwise, store the new amount in b.
|
|
|
|
cp b ; does the new amount meet or exceed the maximum?
|
|
|
|
jr nc,.storeNewAmount
|
|
|
|
ld b,a
|
|
|
|
.storeNewAmount
|
|
|
|
ld a,[hl] ; move PP
|
|
|
|
and a,%11000000 ; PP Up counter bits
|
|
|
|
add b
|
|
|
|
ld [hl],a
|
|
|
|
ret
|
|
|
|
.fullyRestorePP
|
|
|
|
ld a,[hl] ; move PP
|
|
|
|
; Note that this code has a bug. It doesn't mask out the upper two bits, which
|
|
|
|
; are used to count how many PP Ups have been used on the move. So, Max Ethers
|
|
|
|
; and Max Elixirs will not be detected as having no effect on a move with full
|
|
|
|
; PP if the move has had any PP Ups used on it.
|
|
|
|
cp b ; does current PP equal max PP?
|
|
|
|
ret z
|
|
|
|
jr .storeNewAmount
|
|
|
|
.useElixir
|
|
|
|
; decrement the item ID so that ELIXER becomes ETHER and MAX_ELIXER becomes MAX_ETHER
|
2015-07-19 03:49:52 +00:00
|
|
|
ld hl,wPPRestoreItem
|
2014-05-22 22:13:20 +00:00
|
|
|
dec [hl]
|
|
|
|
dec [hl]
|
|
|
|
xor a
|
|
|
|
ld hl,wCurrentMenuItem
|
|
|
|
ld [hli],a
|
|
|
|
ld [hl],a ; zero the counter for number of moves that had their PP restored
|
|
|
|
ld b,4
|
|
|
|
; loop through each move and restore PP
|
|
|
|
.elixirLoop
|
|
|
|
push bc
|
2014-06-14 11:12:40 +00:00
|
|
|
ld hl,wPartyMon1Moves
|
2015-08-07 12:20:37 +00:00
|
|
|
ld bc, wPartyMon2 - wPartyMon1
|
2014-05-22 22:13:20 +00:00
|
|
|
call GetSelectedMoveOffset
|
|
|
|
ld a,[hl]
|
|
|
|
and a ; does the current slot have a move?
|
|
|
|
jr z,.nextMove
|
|
|
|
call .restorePP
|
|
|
|
jr z,.nextMove
|
|
|
|
; if some PP was restored
|
2014-05-26 21:04:56 +00:00
|
|
|
ld hl,wTileBehindCursor ; counter for number of moves that had their PP restored
|
2014-05-22 22:13:20 +00:00
|
|
|
inc [hl]
|
|
|
|
.nextMove
|
|
|
|
ld hl,wCurrentMenuItem
|
|
|
|
inc [hl]
|
|
|
|
pop bc
|
|
|
|
dec b
|
|
|
|
jr nz,.elixirLoop
|
2014-05-26 21:04:56 +00:00
|
|
|
ld a,[wTileBehindCursor]
|
2014-05-22 22:13:20 +00:00
|
|
|
and a ; did any moves have their PP restored?
|
|
|
|
jp nz,.afterRestoringPP
|
|
|
|
.noEffect
|
|
|
|
call ItemUseNoEffect
|
|
|
|
.itemNotUsed
|
|
|
|
call GBPalWhiteOut
|
2015-08-12 09:16:56 +00:00
|
|
|
call RunDefaultPaletteCommand
|
2014-05-22 22:13:20 +00:00
|
|
|
pop af
|
|
|
|
xor a
|
2015-07-15 06:16:06 +00:00
|
|
|
ld [wActionResultOrTookBattleTurn],a ; item use failed
|
2014-05-22 22:13:20 +00:00
|
|
|
ret
|
|
|
|
|
2016-06-12 00:24:04 +00:00
|
|
|
RaisePPWhichTechniqueText:
|
2014-05-22 22:13:20 +00:00
|
|
|
TX_FAR _RaisePPWhichTechniqueText
|
|
|
|
db "@"
|
|
|
|
|
2016-06-12 00:24:04 +00:00
|
|
|
RestorePPWhichTechniqueText:
|
2014-05-22 22:13:20 +00:00
|
|
|
TX_FAR _RestorePPWhichTechniqueText
|
|
|
|
db "@"
|
|
|
|
|
2016-06-12 00:24:04 +00:00
|
|
|
PPMaxedOutText:
|
2014-05-22 22:13:20 +00:00
|
|
|
TX_FAR _PPMaxedOutText
|
|
|
|
db "@"
|
|
|
|
|
2016-06-12 00:24:04 +00:00
|
|
|
PPIncreasedText:
|
2014-05-22 22:13:20 +00:00
|
|
|
TX_FAR _PPIncreasedText
|
|
|
|
db "@"
|
|
|
|
|
2016-06-12 00:24:04 +00:00
|
|
|
PPRestoredText:
|
2014-05-22 22:13:20 +00:00
|
|
|
TX_FAR _PPRestoredText
|
|
|
|
db "@"
|
|
|
|
|
|
|
|
; for items that can't be used from the Item menu
|
2016-06-12 00:24:04 +00:00
|
|
|
UnusableItem:
|
2014-05-22 22:13:20 +00:00
|
|
|
jp ItemUseNotTime
|
|
|
|
|
2016-06-12 00:24:04 +00:00
|
|
|
ItemUseTMHM:
|
2015-08-31 02:38:41 +00:00
|
|
|
ld a,[wIsInBattle]
|
2014-05-22 22:13:20 +00:00
|
|
|
and a
|
|
|
|
jp nz,ItemUseNotTime
|
2014-05-26 21:04:56 +00:00
|
|
|
ld a,[wcf91]
|
2014-05-22 22:13:20 +00:00
|
|
|
sub a,TM_01
|
|
|
|
push af
|
|
|
|
jr nc,.skipAdding
|
|
|
|
add a,55 ; if item is an HM, add 55
|
|
|
|
.skipAdding
|
|
|
|
inc a
|
2014-05-26 21:04:56 +00:00
|
|
|
ld [wd11e],a
|
2014-06-16 20:57:26 +00:00
|
|
|
predef TMToMove ; get move ID from TM/HM ID
|
2014-05-26 21:04:56 +00:00
|
|
|
ld a,[wd11e]
|
2015-02-08 08:17:03 +00:00
|
|
|
ld [wMoveNum],a
|
2014-05-22 22:13:20 +00:00
|
|
|
call GetMoveName
|
2014-05-26 21:04:56 +00:00
|
|
|
call CopyStringToCF4B ; copy name to wcf4b
|
2014-05-22 22:13:20 +00:00
|
|
|
pop af
|
|
|
|
ld hl,BootedUpTMText
|
|
|
|
jr nc,.printBootedUpMachineText
|
|
|
|
ld hl,BootedUpHMText
|
|
|
|
.printBootedUpMachineText
|
|
|
|
call PrintText
|
|
|
|
ld hl,TeachMachineMoveText
|
|
|
|
call PrintText
|
2015-07-18 20:52:03 +00:00
|
|
|
coord hl, 14, 7
|
2015-08-05 21:20:29 +00:00
|
|
|
lb bc, 8, 15
|
2015-02-07 20:27:36 +00:00
|
|
|
ld a,TWO_OPTION_MENU
|
2015-02-07 10:43:08 +00:00
|
|
|
ld [wTextBoxID],a
|
2014-05-22 22:13:20 +00:00
|
|
|
call DisplayTextBoxID ; yes/no menu
|
|
|
|
ld a,[wCurrentMenuItem]
|
|
|
|
and a
|
|
|
|
jr z,.useMachine
|
|
|
|
ld a,2
|
2015-07-15 06:16:06 +00:00
|
|
|
ld [wActionResultOrTookBattleTurn],a ; item not used
|
2014-05-22 22:13:20 +00:00
|
|
|
ret
|
|
|
|
.useMachine
|
|
|
|
ld a,[wWhichPokemon]
|
|
|
|
push af
|
2014-05-26 21:04:56 +00:00
|
|
|
ld a,[wcf91]
|
2014-05-22 22:13:20 +00:00
|
|
|
push af
|
|
|
|
.chooseMon
|
2014-05-26 21:04:56 +00:00
|
|
|
ld hl,wcf4b
|
2015-08-14 07:36:06 +00:00
|
|
|
ld de,wTempMoveNameBuffer
|
2014-05-22 22:13:20 +00:00
|
|
|
ld bc,14
|
2015-08-14 07:36:06 +00:00
|
|
|
call CopyData ; save the move name because DisplayPartyMenu will overwrite it
|
2014-05-22 22:13:20 +00:00
|
|
|
ld a,$ff
|
2014-09-13 07:50:56 +00:00
|
|
|
ld [wUpdateSpritesEnabled],a
|
2015-07-13 22:40:33 +00:00
|
|
|
ld a,TMHM_PARTY_MENU
|
|
|
|
ld [wPartyMenuTypeOrMessageID],a
|
2014-05-22 22:13:20 +00:00
|
|
|
call DisplayPartyMenu
|
|
|
|
push af
|
2015-08-14 07:36:06 +00:00
|
|
|
ld hl,wTempMoveNameBuffer
|
2014-05-26 21:04:56 +00:00
|
|
|
ld de,wcf4b
|
2014-05-22 22:13:20 +00:00
|
|
|
ld bc,14
|
|
|
|
call CopyData
|
|
|
|
pop af
|
|
|
|
jr nc,.checkIfAbleToLearnMove
|
|
|
|
; if the player canceled teaching the move
|
|
|
|
pop af
|
|
|
|
pop af
|
|
|
|
call GBPalWhiteOutWithDelay3
|
2014-05-23 22:34:35 +00:00
|
|
|
call ClearSprites
|
2015-08-12 09:16:56 +00:00
|
|
|
call RunDefaultPaletteCommand
|
2014-05-22 22:13:20 +00:00
|
|
|
jp LoadScreenTilesFromBuffer1 ; restore saved screen
|
|
|
|
.checkIfAbleToLearnMove
|
2014-06-16 20:57:26 +00:00
|
|
|
predef CanLearnTM ; check if the pokemon can learn the move
|
2014-05-22 22:13:20 +00:00
|
|
|
push bc
|
|
|
|
ld a,[wWhichPokemon]
|
2014-06-14 11:12:40 +00:00
|
|
|
ld hl,wPartyMonNicks
|
2014-05-22 22:13:20 +00:00
|
|
|
call GetPartyMonName
|
|
|
|
pop bc
|
|
|
|
ld a,c
|
|
|
|
and a ; can the pokemon learn the move?
|
|
|
|
jr nz,.checkIfAlreadyLearnedMove
|
|
|
|
; if the pokemon can't learn the move
|
2015-07-19 08:46:12 +00:00
|
|
|
ld a,SFX_DENIED
|
2015-07-03 19:37:53 +00:00
|
|
|
call PlaySoundWaitForCurrent
|
2014-05-22 22:13:20 +00:00
|
|
|
ld hl,MonCannotLearnMachineMoveText
|
|
|
|
call PrintText
|
|
|
|
jr .chooseMon
|
|
|
|
.checkIfAlreadyLearnedMove
|
|
|
|
callab CheckIfMoveIsKnown ; check if the pokemon already knows the move
|
|
|
|
jr c,.chooseMon
|
2014-06-16 20:57:26 +00:00
|
|
|
predef LearnMove ; teach move
|
2014-05-22 22:13:20 +00:00
|
|
|
pop af
|
2014-05-26 21:04:56 +00:00
|
|
|
ld [wcf91],a
|
2014-05-22 22:13:20 +00:00
|
|
|
pop af
|
|
|
|
ld [wWhichPokemon],a
|
|
|
|
ld a,b
|
|
|
|
and a
|
|
|
|
ret z
|
2014-05-26 21:04:56 +00:00
|
|
|
ld a,[wcf91]
|
2014-05-22 22:13:20 +00:00
|
|
|
call IsItemHM
|
|
|
|
ret c
|
|
|
|
jp RemoveUsedItem
|
|
|
|
|
2016-06-12 00:24:04 +00:00
|
|
|
BootedUpTMText:
|
2014-05-22 22:13:20 +00:00
|
|
|
TX_FAR _BootedUpTMText
|
|
|
|
db "@"
|
|
|
|
|
2016-06-12 00:24:04 +00:00
|
|
|
BootedUpHMText:
|
2014-05-22 22:13:20 +00:00
|
|
|
TX_FAR _BootedUpHMText
|
|
|
|
db "@"
|
|
|
|
|
2016-06-12 00:24:04 +00:00
|
|
|
TeachMachineMoveText:
|
2014-05-22 22:13:20 +00:00
|
|
|
TX_FAR _TeachMachineMoveText
|
|
|
|
db "@"
|
|
|
|
|
2016-06-12 00:24:04 +00:00
|
|
|
MonCannotLearnMachineMoveText:
|
2014-05-22 22:13:20 +00:00
|
|
|
TX_FAR _MonCannotLearnMachineMoveText
|
|
|
|
db "@"
|
|
|
|
|
2016-06-12 00:24:04 +00:00
|
|
|
PrintItemUseTextAndRemoveItem:
|
2014-05-22 22:13:20 +00:00
|
|
|
ld hl,ItemUseText00
|
|
|
|
call PrintText
|
2015-07-19 08:46:12 +00:00
|
|
|
ld a,SFX_HEAL_AILMENT
|
2015-07-03 19:37:53 +00:00
|
|
|
call PlaySound
|
2014-05-22 22:13:20 +00:00
|
|
|
call WaitForTextScrollButtonPress ; wait for button press
|
|
|
|
|
2016-06-12 00:24:04 +00:00
|
|
|
RemoveUsedItem:
|
2014-05-22 22:13:20 +00:00
|
|
|
ld hl,wNumBagItems
|
|
|
|
ld a,1 ; one item
|
2015-07-13 06:00:48 +00:00
|
|
|
ld [wItemQuantity],a
|
2014-05-22 22:13:20 +00:00
|
|
|
jp RemoveItemFromInventory
|
|
|
|
|
2016-06-12 00:24:04 +00:00
|
|
|
ItemUseNoEffect:
|
2014-05-22 22:13:20 +00:00
|
|
|
ld hl,ItemUseNoEffectText
|
|
|
|
jr ItemUseFailed
|
|
|
|
|
2016-06-12 00:24:04 +00:00
|
|
|
ItemUseNotTime:
|
2014-05-22 22:13:20 +00:00
|
|
|
ld hl,ItemUseNotTimeText
|
|
|
|
jr ItemUseFailed
|
|
|
|
|
2016-06-12 00:24:04 +00:00
|
|
|
ItemUseNotYoursToUse:
|
2014-05-22 22:13:20 +00:00
|
|
|
ld hl,ItemUseNotYoursToUseText
|
|
|
|
jr ItemUseFailed
|
|
|
|
|
2016-06-12 00:24:04 +00:00
|
|
|
ThrowBallAtTrainerMon:
|
2015-08-12 09:16:56 +00:00
|
|
|
call RunDefaultPaletteCommand
|
2014-05-22 22:13:20 +00:00
|
|
|
call LoadScreenTilesFromBuffer1 ; restore saved screen
|
|
|
|
call Delay3
|
|
|
|
ld a,TOSS_ANIM
|
2015-08-31 02:38:41 +00:00
|
|
|
ld [wAnimationID],a
|
2014-06-16 20:57:26 +00:00
|
|
|
predef MoveAnimation ; do animation
|
2014-05-22 22:13:20 +00:00
|
|
|
ld hl,ThrowBallAtTrainerMonText1
|
|
|
|
call PrintText
|
|
|
|
ld hl,ThrowBallAtTrainerMonText2
|
|
|
|
call PrintText
|
|
|
|
jr RemoveUsedItem
|
|
|
|
|
2016-06-12 00:24:04 +00:00
|
|
|
NoCyclingAllowedHere:
|
2014-05-22 22:13:20 +00:00
|
|
|
ld hl,NoCyclingAllowedHereText
|
|
|
|
jr ItemUseFailed
|
|
|
|
|
2016-06-12 00:24:04 +00:00
|
|
|
BoxFullCannotThrowBall:
|
2014-05-22 22:13:20 +00:00
|
|
|
ld hl,BoxFullCannotThrowBallText
|
|
|
|
jr ItemUseFailed
|
|
|
|
|
2016-06-12 00:24:04 +00:00
|
|
|
SurfingAttemptFailed:
|
2014-05-22 22:13:20 +00:00
|
|
|
ld hl,NoSurfingHereText
|
|
|
|
|
2016-06-12 00:24:04 +00:00
|
|
|
ItemUseFailed:
|
2014-05-22 22:13:20 +00:00
|
|
|
xor a
|
2015-07-15 06:16:06 +00:00
|
|
|
ld [wActionResultOrTookBattleTurn],a ; item use failed
|
2014-05-22 22:13:20 +00:00
|
|
|
jp PrintText
|
|
|
|
|
2016-06-12 00:24:04 +00:00
|
|
|
ItemUseNotTimeText:
|
2014-05-22 22:13:20 +00:00
|
|
|
TX_FAR _ItemUseNotTimeText
|
|
|
|
db "@"
|
|
|
|
|
2016-06-12 00:24:04 +00:00
|
|
|
ItemUseNotYoursToUseText:
|
2014-05-22 22:13:20 +00:00
|
|
|
TX_FAR _ItemUseNotYoursToUseText
|
|
|
|
db "@"
|
|
|
|
|
2016-06-12 00:24:04 +00:00
|
|
|
ItemUseNoEffectText:
|
2014-05-22 22:13:20 +00:00
|
|
|
TX_FAR _ItemUseNoEffectText
|
|
|
|
db "@"
|
|
|
|
|
2016-06-12 00:24:04 +00:00
|
|
|
ThrowBallAtTrainerMonText1:
|
2014-05-22 22:13:20 +00:00
|
|
|
TX_FAR _ThrowBallAtTrainerMonText1
|
|
|
|
db "@"
|
|
|
|
|
2016-06-12 00:24:04 +00:00
|
|
|
ThrowBallAtTrainerMonText2:
|
2014-05-22 22:13:20 +00:00
|
|
|
TX_FAR _ThrowBallAtTrainerMonText2
|
|
|
|
db "@"
|
|
|
|
|
2016-06-12 00:24:04 +00:00
|
|
|
NoCyclingAllowedHereText:
|
2014-05-22 22:13:20 +00:00
|
|
|
TX_FAR _NoCyclingAllowedHereText
|
|
|
|
db "@"
|
|
|
|
|
2016-06-12 00:24:04 +00:00
|
|
|
NoSurfingHereText:
|
2014-05-22 22:13:20 +00:00
|
|
|
TX_FAR _NoSurfingHereText
|
|
|
|
db "@"
|
|
|
|
|
2016-06-12 00:24:04 +00:00
|
|
|
BoxFullCannotThrowBallText:
|
2014-05-22 22:13:20 +00:00
|
|
|
TX_FAR _BoxFullCannotThrowBallText
|
|
|
|
db "@"
|
|
|
|
|
2016-06-12 00:24:04 +00:00
|
|
|
ItemUseText00:
|
2014-05-22 22:13:20 +00:00
|
|
|
TX_FAR _ItemUseText001
|
2016-07-18 06:17:03 +00:00
|
|
|
TX_LINE
|
2014-05-22 22:13:20 +00:00
|
|
|
TX_FAR _ItemUseText002
|
|
|
|
db "@"
|
|
|
|
|
2016-06-12 00:24:04 +00:00
|
|
|
GotOnBicycleText:
|
2014-05-22 22:13:20 +00:00
|
|
|
TX_FAR _GotOnBicycleText1
|
2016-07-18 06:17:03 +00:00
|
|
|
TX_LINE
|
2014-05-22 22:13:20 +00:00
|
|
|
TX_FAR _GotOnBicycleText2
|
|
|
|
db "@"
|
|
|
|
|
2016-06-12 00:24:04 +00:00
|
|
|
GotOffBicycleText:
|
2014-05-22 22:13:20 +00:00
|
|
|
TX_FAR _GotOffBicycleText1
|
2016-07-18 06:17:03 +00:00
|
|
|
TX_LINE
|
2014-05-22 22:13:20 +00:00
|
|
|
TX_FAR _GotOffBicycleText2
|
|
|
|
db "@"
|
|
|
|
|
|
|
|
; restores bonus PP (from PP Ups) when healing at a pokemon center
|
|
|
|
; also, when a PP Up is used, it increases the current PP by one PP Up bonus
|
|
|
|
; INPUT:
|
|
|
|
; [wWhichPokemon] = index of pokemon in party
|
|
|
|
; [wCurrentMenuItem] = index of move (when using a PP Up)
|
2016-06-12 00:24:04 +00:00
|
|
|
RestoreBonusPP:
|
2014-06-14 11:12:40 +00:00
|
|
|
ld hl,wPartyMon1Moves
|
2015-08-07 12:20:37 +00:00
|
|
|
ld bc, wPartyMon2 - wPartyMon1
|
2014-05-22 22:13:20 +00:00
|
|
|
ld a,[wWhichPokemon]
|
|
|
|
call AddNTimes
|
|
|
|
push hl
|
2015-07-15 06:16:06 +00:00
|
|
|
ld de,wNormalMaxPPList - 1
|
|
|
|
predef LoadMovePPs ; loads the normal max PP of each of the pokemon's moves to wNormalMaxPPList
|
2014-05-22 22:13:20 +00:00
|
|
|
pop hl
|
2015-08-07 12:20:37 +00:00
|
|
|
ld c, wPartyMon1PP - wPartyMon1Moves
|
2014-05-22 22:13:20 +00:00
|
|
|
ld b,0
|
|
|
|
add hl,bc ; hl now points to move 1 PP
|
2015-07-15 06:16:06 +00:00
|
|
|
ld de,wNormalMaxPPList
|
2014-05-22 22:13:20 +00:00
|
|
|
ld b,0 ; initialize move counter to zero
|
|
|
|
; loop through the pokemon's moves
|
|
|
|
.loop
|
|
|
|
inc b
|
|
|
|
ld a,b
|
|
|
|
cp a,5 ; reached the end of the pokemon's moves?
|
|
|
|
ret z ; if so, return
|
2015-08-07 12:20:37 +00:00
|
|
|
ld a,[wUsingPPUp]
|
2014-05-22 22:13:20 +00:00
|
|
|
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
|
|
|
|
ld a,[wCurrentMenuItem]
|
|
|
|
inc a
|
|
|
|
cp b
|
|
|
|
jr nz,.nextMove
|
|
|
|
.skipMenuItemIDCheck
|
|
|
|
ld a,[hl]
|
|
|
|
and a,%11000000 ; have any PP Ups been used?
|
|
|
|
call nz,AddBonusPP ; if so, add bonus PP
|
|
|
|
.nextMove
|
|
|
|
inc hl
|
|
|
|
inc de
|
|
|
|
jr .loop
|
|
|
|
|
|
|
|
; adds bonus PP from PP Ups to current PP
|
|
|
|
; 1/5 of normal max PP (capped at 7) is added for each PP Up
|
|
|
|
; INPUT:
|
|
|
|
; [de] = normal max PP
|
|
|
|
; [hl] = move PP
|
2016-06-12 00:24:04 +00:00
|
|
|
AddBonusPP:
|
2014-05-22 22:13:20 +00:00
|
|
|
push bc
|
|
|
|
ld a,[de] ; normal max PP of move
|
|
|
|
ld [H_DIVIDEND + 3],a
|
|
|
|
xor a
|
|
|
|
ld [H_DIVIDEND],a
|
|
|
|
ld [H_DIVIDEND + 1],a
|
|
|
|
ld [H_DIVIDEND + 2],a
|
|
|
|
ld a,5
|
|
|
|
ld [H_DIVISOR],a
|
|
|
|
ld b,4
|
|
|
|
call Divide
|
|
|
|
ld a,[hl] ; move PP
|
|
|
|
ld b,a
|
|
|
|
swap a
|
|
|
|
and a,%00001111
|
|
|
|
srl a
|
|
|
|
srl a
|
|
|
|
ld c,a ; c = number of PP Ups used
|
|
|
|
.loop
|
|
|
|
ld a,[H_QUOTIENT + 3]
|
|
|
|
cp a,8 ; is the amount greater than or equal to 8?
|
|
|
|
jr c,.addAmount
|
|
|
|
ld a,7 ; cap the amount at 7
|
|
|
|
.addAmount
|
|
|
|
add b
|
|
|
|
ld b,a
|
2015-08-07 12:20:37 +00:00
|
|
|
ld a,[wUsingPPUp]
|
|
|
|
dec a ; is the player using a PP Up right now?
|
|
|
|
jr z,.done ; if so, only add the bonus once
|
2014-05-22 22:13:20 +00:00
|
|
|
dec c
|
|
|
|
jr nz,.loop
|
|
|
|
.done
|
|
|
|
ld [hl],b
|
|
|
|
pop bc
|
|
|
|
ret
|
|
|
|
|
|
|
|
; gets max PP of a pokemon's move (including PP from PP Ups)
|
|
|
|
; INPUT:
|
|
|
|
; [wWhichPokemon] = index of pokemon within party/box
|
2015-07-16 03:04:58 +00:00
|
|
|
; [wMonDataLocation] = pokemon source
|
2014-05-22 22:13:20 +00:00
|
|
|
; 00: player's party
|
|
|
|
; 01: enemy's party
|
|
|
|
; 02: current box
|
|
|
|
; 03: daycare
|
|
|
|
; 04: player's in-battle pokemon
|
|
|
|
; [wCurrentMenuItem] = move index
|
|
|
|
; OUTPUT:
|
2015-08-07 12:20:37 +00:00
|
|
|
; [wMaxPP] = max PP
|
2016-06-12 00:24:04 +00:00
|
|
|
GetMaxPP:
|
2015-07-16 03:04:58 +00:00
|
|
|
ld a,[wMonDataLocation]
|
2014-05-22 22:13:20 +00:00
|
|
|
and a
|
2014-06-14 11:12:40 +00:00
|
|
|
ld hl,wPartyMon1Moves
|
|
|
|
ld bc,wPartyMon2 - wPartyMon1
|
2014-05-22 22:13:20 +00:00
|
|
|
jr z,.sourceWithMultipleMon
|
2014-06-14 11:12:40 +00:00
|
|
|
ld hl,wEnemyMon1Moves
|
2014-05-22 22:13:20 +00:00
|
|
|
dec a
|
|
|
|
jr z,.sourceWithMultipleMon
|
2014-06-14 11:12:40 +00:00
|
|
|
ld hl,wBoxMon1Moves
|
|
|
|
ld bc,wBoxMon2 - wBoxMon1
|
2014-05-22 22:13:20 +00:00
|
|
|
dec a
|
|
|
|
jr z,.sourceWithMultipleMon
|
2014-06-14 11:12:40 +00:00
|
|
|
ld hl,wDayCareMonMoves
|
2014-05-22 22:13:20 +00:00
|
|
|
dec a
|
|
|
|
jr z,.sourceWithOneMon
|
2014-06-14 11:12:40 +00:00
|
|
|
ld hl,wBattleMonMoves ; player's in-battle pokemon
|
2014-05-22 22:13:20 +00:00
|
|
|
.sourceWithOneMon
|
|
|
|
call GetSelectedMoveOffset2
|
|
|
|
jr .next
|
|
|
|
.sourceWithMultipleMon
|
|
|
|
call GetSelectedMoveOffset
|
|
|
|
.next
|
|
|
|
ld a,[hl]
|
|
|
|
dec a
|
|
|
|
push hl
|
|
|
|
ld hl,Moves
|
2015-08-10 04:56:20 +00:00
|
|
|
ld bc,MoveEnd - Moves
|
2014-05-22 22:13:20 +00:00
|
|
|
call AddNTimes
|
2014-05-26 21:04:56 +00:00
|
|
|
ld de,wcd6d
|
2014-05-22 22:13:20 +00:00
|
|
|
ld a,BANK(Moves)
|
|
|
|
call FarCopyData
|
2015-07-15 06:16:06 +00:00
|
|
|
ld de,wcd6d + 5 ; PP is byte 5 of move data
|
2014-05-22 22:13:20 +00:00
|
|
|
ld a,[de]
|
|
|
|
ld b,a ; b = normal max PP
|
|
|
|
pop hl
|
|
|
|
push bc
|
2015-07-24 08:49:33 +00:00
|
|
|
ld bc,wPartyMon1PP - wPartyMon1Moves ; PP offset if not player's in-battle pokemon data
|
2015-07-16 03:04:58 +00:00
|
|
|
ld a,[wMonDataLocation]
|
2014-05-22 22:13:20 +00:00
|
|
|
cp a,4 ; player's in-battle pokemon?
|
|
|
|
jr nz,.addPPOffset
|
2015-07-24 08:49:33 +00:00
|
|
|
ld bc,wBattleMonPP - wBattleMonMoves ; PP offset if player's in-battle pokemon data
|
2014-05-22 22:13:20 +00:00
|
|
|
.addPPOffset
|
|
|
|
add hl,bc
|
|
|
|
ld a,[hl] ; a = current PP
|
|
|
|
and a,%11000000 ; get PP Up count
|
|
|
|
pop bc
|
|
|
|
or b ; place normal max PP in 6 lower bits of a
|
|
|
|
ld h,d
|
|
|
|
ld l,e
|
2014-05-26 21:04:56 +00:00
|
|
|
inc hl ; hl = wcd73
|
2014-05-22 22:13:20 +00:00
|
|
|
ld [hl],a
|
2015-08-07 12:20:37 +00:00
|
|
|
xor a ; add the bonus for the existing PP Up count
|
|
|
|
ld [wUsingPPUp],a
|
2014-05-22 22:13:20 +00:00
|
|
|
call AddBonusPP ; add bonus PP from PP Ups
|
|
|
|
ld a,[hl]
|
|
|
|
and a,%00111111 ; mask out the PP Up count
|
2015-08-07 12:20:37 +00:00
|
|
|
ld [wMaxPP],a ; store max PP
|
2014-05-22 22:13:20 +00:00
|
|
|
ret
|
|
|
|
|
2016-06-12 00:24:04 +00:00
|
|
|
GetSelectedMoveOffset:
|
2014-05-22 22:13:20 +00:00
|
|
|
ld a,[wWhichPokemon]
|
|
|
|
call AddNTimes
|
|
|
|
|
2016-06-12 00:24:04 +00:00
|
|
|
GetSelectedMoveOffset2:
|
2014-05-22 22:13:20 +00:00
|
|
|
ld a,[wCurrentMenuItem]
|
|
|
|
ld c,a
|
|
|
|
ld b,0
|
|
|
|
add hl,bc
|
|
|
|
ret
|
|
|
|
|
|
|
|
; confirms the item toss and then tosses the item
|
|
|
|
; INPUT:
|
|
|
|
; hl = address of inventory (either wNumBagItems or wNumBoxItems)
|
2014-05-26 21:04:56 +00:00
|
|
|
; [wcf91] = item ID
|
2014-05-22 22:13:20 +00:00
|
|
|
; [wWhichPokemon] = index of item within inventory
|
2015-07-13 06:00:48 +00:00
|
|
|
; [wItemQuantity] = quantity to toss
|
2014-05-22 22:13:20 +00:00
|
|
|
; OUTPUT:
|
|
|
|
; clears carry flag if the item is tossed, sets carry flag if not
|
2016-06-12 00:24:04 +00:00
|
|
|
TossItem_:
|
2014-05-22 22:13:20 +00:00
|
|
|
push hl
|
2014-05-26 21:04:56 +00:00
|
|
|
ld a,[wcf91]
|
2014-05-22 22:13:20 +00:00
|
|
|
call IsItemHM
|
|
|
|
pop hl
|
|
|
|
jr c,.tooImportantToToss
|
|
|
|
push hl
|
|
|
|
call IsKeyItem_
|
2015-07-13 06:00:48 +00:00
|
|
|
ld a,[wIsKeyItem]
|
2014-05-22 22:13:20 +00:00
|
|
|
pop hl
|
|
|
|
and a
|
|
|
|
jr nz,.tooImportantToToss
|
|
|
|
push hl
|
2014-05-26 21:04:56 +00:00
|
|
|
ld a,[wcf91]
|
|
|
|
ld [wd11e],a
|
2014-05-22 22:13:20 +00:00
|
|
|
call GetItemName
|
2014-05-26 21:04:56 +00:00
|
|
|
call CopyStringToCF4B ; copy name to wcf4b
|
2014-05-22 22:13:20 +00:00
|
|
|
ld hl,IsItOKToTossItemText
|
|
|
|
call PrintText
|
2015-07-18 20:52:03 +00:00
|
|
|
coord hl, 14, 7
|
2015-08-05 21:20:29 +00:00
|
|
|
lb bc, 8, 15
|
2015-02-07 20:27:36 +00:00
|
|
|
ld a,TWO_OPTION_MENU
|
2015-02-07 10:43:08 +00:00
|
|
|
ld [wTextBoxID],a
|
2014-05-22 22:13:20 +00:00
|
|
|
call DisplayTextBoxID ; yes/no menu
|
2015-07-13 06:00:48 +00:00
|
|
|
ld a,[wMenuExitMethod]
|
|
|
|
cp a,CHOSE_SECOND_ITEM
|
2014-05-22 22:13:20 +00:00
|
|
|
pop hl
|
|
|
|
scf
|
2015-07-13 06:00:48 +00:00
|
|
|
ret z ; return if the player chose No
|
2014-05-22 22:13:20 +00:00
|
|
|
; if the player chose Yes
|
|
|
|
push hl
|
|
|
|
ld a,[wWhichPokemon]
|
|
|
|
call RemoveItemFromInventory
|
2014-05-26 21:04:56 +00:00
|
|
|
ld a,[wcf91]
|
|
|
|
ld [wd11e],a
|
2014-05-22 22:13:20 +00:00
|
|
|
call GetItemName
|
2014-05-26 21:04:56 +00:00
|
|
|
call CopyStringToCF4B ; copy name to wcf4b
|
2014-05-22 22:13:20 +00:00
|
|
|
ld hl,ThrewAwayItemText
|
|
|
|
call PrintText
|
|
|
|
pop hl
|
|
|
|
and a
|
|
|
|
ret
|
|
|
|
.tooImportantToToss
|
|
|
|
push hl
|
|
|
|
ld hl,TooImportantToTossText
|
|
|
|
call PrintText
|
|
|
|
pop hl
|
|
|
|
scf
|
|
|
|
ret
|
|
|
|
|
2016-06-12 00:24:04 +00:00
|
|
|
ThrewAwayItemText:
|
2014-05-22 22:13:20 +00:00
|
|
|
TX_FAR _ThrewAwayItemText
|
|
|
|
db "@"
|
|
|
|
|
2016-06-12 00:24:04 +00:00
|
|
|
IsItOKToTossItemText:
|
2014-05-22 22:13:20 +00:00
|
|
|
TX_FAR _IsItOKToTossItemText
|
|
|
|
db "@"
|
|
|
|
|
2016-06-12 00:24:04 +00:00
|
|
|
TooImportantToTossText:
|
2014-05-22 22:13:20 +00:00
|
|
|
TX_FAR _TooImportantToTossText
|
|
|
|
db "@"
|
|
|
|
|
|
|
|
; checks if an item is a key item
|
|
|
|
; INPUT:
|
2014-05-26 21:04:56 +00:00
|
|
|
; [wcf91] = item ID
|
2014-05-22 22:13:20 +00:00
|
|
|
; OUTPUT:
|
2015-07-13 06:00:48 +00:00
|
|
|
; [wIsKeyItem] = result
|
2014-05-22 22:13:20 +00:00
|
|
|
; 00: item is not key item
|
|
|
|
; 01: item is key item
|
2016-06-12 00:24:04 +00:00
|
|
|
IsKeyItem_:
|
2014-05-22 22:13:20 +00:00
|
|
|
ld a,$01
|
2015-07-13 06:00:48 +00:00
|
|
|
ld [wIsKeyItem],a
|
2014-05-26 21:04:56 +00:00
|
|
|
ld a,[wcf91]
|
2014-05-22 22:13:20 +00:00
|
|
|
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
|
2015-07-25 03:27:59 +00:00
|
|
|
ld de,wBuffer
|
2014-05-22 22:13:20 +00:00
|
|
|
ld bc,15 ; only 11 bytes are actually used
|
|
|
|
call CopyData
|
|
|
|
pop af
|
|
|
|
dec a
|
|
|
|
ld c,a
|
2015-07-25 03:27:59 +00:00
|
|
|
ld hl,wBuffer
|
2015-07-20 03:45:34 +00:00
|
|
|
ld b,FLAG_TEST
|
|
|
|
predef FlagActionPredef
|
2014-05-22 22:13:20 +00:00
|
|
|
ld a,c
|
|
|
|
and a
|
|
|
|
ret nz
|
|
|
|
.checkIfItemIsHM
|
2014-05-26 21:04:56 +00:00
|
|
|
ld a,[wcf91]
|
2014-05-22 22:13:20 +00:00
|
|
|
call IsItemHM
|
|
|
|
ret c
|
|
|
|
xor a
|
2015-07-13 06:00:48 +00:00
|
|
|
ld [wIsKeyItem],a
|
2014-05-22 22:13:20 +00:00
|
|
|
ret
|
|
|
|
|
|
|
|
INCLUDE "data/key_items.asm"
|
|
|
|
|
2016-06-12 00:24:04 +00:00
|
|
|
SendNewMonToBox:
|
2015-08-31 02:38:41 +00:00
|
|
|
ld de, wNumInBox
|
2014-05-22 22:13:20 +00:00
|
|
|
ld a, [de]
|
|
|
|
inc a
|
|
|
|
ld [de], a
|
2014-05-26 21:04:56 +00:00
|
|
|
ld a, [wcf91]
|
|
|
|
ld [wd0b5], a
|
2014-05-22 22:13:20 +00:00
|
|
|
ld c, a
|
|
|
|
.asm_e7b1
|
|
|
|
inc de
|
|
|
|
ld a, [de]
|
|
|
|
ld b, a
|
|
|
|
ld a, c
|
|
|
|
ld c, b
|
|
|
|
ld [de], a
|
|
|
|
cp $ff
|
|
|
|
jr nz, .asm_e7b1
|
|
|
|
call GetMonHeader
|
2014-06-14 11:12:40 +00:00
|
|
|
ld hl, wBoxMonOT
|
2015-08-11 04:51:20 +00:00
|
|
|
ld bc, NAME_LENGTH
|
2015-08-31 02:38:41 +00:00
|
|
|
ld a, [wNumInBox]
|
2014-05-22 22:13:20 +00:00
|
|
|
dec a
|
|
|
|
jr z, .asm_e7ee
|
|
|
|
dec a
|
|
|
|
call AddNTimes
|
|
|
|
push hl
|
2015-08-11 04:51:20 +00:00
|
|
|
ld bc, NAME_LENGTH
|
2014-05-22 22:13:20 +00:00
|
|
|
add hl, bc
|
|
|
|
ld d, h
|
|
|
|
ld e, l
|
|
|
|
pop hl
|
2015-08-31 02:38:41 +00:00
|
|
|
ld a, [wNumInBox]
|
2014-05-22 22:13:20 +00:00
|
|
|
dec a
|
|
|
|
ld b, a
|
|
|
|
.asm_e7db
|
|
|
|
push bc
|
|
|
|
push hl
|
2015-08-11 04:51:20 +00:00
|
|
|
ld bc, NAME_LENGTH
|
2014-05-22 22:13:20 +00:00
|
|
|
call CopyData
|
|
|
|
pop hl
|
|
|
|
ld d, h
|
|
|
|
ld e, l
|
2015-08-11 04:51:20 +00:00
|
|
|
ld bc, -NAME_LENGTH
|
2014-05-22 22:13:20 +00:00
|
|
|
add hl, bc
|
|
|
|
pop bc
|
|
|
|
dec b
|
|
|
|
jr nz, .asm_e7db
|
|
|
|
.asm_e7ee
|
2015-07-03 19:37:53 +00:00
|
|
|
ld hl, wPlayerName
|
2014-06-14 11:12:40 +00:00
|
|
|
ld de, wBoxMonOT
|
2015-08-11 04:51:20 +00:00
|
|
|
ld bc, NAME_LENGTH
|
2014-05-22 22:13:20 +00:00
|
|
|
call CopyData
|
2015-08-31 02:38:41 +00:00
|
|
|
ld a, [wNumInBox]
|
2014-05-22 22:13:20 +00:00
|
|
|
dec a
|
|
|
|
jr z, .asm_e82a
|
2014-06-14 11:12:40 +00:00
|
|
|
ld hl, wBoxMonNicks
|
2015-08-11 04:51:20 +00:00
|
|
|
ld bc, NAME_LENGTH
|
2014-05-22 22:13:20 +00:00
|
|
|
dec a
|
|
|
|
call AddNTimes
|
|
|
|
push hl
|
2015-08-11 04:51:20 +00:00
|
|
|
ld bc, NAME_LENGTH
|
2014-05-22 22:13:20 +00:00
|
|
|
add hl, bc
|
|
|
|
ld d, h
|
|
|
|
ld e, l
|
|
|
|
pop hl
|
2015-08-31 02:38:41 +00:00
|
|
|
ld a, [wNumInBox]
|
2014-05-22 22:13:20 +00:00
|
|
|
dec a
|
|
|
|
ld b, a
|
|
|
|
.asm_e817
|
|
|
|
push bc
|
|
|
|
push hl
|
2015-08-11 04:51:20 +00:00
|
|
|
ld bc, NAME_LENGTH
|
2014-05-22 22:13:20 +00:00
|
|
|
call CopyData
|
|
|
|
pop hl
|
|
|
|
ld d, h
|
|
|
|
ld e, l
|
2015-08-11 04:51:20 +00:00
|
|
|
ld bc, -NAME_LENGTH
|
2014-05-22 22:13:20 +00:00
|
|
|
add hl, bc
|
|
|
|
pop bc
|
|
|
|
dec b
|
|
|
|
jr nz, .asm_e817
|
|
|
|
.asm_e82a
|
2014-06-14 11:12:40 +00:00
|
|
|
ld hl, wBoxMonNicks
|
2015-07-13 22:40:33 +00:00
|
|
|
ld a, NAME_MON_SCREEN
|
|
|
|
ld [wNamingScreenType], a
|
2014-06-16 20:57:26 +00:00
|
|
|
predef AskName
|
2015-08-31 02:38:41 +00:00
|
|
|
ld a, [wNumInBox]
|
2014-05-22 22:13:20 +00:00
|
|
|
dec a
|
|
|
|
jr z, .asm_e867
|
2014-06-14 11:12:40 +00:00
|
|
|
ld hl, wBoxMons
|
|
|
|
ld bc, wBoxMon2 - wBoxMon1
|
2014-05-22 22:13:20 +00:00
|
|
|
dec a
|
|
|
|
call AddNTimes
|
|
|
|
push hl
|
2014-06-14 11:12:40 +00:00
|
|
|
ld bc, wBoxMon2 - wBoxMon1
|
2014-05-22 22:13:20 +00:00
|
|
|
add hl, bc
|
|
|
|
ld d, h
|
|
|
|
ld e, l
|
|
|
|
pop hl
|
2015-08-31 02:38:41 +00:00
|
|
|
ld a, [wNumInBox]
|
2014-05-22 22:13:20 +00:00
|
|
|
dec a
|
|
|
|
ld b, a
|
|
|
|
.asm_e854
|
|
|
|
push bc
|
|
|
|
push hl
|
2014-06-14 11:12:40 +00:00
|
|
|
ld bc, wBoxMon2 - wBoxMon1
|
2014-05-22 22:13:20 +00:00
|
|
|
call CopyData
|
|
|
|
pop hl
|
|
|
|
ld d, h
|
|
|
|
ld e, l
|
2015-07-24 08:49:33 +00:00
|
|
|
ld bc, wBoxMon1 - wBoxMon2
|
2014-05-22 22:13:20 +00:00
|
|
|
add hl, bc
|
|
|
|
pop bc
|
|
|
|
dec b
|
|
|
|
jr nz, .asm_e854
|
|
|
|
.asm_e867
|
2015-07-03 19:37:53 +00:00
|
|
|
ld a, [wEnemyMonLevel]
|
2014-06-14 11:12:40 +00:00
|
|
|
ld [wEnemyMonBoxLevel], a
|
|
|
|
ld hl, wEnemyMon
|
|
|
|
ld de, wBoxMon1
|
2015-07-24 08:49:33 +00:00
|
|
|
ld bc, wEnemyMonDVs - wEnemyMon
|
2014-05-22 22:13:20 +00:00
|
|
|
call CopyData
|
2015-07-03 19:37:53 +00:00
|
|
|
ld hl, wPlayerID
|
2014-05-22 22:13:20 +00:00
|
|
|
ld a, [hli]
|
|
|
|
ld [de], a
|
|
|
|
inc de
|
|
|
|
ld a, [hl]
|
|
|
|
ld [de], a
|
|
|
|
inc de
|
|
|
|
push de
|
2015-08-31 02:38:41 +00:00
|
|
|
ld a, [wCurEnemyLVL]
|
2014-05-22 22:13:20 +00:00
|
|
|
ld d, a
|
|
|
|
callab CalcExperience
|
|
|
|
pop de
|
2015-07-19 03:49:52 +00:00
|
|
|
ld a, [hExperience]
|
2014-05-22 22:13:20 +00:00
|
|
|
ld [de], a
|
|
|
|
inc de
|
2015-07-19 03:49:52 +00:00
|
|
|
ld a, [hExperience + 1]
|
2014-05-22 22:13:20 +00:00
|
|
|
ld [de], a
|
|
|
|
inc de
|
2015-07-19 03:49:52 +00:00
|
|
|
ld a, [hExperience + 2]
|
2014-05-22 22:13:20 +00:00
|
|
|
ld [de], a
|
|
|
|
inc de
|
|
|
|
xor a
|
2015-07-24 08:49:33 +00:00
|
|
|
ld b, NUM_STATS * 2
|
2014-05-22 22:13:20 +00:00
|
|
|
.asm_e89f
|
|
|
|
ld [de], a
|
|
|
|
inc de
|
|
|
|
dec b
|
|
|
|
jr nz, .asm_e89f
|
2014-06-14 11:12:40 +00:00
|
|
|
ld hl, wEnemyMonDVs
|
2014-05-22 22:13:20 +00:00
|
|
|
ld a, [hli]
|
|
|
|
ld [de], a
|
|
|
|
inc de
|
|
|
|
ld a, [hli]
|
|
|
|
ld [de], a
|
2015-07-03 19:37:53 +00:00
|
|
|
ld hl, wEnemyMonPP
|
2015-07-24 08:49:33 +00:00
|
|
|
ld b, NUM_MOVES
|
2014-05-22 22:13:20 +00:00
|
|
|
.asm_e8b1
|
|
|
|
ld a, [hli]
|
|
|
|
inc de
|
|
|
|
ld [de], a
|
|
|
|
dec b
|
|
|
|
jr nz, .asm_e8b1
|
|
|
|
ret
|
|
|
|
|
|
|
|
; checks if the tile in front of the player is a shore or water tile
|
|
|
|
; used for surfing and fishing
|
|
|
|
; unsets carry if it is, sets carry if not
|
2016-06-12 00:24:04 +00:00
|
|
|
IsNextTileShoreOrWater:
|
2015-08-31 02:38:41 +00:00
|
|
|
ld a, [wCurMapTileset]
|
2014-05-22 22:13:20 +00:00
|
|
|
ld hl, WaterTilesets
|
|
|
|
ld de,1
|
|
|
|
call IsInArray
|
|
|
|
jr nc, .notShoreOrWater
|
2015-08-31 02:38:41 +00:00
|
|
|
ld a, [wCurMapTileset]
|
2014-05-22 22:13:20 +00:00
|
|
|
cp SHIP_PORT ; Vermilion Dock tileset
|
2014-09-13 07:50:56 +00:00
|
|
|
ld a, [wTileInFrontOfPlayer] ; tile in front of player
|
2014-05-22 22:13:20 +00:00
|
|
|
jr z, .skipShoreTiles ; if it's the Vermilion Dock tileset
|
|
|
|
cp $48 ; eastern shore tile in Safari Zone
|
|
|
|
jr z, .shoreOrWater
|
|
|
|
cp $32 ; usual eastern shore tile
|
|
|
|
jr z, .shoreOrWater
|
|
|
|
.skipShoreTiles
|
|
|
|
cp $14 ; water tile
|
|
|
|
jr z, .shoreOrWater
|
|
|
|
.notShoreOrWater
|
|
|
|
scf
|
|
|
|
ret
|
|
|
|
.shoreOrWater
|
|
|
|
and a
|
|
|
|
ret
|
|
|
|
|
|
|
|
; tilesets with water
|
2016-06-12 00:24:04 +00:00
|
|
|
WaterTilesets:
|
2014-05-22 22:13:20 +00:00
|
|
|
db OVERWORLD, FOREST, DOJO, GYM, SHIP, SHIP_PORT, CAVERN, FACILITY, PLATEAU
|
|
|
|
db $ff ; terminator
|
|
|
|
|
2016-06-12 00:24:04 +00:00
|
|
|
ReadSuperRodData:
|
2014-05-22 22:13:20 +00:00
|
|
|
; return e = 2 if no fish on this map
|
|
|
|
; return e = 1 if a bite, bc = level,species
|
|
|
|
; return e = 0 if no bite
|
2015-08-31 02:38:41 +00:00
|
|
|
ld a, [wCurMap]
|
2014-05-22 22:13:20 +00:00
|
|
|
ld de, 3 ; each fishing group is three bytes wide
|
|
|
|
ld hl, SuperRodData
|
|
|
|
call IsInArray
|
|
|
|
jr c, .ReadFishingGroup
|
|
|
|
ld e, $2 ; $2 if no fishing groups found
|
|
|
|
ret
|
|
|
|
|
2015-07-03 19:37:53 +00:00
|
|
|
.ReadFishingGroup
|
2014-05-22 22:13:20 +00:00
|
|
|
; hl points to the fishing group entry in the index
|
|
|
|
inc hl ; skip map id
|
|
|
|
|
|
|
|
; read fishing group address
|
|
|
|
ld a, [hli]
|
|
|
|
ld h, [hl]
|
|
|
|
ld l, a
|
|
|
|
|
|
|
|
ld b, [hl] ; how many mons in group
|
|
|
|
inc hl ; point to data
|
|
|
|
ld e, $0 ; no bite yet
|
|
|
|
|
2015-07-03 19:37:53 +00:00
|
|
|
.RandomLoop
|
2014-05-24 18:40:38 +00:00
|
|
|
call Random
|
2014-05-22 22:13:20 +00:00
|
|
|
srl a
|
|
|
|
ret c ; 50% chance of no battle
|
|
|
|
|
|
|
|
and %11 ; 2-bit random number
|
|
|
|
cp b
|
|
|
|
jr nc, .RandomLoop ; if a is greater than the number of mons, regenerate
|
|
|
|
|
|
|
|
; get the mon
|
|
|
|
add a
|
|
|
|
ld c, a
|
|
|
|
ld b, $0
|
|
|
|
add hl, bc
|
|
|
|
ld b, [hl] ; level
|
|
|
|
inc hl
|
|
|
|
ld c, [hl] ; species
|
|
|
|
ld e, $1 ; $1 if there's a bite
|
|
|
|
ret
|
|
|
|
|
|
|
|
INCLUDE "data/super_rod.asm"
|
|
|
|
|
|
|
|
; reloads map view and processes sprite data
|
|
|
|
; for items that cause the overworld to be displayed
|
2016-06-12 00:24:04 +00:00
|
|
|
ItemUseReloadOverworldData:
|
2014-05-22 22:13:20 +00:00
|
|
|
call LoadCurrentMapView
|
|
|
|
jp UpdateSprites
|
|
|
|
|
2015-02-08 06:18:42 +00:00
|
|
|
; creates a list at wBuffer of maps where the mon in [wd11e] can be found.
|
|
|
|
; this is used by the pokedex to display locations the mon can be found on the map.
|
2016-06-12 00:24:04 +00:00
|
|
|
FindWildLocationsOfMon:
|
2015-02-08 06:18:42 +00:00
|
|
|
ld hl, WildDataPointers
|
|
|
|
ld de, wBuffer
|
2014-05-22 22:13:20 +00:00
|
|
|
ld c, $0
|
2015-02-08 06:18:42 +00:00
|
|
|
.loop
|
2014-05-22 22:13:20 +00:00
|
|
|
inc hl
|
|
|
|
ld a, [hld]
|
|
|
|
inc a
|
2015-02-08 06:18:42 +00:00
|
|
|
jr z, .done
|
2014-05-22 22:13:20 +00:00
|
|
|
push hl
|
|
|
|
ld a, [hli]
|
|
|
|
ld h, [hl]
|
|
|
|
ld l, a
|
|
|
|
ld a, [hli]
|
|
|
|
and a
|
2015-02-08 06:18:42 +00:00
|
|
|
call nz, CheckMapForMon ; land
|
2014-05-22 22:13:20 +00:00
|
|
|
ld a, [hli]
|
|
|
|
and a
|
2015-02-08 06:18:42 +00:00
|
|
|
call nz, CheckMapForMon ; water
|
2014-05-22 22:13:20 +00:00
|
|
|
pop hl
|
|
|
|
inc hl
|
|
|
|
inc hl
|
|
|
|
inc c
|
2015-02-08 06:18:42 +00:00
|
|
|
jr .loop
|
|
|
|
.done
|
|
|
|
ld a, $ff ; list terminator
|
2014-05-22 22:13:20 +00:00
|
|
|
ld [de], a
|
|
|
|
ret
|
|
|
|
|
2016-06-12 00:24:04 +00:00
|
|
|
CheckMapForMon:
|
2014-05-22 22:13:20 +00:00
|
|
|
inc hl
|
|
|
|
ld b, $a
|
2015-02-08 06:18:42 +00:00
|
|
|
.loop
|
2014-05-26 21:04:56 +00:00
|
|
|
ld a, [wd11e]
|
2014-05-22 22:13:20 +00:00
|
|
|
cp [hl]
|
2015-02-08 06:18:42 +00:00
|
|
|
jr nz, .nextEntry
|
2014-05-22 22:13:20 +00:00
|
|
|
ld a, c
|
|
|
|
ld [de], a
|
|
|
|
inc de
|
2015-02-08 06:18:42 +00:00
|
|
|
.nextEntry
|
2014-05-22 22:13:20 +00:00
|
|
|
inc hl
|
|
|
|
inc hl
|
|
|
|
dec b
|
2015-02-08 06:18:42 +00:00
|
|
|
jr nz, .loop
|
2014-05-22 22:13:20 +00:00
|
|
|
dec hl
|
|
|
|
ret
|