summaryrefslogtreecommitdiff
path: root/engine/items
diff options
context:
space:
mode:
Diffstat (limited to 'engine/items')
-rw-r--r--engine/items/inventory.asm4
-rwxr-xr-xengine/items/item_effects.asm144
-rwxr-xr-xengine/items/tm_prices.asm6
-rwxr-xr-xengine/items/town_map.asm54
4 files changed, 104 insertions, 104 deletions
diff --git a/engine/items/inventory.asm b/engine/items/inventory.asm
index 7ce61cb9..bf433175 100644
--- a/engine/items/inventory.asm
+++ b/engine/items/inventory.asm
@@ -12,10 +12,10 @@ AddItemToInventory_::
push hl
push hl
ld d, PC_ITEM_CAPACITY ; how many items the PC can hold
- ld a, wNumBagItems & $FF
+ ld a, LOW(wNumBagItems)
cp l
jr nz, .checkIfInventoryFull
- ld a, wNumBagItems >> 8
+ ld a, HIGH(wNumBagItems)
cp h
jr nz, .checkIfInventoryFull
; if the destination is the bag
diff --git a/engine/items/item_effects.asm b/engine/items/item_effects.asm
index 238c2ea9..b04f11fb 100755
--- a/engine/items/item_effects.asm
+++ b/engine/items/item_effects.asm
@@ -147,7 +147,7 @@ ItemUseBall:
; 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.
- callab IsGhostBattle
+ callfar IsGhostBattle
ld b, $10 ; can't be caught value
jp z, .setAnimData
@@ -239,14 +239,14 @@ ItemUseBall:
; Calculate MaxHP * 255.
xor a
- ld [hMultiplicand], a
+ ldh [hMultiplicand], a
ld hl, wEnemyMonMaxHP
ld a, [hli]
- ld [hMultiplicand + 1], a
+ ldh [hMultiplicand + 1], a
ld a, [hl]
- ld [hMultiplicand + 2], a
+ ldh [hMultiplicand + 2], a
ld a, 255
- ld [hMultiplier], a
+ ldh [hMultiplier], a
call Multiply
; Determine BallFactor. It's 8 for Great Balls and 12 for the others.
@@ -260,7 +260,7 @@ ItemUseBall:
; Note that the results of all division operations are floored.
; Calculate (MaxHP * 255) / BallFactor.
- ld [hDivisor], a
+ ldh [hDivisor], a
ld b, 4 ; number of bytes in dividend
call Divide
@@ -281,17 +281,17 @@ ItemUseBall:
.skip2
; Let W = ((MaxHP * 255) / BallFactor) / max(HP / 4, 1). Calculate W.
- ld [hDivisor], a
+ ldh [hDivisor], a
ld b, 4
call Divide
; If W > 255, store 255 in [hQuotient + 3].
; Let X = min(W, 255) = [hQuotient + 3].
- ld a, [hQuotient + 2]
+ ldh a, [hQuotient + 2]
and a
jr z, .skip3
ld a, 255
- ld [hQuotient + 3], a
+ ldh [hQuotient + 3], a
.skip3
pop bc ; b = Rand1 - Status
@@ -302,7 +302,7 @@ ItemUseBall:
jr c, .failedToCapture
; If W > 255, the ball captures the Pokémon.
- ld a, [hQuotient + 2]
+ ldh a, [hQuotient + 2]
and a
jr nz, .captured
@@ -310,7 +310,7 @@ ItemUseBall:
; If Rand2 > X, the ball fails to capture the Pokémon.
ld b, a
- ld a, [hQuotient + 3]
+ ldh a, [hQuotient + 3]
cp b
jr c, .failedToCapture
@@ -318,17 +318,17 @@ ItemUseBall:
jr .skipShakeCalculations
.failedToCapture
- ld a, [hQuotient + 3]
+ ldh a, [hQuotient + 3]
ld [wPokeBallCaptureCalcTemp], a ; Save X.
; Calculate CatchRate * 100.
xor a
- ld [hMultiplicand], a
- ld [hMultiplicand + 1], a
+ ldh [hMultiplicand], a
+ ldh [hMultiplicand + 1], a
ld a, [wEnemyMonActualCatchRate]
- ld [hMultiplicand + 2], a
+ ldh [hMultiplicand + 2], a
ld a, 100
- ld [hMultiplier], a
+ ldh [hMultiplier], a
call Multiply
; Determine BallFactor2.
@@ -349,26 +349,26 @@ ItemUseBall:
.skip4
; Let Y = (CatchRate * 100) / BallFactor2. Calculate Y.
ld a, b
- ld [hDivisor], a
+ ldh [hDivisor], a
ld b, 4
call Divide
; If Y > 255, there are 3 shakes.
; Note that this shouldn't be possible.
; The maximum value of Y is (255 * 100) / 150 = 170.
- ld a, [hQuotient + 2]
+ ldh a, [hQuotient + 2]
and a
ld b, $63 ; 3 shakes
jr nz, .setAnimData
; Calculate X * Y.
ld a, [wPokeBallCaptureCalcTemp]
- ld [hMultiplier], a
+ ldh [hMultiplier], a
call Multiply
; Calculate (X * Y) / 255.
ld a, 255
- ld [hDivisor], a
+ ldh [hDivisor], a
ld b, 4
call Divide
@@ -386,9 +386,9 @@ ItemUseBall:
.addAilmentValue
; If the Pokémon has a status ailment, add Status2.
- ld a, [hQuotient + 3]
+ ldh a, [hQuotient + 3]
add b
- ld [hQuotient + 3], a
+ ldh [hQuotient + 3], a
.skip5
; Finally determine the number of shakes.
@@ -398,7 +398,7 @@ ItemUseBall:
; 10 ≤ Z < 30: 1 shake
; 30 ≤ Z < 70: 2 shakes
; 70 ≤ Z: 3 shakes
- ld a, [hQuotient + 3]
+ ldh a, [hQuotient + 3]
cp 10
ld b, $20
jr c, .setAnimData
@@ -422,7 +422,7 @@ ItemUseBall:
ld a, TOSS_ANIM
ld [wAnimationID], a
xor a
- ld [hWhoseTurn], a
+ ldh [hWhoseTurn], a
ld [wAnimationType], a
ld [wDamageMultipliers], a
ld a, [wWhichPokemon]
@@ -495,7 +495,7 @@ ItemUseBall:
ld [wcf91], a
ld a, [wEnemyMonLevel]
ld [wCurEnemyLVL], a
- callab LoadEnemyMonData
+ callfar LoadEnemyMonData
pop af
ld [wcf91], a
pop hl
@@ -632,7 +632,7 @@ ItemUseTownMap:
ld a, [wIsInBattle]
and a
jp nz, ItemUseNotTime
- jpba DisplayTownMap
+ farjp DisplayTownMap
ItemUseBicycle:
ld a, [wIsInBattle]
@@ -656,7 +656,7 @@ ItemUseBicycle:
jp nc, NoCyclingAllowedHere
call ItemUseReloadOverworldData
xor a ; no keys pressed
- ld [hJoyHeld], a ; current joypad state
+ ldh [hJoyHeld], a ; current joypad state
inc a
ld [wWalkBikeSurfState], a ; change player state to bicycling
ld hl, GotOnBicycleText
@@ -687,11 +687,11 @@ ItemUseSurfboard:
jp PrintText
.tryToStopSurfing
xor a
- ld [hSpriteIndexOrTextID], a
+ ldh [hSpriteIndexOrTextID], a
ld d, 16 ; talking range in pixels (normal range)
call IsSpriteInFrontOfPlayer2
res 7, [hl]
- ld a, [hSpriteIndexOrTextID]
+ ldh a, [hSpriteIndexOrTextID]
and a ; is there a sprite in the way?
jr nz, .cannotStopSurfing
ld hl, TilePairCollisionsWater
@@ -778,7 +778,7 @@ ItemUseEvoStone:
ld a, SFX_HEAL_AILMENT
call PlaySoundWaitForCurrent
call WaitForSoundToFinish
- callab TryEvolvingMon ; try to evolve pokemon
+ callfar TryEvolvingMon ; try to evolve pokemon
ld a, [wEvolutionOccurred]
and a
jr z, .noEffect
@@ -1018,18 +1018,18 @@ ItemUseMedicine:
call AddNTimes
ld a, [hli]
ld [wHPBarMaxHP + 1], a
- ld [hDividend], a
+ ldh [hDividend], a
ld a, [hl]
ld [wHPBarMaxHP], a
- ld [hDividend + 1], a
+ ldh [hDividend + 1], a
ld a, 5
- ld [hDivisor], a
+ ldh [hDivisor], a
ld b, 2 ; number of bytes
call Divide ; get 1/5 of max HP of pokemon that used Softboiled
ld bc, (wPartyMon1HP + 1) - (wPartyMon1MaxHP + 1)
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, [hQuotient + 3]
+ ldh a, [hQuotient + 3]
push af
ld b, a
ld a, [hl]
@@ -1037,28 +1037,28 @@ ItemUseMedicine:
sub b
ld [hld], a
ld [wHPBarNewHP], a
- ld a, [hQuotient + 2]
+ ldh a, [hQuotient + 2]
ld b, a
ld a, [hl]
ld [wHPBarOldHP+1], a
sbc b
ld [hl], a
ld [wHPBarNewHP+1], a
- coord hl, 4, 1
+ hlcoord 4, 1
ld a, [wWhichPokemon]
ld bc, 2 * SCREEN_WIDTH
call AddNTimes ; calculate coordinates of HP bar of pokemon that used Softboiled
ld a, SFX_HEAL_HP
call PlaySoundWaitForCurrent
- ld a, [hFlagsFFF6]
+ ldh a, [hFlagsFFF6]
set 0, a
- ld [hFlagsFFF6], a
+ ldh [hFlagsFFF6], a
ld a, $02
ld [wHPBarType], a
predef UpdateHPBar2 ; animate HP bar decrease of pokemon that used Softboiled
- ld a, [hFlagsFFF6]
+ ldh a, [hFlagsFFF6]
res 0, a
- ld [hFlagsFFF6], a
+ ldh [hFlagsFFF6], a
pop af
ld b, a ; store heal amount (1/5 of max HP)
ld hl, wHPBarOldHP + 1
@@ -1200,15 +1200,15 @@ ItemUseMedicine:
jr z, .playStatusAilmentCuringSound
ld a, SFX_HEAL_HP
call PlaySoundWaitForCurrent
- ld a, [hFlagsFFF6]
+ ldh a, [hFlagsFFF6]
set 0, a
- ld [hFlagsFFF6], a
+ ldh [hFlagsFFF6], a
ld a, $02
ld [wHPBarType], a
predef UpdateHPBar2 ; animate the HP bar lengthening
- ld a, [hFlagsFFF6]
+ ldh a, [hFlagsFFF6]
res 0, a
- ld [hFlagsFFF6], a
+ ldh [hFlagsFFF6], a
ld a, REVIVE_MSG
ld [wPartyMenuTypeOrMessageID], a
ld a, [wcf91]
@@ -1224,13 +1224,13 @@ ItemUseMedicine:
call PlaySoundWaitForCurrent
.showHealingItemMessage
xor a
- ld [hAutoBGTransferEnabled], a
+ ldh [hAutoBGTransferEnabled], a
call ClearScreen
dec a
ld [wUpdateSpritesEnabled], a
call RedrawPartyMenu ; redraws the party menu and displays the message
ld a, 1
- ld [hAutoBGTransferEnabled], a
+ ldh [hAutoBGTransferEnabled], a
ld c, 50
call DelayFrames
call WaitForTextScrollButtonPress
@@ -1341,17 +1341,17 @@ ItemUseMedicine:
push hl
push de
ld d, a
- callab CalcExperience ; calculate experience for next level and store it at hExperience
+ callfar CalcExperience ; calculate experience for next level and store it at hExperience
pop de
pop hl
ld bc, wPartyMon1Exp - wPartyMon1Level
add hl, bc ; hl now points to MSB of experience
; update experience to minimum for new level
- ld a, [hExperience]
+ ldh a, [hExperience]
ld [hli], a
- ld a, [hExperience + 1]
+ ldh a, [hExperience + 1]
ld [hli], a
- ld a, [hExperience + 2]
+ ldh a, [hExperience + 2]
ld [hl], a
pop hl
ld a, [wWhichPokemon]
@@ -1400,14 +1400,14 @@ ItemUseMedicine:
ld [wMonDataLocation], a
call LoadMonData
ld d, $01
- callab PrintStatsBox ; display new stats text box
+ callfar PrintStatsBox ; display new stats text box
call WaitForTextScrollButtonPress ; wait for button press
xor a ; PLAYER_PARTY_DATA
ld [wMonDataLocation], a
predef LearnMoveFromLevelUp ; learn level up move, if any
xor a
ld [wForceEvolution], a
- callab TryEvolvingMon ; evolve pokemon, if appropriate
+ callfar TryEvolvingMon ; evolve pokemon, if appropriate
ld a, $01
ld [wUpdateSpritesEnabled], a
pop af
@@ -1459,7 +1459,7 @@ BaitRockCommon:
ld [wAnimationID], a
xor a
ld [wAnimationType], a
- ld [hWhoseTurn], a
+ ldh [hWhoseTurn], 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
call Random
@@ -1698,8 +1698,8 @@ ItemUseXStat:
call LoadScreenTilesFromBuffer1 ; restore saved screen
call Delay3
xor a
- ld [hWhoseTurn], a ; set turn to player's turn
- callba StatModifierUpEffect ; do stat increase move
+ ldh [hWhoseTurn], a ; set turn to player's turn
+ farcall StatModifierUpEffect ; do stat increase move
pop hl
pop af
ld [hld], a ; restore [wPlayerMoveEffect]
@@ -1775,7 +1775,7 @@ ItemUsePokeflute:
and $80
jr nz, .skipMusic
call WaitForSoundToFinish ; wait for sound to end
- callba Music_PokeFluteInBattle ; play in-battle pokeflute music
+ farcall Music_PokeFluteInBattle ; play in-battle pokeflute music
.musicWaitLoop ; wait for music to finish playing
ld a, [wChannelSoundIDs + Ch7]
and a ; music off?
@@ -1927,7 +1927,7 @@ RodResponse:
push af
push hl
ld [hl], 0
- callba FishingAnim
+ farcall FishingAnim
pop hl
pop af
ld [hl], a
@@ -1968,7 +1968,7 @@ ItemUseItemfinder:
and a
jp nz, ItemUseNotTime
call ItemUseReloadOverworldData
- callba HiddenItemNear ; check for hidden items
+ farcall HiddenItemNear ; check for hidden items
ld hl, ItemfinderFoundNothingText
jr nc, .printText ; if no hidden items
ld c, 4
@@ -2024,7 +2024,7 @@ ItemUsePPRestore:
call PrintText
xor a
ld [wPlayerMoveListIndex], a
- callab MoveSelectionMenu ; move selection menu
+ callfar MoveSelectionMenu ; move selection menu
ld a, 0
ld [wPlayerMoveListIndex], a
jr nz, .chooseMon
@@ -2221,7 +2221,7 @@ ItemUseTMHM:
call PrintText
ld hl, TeachMachineMoveText
call PrintText
- coord hl, 14, 7
+ hlcoord 14, 7
lb bc, 8, 15
ld a, TWO_OPTION_MENU
ld [wTextBoxID], a
@@ -2278,7 +2278,7 @@ ItemUseTMHM:
call PrintText
jr .chooseMon
.checkIfAlreadyLearnedMove
- callab CheckIfMoveIsKnown ; check if the pokemon already knows the move
+ callfar CheckIfMoveIsKnown ; check if the pokemon already knows the move
jr c, .chooseMon
predef LearnMove ; teach move
pop af
@@ -2463,13 +2463,13 @@ RestoreBonusPP:
AddBonusPP:
push bc
ld a, [de] ; normal max PP of move
- ld [hDividend + 3], a
+ ldh [hDividend + 3], a
xor a
- ld [hDividend], a
- ld [hDividend + 1], a
- ld [hDividend + 2], a
+ ldh [hDividend], a
+ ldh [hDividend + 1], a
+ ldh [hDividend + 2], a
ld a, 5
- ld [hDivisor], a
+ ldh [hDivisor], a
ld b, 4
call Divide
ld a, [hl] ; move PP
@@ -2480,7 +2480,7 @@ AddBonusPP:
srl a
ld c, a ; c = number of PP Ups used
.loop
- ld a, [hQuotient + 3]
+ ldh a, [hQuotient + 3]
cp 8 ; is the amount greater than or equal to 8?
jr c, .addAmount
ld a, 7 ; cap the amount at 7
@@ -2607,7 +2607,7 @@ TossItem_::
call CopyStringToCF4B ; copy name to wcf4b
ld hl, IsItOKToTossItemText
call PrintText
- coord hl, 14, 7
+ hlcoord 14, 7
lb bc, 8, 15
ld a, TWO_OPTION_MENU
ld [wTextBoxID], a
@@ -2820,15 +2820,15 @@ SendNewMonToBox:
push de
ld a, [wCurEnemyLVL]
ld d, a
- callab CalcExperience
+ callfar CalcExperience
pop de
- ld a, [hExperience]
+ ldh a, [hExperience]
ld [de], a
inc de
- ld a, [hExperience + 1]
+ ldh a, [hExperience + 1]
ld [de], a
inc de
- ld a, [hExperience + 2]
+ ldh a, [hExperience + 2]
ld [de], a
inc de
xor a
diff --git a/engine/items/tm_prices.asm b/engine/items/tm_prices.asm
index 502191d5..df9761bd 100755
--- a/engine/items/tm_prices.asm
+++ b/engine/items/tm_prices.asm
@@ -16,10 +16,10 @@ GetMachinePrice::
swap a
.highNybbleIsPrice
and $f0
- ld [hItemPrice + 1], a
+ ldh [hItemPrice + 1], a
xor a
- ld [hItemPrice], a
- ld [hItemPrice + 2], a
+ ldh [hItemPrice], a
+ ldh [hItemPrice + 2], a
ret
INCLUDE "data/items/tm_prices.asm"
diff --git a/engine/items/town_map.asm b/engine/items/town_map.asm
index 285dbfa5..83ea81bf 100755
--- a/engine/items/town_map.asm
+++ b/engine/items/town_map.asm
@@ -6,19 +6,19 @@ DisplayTownMap:
ld [hl], $ff
push hl
ld a, $1
- ld [hJoy7], a
+ ldh [hJoy7], a
ld a, [wCurMap]
push af
ld b, $0
call DrawPlayerOrBirdSprite ; player sprite
- coord hl, 1, 0
+ hlcoord 1, 0
ld de, wcd6d
call PlaceString
ld hl, wOAMBuffer
ld de, wTileMapBackup
ld bc, $10
call CopyData
- ld hl, vSprites + $40
+ ld hl, vSprites tile $04
ld de, TownMapCursor
lb bc, BANK(TownMapCursor), (TownMapCursorEnd - TownMapCursor) / $8
call CopyVideoDataDouble
@@ -28,7 +28,7 @@ DisplayTownMap:
jr .enterLoop
.townMapLoop
- coord hl, 0, 0
+ hlcoord 0, 0
lb bc, 1, 20
call ClearScreenArea
ld hl, TownMapOrder
@@ -55,7 +55,7 @@ DisplayTownMap:
inc de
cp $50
jr nz, .copyMapName
- coord hl, 1, 0
+ hlcoord 1, 0
ld de, wcd6d
call PlaceString
ld hl, wOAMBuffer + $10
@@ -65,7 +65,7 @@ DisplayTownMap:
.inputLoop
call TownMapSpriteBlinkingAnimation
call JoypadLowSensitivity
- ld a, [hJoy5]
+ ldh a, [hJoy5]
ld b, a
and A_BUTTON | B_BUTTON | D_UP | D_DOWN
jr z, .inputLoop
@@ -77,7 +77,7 @@ DisplayTownMap:
jr nz, .pressedDown
xor a
ld [wTownMapSpriteBlinkingEnabled], a
- ld [hJoy7], a
+ ldh [hJoy7], a
ld [wAnimCounter], a
call ExitTownMap
pop hl
@@ -118,7 +118,7 @@ LoadTownMap_Nest:
push hl
call DisplayWildLocations
call GetMonName
- coord hl, 1, 0
+ hlcoord 1, 0
call PlaceString
ld h, b
ld l, c
@@ -140,11 +140,11 @@ LoadTownMap_Fly::
call LoadPlayerSpriteGraphics
call LoadFontTilePatterns
ld de, BirdSprite
- ld hl, vSprites + $40
- lb bc, BANK(BirdSprite), $c
+ ld hl, vSprites tile $04
+ lb bc, BANK(BirdSprite), 12
call CopyVideoData
ld de, TownMapUpArrow
- ld hl, vChars1 + $6d0
+ ld hl, vChars1 tile $6d
lb bc, BANK(TownMapUpArrow), (TownMapUpArrowEnd - TownMapUpArrow) / $8
call CopyVideoDataDouble
call BuildFlyLocationsList
@@ -153,41 +153,41 @@ LoadTownMap_Fly::
push af
ld [hl], $ff
push hl
- coord hl, 0, 0
+ hlcoord 0, 0
ld de, ToText
call PlaceString
ld a, [wCurMap]
ld b, $0
call DrawPlayerOrBirdSprite
ld hl, wFlyLocationsList
- coord de, 18, 0
+ decoord 18, 0
.townMapFlyLoop
ld a, " "
ld [de], a
push hl
push hl
- coord hl, 3, 0
+ hlcoord 3, 0
lb bc, 1, 15
call ClearScreenArea
pop hl
ld a, [hl]
ld b, $4
call DrawPlayerOrBirdSprite ; draw bird sprite
- coord hl, 3, 0
+ hlcoord 3, 0
ld de, wcd6d
call PlaceString
ld c, 15
call DelayFrames
- coord hl, 18, 0
+ hlcoord 18, 0
ld [hl], "▲"
- coord hl, 19, 0
+ hlcoord 19, 0
ld [hl], "▼"
pop hl
.inputLoop
push hl
call DelayFrame
call JoypadLowSensitivity
- ld a, [hJoy5]
+ ldh a, [hJoy5]
ld b, a
pop hl
and A_BUTTON | B_BUTTON | D_UP | D_DOWN
@@ -219,7 +219,7 @@ LoadTownMap_Fly::
ld [hl], a
ret
.pressedUp
- coord de, 18, 0
+ decoord 18, 0
inc hl
ld a, [hl]
cp $ff
@@ -231,7 +231,7 @@ LoadTownMap_Fly::
ld hl, wFlyLocationsList
jp .townMapFlyLoop
.pressedDown
- coord de, 19, 0
+ decoord 19, 0
dec hl
ld a, [hl]
cp $ff
@@ -278,22 +278,22 @@ LoadTownMap:
call GBPalWhiteOutWithDelay3
call ClearScreen
call UpdateSprites
- coord hl, 0, 0
+ hlcoord 0, 0
ld b, $12
ld c, $12
call TextBoxBorder
call DisableLCD
ld hl, WorldMapTileGraphics
- ld de, vChars2 + $600
+ ld de, vChars2 tile $60
ld bc, WorldMapTileGraphicsEnd - WorldMapTileGraphics
ld a, BANK(WorldMapTileGraphics)
call FarCopyData2
ld hl, MonNestIcon
- ld de, vSprites + $40
+ ld de, vSprites tile $04
ld bc, MonNestIconEnd - MonNestIcon
ld a, BANK(MonNestIcon)
call FarCopyDataDouble
- coord hl, 0, 0
+ hlcoord 0, 0
ld de, CompressedMap
.nextTile
ld a, [de]
@@ -366,7 +366,7 @@ DrawPlayerOrBirdSprite:
jp CopyData
DisplayWildLocations:
- callba FindWildLocationsOfMon
+ farcall FindWildLocationsOfMon
call ZeroOutDuplicatesInList
ld hl, wOAMBuffer
ld de, wTownMapCoords
@@ -395,11 +395,11 @@ DisplayWildLocations:
and a ; were any OAM entries written?
jr nz, .drawPlayerSprite
; if no OAM entries were written, print area unknown text
- coord hl, 1, 7
+ hlcoord 1, 7
ld b, 2
ld c, 15
call TextBoxBorder
- coord hl, 2, 9
+ hlcoord 2, 9
ld de, AreaUnknownText
call PlaceString
jr .done