summaryrefslogtreecommitdiff
path: root/battle/core.asm
diff options
context:
space:
mode:
Diffstat (limited to 'battle/core.asm')
-rw-r--r--battle/core.asm450
1 files changed, 209 insertions, 241 deletions
diff --git a/battle/core.asm b/battle/core.asm
index 1bffd407e..9cae539c3 100644
--- a/battle/core.asm
+++ b/battle/core.asm
@@ -175,13 +175,13 @@ BattleTurn: ; 3c12f
call HandleBerserkGene
call UpdateBattleMonInParty
- callba AIChooseMove
+ farcall AIChooseMove
call IsMobileBattle
jr nz, .not_disconnected
- callba Function100da5
- callba StartMobileInactivityTimer
- callba Function100dd8
+ farcall Function100da5
+ farcall StartMobileInactivityTimer
+ farcall Function100dd8
jp c, .quit
.not_disconnected
@@ -377,7 +377,7 @@ HandleBerserkGene: ; 3c27c
.go
push de
push bc
- callab GetUserItem
+ callfar GetUserItem
ld a, [hl]
ld [wd265], a
sub BERSERK_GENE
@@ -405,14 +405,14 @@ HandleBerserkGene: ; 3c27c
ld [hl], a
ld [AttackMissed], a
ld [EffectFailed], a
- callba BattleCommand_AttackUp2
+ farcall BattleCommand_AttackUp2
pop af
pop hl
ld [hl], a
call GetItemName
ld hl, BattleText_UsersStringBuffer1Activated
call StdBattleTextBox
- callab BattleCommand_StatUpMessage
+ callfar BattleCommand_StatUpMessage
pop af
bit SUBSTATUS_CONFUSED, a
ret nz
@@ -473,7 +473,7 @@ DetermineMoveOrder: ; 3c314
jp .player_first
.switch
- callab AI_Switch
+ callfar AI_Switch
call SetEnemyTurn
call SpikesDamage
jp .enemy_first
@@ -489,9 +489,9 @@ DetermineMoveOrder: ; 3c314
.equal_priority
call SetPlayerTurn
- callab GetUserItem
+ callfar GetUserItem
push bc
- callab GetOpponentItem
+ callfar GetOpponentItem
pop de
ld a, d
cp HELD_QUICK_CLAW
@@ -633,7 +633,7 @@ ParsePlayerAction: ; 3c434
xor a
ld [wMoveSelectionMenuType], a
inc a ; POUND
- ld [FXAnimIDLo], a
+ ld [FXAnimID], a
call MoveSelectionScreen
push af
call Call_LoadTempTileMapToTileMap
@@ -651,7 +651,7 @@ ParsePlayerAction: ; 3c434
.encored
call SetPlayerTurn
- callab UpdateMoveData
+ callfar UpdateMoveData
xor a
ld [wPlayerCharging], a
ld a, [wPlayerMoveStruct + MOVE_EFFECT]
@@ -820,41 +820,7 @@ TryEnemyFlee: ; 3c543
ret
; 3c59a
-FleeMons:
-
-SometimesFleeMons: ; 3c59a
- db MAGNEMITE
- db GRIMER
- db TANGELA
- db MR__MIME
- db EEVEE
- db PORYGON
- db DRATINI
- db DRAGONAIR
- db TOGETIC
- db UMBREON
- db UNOWN
- db SNUBBULL
- db HERACROSS
- db -1
-
-OftenFleeMons: ; 3c5a8
- db CUBONE
- db ARTICUNO
- db ZAPDOS
- db MOLTRES
- db QUAGSIRE
- db DELIBIRD
- db PHANPY
- db TEDDIURSA
- db -1
-
-AlwaysFleeMons: ; 3c5b1
- db RAIKOU
- db ENTEI
-; db SUICUNE
- db -1
-; 3c5b4
+INCLUDE "data/battle/flee_mons.asm"
CompareMovePriority: ; 3c5b4
; Compare the priority of the player and enemy's moves.
@@ -876,7 +842,7 @@ GetMovePriority: ; 3c5c5
ld b, a
- ; Vital throw goes last.
+ ; Vital Throw goes last.
cp VITAL_THROW
ld a, 0
ret z
@@ -928,7 +894,7 @@ Battle_EnemyFirst: ; 3c5fe
call SetEnemyTurn
ld a, $1
ld [wEnemyGoesFirst], a
- callab AI_SwitchOrTryItem
+ callfar AI_SwitchOrTryItem
jr c, .switch_item
call EnemyTurn_EndOpponentProtectEndureDestinyBond
call CheckMobileBattleError
@@ -969,7 +935,7 @@ Battle_PlayerFirst: ; 3c664
xor a
ld [wEnemyGoesFirst], a
call SetEnemyTurn
- callab AI_SwitchOrTryItem
+ callfar AI_SwitchOrTryItem
push af
call PlayerTurn_EndOpponentProtectEndureDestinyBond
pop bc
@@ -1018,14 +984,14 @@ Battle_PlayerFirst: ; 3c664
PlayerTurn_EndOpponentProtectEndureDestinyBond: ; 3c6cf
call SetPlayerTurn
call EndUserDestinyBond
- callab DoPlayerTurn
+ callfar DoPlayerTurn
jp EndOpponentProtectEndureDestinyBond
; 3c6de
EnemyTurn_EndOpponentProtectEndureDestinyBond: ; 3c6de
call SetEnemyTurn
call EndUserDestinyBond
- callab DoEnemyTurn
+ callfar DoEnemyTurn
jp EndOpponentProtectEndureDestinyBond
; 3c6ed
@@ -1305,7 +1271,7 @@ HandleWrap: ; 3c874
ld a, [de]
ld [wd265], a
- ld [FXAnimIDLo], a
+ ld [FXAnimID], a
call GetMoveName
dec [hl]
jr z, .release_from_bounds
@@ -1318,7 +1284,7 @@ HandleWrap: ; 3c874
call SwitchTurnCore
xor a
ld [wNumHits], a
- ld [FXAnimIDHi], a
+ ld [FXAnimID + 1], a
predef PlayBattleAnim
call SwitchTurnCore
@@ -1357,7 +1323,7 @@ HandleLeftovers: ; 3c8eb
call SetPlayerTurn
.do_it
- callab GetUserItem
+ callfar GetUserItem
ld a, [hl]
ld [wd265], a
call GetItemName
@@ -1407,7 +1373,7 @@ HandleMysteryberry: ; 3c93c
call SetPlayerTurn
.do_it
- callab GetUserItem
+ callfar GetUserItem
ld a, b
cp HELD_RESTORE_PP
jr nz, .quit
@@ -1504,7 +1470,7 @@ HandleMysteryberry: ; 3c93c
add b
ld [de], a
.skip_checks
- callab GetUserItem
+ callfar GetUserItem
ld a, [hl]
ld [wd265], a
xor a
@@ -1570,13 +1536,13 @@ HandleFutureSight: ; 3ca26
ld a, FUTURE_SIGHT
ld [hl], a
- callab UpdateMoveData
+ callfar UpdateMoveData
xor a
ld [AttackMissed], a
ld [AlreadyDisobeyed], a
ld a, 10
ld [TypeModifier], a
- callab DoMove
+ callfar DoMove
xor a
ld [CurDamage], a
ld [CurDamage + 1], a
@@ -2393,7 +2359,7 @@ HandleEnemySwitch: ; 3cf4a
ld e, HP_BAR_LENGTH_PX
call UpdateHPPal
call WaitBGMap
- callba EnemySwitch_TrainerHud
+ farcall EnemySwitch_TrainerHud
ld a, [wLinkMode]
and a
jr z, .not_linked
@@ -2451,7 +2417,7 @@ WinTrainerBattle: ; 3cfa4
and a
ld a, b
call z, PlayVictoryMusic
- callab Battle_GetTrainerName
+ callfar Battle_GetTrainerName
ld hl, BattleText_EnemyWasDefeated
call StdBattleTextBox
@@ -2486,7 +2452,7 @@ WinTrainerBattle: ; 3cfa4
ld c, 40
call DelayFrames
ld c, $4 ; win
- callba Mobile_PrintOpponentBattleMessage
+ farcall Mobile_PrintOpponentBattleMessage
ret
.battle_tower
@@ -2495,7 +2461,7 @@ WinTrainerBattle: ; 3cfa4
call DelayFrames
call EmptyBattleTextBox
ld c, $3
- callba BattleTowerText
+ farcall BattleTowerText
call WaitPressAorB_BlinkCursor
ld hl, wPayDayMoney
ld a, [hli]
@@ -2607,11 +2573,11 @@ WinTrainerBattle: ; 3cfa4
.CheckMaxedOutMomMoney: ; 3d0b1
ld hl, wMomsMoney + 2
ld a, [hld]
- cp 999999 % $100
+ cp MAX_MONEY % $100
ld a, [hld]
- sbc 999999 / $100 % $100
+ sbc MAX_MONEY / $100 % $100
ld a, [hl]
- sbc 999999 / $10000 % $100
+ sbc MAX_MONEY / $10000 % $100
ret
; 3d0be
@@ -2623,7 +2589,7 @@ AddBattleMoneyToAccount: ; 3d0be
push bc
ld b, h
ld c, l
- callba TrainerRankings_AddToBattlePayouts
+ farcall TrainerRankings_AddToBattlePayouts
pop bc
pop hl
.loop
@@ -2636,17 +2602,17 @@ AddBattleMoneyToAccount: ; 3d0be
jr nz, .loop
pop hl
ld a, [hld]
- cp 999999 % $100
+ cp MAX_MONEY % $100
ld a, [hld]
- sbc 999999 / $100 % $100
+ sbc MAX_MONEY / $100 % $100
ld a, [hl]
- sbc 999999 / $10000 % $100
+ sbc MAX_MONEY / $10000 % $100
ret c
- ld [hl], 999999 / $10000 % $100
+ ld [hl], MAX_MONEY / $10000 % $100
inc hl
- ld [hl], 999999 / $100 % $100
+ ld [hl], MAX_MONEY / $100 % $100
inc hl
- ld [hl], 999999 % $100
+ ld [hl], MAX_MONEY % $100
ret
; 3d0ea
@@ -2817,7 +2783,7 @@ PlayerMonFaintHappinessMod: ; 3d1aa
.got_param
ld a, [CurBattleMon]
ld [CurPartyMon], a
- callab ChangeHappiness
+ callfar ChangeHappiness
ld a, [wBattleResult]
and %11000000
add $1
@@ -2966,16 +2932,16 @@ IsMobileBattle: ; 3d2f1
SetUpBattlePartyMenu_NoLoop: ; 3d2f7
call ClearBGPalettes
SetUpBattlePartyMenu: ; switch to fullscreen menu?
- callba LoadPartyMenuGFX
- callba InitPartyMenuWithCancel
- callba InitPartyMenuBGPal7
- callba InitPartyMenuGFX
+ farcall LoadPartyMenuGFX
+ farcall InitPartyMenuWithCancel
+ farcall InitPartyMenuBGPal7
+ farcall InitPartyMenuGFX
ret
; 3d313
JumpToPartyMenuAndPrintText: ; 3d313
- callba WritePartyMenuTilemap
- callba PrintPartyMenuText
+ farcall WritePartyMenuTilemap
+ farcall PrintPartyMenuText
call WaitBGMap
call SetPalettes
call DelayFrame
@@ -2985,11 +2951,11 @@ JumpToPartyMenuAndPrintText: ; 3d313
SelectBattleMon: ; 3d329
call IsMobileBattle
jr z, .mobile
- callba PartyMenuSelect
+ farcall PartyMenuSelect
ret
.mobile
- callba Mobile_PartyMenuSelect
+ farcall Mobile_PartyMenuSelect
ret
; 3d33c
@@ -3101,7 +3067,7 @@ LostBattle: ; 3d38e
call EmptyBattleTextBox
ld c, 2
- callba BattleTowerText
+ farcall BattleTowerText
call WaitPressAorB_BlinkCursor
call ClearTileMap
call ClearBGPalettes
@@ -3152,7 +3118,7 @@ LostBattle: ; 3d38e
call DelayFrames
ld c, $3 ; lost
- callba Mobile_PrintOpponentBattleMessage
+ farcall Mobile_PrintOpponentBattleMessage
scf
ret
; 3d432
@@ -3458,7 +3424,7 @@ LookUpTheEffectivenessOfEveryMove: ; 3d5d7
ld a, BANK(Moves)
call FarCopyBytes
call SetEnemyTurn
- callab BattleCheckTypeMatchup
+ callfar BattleCheckTypeMatchup
pop bc
pop de
pop hl
@@ -3484,23 +3450,23 @@ IsThePlayerPkmnTypesEffectiveAgainstOTPkmn: ; 3d618
add hl, bc
ld a, [hl]
dec a
- ld hl, BaseData + 7 ; type
- ld bc, BaseData1 - BaseData0
+ ld hl, BaseData + BASE_TYPES
+ ld bc, BASE_DATA_SIZE
call AddNTimes
ld de, EnemyMonType
- ld bc, 2
+ ld bc, BASE_CATCH_RATE - BASE_TYPES
ld a, BANK(BaseData)
call FarCopyBytes
ld a, [BattleMonType1]
ld [wPlayerMoveStruct + MOVE_TYPE], a
call SetPlayerTurn
- callab BattleCheckTypeMatchup
+ callfar BattleCheckTypeMatchup
ld a, [wd265]
cp 10 + 1 ; 1.0 + 0.1
jr nc, .super_effective
ld a, [BattleMonType2]
ld [wPlayerMoveStruct + MOVE_TYPE], a
- callab BattleCheckTypeMatchup
+ callfar BattleCheckTypeMatchup
ld a, [wd265]
cp 10 + 1 ; 1.0 + 0.1
jr nc, .super_effective
@@ -3642,7 +3608,7 @@ CheckWhetherToAskSwitch: ; 3d714
push af
ld a, [CurBattleMon]
ld [CurPartyMon], a
- callba CheckCurPartyMonFainted
+ farcall CheckCurPartyMonFainted
pop bc
ld a, b
ld [CurPartyMon], a
@@ -3658,7 +3624,7 @@ CheckWhetherToAskSwitch: ; 3d714
OfferSwitch: ; 3d74b
ld a, [CurPartyMon]
push af
- callab Battle_GetTrainerName
+ callfar Battle_GetTrainerName
ld hl, BattleText_EnemyIsAboutToUseWillPlayerChangePkmn
call StdBattleTextBox
lb bc, 1, 7
@@ -3709,7 +3675,7 @@ ClearEnemyMonBox: ; 3d7a0
; 3d7b8
Function_BattleTextEnemySentOut: ; 3d7b8
- callab Battle_GetTrainerName
+ callfar Battle_GetTrainerName
ld hl, BattleText_EnemySentOut
call StdBattleTextBox
jp WaitBGMap
@@ -3723,7 +3689,7 @@ Function_SetEnemyPkmnAndSendOutAnimation: ; 3d7c7
ld a, OTPARTYMON
ld [MonType], a
predef CopyPkmnToTempMon
- call GetMonFrontpic
+ call GetEnemyMonFrontpic
xor a
ld [wNumHits], a
@@ -3741,9 +3707,9 @@ Function_SetEnemyPkmnAndSendOutAnimation: ; 3d7c7
.not_shiny
ld bc, TempMonSpecies
- callba CheckFaintedFrzSlp
+ farcall CheckFaintedFrzSlp
jr c, .skip_cry
- callba CheckBattleScene
+ farcall CheckBattleScene
jr c, .cry_no_anim
hlcoord 12, 0
ld d, $0
@@ -3885,7 +3851,7 @@ TryToRunAwayFromBattle: ; 3d8b3
ld a, [BattleMonItem]
ld [wd265], a
ld b, a
- callab GetItemHeldEffect
+ callfar GetItemHeldEffect
ld a, b
cp HELD_ESCAPE
pop de
@@ -4088,7 +4054,7 @@ BattleCheckEnemyShininess: ; 3da79
BattleCheckShininess: ; 3da7c
ld b, h
ld c, l
- callab CheckShininess
+ callfar CheckShininess
ret
; 3da85
@@ -4210,10 +4176,10 @@ SendOutPlayerMon: ; 3db5f
call WaitBGMap
xor a
ld [hBGMapMode], a
- call GetMonBackpic
+ call GetBattleMonBackpic
xor a
ld [hGraphicStartTile], a
- ld [wd0d2], a
+ ld [wBattleMenuCursorBuffer], a
ld [CurMoveNum], a
ld [TypeModifier], a
ld [wPlayerMoveStruct + MOVE_ANIM], a
@@ -4242,7 +4208,7 @@ SendOutPlayerMon: ; 3db5f
call GetPartyParamLocation
ld b, h
ld c, l
- callba CheckFaintedFrzSlp
+ farcall CheckFaintedFrzSlp
jr c, .statused
ld a, $f0
ld [CryTracks], a
@@ -4452,9 +4418,9 @@ HandleHealingItems: ; 3dcf9
; 3dd2f
HandleHPHealingItem: ; 3dd2f
- callab GetOpponentItem
+ callfar GetOpponentItem
ld a, b
- cp $1
+ cp HELD_BERRY
ret nz
ld de, EnemyMonHP + 1
ld hl, EnemyMonMaxHP
@@ -4536,11 +4502,11 @@ HandleHPHealingItem: ; 3dd2f
predef AnimateHPBar
UseOpponentItem:
call RefreshBattleHuds
- callab GetOpponentItem
+ callfar GetOpponentItem
ld a, [hl]
ld [wNamedObjectIndexBuffer], a
call GetItemName
- callab ConsumeHeldItem
+ callfar ConsumeHeldItem
ld hl, RecoveredUsingText
jp StdBattleTextBox
; 3ddc8
@@ -4551,11 +4517,11 @@ ItemRecoveryAnim: ; 3ddc8
push bc
call EmptyBattleTextBox
ld a, RECOVER
- ld [FXAnimIDLo], a
+ ld [FXAnimID], a
call SwitchTurnCore
xor a
ld [wNumHits], a
- ld [FXAnimIDHi], a
+ ld [FXAnimID + 1], a
predef PlayBattleAnim
call SwitchTurnCore
pop bc
@@ -4565,7 +4531,7 @@ ItemRecoveryAnim: ; 3ddc8
; 3dde9
UseHeldStatusHealingItem: ; 3dde9
- callab GetOpponentItem
+ callfar GetOpponentItem
ld hl, .Statuses
.loop
ld a, [hli]
@@ -4634,7 +4600,7 @@ UseConfusionHealingItem: ; 3de51
call GetBattleVar
bit SUBSTATUS_CONFUSED, a
ret z
- callab GetOpponentItem
+ callfar GetOpponentItem
ld a, b
cp HELD_HEAL_CONFUSION
jr z, .heal_status
@@ -4701,7 +4667,7 @@ HandleStatBoostingHeldItems: ; 3de97
push bc
ld a, [bc]
ld b, a
- callab GetItemHeldEffect
+ callfar GetItemHeldEffect
ld hl, .StatUpItems
.loop
ld a, [hli]
@@ -4733,7 +4699,7 @@ HandleStatBoostingHeldItems: ; 3de97
call GetItemName
ld hl, BattleText_UsersStringBuffer1Activated
call StdBattleTextBox
- callab BattleCommand_StatUpMessage
+ callfar BattleCommand_StatUpMessage
ret
.finish
@@ -4808,7 +4774,7 @@ DrawPlayerHUD: ; 3df58
lb bc, 5, 11
call ClearBox
- callba DrawPlayerHUDBorder
+ farcall DrawPlayerHUDBorder
hlcoord 18, 9
ld [hl], $73 ; vertical bar
@@ -4856,12 +4822,12 @@ CheckDanger: ; 3df9e
.no_danger
ld hl, Danger
- res 7, [hl]
+ res DANGER_ON_F, [hl]
jr .done
.danger
ld hl, Danger
- set 7, [hl]
+ set DANGER_ON_F, [hl]
.done
ret
@@ -4901,7 +4867,7 @@ PrintPlayerHUD: ; 3dfbf
ld a, TEMPMON
ld [MonType], a
- callab GetGender
+ callfar GetGender
ld a, " "
jr c, .got_gender_char
ld a, "♂"
@@ -4950,7 +4916,7 @@ DrawEnemyHUD: ; 3e043
lb bc, 4, 11
call ClearBox
- callba DrawEnemyHUDBorder
+ farcall DrawEnemyHUDBorder
ld a, [TempEnemyMonSpecies]
ld [CurSpecies], a
@@ -4979,7 +4945,7 @@ DrawEnemyHUD: ; 3e043
ld a, TEMPMON
ld [MonType], a
- callab GetGender
+ callfar GetGender
ld a, " "
jr c, .got_gender
ld a, "♂"
@@ -5114,7 +5080,7 @@ BattleMenu: ; 3e139
ld a, [BattleType]
cp BATTLETYPE_CONTEST
jr nz, .not_contest
- callba ContestBattleMenu
+ farcall ContestBattleMenu
jr .next
.not_contest
@@ -5122,7 +5088,7 @@ BattleMenu: ; 3e139
ld a, [InputType]
or a
jr z, .skip_dude_pack_select
- callba _DudeAutoInput_DownA
+ farcall _DudeAutoInput_DownA
.skip_dude_pack_select
call LoadBattleMenu2
ret c
@@ -5130,7 +5096,7 @@ BattleMenu: ; 3e139
.next
ld a, $1
ld [hBGMapMode], a
- ld a, [wd0d2]
+ ld a, [wBattleMenuCursorBuffer]
cp $1
jp z, BattleMenu_Fight
cp $3
@@ -5154,12 +5120,12 @@ LoadBattleMenu2: ; 3e19b
call IsMobileBattle
jr z, .mobile
- callba LoadBattleMenu
+ farcall LoadBattleMenu
and a
ret
.mobile
- callba Function100b12
+ farcall Function100b12
ld a, [wcd2b]
and a
ret z
@@ -5193,14 +5159,14 @@ BattleMenu_Pack: ; 3e1c7
cp BATTLETYPE_CONTEST
jr z, .contest
- callba BattlePack
+ farcall BattlePack
ld a, [wPlayerAction]
and a
jr z, .didnt_use_item
jr .got_item
.tutorial
- callba TutorialPack
+ farcall TutorialPack
ld a, POKE_BALL
ld [CurItem], a
call DoItemEffect
@@ -5219,8 +5185,8 @@ BattleMenu_Pack: ; 3e1c7
call ClearPalettes
call DelayFrame
call _LoadBattleFontsHPBar
- call GetMonBackpic
- call GetMonFrontpic
+ call GetBattleMonBackpic
+ call GetEnemyMonFrontpic
call ExitMenu
call WaitBGMap
call FinishBattleAnim
@@ -5238,7 +5204,7 @@ BattleMenu_Pack: ; 3e1c7
ld a, [wWildMon]
and a
jr nz, .run
- callab CheckItemPocket
+ callfar CheckItemPocket
ld a, [wItemAttributeParamBuffer]
cp BALL
jr z, .ball
@@ -5252,10 +5218,10 @@ BattleMenu_Pack: ; 3e1c7
ld a, [BattleType]
cp BATTLETYPE_TUTORIAL
jr z, .tutorial2
- call GetMonBackpic
+ call GetBattleMonBackpic
.tutorial2
- call GetMonFrontpic
+ call GetEnemyMonFrontpic
ld a, $1
ld [wMenuCursorY], a
call ExitMenu
@@ -5293,7 +5259,7 @@ BattleMenuPKMN_Loop:
call SelectBattleMon
jr c, .Cancel
.loop
- callba FreezeMonIcons
+ farcall FreezeMonIcons
call .GetMenu
jr c, .PressedB
call PlaceHollowCursor
@@ -5332,11 +5298,11 @@ BattleMenuPKMN_Loop:
.GetMenu: ; 3e2f5
call IsMobileBattle
jr z, .mobile
- callba BattleMonMenu
+ farcall BattleMonMenu
ret
.mobile
- callba MobileBattleMonMenu
+ farcall MobileBattleMonMenu
ret
; 3e308
@@ -5359,7 +5325,7 @@ Battle_StatsScreen: ; 3e308
call LowVolume
xor a ; PARTYMON
ld [MonType], a
- callba BattleStatsScreenInit
+ farcall BattleStatsScreenInit
call MaxVolume
call DisableLCD
@@ -5468,7 +5434,7 @@ PlayerSwitch: ; 3e3ad
; 3e3ff
EnemyMonEntrance: ; 3e3ff
- callab AI_Switch
+ callfar AI_Switch
call SetEnemyTurn
jp SpikesDamage
; 3e40b
@@ -5551,7 +5517,7 @@ BattleMenu_Run: ; 3e489
CheckAmuletCoin: ; 3e4a8
ld a, [BattleMonItem]
ld b, a
- callab GetItemHeldEffect
+ callfar GetItemHeldEffect
ld a, b
cp HELD_AMULET_COIN
ret nz
@@ -5563,7 +5529,7 @@ CheckAmuletCoin: ; 3e4a8
MoveSelectionScreen: ; 3e4bc
call IsMobileBattle
jr nz, .not_mobile
- callba MobileMoveSelectionScreen
+ farcall MobileMoveSelectionScreen
ret
.not_mobile
@@ -5918,7 +5884,7 @@ MoveInfoBox: ; 3e6c8
ld [CurPartyMon], a
ld a, WILDMON
ld [MonType], a
- callab GetMaxPPOfMove
+ callfar GetMaxPPOfMove
ld hl, wMenuCursorY
ld c, [hl]
@@ -5938,7 +5904,7 @@ MoveInfoBox: ; 3e6c8
hlcoord 7, 11
ld [hl], "/"
- callab UpdateMoveData
+ callfar UpdateMoveData
ld a, [wPlayerMoveStruct + MOVE_ANIM]
ld b, a
hlcoord 2, 10
@@ -5998,7 +5964,7 @@ CheckPlayerHasUsableMoves: ; 3e786
swap a
and $f
ld b, a
- ld d, $5
+ ld d, NUM_MOVES + 1
xor a
.loop
dec d
@@ -6011,7 +5977,9 @@ CheckPlayerHasUsableMoves: ; 3e786
jr .loop
.done
- and a ; This is probably a bug, and will result in a move with PP Up confusing the game.
+ ; Bug: this will result in a move with PP Up confusing the game.
+ ; Replace with "and $3f" to fix.
+ and a
ret nz
.force_struggle
@@ -6136,7 +6104,7 @@ ParseEnemyAction: ; 3e7c1
.skip_load
call SetEnemyTurn
- callab UpdateMoveData
+ callfar UpdateMoveData
call CheckEnemyLockedIn
jr nz, .raging
xor a
@@ -6199,7 +6167,7 @@ CheckEnemyLockedIn: ; 3e8d1
; 3e8e4
LinkBattleSendReceiveAction: ; 3e8e4
- callba _LinkBattleSendReceiveAction
+ farcall _LinkBattleSendReceiveAction
ret
; 3e8eb
@@ -6267,13 +6235,13 @@ LoadEnemyMon: ; 3e8eb
; 25% chance of getting an item
call BattleRandom
- cp a, 1 + (75 percent)
+ cp 1 + (75 percent)
ld a, NO_ITEM
jr c, .UpdateItem
; From there, an 8% chance for Item2
call BattleRandom
- cp a, 8 percent ; 8% of 25% = 2% Item2
+ cp 8 percent ; 8% of 25% = 2% Item2
ld a, [BaseItems]
jr nc, .UpdateItem
ld a, [BaseItems+1]
@@ -6308,7 +6276,7 @@ LoadEnemyMon: ; 3e8eb
; All trainers have preset DVs, determined by class
; See GetTrainerDVs for more on that
- callba GetTrainerDVs
+ farcall GetTrainerDVs
; These are the DVs we'll use if we're actually in a trainer battle
ld a, [wBattleMode]
dec a
@@ -6320,7 +6288,7 @@ LoadEnemyMon: ; 3e8eb
; Roaming monsters (Entei, Raikou) work differently
; They have their own structs, which are shorter than normal
ld a, [BattleType]
- cp a, BATTLETYPE_ROAMING
+ cp BATTLETYPE_ROAMING
jr nz, .NotRoaming
; Grab HP
@@ -6361,7 +6329,7 @@ LoadEnemyMon: ; 3e8eb
; Forced shiny battle type
; Used by Red Gyarados at Lake of Rage
- cp a, BATTLETYPE_SHINY
+ cp BATTLETYPE_SHINY
jr nz, .GenerateDVs
ld b, ATKDEFDV_SHINY ; $ea
@@ -6391,7 +6359,7 @@ LoadEnemyMon: ; 3e8eb
; Unown
ld a, [TempEnemyMonSpecies]
- cp a, UNOWN
+ cp UNOWN
jr nz, .Magikarp
; Get letter based on DVs
@@ -6406,35 +6374,35 @@ LoadEnemyMon: ; 3e8eb
; Skimming this part recommended
ld a, [TempEnemyMonSpecies]
- cp a, MAGIKARP
+ cp MAGIKARP
jr nz, .Happiness
; Get Magikarp's length
ld de, EnemyMonDVs
ld bc, PlayerID
- callab CalcMagikarpLength
+ callfar CalcMagikarpLength
; We're clear if the length is < 1536
- ld a, [MagikarpLength]
- cp a, $06 ; $600 = 1536
+ ld a, [wMagikarpLength]
+ cp $06 ; $600 = 1536
jr nz, .CheckMagikarpArea
; 5% chance of skipping size checks
call Random
- cp a, $0c ; / $100
+ cp $0c ; / $100
jr c, .CheckMagikarpArea
; Try again if > 1614
- ld a, [MagikarpLength + 1]
- cp a, $50
+ ld a, [wMagikarpLength + 1]
+ cp $50
jr nc, .GenerateDVs
; 20% chance of skipping this check
call Random
- cp a, $32 ; / $100
+ cp $32 ; / $100
jr c, .CheckMagikarpArea
; Try again if > 1598
- ld a, [MagikarpLength + 1]
- cp a, $40
+ ld a, [wMagikarpLength + 1]
+ cp $40
jr nc, .GenerateDVs
.CheckMagikarpArea:
@@ -6448,18 +6416,18 @@ LoadEnemyMon: ; 3e8eb
; Intended behavior enforces a minimum size at Lake of Rage
; The real behavior prevents size flooring in the Lake of Rage area
ld a, [MapGroup]
- cp a, GROUP_LAKE_OF_RAGE
+ cp GROUP_LAKE_OF_RAGE
jr z, .Happiness
ld a, [MapNumber]
- cp a, MAP_LAKE_OF_RAGE
+ cp MAP_LAKE_OF_RAGE
jr z, .Happiness
; 40% chance of not flooring
call Random
- cp a, $64 ; / $100
+ cp $64 ; / $100
jr c, .Happiness
; Floor at length 1024
- ld a, [MagikarpLength]
- cp a, 1024 >> 8
+ ld a, [wMagikarpLength]
+ cp 1024 >> 8
jr c, .GenerateDVs ; try again
; Finally done with DVs
@@ -6480,7 +6448,7 @@ LoadEnemyMon: ; 3e8eb
; If we're in a trainer battle,
; get the rest of the parameters from the party struct
ld a, [wBattleMode]
- cp a, TRAINER_BATTLE
+ cp TRAINER_BATTLE
jr z, .OpponentParty
; If we're in a wild battle, check wild-specific stuff
@@ -6515,7 +6483,7 @@ LoadEnemyMon: ; 3e8eb
; ..unless it's a RoamMon
ld a, [BattleType]
- cp a, BATTLETYPE_ROAMING
+ cp BATTLETYPE_ROAMING
jr nz, .Moves
; Grab HP
@@ -6568,7 +6536,7 @@ LoadEnemyMon: ; 3e8eb
ld de, EnemyMonMoves
; Are we in a trainer battle?
ld a, [wBattleMode]
- cp a, TRAINER_BATTLE
+ cp TRAINER_BATTLE
jr nz, .WildMoves
; Then copy moves from the party struct
ld hl, OTPartyMon1Moves
@@ -6588,14 +6556,14 @@ LoadEnemyMon: ; 3e8eb
ld [hli], a
ld [hl], a
; Make sure the predef knows this isn't a partymon
- ld [MagikarpLength], a
+ ld [wEvolutionOldSpecies], a
; Fill moves based on level
predef FillMoves
.PP:
; Trainer battle?
ld a, [wBattleMode]
- cp a, TRAINER_BATTLE
+ cp TRAINER_BATTLE
jr z, .TrainerPP
; Fill wild PP
@@ -6670,13 +6638,13 @@ CheckSleepingTreeMon: ; 3eb38
; Don't do anything if this isn't a tree encounter
ld a, [BattleType]
- cp a, BATTLETYPE_TREE
+ cp BATTLETYPE_TREE
jr nz, .NotSleeping
; Get list for the time of day
ld hl, .Morn
ld a, [TimeOfDay]
- cp a, DAY
+ cp DAY_F
jr c, .Check
ld hl, .Day
jr z, .Check
@@ -6759,7 +6727,7 @@ CheckUnownLetter: ; 3eb75
inc e
inc e
ld a, e
- cp a, .Set1 - .LetterSets
+ cp .Set1 - .LetterSets
jr c, .loop
; Hasn't been unlocked, or the letter is invalid
@@ -6812,7 +6780,7 @@ BattleWinSlideInEnemyTrainerFrontpic: ; 3ebd8
ld a, [OtherTrainerClass]
ld [TrainerClass], a
ld de, VTiles2
- callab GetTrainerPic
+ callfar GetTrainerPic
hlcoord 19, 0
ld c, 0
@@ -7041,14 +7009,14 @@ ApplyStatLevelMultiplier: ; 3ecb7
; Cap at 999.
ld a, [hQuotient + 2]
- sub 999 % $100
+ sub MAX_STAT_VALUE % $100
ld a, [hQuotient + 1]
- sbc 999 / $100
+ sbc MAX_STAT_VALUE / $100
jp c, .okay3
- ld a, 999 / $100
+ ld a, MAX_STAT_VALUE / $100
ld [hQuotient + 1], a
- ld a, 999 % $100
+ ld a, MAX_STAT_VALUE % $100
ld [hQuotient + 2], a
.okay3
@@ -7164,24 +7132,24 @@ BoostStat: ; 3ed7c
; Cap at 999.
ld a, [hld]
- sub 999 % $100
+ sub MAX_STAT_VALUE % $100
ld a, [hl]
- sbc 999 / $100
+ sbc MAX_STAT_VALUE / $100
ret c
- ld a, 999 / $100
+ ld a, MAX_STAT_VALUE / $100
ld [hli], a
- ld a, 999 % $100
+ ld a, MAX_STAT_VALUE % $100
ld [hld], a
ret
; 3ed9f
_LoadBattleFontsHPBar: ; 3ed9f
- callab LoadBattleFontsHPBar
+ callfar LoadBattleFontsHPBar
ret
; 3eda6
_LoadHPBar: ; 3eda6
- callab LoadHPBar
+ callfar LoadHPBar
ret
; 3edad
@@ -7285,9 +7253,9 @@ Call_PlayBattleAnim_OnlyIfVisible: ; 3ee0f
Call_PlayBattleAnim: ; 3ee17
ld a, e
- ld [FXAnimIDLo], a
+ ld [FXAnimID], a
ld a, d
- ld [FXAnimIDHi], a
+ ld [FXAnimID + 1], a
call WaitBGMap
predef_jump PlayBattleAnim
; 3ee27
@@ -7487,7 +7455,7 @@ GiveExperiencePoints: ; 3ee3b
call GetBaseData
push bc
ld d, MAX_LEVEL
- callab CalcExpAtLevel
+ callfar CalcExpAtLevel
pop bc
ld hl, MON_STAT_EXP - 1
add hl, bc
@@ -7516,7 +7484,7 @@ GiveExperiencePoints: ; 3ee3b
xor a ; PARTYMON
ld [MonType], a
predef CopyPkmnToTempMon
- callab CalcLevel
+ callfar CalcLevel
pop bc
ld hl, MON_LEVEL
add hl, bc
@@ -7603,16 +7571,16 @@ GiveExperiencePoints: ; 3ee3b
xor a
ld [wd265], a
call ApplyStatLevelMultiplierOnAllStats
- callab ApplyStatusEffectOnPlayerStats
- callab BadgeStatBoosts
- callab UpdatePlayerHUD
+ callfar ApplyStatusEffectOnPlayerStats
+ callfar BadgeStatBoosts
+ callfar UpdatePlayerHUD
call EmptyBattleTextBox
call LoadTileMapToTempTileMap
ld a, $1
ld [hBGMapMode], a
.skip_animation
- callba LevelUpHappinessMod
+ farcall LevelUpHappinessMod
ld a, [CurBattleMon]
ld b, a
ld a, [CurPartyMon]
@@ -7813,7 +7781,7 @@ AnimateExpBar: ; 3f136
.NoOverflow:
ld d, MAX_LEVEL
- callab CalcExpAtLevel
+ callfar CalcExpAtLevel
ld a, [hProduct + 1]
ld b, a
ld a, [hProduct + 2]
@@ -7836,7 +7804,7 @@ AnimateExpBar: ; 3f136
ld [hld], a
.AlreadyAtMaxExp:
- callab CalcLevel
+ callfar CalcLevel
ld a, d
pop bc
pop de
@@ -7868,7 +7836,7 @@ AnimateExpBar: ; 3f136
call TerminateExpBarSound
ld de, SFX_HIT_END_OF_EXP_BAR
call PlaySFX
- callba AnimateEndOfExpBar
+ farcall AnimateEndOfExpBar
call WaitSFX
ld hl, BattleText_StringBuffer1GrewToLevel
call StdBattleTextBox
@@ -8174,7 +8142,7 @@ CalcExpBar: ; 3f39c
push de
ld d, b
push de
- callab CalcExpAtLevel
+ callfar CalcExpAtLevel
pop de
; exp at current level gets pushed to the stack
ld hl, hMultiplicand
@@ -8186,7 +8154,7 @@ CalcExpBar: ; 3f39c
push af
; next level
inc d
- callab CalcExpAtLevel
+ callfar CalcExpAtLevel
; back up the next level exp, and subtract the two levels
ld hl, hMultiplicand + 2
ld a, [hl]
@@ -8301,17 +8269,17 @@ PlaceExpBar: ; 3f41c
ret
; 3f43d
-GetMonBackpic: ; 3f43d
+GetBattleMonBackpic: ; 3f43d
ld a, [PlayerSubStatus4]
bit SUBSTATUS_SUBSTITUTE, a
ld hl, BattleAnimCmd_RaiseSub
- jr nz, GetBackpic_DoAnim ; substitute
+ jr nz, GetBattleMonBackpic_DoAnim ; substitute
DropPlayerSub: ; 3f447
ld a, [wPlayerMinimized]
and a
ld hl, BattleAnimCmd_MinimizeOpp
- jr nz, GetBackpic_DoAnim
+ jr nz, GetBattleMonBackpic_DoAnim
ld a, [CurPartySpecies]
push af
ld a, [BattleMonSpecies]
@@ -8319,13 +8287,13 @@ DropPlayerSub: ; 3f447
ld hl, BattleMonDVs
predef GetUnownLetter
ld de, VTiles2 tile $31
- predef GetBackpic
+ predef GetMonBackpic
pop af
ld [CurPartySpecies], a
ret
; 3f46f
-GetBackpic_DoAnim: ; 3f46f
+GetBattleMonBackpic_DoAnim: ; 3f46f
ld a, [hBattleTurn]
push af
xor a
@@ -8337,17 +8305,17 @@ GetBackpic_DoAnim: ; 3f46f
ret
; 3f47c
-GetMonFrontpic: ; 3f47c
+GetEnemyMonFrontpic: ; 3f47c
ld a, [EnemySubStatus4]
bit SUBSTATUS_SUBSTITUTE, a
ld hl, BattleAnimCmd_RaiseSub
- jr nz, GetFrontpic_DoAnim
+ jr nz, GetEnemyMonFrontpic_DoAnim
DropEnemySub: ; 3f486
ld a, [wEnemyMinimized]
and a
ld hl, BattleAnimCmd_MinimizeOpp
- jr nz, GetFrontpic_DoAnim
+ jr nz, GetEnemyMonFrontpic_DoAnim
ld a, [CurPartySpecies]
push af
@@ -8358,13 +8326,13 @@ DropEnemySub: ; 3f486
ld hl, EnemyMonDVs
predef GetUnownLetter
ld de, VTiles2
- predef FrontpicPredef
+ predef GetAnimatedFrontpicPredef
pop af
ld [CurPartySpecies], a
ret
; 3f4b4
-GetFrontpic_DoAnim: ; 3f4b4
+GetEnemyMonFrontpic_DoAnim: ; 3f4b4
ld a, [hBattleTurn]
push af
call SetEnemyTurn
@@ -8401,18 +8369,18 @@ _DoBattle: ; 3f4d9
; 3f4dd
BattleIntro: ; 3f4dd
- callba TrainerRankings_Battles ; mobile
+ farcall TrainerRankings_Battles ; mobile
call LoadTrainerOrWildMonPic
xor a
ld [TempBattleMonSpecies], a
- ld [wd0d2], a
+ ld [wBattleMenuCursorBuffer], a
xor a
ld [hMapAnims], a
- callba PlayBattleMusic
- callba ShowLinkBattleParticipants
- callba FindFirstAliveMonAndStartBattle
+ farcall PlayBattleMusic
+ farcall ShowLinkBattleParticipants
+ farcall FindFirstAliveMonAndStartBattle
call DisableSpriteUpdates
- callba ClearBattleRAM
+ farcall ClearBattleRAM
call InitEnemy
call BackUpVBGMap2
ld b, SCGB_BATTLE_GRAYSCALE
@@ -8486,11 +8454,11 @@ BackUpVBGMap2: ; 3f568
InitEnemyTrainer: ; 3f594
ld [TrainerClass], a
- callba TrainerRankings_TrainerBattles
+ farcall TrainerRankings_TrainerBattles
xor a
ld [TempEnemyMonSpecies], a
- callab GetTrainerAttributes
- callab ReadTrainerParty
+ callfar GetTrainerAttributes
+ callfar ReadTrainerParty
ld a, [TrainerClass]
cp RIVAL1
@@ -8500,7 +8468,7 @@ InitEnemyTrainer: ; 3f594
.ok
ld de, VTiles2
- callab GetTrainerPic
+ callfar GetTrainerPic
xor a
ld [hGraphicStartTile], a
dec a
@@ -8527,7 +8495,7 @@ InitEnemyTrainer: ; 3f594
or [hl]
jr z, .skipfaintedmon
ld c, HAPPINESS_GYMBATTLE
- callab ChangeHappiness
+ callfar ChangeHappiness
.skipfaintedmon
pop bc
dec b
@@ -8542,7 +8510,7 @@ InitEnemyTrainer: ; 3f594
InitEnemyWildmon: ; 3f607
ld a, WILD_BATTLE
ld [wBattleMode], a
- callba TrainerRankings_WildBattles
+ farcall TrainerRankings_WildBattles
call LoadEnemyMon
ld hl, EnemyMonMoves
ld de, wWildMonMoves
@@ -8564,7 +8532,7 @@ InitEnemyWildmon: ; 3f607
ld [wFirstUnownSeen], a
.skip_unown
ld de, VTiles2
- predef FrontpicPredef
+ predef GetAnimatedFrontpicPredef
xor a
ld [TrainerClass], a
ld [hGraphicStartTile], a
@@ -8651,7 +8619,7 @@ ExitBattle: ; 3f69e
xor a
ld [wForceEvolution], a
predef EvolveAfterBattle
- callba GivePokerusAndConvertBerries
+ farcall GivePokerusAndConvertBerries
ret
; 3f6d0
@@ -8670,7 +8638,7 @@ CleanUpBattleRAM: ; 3f6d0
ld [wPartyMenuCursor], a
ld [wKeyItemsPocketCursor], a
ld [wItemsPocketCursor], a
- ld [wd0d2], a
+ ld [wBattleMenuCursorBuffer], a
ld [CurMoveNum], a
ld [wBallsPocketCursor], a
ld [wLastPocket], a
@@ -8725,20 +8693,20 @@ CheckPayDay: ; 3f71d
; 3f759
ShowLinkBattleParticipantsAfterEnd: ; 3f759
- callba TrainerRankings_LinkBattles
- callba BackupMobileEventIndex
+ farcall TrainerRankings_LinkBattles
+ farcall BackupMobileEventIndex
ld a, [CurOTMon]
ld hl, OTPartyMon1Status
call GetPartyLocation
ld a, [EnemyMonStatus]
ld [hl], a
call ClearTileMap
- callba _ShowLinkBattleParticipants
+ farcall _ShowLinkBattleParticipants
ret
; 3f77c
DisplayLinkBattleResult: ; 3f77c
- callba CheckMobileBattleError
+ farcall CheckMobileBattleError
jp c, .Mobile_InvalidBattle
call IsMobileBattle2
jr nz, .proceed
@@ -8747,7 +8715,7 @@ DisplayLinkBattleResult: ; 3f77c
bit 4, [hl]
jr z, .proceed
- callba DetermineLinkBattleResult
+ farcall DetermineLinkBattleResult
.proceed
ld a, [wBattleResult]
@@ -8755,24 +8723,24 @@ DisplayLinkBattleResult: ; 3f77c
cp $1
jr c, .victory
jr z, .loss
- callba TrainerRankings_ColosseumDraws
+ farcall TrainerRankings_ColosseumDraws
ld de, .Draw
jr .store_result
.victory
- callba TrainerRankings_ColosseumWins
+ farcall TrainerRankings_ColosseumWins
ld de, .Win
jr .store_result
.loss
- callba TrainerRankings_ColosseumLosses
+ farcall TrainerRankings_ColosseumLosses
ld de, .Lose
jr .store_result
.store_result
hlcoord 6, 8
call PlaceString
- callba BackupMobileEventIndex
+ farcall BackupMobileEventIndex
ld c, 200
call DelayFrames
@@ -9009,7 +8977,7 @@ BattleEnd_HandleRoamMons: ; 3f998
ret nz
.update_roam_mons
- callab UpdateRoamMons
+ callfar UpdateRoamMons
ret
; 3f9d1
@@ -9167,10 +9135,10 @@ AddLastMobileBattleToLinkRecord: ; 3fa42
dec hl
ld a, [hl]
inc hl
- cp 9999 / $100
+ cp MAX_LINK_RECORD / $100
ret c
ld a, [hl]
- cp 9999 % $100
+ cp MAX_LINK_RECORD % $100
ret
; 3fac8
@@ -9301,7 +9269,7 @@ InitBattleDisplay: ; 3fb6c
ld b, 4
ld c, 18
call TextBox
- callba MobileTextBorder
+ farcall MobileTextBorder
hlcoord 1, 5
lb bc, 3, 7
call ClearBox
@@ -9317,7 +9285,7 @@ InitBattleDisplay: ; 3fb6c
call WaitBGMap
xor a
ld [hBGMapMode], a
- callba BattleIntroSlidingPics
+ farcall BattleIntroSlidingPics
ld a, $1
ld [hBGMapMode], a
ld a, $31
@@ -9386,7 +9354,7 @@ GetTrainerBackpic: ; 3fbff
jr z, .Chris
; It's a girl.
- callba GetKrisBackpic
+ farcall GetKrisBackpic
ret
.Chris:
@@ -9471,7 +9439,7 @@ BattleStartMessage: ; 3fc8b
ld c, 20
call DelayFrames
- callba Battle_GetTrainerName
+ farcall Battle_GetTrainerName
ld hl, WantsToBattleText
jr .PlaceBattleStartText
@@ -9490,10 +9458,10 @@ BattleStartMessage: ; 3fc8b
call Call_PlayBattleAnim
.not_shiny
- callba CheckSleepingTreeMon
+ farcall CheckSleepingTreeMon
jr c, .skip_cry
- callba CheckBattleScene
+ farcall CheckBattleScene
jr c, .cry_no_anim
hlcoord 12, 0
@@ -9513,7 +9481,7 @@ BattleStartMessage: ; 3fc8b
cp BATTLETYPE_FISH
jr nz, .NotFishing
- callba TrainerRankings_HookedEncounters
+ farcall TrainerRankings_HookedEncounters
ld hl, HookedPokemonAttackedText
jr .PlaceBattleStartText
@@ -9529,7 +9497,7 @@ BattleStartMessage: ; 3fc8b
.PlaceBattleStartText:
push hl
- callba BattleStart_TrainerHuds
+ farcall BattleStart_TrainerHuds
pop hl
call StdBattleTextBox
@@ -9537,7 +9505,7 @@ BattleStartMessage: ; 3fc8b
ret nz
ld c, $2 ; start
- callba Mobile_PrintOpponentBattleMessage
+ farcall Mobile_PrintOpponentBattleMessage
ret
; 3fd26