diff options
Diffstat (limited to 'engine/battle/core.asm')
-rw-r--r-- | engine/battle/core.asm | 1141 |
1 files changed, 414 insertions, 727 deletions
diff --git a/engine/battle/core.asm b/engine/battle/core.asm index 0fe77df40..d1bd41b84 100644 --- a/engine/battle/core.asm +++ b/engine/battle/core.asm @@ -1,6 +1,6 @@ ; Core components of the battle engine. -BattleCore: -DoBattle: ; 3c000 + +DoBattle: xor a ld [wBattleParticipantsNotFainted], a ld [wBattleParticipantsIncludingFainted], a @@ -47,7 +47,7 @@ DoBattle: ; 3c000 .player_2 call LoadTileMapToTempTileMap - call CheckPlayerPartyForFitPkmn + call CheckPlayerPartyForFitMon ld a, d and a jp z, LostBattle @@ -86,7 +86,7 @@ DoBattle: ; 3c000 call ResetBattleParticipants call InitBattleMon call ResetPlayerStatLevels - call SendOutPkmnText + call SendOutMonText call NewBattleMonStatus call BreakAttraction call SendOutPlayerMon @@ -114,13 +114,12 @@ DoBattle: ; 3c000 .tutorial_debug jp BattleMenu -; 3c0e5 -WildFled_EnemyFled_LinkBattleCanceled: ; 3c0e5 +WildFled_EnemyFled_LinkBattleCanceled: call Call_LoadTempTileMapToTileMap ld a, [wBattleResult] - and $c0 - add $2 + and BATTLERESULT_BITMASK + add DRAW ld [wBattleResult], a ld a, [wLinkMode] and a @@ -128,8 +127,8 @@ WildFled_EnemyFled_LinkBattleCanceled: ; 3c0e5 jr z, .print_text ld a, [wBattleResult] - and $c0 - ld [wBattleResult], a + and BATTLERESULT_BITMASK + ld [wBattleResult], a ; WIN ld hl, BattleText_EnemyFled call CheckMobileBattleError jr nc, .print_text @@ -156,9 +155,8 @@ WildFled_EnemyFled_LinkBattleCanceled: ; 3c0e5 ld a, 1 ld [wBattleEnded], a ret -; 3c12f -BattleTurn: ; 3c12f +BattleTurn: .loop call Stubbed_Function3c1bf call CheckContestBattleOver @@ -229,7 +227,6 @@ BattleTurn: ; 3c12f .quit ret -; 3c1bf Stubbed_Function3c1bf: ret @@ -248,9 +245,8 @@ Stubbed_Function3c1bf: .finish call CloseSRAM ret -; 3c1d6 -HandleBetweenTurnEffects: ; 3c1d6 +HandleBetweenTurnEffects: ld a, [hSerialConnectionStatus] cp USING_EXTERNAL_CLOCK jr z, .CheckEnemyFirst @@ -289,7 +285,7 @@ HandleBetweenTurnEffects: ; 3c1d6 .NoMoreFaintingConditions: call HandleLeftovers call HandleMysteryberry - call HanleDefrost + call HandleDefrost call HandleSafeguard call HandleScreens call HandleStatBoostingHeldItems @@ -297,9 +293,8 @@ HandleBetweenTurnEffects: ; 3c1d6 call UpdateBattleMonInParty call LoadTileMapToTempTileMap jp HandleEncore -; 3c23c -CheckFaint_PlayerThenEnemy: ; 3c23c +CheckFaint_PlayerThenEnemy: call HasPlayerFainted jr nz, .PlayerNotFainted call HandlePlayerMonFaint @@ -322,9 +317,8 @@ CheckFaint_PlayerThenEnemy: ; 3c23c .BattleIsOver: scf ret -; 3c25c -CheckFaint_EnemyThenPlayer: ; 3c25c +CheckFaint_EnemyThenPlayer: call HasEnemyFainted jr nz, .EnemyNotFainted call HandleEnemyMonFaint @@ -347,9 +341,8 @@ CheckFaint_EnemyThenPlayer: ; 3c25c .BattleIsOver: scf ret -; 3c27c -HandleBerserkGene: ; 3c27c +HandleBerserkGene: ld a, [hSerialConnectionStatus] cp USING_EXTERNAL_CLOCK jr z, .reverse @@ -424,9 +417,8 @@ HandleBerserkGene: ; 3c27c call SwitchTurnCore ld hl, BecameConfusedText jp StdBattleTextBox -; 3c300 -EnemyTriesToFlee: ; 3c300 +EnemyTriesToFlee: ld a, [wLinkMode] and a jr z, .not_linked @@ -442,9 +434,8 @@ EnemyTriesToFlee: ; 3c300 call WildFled_EnemyFled_LinkBattleCanceled scf ret -; 3c314 -DetermineMoveOrder: ; 3c314 +DetermineMoveOrder: ld a, [wLinkMode] and a jr z, .use_move @@ -463,13 +454,13 @@ DetermineMoveOrder: ; 3c314 jr z, .player_2 call BattleRandom - cp 1 + (50 percent) + cp 50 percent + 1 jp c, .player_first jp .enemy_first .player_2 call BattleRandom - cp 1 + (50 percent) + cp 50 percent + 1 jp c, .enemy_first jp .player_first @@ -549,25 +540,23 @@ DetermineMoveOrder: ; 3c314 cp USING_INTERNAL_CLOCK jr z, .player_2c call BattleRandom - cp 1 + (50 percent) + cp 50 percent + 1 jp c, .player_first jp .enemy_first .player_2c call BattleRandom - cp 1 + (50 percent) + cp 50 percent + 1 jp c, .enemy_first .player_first scf ret -; 3c3f3 -.enemy_first ; 3c3f3 +.enemy_first and a ret -; 3c3f5 -CheckContestBattleOver: ; 3c3f5 +CheckContestBattleOver: ld a, [wBattleType] cp BATTLETYPE_CONTEST jr nz, .contest_not_over @@ -575,8 +564,8 @@ CheckContestBattleOver: ; 3c3f5 and a jr nz, .contest_not_over ld a, [wBattleResult] - and $c0 - add $2 + and BATTLERESULT_BITMASK + add DRAW ld [wBattleResult], a scf ret @@ -584,9 +573,8 @@ CheckContestBattleOver: ; 3c3f5 .contest_not_over and a ret -; 3c410 -CheckPlayerLockedIn: ; 3c410 +CheckPlayerLockedIn: ld a, [wPlayerSubStatus4] and 1 << SUBSTATUS_RECHARGE jp nz, .quit @@ -610,9 +598,8 @@ CheckPlayerLockedIn: ; 3c410 .quit scf ret -; 3c434 -ParsePlayerAction: ; 3c434 +ParsePlayerAction: call CheckPlayerLockedIn jp c, .locked_in ld hl, wPlayerSubStatus5 @@ -706,9 +693,8 @@ ParsePlayerAction: ; 3c434 res SUBSTATUS_RAGE, [hl] xor a ret -; 3c4df -HandleEncore: ; 3c4df +HandleEncore: ld a, [hSerialConnectionStatus] cp USING_EXTERNAL_CLOCK jr z, .player_1 @@ -764,9 +750,8 @@ HandleEncore: ; 3c4df call SetPlayerTurn ld hl, BattleText_TargetsEncoreEnded jp StdBattleTextBox -; 3c543 -TryEnemyFlee: ; 3c543 +TryEnemyFlee: ld a, [wBattleMode] dec a jr nz, .Stay @@ -791,7 +776,7 @@ TryEnemyFlee: ; 3c543 call BattleRandom ld b, a - cp 1 + (50 percent) + cp 50 percent + 1 jr nc, .Stay push bc @@ -803,7 +788,7 @@ TryEnemyFlee: ; 3c543 jr c, .Flee ld a, b - cp 1 + (10 percent) + cp 10 percent + 1 jr nc, .Stay ld a, [wTempEnemyMonSpecies] @@ -819,11 +804,10 @@ TryEnemyFlee: ; 3c543 .Flee: scf ret -; 3c59a INCLUDE "data/wild/flee_mons.asm" -CompareMovePriority: ; 3c5b4 +CompareMovePriority: ; Compare the priority of the player and enemy's moves. ; Return carry if the player goes first, or z if they match. @@ -836,9 +820,8 @@ CompareMovePriority: ; 3c5b4 pop bc cp b ret -; 3c5c5 -GetMovePriority: ; 3c5c5 +GetMovePriority: ; Return the priority (0-3) of move a. ld b, a @@ -864,11 +847,10 @@ GetMovePriority: ; 3c5c5 .done ld a, [hl] ret -; 3c5df INCLUDE "data/moves/effects_priorities.asm" -GetMoveEffect: ; 3c5ec +GetMoveEffect: ld a, b dec a ld hl, Moves + MOVE_EFFECT @@ -878,9 +860,8 @@ GetMoveEffect: ; 3c5ec call GetFarByte ld b, a ret -; 3c5fe -Battle_EnemyFirst: ; 3c5fe +Battle_EnemyFirst: call LoadTileMapToTempTileMap call TryEnemyFlee jp c, WildFled_EnemyFled_LinkBattleCanceled @@ -922,9 +903,8 @@ Battle_EnemyFirst: ; 3c5fe xor a ld [wBattlePlayerAction], a ret -; 3c664 -Battle_PlayerFirst: ; 3c664 +Battle_PlayerFirst: xor a ld [wEnemyGoesFirst], a call SetEnemyTurn @@ -972,23 +952,20 @@ Battle_PlayerFirst: ; 3c664 xor a ld [wBattlePlayerAction], a ret -; 3c6cf -PlayerTurn_EndOpponentProtectEndureDestinyBond: ; 3c6cf +PlayerTurn_EndOpponentProtectEndureDestinyBond: call SetPlayerTurn call EndUserDestinyBond callfar DoPlayerTurn jp EndOpponentProtectEndureDestinyBond -; 3c6de -EnemyTurn_EndOpponentProtectEndureDestinyBond: ; 3c6de +EnemyTurn_EndOpponentProtectEndureDestinyBond: call SetEnemyTurn call EndUserDestinyBond callfar DoEnemyTurn jp EndOpponentProtectEndureDestinyBond -; 3c6ed -EndOpponentProtectEndureDestinyBond: ; 3c6ed +EndOpponentProtectEndureDestinyBond: ld a, BATTLE_VARS_SUBSTATUS1_OPP call GetBattleVarAddr res SUBSTATUS_PROTECT, [hl] @@ -997,33 +974,30 @@ EndOpponentProtectEndureDestinyBond: ; 3c6ed call GetBattleVarAddr res SUBSTATUS_DESTINY_BOND, [hl] ret -; 3c6fe -EndUserDestinyBond: ; 3c6fe +EndUserDestinyBond: ld a, BATTLE_VARS_SUBSTATUS5 call GetBattleVarAddr res SUBSTATUS_DESTINY_BOND, [hl] ret -; 3c706 -HasUserFainted: ; 3c706 +HasUserFainted: ld a, [hBattleTurn] and a jr z, HasPlayerFainted -HasEnemyFainted: ; 3c70b +HasEnemyFainted: ld hl, wEnemyMonHP jr CheckIfHPIsZero -HasPlayerFainted: ; 3c710 +HasPlayerFainted: ld hl, wBattleMonHP -CheckIfHPIsZero: ; 3c713 +CheckIfHPIsZero: ld a, [hli] or [hl] ret -; 3c716 -ResidualDamage: ; 3c716 +ResidualDamage: ; Return z if the user fainted before ; or as a result of residual damage. ; For Sandstorm damage, see HandleWeather. @@ -1158,9 +1132,8 @@ ResidualDamage: ; 3c716 call DelayFrames xor a ret -; 3c801 -HandlePerishSong: ; 3c801 +HandlePerishSong: ld a, [hSerialConnectionStatus] cp USING_EXTERNAL_CLOCK jr z, .EnemyFirst @@ -1227,9 +1200,8 @@ HandlePerishSong: ; 3c801 ld [hli], a ld [hl], a ret -; 3c874 -HandleWrap: ; 3c874 +HandleWrap: ld a, [hSerialConnectionStatus] cp USING_EXTERNAL_CLOCK jr z, .EnemyFirst @@ -1292,16 +1264,14 @@ HandleWrap: ; 3c874 .print_text jp StdBattleTextBox -; 3c8e4 -SwitchTurnCore: ; 3c8e4 +SwitchTurnCore: ld a, [hBattleTurn] xor 1 ld [hBattleTurn], a ret -; 3c8eb -HandleLeftovers: ; 3c8eb +HandleLeftovers: ld a, [hSerialConnectionStatus] cp USING_EXTERNAL_CLOCK jr z, .DoEnemyFirst @@ -1349,9 +1319,8 @@ HandleLeftovers: ; 3c8eb call RestoreHP ld hl, BattleText_TargetRecoveredWithItem jp StdBattleTextBox -; 3c93c -HandleMysteryberry: ; 3c93c +HandleMysteryberry: ld a, [hSerialConnectionStatus] cp USING_EXTERNAL_CLOCK jr z, .DoEnemyFirst @@ -1488,9 +1457,8 @@ HandleMysteryberry: ; 3c93c call SwitchTurnCore ld hl, BattleText_UserRecoveredPPUsing jp StdBattleTextBox -; 3ca26 -HandleFutureSight: ; 3ca26 +HandleFutureSight: ld a, [hSerialConnectionStatus] cp USING_EXTERNAL_CLOCK jr z, .enemy_first @@ -1533,7 +1501,7 @@ HandleFutureSight: ; 3ca26 xor a ld [wAttackMissed], a ld [wAlreadyDisobeyed], a - ld a, 10 + ld a, EFFECTIVE ld [wTypeModifier], a callfar DoMove xor a @@ -1547,9 +1515,8 @@ HandleFutureSight: ; 3ca26 call UpdateBattleMonInParty jp UpdateEnemyMonInParty -; 3ca8f -HanleDefrost: ; 3ca8f +HandleDefrost: ld a, [hSerialConnectionStatus] cp USING_EXTERNAL_CLOCK jr z, .enemy_first @@ -1607,9 +1574,8 @@ HanleDefrost: ; 3ca8f call SetPlayerTurn ld hl, DefrostedOpponentText jp StdBattleTextBox -; 3cafb -HandleSafeguard: ; 3cafb +HandleSafeguard: ld a, [hSerialConnectionStatus] cp USING_EXTERNAL_CLOCK jr z, .player1 @@ -1646,7 +1612,7 @@ HandleSafeguard: ; 3cafb ld hl, BattleText_SafeguardFaded jp StdBattleTextBox -HandleScreens: ; 3cb36 +HandleScreens: ld a, [hSerialConnectionStatus] cp USING_EXTERNAL_CLOCK jr z, .Both @@ -1681,15 +1647,13 @@ HandleScreens: ; 3cb36 .Copy: ld hl, wStringBuffer1 jp CopyName2 -; 3cb75 .Your: db "Your@" .Enemy: db "Enemy@" -; 3cb80 -.LightScreenTick: ; 3cb80 +.LightScreenTick: ld a, [de] dec a ld [de], a @@ -1697,25 +1661,23 @@ HandleScreens: ; 3cb36 res SCREENS_LIGHT_SCREEN, [hl] push hl push de - ld hl, BattleText_PkmnLightScreenFell + ld hl, BattleText_MonsLightScreenFell call StdBattleTextBox pop de pop hl ret -; 3cb91 -.ReflectTick: ; 3cb91 +.ReflectTick: inc de ld a, [de] dec a ld [de], a ret nz res SCREENS_REFLECT, [hl] - ld hl, BattleText_PkmnReflectFaded + ld hl, BattleText_MonsReflectFaded jp StdBattleTextBox -; 3cb9e -HandleWeather: ; 3cb9e +HandleWeather: ld a, [wBattleWeather] cp WEATHER_NONE ret z @@ -1804,30 +1766,29 @@ HandleWeather: ; 3cb9e ld h, [hl] ld l, a jp StdBattleTextBox -; 3cc2d .WeatherMessages: +; entries correspond to WEATHER_* constants dw BattleText_RainContinuesToFall dw BattleText_TheSunlightIsStrong dw BattleText_TheSandstormRages + .WeatherEndedMessages: +; entries correspond to WEATHER_* constants dw BattleText_TheRainStopped dw BattleText_TheSunlightFaded dw BattleText_TheSandstormSubsided -; 3cc39 -SubtractHPFromTarget: ; 3cc39 +SubtractHPFromTarget: call SubtractHP jp UpdateHPBar -; 3cc3f -SubtractHPFromUser: ; 3cc3f -; Subtract HP from Pkmn +SubtractHPFromUser: +; Subtract HP from mon call SubtractHP jp UpdateHPBarBattleHuds -; 3cc45 -SubtractHP: ; 3cc45 +SubtractHP: ld hl, wBattleMonHP ld a, [hBattleTurn] and a @@ -1857,9 +1818,8 @@ SubtractHP: ; 3cc45 ld [wBuffer5], a ld [wBuffer6], a ret -; 3cc76 -GetSixteenthMaxHP: ; 3cc76 +GetSixteenthMaxHP: call GetQuarterMaxHP ; quarter result srl c @@ -1871,9 +1831,8 @@ GetSixteenthMaxHP: ; 3cc76 inc c .ok ret -; 3cc83 -GetEighthMaxHP: ; 3cc83 +GetEighthMaxHP: ; output: bc call GetQuarterMaxHP ; assumes nothing can have 1024 or more hp @@ -1886,9 +1845,8 @@ GetEighthMaxHP: ; 3cc83 inc c .end ret -; 3cc8e -GetQuarterMaxHP: ; 3cc8e +GetQuarterMaxHP: ; output: bc call GetMaxHP @@ -1906,9 +1864,8 @@ GetQuarterMaxHP: ; 3cc8e inc c .end ret -; 3cc9f -GetHalfMaxHP: ; 3cc9f +GetHalfMaxHP: ; output: bc call GetMaxHP @@ -1923,9 +1880,8 @@ GetHalfMaxHP: ; 3cc9f inc c .end ret -; 3ccac -GetMaxHP: ; 3ccac +GetMaxHP: ; output: bc, wBuffer1-2 ld hl, wBattleMonMaxHP @@ -1942,9 +1898,8 @@ GetMaxHP: ; 3ccac ld [wBuffer1], a ld c, a ret -; 3ccc2 -Unreferenced_GetHalfHP: ; 3ccc2 +Unreferenced_GetHalfHP: ld hl, wBattleMonHP ld a, [hBattleTurn] and a @@ -1962,9 +1917,8 @@ Unreferenced_GetHalfHP: ; 3ccc2 ld a, [hl] ld [wBuffer1], a ret -; 3ccde -CheckUserHasEnoughHP: ; 3ccde +CheckUserHasEnoughHP: ld hl, wBattleMonHP + 1 ld a, [hBattleTurn] and a @@ -1977,9 +1931,8 @@ CheckUserHasEnoughHP: ; 3ccde ld a, b sbc [hl] ret -; 3ccef -RestoreHP ; 3ccef +RestoreHP ld hl, wEnemyMonMaxHP ld a, [hBattleTurn] and a @@ -2022,14 +1975,12 @@ RestoreHP ; 3ccef call SwitchTurnCore call UpdateHPBarBattleHuds jp SwitchTurnCore -; 3cd36 -UpdateHPBarBattleHuds: ; 3cd36 +UpdateHPBarBattleHuds: call UpdateHPBar jp UpdateBattleHuds -; 3cd3c -UpdateHPBar: ; 3cd3c +UpdateHPBar: hlcoord 10, 9 ld a, [hBattleTurn] and a @@ -2043,9 +1994,8 @@ UpdateHPBar: ; 3cd3c predef AnimateHPBar pop bc ret -; 3cd55 -HandleEnemyMonFaint: ; 3cd55 +HandleEnemyMonFaint: call FaintEnemyPokemon ld hl, wBattleMonHP ld a, [hli] @@ -2054,7 +2004,7 @@ HandleEnemyMonFaint: ; 3cd55 xor a ld [wWhichMonFaintedFirst], a call UpdateBattleStateAndExperienceAfterEnemyFaint - call CheckPlayerPartyForFitPkmn + call CheckPlayerPartyForFitMon ld a, d and a jp z, LostBattle @@ -2112,9 +2062,8 @@ HandleEnemyMonFaint: ; 3cd55 xor a ld [wBattlePlayerAction], a ret -; 3cdca -DoubleSwitch: ; 3cdca +DoubleSwitch: ld a, [hSerialConnectionStatus] cp USING_EXTERNAL_CLOCK jr z, .player_1 @@ -2142,9 +2091,8 @@ DoubleSwitch: ; 3cdca xor a ld [wBattlePlayerAction], a ret -; 3ce01 -UpdateBattleStateAndExperienceAfterEnemyFaint: ; 3ce01 +UpdateBattleStateAndExperienceAfterEnemyFaint: call UpdateBattleMonInParty ld a, [wBattleMode] dec a @@ -2186,7 +2134,7 @@ UpdateBattleStateAndExperienceAfterEnemyFaint: ; 3ce01 call PlayerMonFaintHappinessMod .player_mon_did_not_faint - call CheckPlayerPartyForFitPkmn + call CheckPlayerPartyForFitMon ld a, d and a ret z @@ -2196,8 +2144,8 @@ UpdateBattleStateAndExperienceAfterEnemyFaint: ; 3ce01 call EmptyBattleTextBox call LoadTileMapToTempTileMap ld a, [wBattleResult] - and $c0 - ld [wBattleResult], a + and BATTLERESULT_BITMASK + ld [wBattleResult], a ; WIN call IsAnyMonHoldingExpShare jr z, .skip_exp ld hl, wEnemyMonBaseStats @@ -2233,9 +2181,8 @@ UpdateBattleStateAndExperienceAfterEnemyFaint: ; 3ce01 pop af ld [wBattleParticipantsNotFainted], a ret -; 3ceaa -IsAnyMonHoldingExpShare: ; 3ceaa +IsAnyMonHoldingExpShare: ld a, [wPartyCount] ld b, a ld hl, wPartyMon1 @@ -2289,15 +2236,13 @@ IsAnyMonHoldingExpShare: ; 3ceaa ld a, e and a ret -; 3ceec -StopDangerSound: ; 3ceec +StopDangerSound: xor a ld [wLowHealthAlarm], a ret -; 3cef1 -FaintYourPokemon: ; 3cef1 +FaintYourPokemon: call StopDangerSound call WaitSFX ld a, $f0 @@ -2308,11 +2253,10 @@ FaintYourPokemon: ; 3cef1 hlcoord 9, 7 lb bc, 5, 11 call ClearBox - ld hl, BattleText_PkmnFainted + ld hl, BattleText_MonFainted jp StdBattleTextBox -; 3cf14 -FaintEnemyPokemon: ; 3cf14 +FaintEnemyPokemon: call WaitSFX ld de, SFX_KINESIS call PlaySFX @@ -2322,11 +2266,10 @@ FaintEnemyPokemon: ; 3cf14 hlcoord 1, 0 lb bc, 4, 10 call ClearBox - ld hl, BattleText_EnemyPkmnFainted + ld hl, BattleText_EnemyMonFainted jp StdBattleTextBox -; 3cf35 -CheckEnemyTrainerDefeated: ; 3cf35 +CheckEnemyTrainerDefeated: ld a, [wOTPartyCount] ld b, a xor a @@ -2344,9 +2287,8 @@ CheckEnemyTrainerDefeated: ; 3cf35 and a ret -; 3cf4a -HandleEnemySwitch: ; 3cf4a +HandleEnemySwitch: ld hl, wEnemyHPPal ld e, HP_BAR_LENGTH_PX call UpdateHPPal @@ -2371,9 +2313,8 @@ HandleEnemySwitch: ; 3cf4a jr nz, EnemyPartyMonEntrance inc a ret -; 3cf78 -EnemyPartyMonEntrance: ; 3cf78 +EnemyPartyMonEntrance: push af xor a ld [wEnemySwitchMonIndex], a @@ -2397,9 +2338,8 @@ EnemyPartyMonEntrance: ; 3cf78 ld [wBattlePlayerAction], a inc a ret -; 3cfa4 -WinTrainerBattle: ; 3cfa4 +WinTrainerBattle: ; Player won the battle call StopDangerSound ld a, $1 @@ -2471,22 +2411,22 @@ WinTrainerBattle: ; 3cfa4 call nz, .DoubleReward call .CheckMaxedOutMomMoney push af - ld a, $0 + ld a, FALSE jr nc, .okay ld a, [wMomSavingMoney] - and $7 - cp $3 + and MOM_SAVING_MONEY_MASK + cp (1 << MOM_SAVING_SOME_MONEY_F) | (1 << MOM_SAVING_HALF_MONEY_F) jr nz, .okay - inc a + inc a ; TRUE .okay ld b, a - ld c, $4 + ld c, 4 .loop ld a, b and a jr z, .loop2 - call .SendMoneyToMom + call .AddMoneyToMom dec c dec b jr .loop @@ -2505,7 +2445,7 @@ WinTrainerBattle: ; 3cfa4 pop af jr nc, .KeepItAll ld a, [wMomSavingMoney] - and $7 + and MOM_SAVING_MONEY_MASK jr z, .KeepItAll ld hl, .SentToMomTexts dec a @@ -2521,27 +2461,24 @@ WinTrainerBattle: ; 3cfa4 .KeepItAll: ld hl, GotMoneyForWinningText jp StdBattleTextBox -; 3d081 -.SendMoneyToMom: ; 3d081 +.AddMoneyToMom: push bc ld hl, wBattleReward + 2 ld de, wMomsMoney + 2 call AddBattleMoneyToAccount pop bc ret -; 3d08d -.AddMoneyToWallet: ; 3d08d +.AddMoneyToWallet: push bc ld hl, wBattleReward + 2 ld de, wMoney + 2 call AddBattleMoneyToAccount pop bc ret -; 3d099 -.DoubleReward: ; 3d099 +.DoubleReward: ld hl, wBattleReward + 2 sla [hl] dec hl @@ -2554,15 +2491,14 @@ WinTrainerBattle: ; 3cfa4 ld [hli], a ld [hl], a ret -; 3d0ab -.SentToMomTexts: ; 3d0ab +.SentToMomTexts: +; entries correspond to MOM_SAVING_* constants dw SentSomeToMomText dw SentHalfToMomText dw SentAllToMomText -; 3d0b1 -.CheckMaxedOutMomMoney: ; 3d0b1 +.CheckMaxedOutMomMoney: ld hl, wMomsMoney + 2 ld a, [hld] cp LOW(MAX_MONEY) @@ -2571,10 +2507,9 @@ WinTrainerBattle: ; 3cfa4 ld a, [hl] sbc HIGH(MAX_MONEY >> 8) ret -; 3d0be -AddBattleMoneyToAccount: ; 3d0be - ld c, $3 +AddBattleMoneyToAccount: + ld c, 3 and a push de push hl @@ -2606,9 +2541,8 @@ AddBattleMoneyToAccount: ; 3d0be inc hl ld [hl], LOW(MAX_MONEY) ret -; 3d0ea -PlayVictoryMusic: ; 3d0ea +PlayVictoryMusic: push de ld de, MUSIC_NONE call PlayMusic @@ -2642,26 +2576,24 @@ PlayVictoryMusic: ; 3d0ea .lost pop de ret -; 3d123 -IsKantoGymLeader: ; 0x3d123 +IsKantoGymLeader: ld hl, KantoGymLeaders jr IsGymLeaderCommon -IsGymLeader: ; 0x3d128 +IsGymLeader: ld hl, GymLeaders IsGymLeaderCommon: push de ld a, [wOtherTrainerClass] - ld de, $1 + ld de, 1 call IsInArray pop de ret -; 0x3d137 INCLUDE "data/trainers/leaders.asm" -HandlePlayerMonFaint: ; 3d14e +HandlePlayerMonFaint: call FaintYourPokemon ld hl, wEnemyMonHP ld a, [hli] @@ -2670,7 +2602,7 @@ HandlePlayerMonFaint: ; 3d14e ld a, $1 ld [wWhichMonFaintedFirst], a call PlayerMonFaintHappinessMod - call CheckPlayerPartyForFitPkmn + call CheckPlayerPartyForFitMon ld a, d and a jp z, LostBattle @@ -2709,9 +2641,8 @@ HandlePlayerMonFaint: ; 3d14e call HandleEnemySwitch jp z, WildFled_EnemyFled_LinkBattleCanceled jp DoubleSwitch -; 3d1aa -PlayerMonFaintHappinessMod: ; 3d1aa +PlayerMonFaintHappinessMod: ld a, [wCurBattleMon] ld c, a ld hl, wBattleParticipantsNotFainted @@ -2741,16 +2672,15 @@ PlayerMonFaintHappinessMod: ; 3d1aa ld [wCurPartyMon], a callfar ChangeHappiness ld a, [wBattleResult] - and %11000000 - add $1 + and BATTLERESULT_BITMASK + add LOSE ld [wBattleResult], a ld a, [wWhichMonFaintedFirst] and a ret z ret ; ?????????? -; 3d1f8 -AskUseNextPokemon: ; 3d1f8 +AskUseNextPokemon: call EmptyBattleTextBox call LoadTileMapToTempTileMap ; We don't need to be here if we're in a Trainer battle, @@ -2777,11 +2707,10 @@ AskUseNextPokemon: ; 3d1f8 ld hl, wPartyMon1Speed ld de, wEnemyMonSpeed jp TryToRunAwayFromBattle -; 3d227 -ForcePlayerMonChoice: ; 3d227 +ForcePlayerMonChoice: call EmptyBattleTextBox - call LoadStandardMenuDataHeader + call LoadStandardMenuHeader call SetUpBattlePartyMenu_NoLoop call ForcePickPartyMonInBattle ld a, [wLinkMode] @@ -2829,7 +2758,7 @@ ForcePlayerMonChoice: ; 3d227 call CloseWindow call GetMemSGBLayout call SetPalettes - call SendOutPkmnText + call SendOutMonText call NewBattleMonStatus call BreakAttraction call SendOutPlayerMon @@ -2841,9 +2770,8 @@ ForcePlayerMonChoice: ; 3d227 and a ld c, a ret -; 3d2b3 -PlayerPartyMonEntrance: ; 3d2b3 +PlayerPartyMonEntrance: ld a, [wCurBattleMon] ld [wLastPlayerMon], a ld a, [wCurPartyMon] @@ -2851,7 +2779,7 @@ PlayerPartyMonEntrance: ; 3d2b3 call AddBattleParticipant call InitBattleMon call ResetPlayerStatLevels - call SendOutPkmnText + call SendOutMonText call NewBattleMonStatus call BreakAttraction call SendOutPlayerMon @@ -2859,9 +2787,8 @@ PlayerPartyMonEntrance: ; 3d2b3 call LoadTileMapToTempTileMap call SetPlayerTurn jp SpikesDamage -; 3d2e0 -CheckMobileBattleError: ; 3d2e0 +CheckMobileBattleError: ld a, [wLinkMode] cp LINK_MOBILE jr nz, .not_mobile ; It's not a mobile battle @@ -2877,15 +2804,13 @@ CheckMobileBattleError: ; 3d2e0 .not_mobile xor a ret -; 3d2f1 -IsMobileBattle: ; 3d2f1 +IsMobileBattle: ld a, [wLinkMode] cp LINK_MOBILE ret -; 3d2f7 -SetUpBattlePartyMenu_NoLoop: ; 3d2f7 +SetUpBattlePartyMenu_NoLoop: call ClearBGPalettes SetUpBattlePartyMenu: ; switch to fullscreen menu? farcall LoadPartyMenuGFX @@ -2893,18 +2818,16 @@ SetUpBattlePartyMenu: ; switch to fullscreen menu? farcall InitPartyMenuBGPal7 farcall InitPartyMenuGFX ret -; 3d313 -JumpToPartyMenuAndPrintText: ; 3d313 +JumpToPartyMenuAndPrintText: farcall WritePartyMenuTilemap farcall PrintPartyMenuText call WaitBGMap call SetPalettes call DelayFrame ret -; 3d329 -SelectBattleMon: ; 3d329 +SelectBattleMon: call IsMobileBattle jr z, .mobile farcall PartyMenuSelect @@ -2913,9 +2836,8 @@ SelectBattleMon: ; 3d329 .mobile farcall Mobile_PartyMenuSelect ret -; 3d33c -PickPartyMonInBattle: ; 3d33c +PickPartyMonInBattle: .loop ld a, PARTYMENUACTION_SWITCH ; Which PKMN? ld [wPartyMenuActionText], a @@ -2926,15 +2848,14 @@ PickPartyMonInBattle: ; 3d33c jr z, .loop xor a ret -; 3d34f -SwitchMonAlreadyOut: ; 3d34f +SwitchMonAlreadyOut: ld hl, wCurBattleMon ld a, [wCurPartyMon] cp [hl] jr nz, .notout - ld hl, BattleText_PkmnIsAlreadyOut + ld hl, BattleText_MonIsAlreadyOut call StdBattleTextBox scf ret @@ -2942,9 +2863,8 @@ SwitchMonAlreadyOut: ; 3d34f .notout xor a ret -; 3d362 -ForcePickPartyMonInBattle: ; 3d362 +ForcePickPartyMonInBattle: ; Can't back out. .pick @@ -2957,9 +2877,8 @@ ForcePickPartyMonInBattle: ; 3d362 call PlaySFX call WaitSFX jr .pick -; 3d375 -PickSwitchMonInBattle: ; 3d375 +PickSwitchMonInBattle: .pick call PickPartyMonInBattle ret c @@ -2967,9 +2886,8 @@ PickSwitchMonInBattle: ; 3d375 jr c, .pick xor a ret -; 3d380 -ForcePickSwitchMonInBattle: ; 3d380 +ForcePickSwitchMonInBattle: ; Can't back out. .pick @@ -2981,9 +2899,8 @@ ForcePickSwitchMonInBattle: ; 3d380 xor a ret -; 3d38e -LostBattle: ; 3d38e +LostBattle: ld a, 1 ld [wBattleEnded], a @@ -3046,8 +2963,8 @@ LostBattle: ; 3d38e jr nz, .not_tied ld hl, TiedAgainstText ld a, [wBattleResult] - and $c0 - add 2 + and BATTLERESULT_BITMASK + add DRAW ld [wBattleResult], a jr .text @@ -3077,21 +2994,18 @@ LostBattle: ; 3d38e farcall Mobile_PrintOpponentBattleMessage scf ret -; 3d432 -EnemyMonFaintedAnimation: ; 3d432 +EnemyMonFaintedAnimation: hlcoord 12, 5 decoord 12, 6 jp MonFaintedAnimation -; 3d43b -PlayerMonFaintedAnimation: ; 3d43b +PlayerMonFaintedAnimation: hlcoord 1, 10 decoord 1, 11 jp MonFaintedAnimation -; 3d444 -MonFaintedAnimation: ; 3d444 +MonFaintedAnimation: ld a, [wcfbe] push af set 6, a @@ -3140,13 +3054,11 @@ MonFaintedAnimation: ; 3d444 pop af ld [wcfbe], a ret -; 3d488 .Spaces: db " @" -; 3d490 -SlideBattlePicOut: ; 3d490 +SlideBattlePicOut: ld [hMapObjectIndexBuffer], a ld c, a .loop @@ -3168,9 +3080,8 @@ SlideBattlePicOut: ; 3d490 dec c jr nz, .loop ret -; 3d4ae -.DoFrame: ; 3d4ae +.DoFrame: ld a, [hMapObjectIndexBuffer] ld c, a cp $8 @@ -3190,39 +3101,37 @@ SlideBattlePicOut: ; 3d490 dec c jr nz, .back ret -; 3d4c3 -ForceEnemySwitch: ; 3d4c3 +ForceEnemySwitch: call ResetEnemyBattleVars ld a, [wEnemySwitchMonIndex] dec a ld b, a - call LoadEnemyPkmnToSwitchTo + call LoadEnemyMonToSwitchTo call ClearEnemyMonBox call NewEnemyMonStatus call ResetEnemyStatLevels - call Function_SetEnemyPkmnAndSendOutAnimation + call Function_SetEnemyMonAndSendOutAnimation call BreakAttraction call ResetBattleParticipants ret -; 3d4e1 -EnemySwitch: ; 3d4e1 +EnemySwitch: call CheckWhetherToAskSwitch jr nc, EnemySwitch_SetMode ; Shift Mode call ResetEnemyBattleVars call CheckWhetherSwitchmonIsPredetermined jr c, .skip - call FindPkmnInOTPartyToSwitchIntoBattle + call FindMonInOTPartyToSwitchIntoBattle .skip - ; 'b' contains the PartyNr of the Pkmn the AI will switch to - call LoadEnemyPkmnToSwitchTo + ; 'b' contains the PartyNr of the mon the AI will switch to + call LoadEnemyMonToSwitchTo call OfferSwitch push af call ClearEnemyMonBox call Function_BattleTextEnemySentOut - call Function_SetEnemyPkmnAndSendOutAnimation + call Function_SetEnemyMonAndSendOutAnimation pop af ret c ; If we're here, then we're switching too @@ -3234,24 +3143,22 @@ EnemySwitch: ; 3d4e1 ld [wEnemyIsSwitching], a call LoadTileMapToTempTileMap jp PlayerSwitch -; 3d517 -EnemySwitch_SetMode: ; 3d517 +EnemySwitch_SetMode: call ResetEnemyBattleVars call CheckWhetherSwitchmonIsPredetermined jr c, .skip - call FindPkmnInOTPartyToSwitchIntoBattle + call FindMonInOTPartyToSwitchIntoBattle .skip - ; 'b' contains the PartyNr of the Pkmn the AI will switch to - call LoadEnemyPkmnToSwitchTo + ; 'b' contains the PartyNr of the mon the AI will switch to + call LoadEnemyMonToSwitchTo ld a, 1 ld [wEnemyIsSwitching], a call ClearEnemyMonBox call Function_BattleTextEnemySentOut - jp Function_SetEnemyPkmnAndSendOutAnimation -; 3d533 + jp Function_SetEnemyMonAndSendOutAnimation -CheckWhetherSwitchmonIsPredetermined: ; 3d533 +CheckWhetherSwitchmonIsPredetermined: ; returns carry if: ??? ld a, [wLinkMode] and a @@ -3283,9 +3190,8 @@ CheckWhetherSwitchmonIsPredetermined: ; 3d533 .return_carry scf ret -; 3d557 -ResetEnemyBattleVars: ; 3d557 +ResetEnemyBattleVars: ; and draw empty TextBox xor a ld [wLastPlayerCounterMove], a @@ -3300,14 +3206,13 @@ ResetEnemyBattleVars: ; 3d557 ld a, 8 call SlideBattlePicOut call EmptyBattleTextBox - jp LoadStandardMenuDataHeader -; 3d57a + jp LoadStandardMenuHeader -ResetBattleParticipants: ; 3d57a +ResetBattleParticipants: xor a ld [wBattleParticipantsNotFainted], a ld [wBattleParticipantsIncludingFainted], a -AddBattleParticipant: ; 3d581 +AddBattleParticipant: ld a, [wCurBattleMon] ld c, a ld hl, wBattleParticipantsNotFainted @@ -3317,10 +3222,9 @@ AddBattleParticipant: ; 3d581 pop bc ld hl, wBattleParticipantsIncludingFainted predef_jump SmallFarFlagAction -; 3d599 -FindPkmnInOTPartyToSwitchIntoBattle: ; 3d599 - ld b, $ff +FindMonInOTPartyToSwitchIntoBattle: + ld b, -1 ld a, $1 ld [wBuffer1], a ld [wBuffer2], a @@ -3347,16 +3251,15 @@ FindPkmnInOTPartyToSwitchIntoBattle: ; 3d599 pop bc jr z, .discourage call LookUpTheEffectivenessOfEveryMove - call IsThePlayerPkmnTypesEffectiveAgainstOTPkmn + call IsThePlayerMonTypesEffectiveAgainstOTMon jr .loop .discourage ld hl, wBuffer2 set 0, [hl] jr .loop -; 3d5d7 -LookUpTheEffectivenessOfEveryMove: ; 3d5d7 +LookUpTheEffectivenessOfEveryMove: push bc ld hl, wOTPartyMon1Moves ld a, b @@ -3392,11 +3295,10 @@ LookUpTheEffectivenessOfEveryMove: ; 3d5d7 ret .done ret -; 3d618 -IsThePlayerPkmnTypesEffectiveAgainstOTPkmn: ; 3d618 -; Calculates the effectiveness of the types of the PlayerPkmn -; against the OTPkmn +IsThePlayerMonTypesEffectiveAgainstOTMon: +; Calculates the effectiveness of the types of the PlayerMon +; against the OTMon push bc ld hl, wOTPartyCount ld a, b @@ -3441,9 +3343,8 @@ IsThePlayerPkmnTypesEffectiveAgainstOTPkmn: ; 3d618 .reset res 0, [hl] ret -; 3d672 -ScoreMonTypeMatchups: ; 3d672 +ScoreMonTypeMatchups: .loop1 ld hl, wBuffer1 sla [hl] @@ -3464,7 +3365,7 @@ ScoreMonTypeMatchups: ; 3d672 ld a, [wBuffer1] and a jr z, .okay2 - ld b, $ff + ld b, -1 ld c, a .loop3 inc b @@ -3473,7 +3374,7 @@ ScoreMonTypeMatchups: ; 3d672 jr .quit .okay2 - ld b, $ff + ld b, -1 ld a, [wBuffer2] ld c, a .loop4 @@ -3506,10 +3407,9 @@ ScoreMonTypeMatchups: ; 3d672 .quit ret -; 3d6ca -LoadEnemyPkmnToSwitchTo: ; 3d6ca - ; 'b' contains the PartyNr of the Pkmn the AI will switch to +LoadEnemyMonToSwitchTo: + ; 'b' contains the PartyNr of the mon the AI will switch to ld a, b ld [wCurPartyMon], a ld hl, wOTPartyMon1Level @@ -3545,9 +3445,8 @@ LoadEnemyPkmnToSwitchTo: ; 3d6ca ld a, [hl] ld [wEnemyHPAtTimeOfPlayerSwitch + 1], a ret -; 3d714 -CheckWhetherToAskSwitch: ; 3d714 +CheckWhetherToAskSwitch: ld a, [wBattleHasJustStarted] dec a jp z, .return_nc @@ -3575,13 +3474,12 @@ CheckWhetherToAskSwitch: ; 3d714 .return_nc and a ret -; 3d74b -OfferSwitch: ; 3d74b +OfferSwitch: ld a, [wCurPartyMon] push af callfar Battle_GetTrainerName - ld hl, BattleText_EnemyIsAboutToUseWillPlayerChangePkmn + ld hl, BattleText_EnemyIsAboutToUseWillPlayerChangeMon call StdBattleTextBox lb bc, 1, 7 call PlaceYesNoBox @@ -3616,9 +3514,8 @@ OfferSwitch: ; 3d74b ld [wCurPartyMon], a scf ret -; 3d7a0 -ClearEnemyMonBox: ; 3d7a0 +ClearEnemyMonBox: xor a ld [hBGMapMode], a call ExitMenu @@ -3628,23 +3525,21 @@ ClearEnemyMonBox: ; 3d7a0 call ClearBox call WaitBGMap jp FinishBattleAnim -; 3d7b8 -Function_BattleTextEnemySentOut: ; 3d7b8 +Function_BattleTextEnemySentOut: callfar Battle_GetTrainerName ld hl, BattleText_EnemySentOut call StdBattleTextBox jp WaitBGMap -; 3d7c7 -Function_SetEnemyPkmnAndSendOutAnimation: ; 3d7c7 +Function_SetEnemyMonAndSendOutAnimation: ld a, [wTempEnemyMonSpecies] ld [wCurPartySpecies], a ld [wCurSpecies], a call GetBaseData ld a, OTPARTYMON ld [wMonType], a - predef CopyPkmnToTempMon + predef CopyMonToTempMon call GetEnemyMonFrontpic xor a @@ -3684,9 +3579,8 @@ Function_SetEnemyPkmnAndSendOutAnimation: ; 3d7c7 ld a, $1 ld [hBGMapMode], a ret -; 3d834 -NewEnemyMonStatus: ; 3d834 +NewEnemyMonStatus: xor a ld [wLastPlayerCounterMove], a ld [wLastEnemyCounterMove], a @@ -3708,9 +3602,8 @@ endr ld hl, wPlayerSubStatus5 res SUBSTATUS_CANT_RUN, [hl] ret -; 3d867 -ResetEnemyStatLevels: ; 3d867 +ResetEnemyStatLevels: ld a, BASE_STAT_LEVEL ld b, NUM_LEVEL_STATS ld hl, wEnemyStatLevels @@ -3719,27 +3612,25 @@ ResetEnemyStatLevels: ; 3d867 dec b jr nz, .loop ret -; 3d873 -CheckPlayerPartyForFitPkmn: ; 3d873 -; Has the player any Pkmn in his Party that can fight? +CheckPlayerPartyForFitMon: +; Has the player any mon in his Party that can fight? ld a, [wPartyCount] ld e, a xor a ld hl, wPartyMon1HP - ld bc, wPartyMon2 - (wPartyMon1 + 1) + ld bc, PARTYMON_STRUCT_LENGTH - 1 .loop or [hl] - inc hl + inc hl ; + 1 or [hl] add hl, bc dec e jr nz, .loop ld d, a ret -; 3d887 -CheckIfCurPartyMonIsFitToFight: ; 3d887 +CheckIfCurPartyMonIsFitToFight: ld a, [wCurPartyMon] ld hl, wPartyMon1HP call GetPartyLocation @@ -3768,9 +3659,8 @@ CheckIfCurPartyMonIsFitToFight: ; 3d887 .finish_fail xor a ret -; 3d8b3 -TryToRunAwayFromBattle: ; 3d8b3 +TryToRunAwayFromBattle: ; Run away from battle, with or without item ld a, [wBattleType] cp BATTLETYPE_DEBUG @@ -3924,11 +3814,11 @@ TryToRunAwayFromBattle: ; 3d8b3 cp BATTLEACTION_FORFEIT ld a, DRAW jr z, .fled - dec a + dec a ; LOSE .fled ld b, a ld a, [wBattleResult] - and $c0 + and BATTLERESULT_BITMASK add b ld [wBattleResult], a call StopDangerSound @@ -3957,9 +3847,8 @@ TryToRunAwayFromBattle: ; 3d8b3 call LoadTileMapToTempTileMap scf ret -; 3da0d -InitBattleMon: ; 3da0d +InitBattleMon: ld a, MON_SPECIES call GetPartyParamLocation ld de, wBattleMonSpecies @@ -3998,23 +3887,21 @@ InitBattleMon: ; 3da0d call ApplyStatusEffectOnPlayerStats call BadgeStatBoosts ret -; 3da74 -BattleCheckPlayerShininess: ; 3da74 +BattleCheckPlayerShininess: call GetPartyMonDVs jr BattleCheckShininess -BattleCheckEnemyShininess: ; 3da79 +BattleCheckEnemyShininess: call GetEnemyMonDVs -BattleCheckShininess: ; 3da7c +BattleCheckShininess: ld b, h ld c, l callfar CheckShininess ret -; 3da85 -GetPartyMonDVs: ; 3da85 +GetPartyMonDVs: ld hl, wBattleMonDVs ld a, [wPlayerSubStatus5] bit SUBSTATUS_TRANSFORMED, a @@ -4022,9 +3909,8 @@ GetPartyMonDVs: ; 3da85 ld hl, wPartyMon1DVs ld a, [wCurBattleMon] jp GetPartyLocation -; 3da97 -GetEnemyMonDVs: ; 3da97 +GetEnemyMonDVs: ld hl, wEnemyMonDVs ld a, [wEnemySubStatus5] bit SUBSTATUS_TRANSFORMED, a @@ -4036,9 +3922,8 @@ GetEnemyMonDVs: ; 3da97 ld hl, wOTPartyMon1DVs ld a, [wCurOTMon] jp GetPartyLocation -; 3dab1 -ResetPlayerStatLevels: ; 3dab1 +ResetPlayerStatLevels: ld a, BASE_STAT_LEVEL ld b, NUM_LEVEL_STATS ld hl, wPlayerStatLevels @@ -4047,9 +3932,8 @@ ResetPlayerStatLevels: ; 3dab1 dec b jr nz, .loop ret -; 3dabd -InitEnemyMon: ; 3dabd +InitEnemyMon: ld a, [wCurPartyMon] ld hl, wOTPartyMon1Species call GetPartyLocation @@ -4100,9 +3984,8 @@ InitEnemyMon: ; 3dabd ld a, [wCurPartyMon] ld [wCurOTMon], a ret -; 3db32 -SwitchPlayerMon: ; 3db32 +SwitchPlayerMon: call ClearSprites ld a, [wCurBattleMon] ld [wLastPlayerMon], a @@ -4120,9 +4003,8 @@ SwitchPlayerMon: ; 3db32 ld a, [hli] or [hl] ret -; 3db5f -SendOutPlayerMon: ; 3db5f +SendOutPlayerMon: ld hl, wBattleMonDVs predef GetUnownLetter hlcoord 1, 5 @@ -4176,9 +4058,8 @@ SendOutPlayerMon: ; 3db5f ld a, $1 ld [hBGMapMode], a ret -; 3dbde -NewBattleMonStatus: ; 3dbde +NewBattleMonStatus: xor a ld [wLastPlayerCounterMove], a ld [wLastEnemyCounterMove], a @@ -4205,17 +4086,15 @@ endr ld hl, wEnemySubStatus5 res SUBSTATUS_CANT_RUN, [hl] ret -; 3dc18 -BreakAttraction: ; 3dc18 +BreakAttraction: ld hl, wPlayerSubStatus1 res SUBSTATUS_IN_LOVE, [hl] ld hl, wEnemySubStatus1 res SUBSTATUS_IN_LOVE, [hl] ret -; 3dc23 -SpikesDamage: ; 3dc23 +SpikesDamage: ld hl, wPlayerScreens ld de, wBattleMonType ld bc, UpdatePlayerHUD @@ -4254,9 +4133,8 @@ SpikesDamage: ; 3dc23 .hl jp hl -; 3dc5b -PursuitSwitch: ; 3dc5b +PursuitSwitch: ld a, BATTLE_VARS_MOVE call GetBattleVar ld b, a @@ -4308,7 +4186,7 @@ PursuitSwitch: ; 3dc5b ld b, RESET_FLAG predef SmallFarFlagAction call PlayerMonFaintedAnimation - ld hl, BattleText_PkmnFainted + ld hl, BattleText_MonFainted jr .done_fainted .check_enemy_fainted @@ -4324,7 +4202,7 @@ PursuitSwitch: ; 3dc5b call PlaySFX call WaitSFX call EnemyMonFaintedAnimation - ld hl, BattleText_EnemyPkmnFainted + ld hl, BattleText_EnemyMonFainted .done_fainted call StdBattleTextBox @@ -4334,9 +4212,8 @@ PursuitSwitch: ; 3dc5b .done and a ret -; 3dce6 -RecallPlayerMon: ; 3dce6 +RecallPlayerMon: ld a, [hBattleTurn] push af xor a @@ -4347,9 +4224,8 @@ RecallPlayerMon: ; 3dce6 pop af ld [hBattleTurn], a ret -; 3dcf9 -HandleHealingItems: ; 3dcf9 +HandleHealingItems: ld a, [hSerialConnectionStatus] cp USING_EXTERNAL_CLOCK jr z, .player_1 @@ -4371,9 +4247,8 @@ HandleHealingItems: ; 3dcf9 call HandleHPHealingItem call UseHeldStatusHealingItem jp UseConfusionHealingItem -; 3dd2f -HandleHPHealingItem: ; 3dd2f +HandleHPHealingItem: callfar GetOpponentItem ld a, b cp HELD_BERRY @@ -4427,7 +4302,7 @@ HandleHPHealingItem: ; 3dd2f ld c, a dec de ld a, [de] - adc $0 + adc 0 ld [wBuffer6], a ld b, a ld a, [hld] @@ -4465,9 +4340,8 @@ UseOpponentItem: callfar ConsumeHeldItem ld hl, RecoveredUsingText jp StdBattleTextBox -; 3ddc8 -ItemRecoveryAnim: ; 3ddc8 +ItemRecoveryAnim: push hl push de push bc @@ -4484,11 +4358,10 @@ ItemRecoveryAnim: ; 3ddc8 pop de pop hl ret -; 3dde9 -UseHeldStatusHealingItem: ; 3dde9 +UseHeldStatusHealingItem: callfar GetOpponentItem - ld hl, .Statuses + ld hl, HeldStatusHealingEffects .loop ld a, [hli] cp $ff @@ -4539,19 +4412,10 @@ UseHeldStatusHealingItem: ; 3dde9 ld a, $1 and a ret -; 3de44 -.Statuses: ; 3de44 - db HELD_HEAL_POISON, 1 << PSN - db HELD_HEAL_FREEZE, 1 << FRZ - db HELD_HEAL_BURN, 1 << BRN - db HELD_HEAL_SLEEP, SLP - db HELD_HEAL_PARALYZE, 1 << PAR - db HELD_HEAL_STATUS, ALL_STATUS - db -1 ; end -; 3de51 +INCLUDE "data/battle/held_heal_status.asm" -UseConfusionHealingItem: ; 3de51 +UseConfusionHealingItem: ld a, BATTLE_VARS_SUBSTATUS3_OPP call GetBattleVar bit SUBSTATUS_CONFUSED, a @@ -4591,9 +4455,8 @@ UseConfusionHealingItem: ; 3de51 ld [bc], a ld [hl], a ret -; 3de97 -HandleStatBoostingHeldItems: ; 3de97 +HandleStatBoostingHeldItems: ; The effects handled here are not used in-game. ld a, [hSerialConnectionStatus] cp USING_EXTERNAL_CLOCK @@ -4604,18 +4467,16 @@ HandleStatBoostingHeldItems: ; 3de97 .player_1 call .DoEnemy jp .DoPlayer -; 3dea9 -.DoPlayer: ; 3dea9 +.DoPlayer: call GetPartymonItem ld a, $0 jp .HandleItem -; 3deb1 -.DoEnemy: ; 3deb1 +.DoEnemy: call GetOTPartymonItem ld a, $1 -.HandleItem: ; 3deb6 +.HandleItem: ld [hBattleTurn], a ld d, h ld e, l @@ -4624,10 +4485,10 @@ HandleStatBoostingHeldItems: ; 3de97 ld a, [bc] ld b, a callfar GetItemHeldEffect - ld hl, .StatUpItems + ld hl, HeldStatUpItems .loop ld a, [hli] - cp $ff + cp -1 jr z, .finish inc hl inc hl @@ -4662,36 +4523,24 @@ HandleStatBoostingHeldItems: ; 3de97 pop bc pop de ret -; 3defc -.StatUpItems: - dbw HELD_ATTACK_UP, BattleCommand_AttackUp - dbw HELD_DEFENSE_UP, BattleCommand_DefenseUp - dbw HELD_SPEED_UP, BattleCommand_SpeedUp - dbw HELD_SP_ATTACK_UP, BattleCommand_SpecialAttackUp - dbw HELD_SP_DEFENSE_UP, BattleCommand_SpecialDefenseUp - dbw HELD_ACCURACY_UP, BattleCommand_AccuracyUp - dbw HELD_EVASION_UP, BattleCommand_EvasionUp - db -1 ; end -; 3df12 +INCLUDE "data/battle/held_stat_up.asm" -GetPartymonItem: ; 3df12 +GetPartymonItem: ld hl, wPartyMon1Item ld a, [wCurBattleMon] call GetPartyLocation ld bc, wBattleMonItem ret -; 3df1f -GetOTPartymonItem: ; 3df1f +GetOTPartymonItem: ld hl, wOTPartyMon1Item ld a, [wCurOTMon] call GetPartyLocation ld bc, wEnemyMonItem ret -; 3df2c -UpdateBattleHUDs: ; 3df2c +UpdateBattleHUDs: push hl push de push bc @@ -4706,9 +4555,8 @@ UpdateBattleHUDs: ; 3df2c pop de pop hl ret -; 3df48 -UpdatePlayerHUD:: ; 3df48 +UpdatePlayerHUD:: push hl push de push bc @@ -4719,9 +4567,8 @@ UpdatePlayerHUD:: ; 3df48 pop de pop hl ret -; 3df58 -DrawPlayerHUD: ; 3df58 +DrawPlayerHUD: xor a ld [hBGMapMode], a @@ -4757,14 +4604,12 @@ DrawPlayerHUD: ; 3df58 call FillInExpBar pop de ret -; 3df98 -UpdatePlayerHPPal: ; 3df98 +UpdatePlayerHPPal: ld hl, wPlayerHPPal jp UpdateHPPal -; 3df9e -CheckDanger: ; 3df9e +CheckDanger: ld hl, wBattleMonHP ld a, [hli] or [hl] @@ -4787,9 +4632,8 @@ CheckDanger: ; 3df9e .done ret -; 3dfbf -PrintPlayerHUD: ; 3dfbf +PrintPlayerHUD: ld de, wBattleMonNick hlcoord 10, 7 call ret_3e138 @@ -4850,9 +4694,8 @@ PrintPlayerHUD: ; 3dfbf ld a, [wBattleMonLevel] ld [wTempMonLevel], a jp PrintLevel -; 3e036 -UpdateEnemyHUD:: ; 3e036 +UpdateEnemyHUD:: push hl push de push bc @@ -4862,9 +4705,8 @@ UpdateEnemyHUD:: ; 3e036 pop de pop hl ret -; 3e043 -DrawEnemyHUD: ; 3e043 +DrawEnemyHUD: xor a ld [hBGMapMode], a @@ -4995,28 +4837,24 @@ DrawEnemyHUD: ; 3e043 ld b, 0 call DrawBattleHPBar ret -; 3e127 -UpdateEnemyHPPal: ; 3e127 +UpdateEnemyHPPal: ld hl, wEnemyHPPal call UpdateHPPal ret -; 3e12e -UpdateHPPal: ; 3e12e +UpdateHPPal: ld b, [hl] call SetHPPal ld a, [hl] cp b ret z jp FinishBattleAnim -; 3e138 -ret_3e138: ; 3e138 +ret_3e138: ret -; 3e139 -BattleMenu: ; 3e139 +BattleMenu: xor a ld [hBGMapMode], a call LoadTempTileMapToTileMap @@ -5062,17 +4900,15 @@ BattleMenu: ; 3e139 cp $4 jp z, BattleMenu_Run jr .loop -; 3e192 -BattleMenu_Fight: ; 3e192 +BattleMenu_Fight: xor a ld [wNumFleeAttempts], a call Call_LoadTempTileMapToTileMap and a ret -; 3e19b -LoadBattleMenu2: ; 3e19b +LoadBattleMenu2: call IsMobileBattle jr z, .mobile @@ -5096,9 +4932,8 @@ LoadBattleMenu2: ; 3e19b .error scf ret -; 3e1c7 -BattleMenu_Pack: ; 3e1c7 +BattleMenu_Pack: ld a, [wLinkMode] and a jp nz, .ItemsCantBeUsed @@ -5107,7 +4942,7 @@ BattleMenu_Pack: ; 3e1c7 and a jp nz, .ItemsCantBeUsed - call LoadStandardMenuDataHeader + call LoadStandardMenuHeader ld a, [wBattleType] cp BATTLETYPE_TUTORIAL @@ -5148,15 +4983,13 @@ BattleMenu_Pack: ; 3e1c7 call FinishBattleAnim call LoadTileMapToTempTileMap jp BattleMenu -; 3e22b -.ItemsCantBeUsed: ; 3e22b +.ItemsCantBeUsed: ld hl, BattleText_ItemsCantBeUsedHere call StdBattleTextBox jp BattleMenu -; 3e234 -.UseItem: ; 3e234 +.UseItem: ld a, [wWildMon] and a jr nz, .run @@ -5193,19 +5026,18 @@ BattleMenu_Pack: ; 3e1c7 xor a ld [wWildMon], a ld a, [wBattleResult] - and $c0 - ld [wBattleResult], a + and BATTLERESULT_BITMASK + ld [wBattleResult], a ; WIN call ClearWindowData call SetPalettes scf ret -; 3e28d -BattleMenu_PKMN: ; 3e28d - call LoadStandardMenuDataHeader +BattleMenu_PKMN: + call LoadStandardMenuHeader BattleMenuPKMN_ReturnFromStats: call ExitMenu - call LoadStandardMenuDataHeader + call LoadStandardMenuHeader call ClearBGPalettes BattleMenuPKMN_Loop: call SetUpBattlePartyMenu @@ -5249,9 +5081,8 @@ BattleMenuPKMN_Loop: call GetMemSGBLayout call SetPalettes jp BattleMenu -; 3e2f5 -.GetMenu: ; 3e2f5 +.GetMenu: call IsMobileBattle jr z, .mobile farcall BattleMonMenu @@ -5260,9 +5091,8 @@ BattleMenuPKMN_Loop: .mobile farcall MobileBattleMonMenu ret -; 3e308 -Battle_StatsScreen: ; 3e308 +Battle_StatsScreen: call DisableLCD ld hl, vTiles2 tile $31 @@ -5298,15 +5128,14 @@ Battle_StatsScreen: ; 3e308 call EnableLCD ret -; 3e358 -TryPlayerSwitch: ; 3e358 +TryPlayerSwitch: ld a, [wCurBattleMon] ld d, a ld a, [wCurPartyMon] cp d jr nz, .check_trapped - ld hl, BattleText_PkmnIsAlreadyOut + ld hl, BattleText_MonIsAlreadyOut call StdBattleTextBox jp BattleMenuPKMN_Loop @@ -5319,7 +5148,7 @@ TryPlayerSwitch: ; 3e358 jr z, .try_switch .trapped - ld hl, BattleText_PkmnCantBeRecalled + ld hl, BattleText_MonCantBeRecalled call StdBattleTextBox jp BattleMenuPKMN_Loop @@ -5339,13 +5168,13 @@ TryPlayerSwitch: ; 3e358 call SetPalettes ld a, [wCurPartyMon] ld [wCurBattleMon], a -PlayerSwitch: ; 3e3ad +PlayerSwitch: ld a, 1 ld [wPlayerIsSwitching], a ld a, [wLinkMode] and a jr z, .not_linked - call LoadStandardMenuDataHeader + call LoadStandardMenuHeader call LinkBattleSendReceiveAction call CloseWindow @@ -5387,16 +5216,14 @@ PlayerSwitch: ; 3e3ad call BattleMonEntrance and a ret -; 3e3ff -EnemyMonEntrance: ; 3e3ff +EnemyMonEntrance: callfar AI_Switch call SetEnemyTurn jp SpikesDamage -; 3e40b -BattleMonEntrance: ; 3e40b - call WithdrawPkmnText +BattleMonEntrance: + call WithdrawMonText ld c, 50 call DelayFrames @@ -5419,7 +5246,7 @@ BattleMonEntrance: ; 3e40b call AddBattleParticipant call InitBattleMon call ResetPlayerStatLevels - call SendOutPkmnText + call SendOutMonText call NewBattleMonStatus call BreakAttraction call SendOutPlayerMon @@ -5430,9 +5257,8 @@ BattleMonEntrance: ; 3e40b ld a, $2 ld [wMenuCursorY], a ret -; 3e459 -PassedBattleMonEntrance: ; 3e459 +PassedBattleMonEntrance: ld c, 50 call DelayFrames @@ -5452,9 +5278,8 @@ PassedBattleMonEntrance: ; 3e459 call LoadTileMapToTempTileMap call SetPlayerTurn jp SpikesDamage -; 3e489 -BattleMenu_Run: ; 3e489 +BattleMenu_Run: call Call_LoadTempTileMapToTileMap ld a, $3 ld [wMenuCursorY], a @@ -5468,9 +5293,8 @@ BattleMenu_Run: ; 3e489 and a ret nz jp BattleMenu -; 3e4a8 -CheckAmuletCoin: ; 3e4a8 +CheckAmuletCoin: ld a, [wBattleMonItem] ld b, a callfar GetItemHeldEffect @@ -5480,9 +5304,8 @@ CheckAmuletCoin: ; 3e4a8 ld a, 1 ld [wAmuletCoin], a ret -; 3e4bc -MoveSelectionScreen: ; 3e4bc +MoveSelectionScreen: call IsMobileBattle jr nz, .not_mobile farcall MobileMoveSelectionScreen @@ -5684,11 +5507,9 @@ MoveSelectionScreen: ; 3e4bc call StdBattleTextBox call Call_LoadTempTileMapToTileMap jp MoveSelectionScreen -; 3e61c -.string_3e61c ; 3e61c +.string_3e61c db "@" -; 3e61d .pressed_up ld a, [wMenuCursorY] @@ -5698,9 +5519,8 @@ MoveSelectionScreen: ; 3e4bc inc a ld [wMenuCursorY], a jp .menu_loop -; 3e62e -.pressed_down ; 3e62e +.pressed_down ld a, [wMenuCursorY] ld b, a ld a, [wNumMoves] @@ -5711,9 +5531,8 @@ MoveSelectionScreen: ; 3e4bc ld a, $1 ld [wMenuCursorY], a jp .menu_loop -; 3e643 -.pressed_select ; 3e643 +.pressed_select ld a, [wMoveSwapBuffer] and a jr z, .start_swap @@ -5796,9 +5615,8 @@ MoveSelectionScreen: ; 3e4bc ld a, [wMenuCursorY] ld [wMoveSwapBuffer], a jp MoveSelectionScreen -; 3e6c8 -MoveInfoBox: ; 3e6c8 +MoveInfoBox: xor a ld [hBGMapMode], a @@ -5868,15 +5686,13 @@ MoveInfoBox: ; 3e6c8 .done ret -; 3e74f .Disabled: db "Disabled!@" .Type: db "TYPE/@" -; 3e75f -.PrintPP: ; 3e75f +.PrintPP: hlcoord 5, 11 ld a, [wLinkMode] ; What's the point of this check? cp LINK_MOBILE @@ -5896,9 +5712,8 @@ MoveInfoBox: ; 3e6c8 lb bc, 1, 2 call PrintNum ret -; 3e786 -CheckPlayerHasUsableMoves: ; 3e786 +CheckPlayerHasUsableMoves: ld a, STRUGGLE ld [wCurPlayerMove], a ld a, [wPlayerDisableCount] @@ -5938,15 +5753,14 @@ CheckPlayerHasUsableMoves: ; 3e786 ret nz .force_struggle - ld hl, BattleText_PkmnHasNoMovesLeft + ld hl, BattleText_MonHasNoMovesLeft call StdBattleTextBox ld c, 60 call DelayFrames xor a ret -; 3e7c1 -ParseEnemyAction: ; 3e7c1 +ParseEnemyAction: ld a, [wEnemyIsSwitching] and a ret nz @@ -6094,9 +5908,8 @@ ParseEnemyAction: ; 3e7c1 .struggle ld a, STRUGGLE jr .finish -; 3e8c1 -ResetVarsForSubstatusRage: ; 3e8c1 +ResetVarsForSubstatusRage: xor a ld [wEnemyFuryCutterCount], a ld [wEnemyProtectCount], a @@ -6104,9 +5917,8 @@ ResetVarsForSubstatusRage: ; 3e8c1 ld hl, wEnemySubStatus4 res SUBSTATUS_RAGE, [hl] ret -; 3e8d1 -CheckEnemyLockedIn: ; 3e8d1 +CheckEnemyLockedIn: ld a, [wEnemySubStatus4] and 1 << SUBSTATUS_RECHARGE ret nz @@ -6119,14 +5931,12 @@ CheckEnemyLockedIn: ; 3e8d1 ld hl, wEnemySubStatus1 bit SUBSTATUS_ROLLOUT, [hl] ret -; 3e8e4 -LinkBattleSendReceiveAction: ; 3e8e4 +LinkBattleSendReceiveAction: farcall _LinkBattleSendReceiveAction ret -; 3e8eb -LoadEnemyMon: ; 3e8eb +LoadEnemyMon: ; Initialize enemy monster parameters ; To do this we pull the species from wTempEnemyMonSpecies @@ -6190,7 +6000,7 @@ LoadEnemyMon: ; 3e8eb ; 25% chance of getting an item call BattleRandom - cp 1 + (75 percent) + cp 75 percent + 1 ld a, NO_ITEM jr c, .UpdateItem @@ -6226,7 +6036,6 @@ LoadEnemyMon: ; 3e8eb jp .Happiness .InitDVs: - ; Trainer DVs ; All trainers have preset DVs, determined by class @@ -6408,7 +6217,7 @@ LoadEnemyMon: ; 3e8eb ld de, wEnemyMonMaxHP ld b, FALSE ld hl, wEnemyMonDVs - (MON_DVS - MON_STAT_EXP + 1) ; wLinkBattleRNs + 7 ; ? - predef CalcPkmnStats + predef CalcMonStats ; If we're in a trainer battle, ; get the rest of the parameters from the party struct @@ -6464,7 +6273,7 @@ LoadEnemyMon: ; 3e8eb .InitRoamHP: ; HP only uses the lo byte in the RoamMon struct since -; Raikou/Entei/Suicune will have < 256 hp at level 40 +; Raikou and Entei will have < 256 hp at level 40 ld a, [wEnemyMonHP + 1] ld [hl], a jr .Moves @@ -6595,9 +6404,8 @@ LoadEnemyMon: ; 3e8eb call CopyBytes ret -; 3eb38 -CheckSleepingTreeMon: ; 3eb38 +CheckSleepingTreeMon: ; Return carry if species is in the list ; for the current time of day @@ -6628,7 +6436,7 @@ CheckSleepingTreeMon: ; 3eb38 INCLUDE "data/wild/treemons_asleep.asm" -CheckUnownLetter: ; 3eb75 +CheckUnownLetter: ; Return carry if the Unown letter hasn't been unlocked yet ld a, [wUnlockedUnowns] @@ -6642,7 +6450,7 @@ CheckUnownLetter: ; 3eb75 jr nc, .next ; Is our letter in the set? - ld hl, .LetterSets + ld hl, UnlockedUnownLetterSets add hl, de ld a, [hli] ld h, [hl] @@ -6663,7 +6471,7 @@ CheckUnownLetter: ; 3eb75 inc e inc e ld a, e - cp .Set1 - .LetterSets + cp UnlockedUnownLetterSets.End - UnlockedUnownLetterSets jr c, .loop ; Hasn't been unlocked, or the letter is invalid @@ -6675,28 +6483,9 @@ CheckUnownLetter: ; 3eb75 and a ret -.LetterSets: - dw .Set1 - dw .Set2 - dw .Set3 - dw .Set4 - -.Set1: - ; A B C D E F G H I J K - db 01, 02, 03, 04, 05, 06, 07, 08, 09, 10, 11, $ff -.Set2: - ; L M N O P Q R - db 12, 13, 14, 15, 16, 17, 18, $ff -.Set3: - ; S T U V W - db 19, 20, 21, 22, 23, $ff -.Set4: - ; X Y Z - db 24, 25, 26, $ff - -; 3ebc7 +INCLUDE "data/wild/unlocked_unowns.asm" -Unreferenced_SwapBattlerLevels: ; 3ebc7 +Unreferenced_SwapBattlerLevels: push bc ld a, [wBattleMonLevel] ld b, a @@ -6706,9 +6495,8 @@ Unreferenced_SwapBattlerLevels: ; 3ebc7 ld [wEnemyMonLevel], a pop bc ret -; 3ebd8 -BattleWinSlideInEnemyTrainerFrontpic: ; 3ebd8 +BattleWinSlideInEnemyTrainerFrontpic: xor a ld [wTempEnemyMonSpecies], a call FinishBattleAnim @@ -6748,9 +6536,8 @@ BattleWinSlideInEnemyTrainerFrontpic: ; 3ebd8 pop bc dec hl jr .outer_loop -; 3ec1a -.CopyColumn: ; 3ec1a +.CopyColumn: push hl push de push bc @@ -6768,24 +6555,20 @@ BattleWinSlideInEnemyTrainerFrontpic: ; 3ebd8 pop de pop hl ret -; 3ec2c -ApplyStatusEffectOnPlayerStats: ; 3ec2c +ApplyStatusEffectOnPlayerStats: ld a, 1 jr ApplyStatusEffectOnStats -; 3ec30 -ApplyStatusEffectOnEnemyStats: ; 3ec30 +ApplyStatusEffectOnEnemyStats: xor a -; 3ec31 -ApplyStatusEffectOnStats: ; 3ec31 +ApplyStatusEffectOnStats: ld [hBattleTurn], a call ApplyPrzEffectOnSpeed jp ApplyBrnEffectOnAttack -; 3ec39 -ApplyPrzEffectOnSpeed: ; 3ec39 +ApplyPrzEffectOnSpeed: ld a, [hBattleTurn] and a jr z, .enemy @@ -6829,9 +6612,8 @@ ApplyPrzEffectOnSpeed: ; 3ec39 .enemy_ok ld [hl], b ret -; 3ec76 -ApplyBrnEffectOnAttack: ; 3ec76 +ApplyBrnEffectOnAttack: ld a, [hBattleTurn] and a jr z, .enemy @@ -6871,9 +6653,8 @@ ApplyBrnEffectOnAttack: ; 3ec76 .enemy_ok ld [hl], b ret -; 3ecab -ApplyStatLevelMultiplierOnAllStats: ; 3ecab +ApplyStatLevelMultiplierOnAllStats: ; Apply StatLevelMultipliers on all 5 Stats ld c, 0 .stat_loop @@ -6883,9 +6664,8 @@ ApplyStatLevelMultiplierOnAllStats: ; 3ecab cp 5 jr nz, .stat_loop ret -; 3ecb7 -ApplyStatLevelMultiplier: ; 3ecb7 +ApplyStatLevelMultiplier: push bc push bc ld a, [wd265] @@ -6920,7 +6700,7 @@ ApplyStatLevelMultiplier: ; 3ecb7 .okay2 pop bc push hl - ld hl, .StatLevelMultipliers + ld hl, StatLevelMultipliers_Applied dec b sla b ld c, b @@ -6967,28 +6747,10 @@ ApplyStatLevelMultiplier: ; 3ecb7 .okay4 pop bc ret -; 3ed2b -.StatLevelMultipliers: -; / - db 25, 100 ; 25% - db 28, 100 ; 28% - db 33, 100 ; 33% - db 40, 100 ; 40% - db 50, 100 ; 50% - db 66, 100 ; 66% +INCLUDE "data/battle/stat_multipliers_2.asm" - db 1, 1 ; 100% - - db 15, 10 ; 150% - db 2, 1 ; 200% - db 25, 10 ; 250% - db 3, 1 ; 300% - db 35, 10 ; 350% - db 4, 1 ; 400% -; 3ed45 - -BadgeStatBoosts: ; 3ed45 +BadgeStatBoosts: ; Raise the stats of the battle mon in wBattleMon ; depending on which badges have been obtained. @@ -7045,9 +6807,8 @@ BadgeStatBoosts: ; 3ed45 srl a call c, BoostStat ret -; 3ed7c -BoostStat: ; 3ed7c +BoostStat: ; Raise stat at hl by 1/8. ld a, [hli] @@ -7077,17 +6838,14 @@ BoostStat: ; 3ed7c ld a, LOW(MAX_STAT_VALUE) ld [hld], a ret -; 3ed9f -_LoadBattleFontsHPBar: ; 3ed9f +_LoadBattleFontsHPBar: callfar LoadBattleFontsHPBar ret -; 3eda6 -_LoadHPBar: ; 3eda6 +_LoadHPBar: callfar LoadHPBar ret -; 3edad Unreferenced_LoadHPExpBarGFX: ld de, EnemyHPBarBorderGFX @@ -7102,16 +6860,14 @@ Unreferenced_LoadHPExpBarGFX: ld hl, vTiles2 tile $55 lb bc, BANK(ExpBarGFX), 8 jp Get2bpp -; 3edd1 -EmptyBattleTextBox: ; 3edd1 +EmptyBattleTextBox: ld hl, .empty jp BattleTextBox .empty db "@" -; 3edd8 -_BattleRandom:: ; 3edd8 +_BattleRandom:: ; If the normal RNG is used in a link battle it'll desync. ; To circumvent this a shared PRNG is used instead. @@ -7178,25 +6934,22 @@ _BattleRandom:: ; 3edd8 pop bc pop hl ret -; 3ee0f -Call_PlayBattleAnim_OnlyIfVisible: ; 3ee0f +Call_PlayBattleAnim_OnlyIfVisible: ld a, BATTLE_VARS_SUBSTATUS3 call GetBattleVar and 1 << SUBSTATUS_FLYING | 1 << SUBSTATUS_UNDERGROUND ret nz -; 3ee17 -Call_PlayBattleAnim: ; 3ee17 +Call_PlayBattleAnim: ld a, e ld [wFXAnimID], a ld a, d ld [wFXAnimID + 1], a call WaitBGMap predef_jump PlayBattleAnim -; 3ee27 -FinishBattleAnim: ; 3ee27 +FinishBattleAnim: push af push bc push de @@ -7210,9 +6963,8 @@ FinishBattleAnim: ; 3ee27 pop bc pop af ret -; 3ee3b -GiveExperiencePoints: ; 3ee3b +GiveExperiencePoints: ; Give experience. ; Don't give experience if linked or in the Battle Tower. ld a, [wLinkMode] @@ -7240,7 +6992,7 @@ GiveExperiencePoints: ; 3ee3b ld a, [wCurPartyMon] ld c, a ld b, CHECK_FLAG - ld d, $0 + ld d, FALSE predef SmallFarFlagAction ld a, c and a @@ -7254,7 +7006,7 @@ GiveExperiencePoints: ; 3ee3b ld e, l ld hl, wEnemyMonBaseStats - 1 push bc - ld c, $5 + ld c, NUM_EXP_STATS .loop1 inc hl ld a, [de] @@ -7350,7 +7102,7 @@ GiveExperiencePoints: ; 3ee3b ld a, [wCurPartyMon] ld hl, wPartyMonNicknames call GetNick - ld hl, Text_PkmnGainedExpPoint + ld hl, Text_MonGainedExpPoint call BattleTextBox ld a, [wStringBuffer2 + 1] ld [hQuotient + 2], a @@ -7419,7 +7171,7 @@ GiveExperiencePoints: ; 3ee3b .not_max_exp xor a ; PARTYMON ld [wMonType], a - predef CopyPkmnToTempMon + predef CopyMonToTempMon callfar CalcLevel pop bc ld hl, MON_LEVEL @@ -7456,7 +7208,7 @@ GiveExperiencePoints: ; 3ee3b add hl, bc push bc ld b, TRUE - predef CalcPkmnStats + predef CalcMonStats pop bc pop de ld hl, MON_MAXHP + 1 @@ -7532,15 +7284,15 @@ GiveExperiencePoints: ; 3ee3b .skip_animation2 xor a ; PARTYMON ld [wMonType], a - predef CopyPkmnToTempMon + predef CopyMonToTempMon hlcoord 9, 0 - ld b, $a - ld c, $9 + ld b, 10 + ld c, 9 call TextBox hlcoord 11, 1 ld bc, 4 predef PrintTempMonStats - ld c, $1e + ld c, 30 call DelayFrames call WaitPressAorB_BlinkCursor call Call_LoadTempTileMapToTileMap @@ -7590,7 +7342,6 @@ GiveExperiencePoints: ; 3ee3b .done jp ResetBattleParticipants -; 3f0d4 .EvenlyDivideExpAmongParticipants: ; count number of battle participants @@ -7625,9 +7376,8 @@ GiveExperiencePoints: ; 3ee3b dec c jr nz, .count_loop2 ret -; 3f106 -BoostExp: ; 3f106 +BoostExp: ; Multiply experience by 1.5x push bc ; load experience value @@ -7646,9 +7396,8 @@ BoostExp: ; 3f106 ld [hProduct + 2], a pop bc ret -; 3f11b -Text_PkmnGainedExpPoint: ; 3f11b +Text_MonGainedExpPoint: text_jump Text_Gained start_asm ld hl, TextJump_StringBuffer2ExpPoints @@ -7658,19 +7407,16 @@ Text_PkmnGainedExpPoint: ; 3f11b ld hl, TextJump_ABoostedStringBuffer2ExpPoints ret -; 3f12c -TextJump_ABoostedStringBuffer2ExpPoints: ; 3f12c +TextJump_ABoostedStringBuffer2ExpPoints: text_jump Text_ABoostedStringBuffer2ExpPoints db "@" -; 3f131 -TextJump_StringBuffer2ExpPoints: ; 3f131 +TextJump_StringBuffer2ExpPoints: text_jump Text_StringBuffer2ExpPoints db "@" -; 3f136 -AnimateExpBar: ; 3f136 +AnimateExpBar: push bc ld hl, wCurPartyMon @@ -7692,7 +7438,7 @@ AnimateExpBar: ; 3f136 ld [wd002], a xor a ; PARTYMON ld [wMonType], a - predef CopyPkmnToTempMon + predef CopyMonToTempMon ld a, [wTempMonLevel] ld b, a ld e, a @@ -7856,23 +7602,23 @@ AnimateExpBar: ; 3f136 ld [hBGMapMode], a ret -SendOutPkmnText: ; 3f26d +SendOutMonText: ld a, [wLinkMode] and a jr z, .not_linked - ld hl, JumpText_GoPkmn ; If we're in a LinkBattle print just "Go <PlayerMon>" + ld hl, JumpText_GoMon ; If we're in a LinkBattle print just "Go <PlayerMon>" ld a, [wBattleHasJustStarted] ; unless this (unidentified) variable is set and a jr nz, .skip_to_textbox .not_linked -; Depending on the HP of the enemy Pkmn, the game prints a different text +; Depending on the HP of the enemy mon, the game prints a different text ld hl, wEnemyMonHP ld a, [hli] or [hl] - ld hl, JumpText_GoPkmn + ld hl, JumpText_GoMon jr z, .skip_to_textbox ; compute enemy helth remaining as a percentage @@ -7901,62 +7647,56 @@ SendOutPkmnText: ; 3f26d call Divide ld a, [hQuotient + 2] - ld hl, JumpText_GoPkmn + ld hl, JumpText_GoMon cp 70 jr nc, .skip_to_textbox - ld hl, JumpText_DoItPkmn + ld hl, JumpText_DoItMon cp 40 jr nc, .skip_to_textbox - ld hl, JumpText_GoForItPkmn + ld hl, JumpText_GoForItMon cp 10 jr nc, .skip_to_textbox - ld hl, JumpText_YourFoesWeakGetmPkmn + ld hl, JumpText_YourFoesWeakGetmMon .skip_to_textbox jp BattleTextBox -; 3f2d1 -JumpText_GoPkmn: ; 3f2d1 - text_jump Text_GoPkmn +JumpText_GoMon: + text_jump Text_GoMon start_asm jr Function_TextJump_BattleMonNick01 -; 3f2d6 -JumpText_DoItPkmn: ; 3f2d8 - text_jump Text_DoItPkmn +JumpText_DoItMon: + text_jump Text_DoItMon start_asm jr Function_TextJump_BattleMonNick01 -; 3f2dd -JumpText_GoForItPkmn: ; 3f2df - text_jump Text_GoForItPkmn +JumpText_GoForItMon: + text_jump Text_GoForItMon start_asm jr Function_TextJump_BattleMonNick01 -; 3f2e4 -JumpText_YourFoesWeakGetmPkmn: ; 3f2e6 - text_jump Text_YourFoesWeakGetmPkmn +JumpText_YourFoesWeakGetmMon: + text_jump Text_YourFoesWeakGetmMon start_asm -Function_TextJump_BattleMonNick01: ; 3f2eb +Function_TextJump_BattleMonNick01: ld hl, TextJump_BattleMonNick01 ret -; 3f2ef -TextJump_BattleMonNick01: ; 3f2ef +TextJump_BattleMonNick01: text_jump Text_BattleMonNick01 db "@" -; 3f2f4 -WithdrawPkmnText: ; 3f2f4 - ld hl, .WithdrawPkmnText +WithdrawMonText: + ld hl, .WithdrawMonText jp BattleTextBox -.WithdrawPkmnText: +.WithdrawMonText: text_jump Text_BattleMonNickComma start_asm -; Print text to withdraw Pkmn +; Print text to withdraw mon ; depending on HP the message is different push de push bc @@ -8003,33 +7743,27 @@ WithdrawPkmnText: ; 3f2f4 ld hl, TextJump_GoodComeBack ret -; 3f348 -TextJump_ThatsEnoughComeBack: ; 3f348 +TextJump_ThatsEnoughComeBack: text_jump Text_ThatsEnoughComeBack db "@" -; 3f34d -TextJump_OKComeBack: ; 3f34d +TextJump_OKComeBack: text_jump Text_OKComeBack db "@" -; 3f352 -TextJump_GoodComeBack: ; 3f352 +TextJump_GoodComeBack: text_jump Text_GoodComeBack db "@" -; 3f357 -Unreferenced_TextJump_ComeBack: ; 3f357 +Unreferenced_TextJump_ComeBack: ; this function doesn't seem to be used ld hl, TextJump_ComeBack ret -; 3f35b -TextJump_ComeBack: ; 3f35b +TextJump_ComeBack: text_jump Text_ComeBack db "@" -; 3f360 Unreferenced_HandleSafariAngerEatingStatus: ld hl, wSafariMonEating @@ -8037,7 +7771,7 @@ Unreferenced_HandleSafariAngerEatingStatus: and a jr z, .angry dec [hl] - ld hl, BattleText_WildPkmnIsEating + ld hl, BattleText_WildMonIsEating jr .finish .angry @@ -8046,7 +7780,7 @@ Unreferenced_HandleSafariAngerEatingStatus: and a ret z dec [hl] - ld hl, BattleText_WildPkmnIsAngry + ld hl, BattleText_WildMonIsAngry jr nz, .finish push hl ld a, [wEnemyMonSpecies] @@ -8061,18 +7795,16 @@ Unreferenced_HandleSafariAngerEatingStatus: call Call_LoadTempTileMapToTileMap pop hl jp StdBattleTextBox -; 3f390 -FillInExpBar: ; 3f390 +FillInExpBar: push hl call CalcExpBar pop hl ld de, 7 add hl, de jp PlaceExpBar -; 3f39c -CalcExpBar: ; 3f39c +CalcExpBar: ; Calculate the percent exp between this level and the next ; Level in b push de @@ -8171,9 +7903,8 @@ CalcExpBar: ; 3f39c sub b ld b, a ret -; 3f41c -PlaceExpBar: ; 3f41c +PlaceExpBar: ld c, $8 ; number of tiles .loop1 ld a, b @@ -8203,15 +7934,14 @@ PlaceExpBar: ; 3f41c .finish ret -; 3f43d -GetBattleMonBackpic: ; 3f43d +GetBattleMonBackpic: ld a, [wPlayerSubStatus4] bit SUBSTATUS_SUBSTITUTE, a ld hl, BattleAnimCmd_RaiseSub jr nz, GetBattleMonBackpic_DoAnim ; substitute -DropPlayerSub: ; 3f447 +DropPlayerSub: ld a, [wPlayerMinimized] and a ld hl, BattleAnimCmd_MinimizeOpp @@ -8227,9 +7957,8 @@ DropPlayerSub: ; 3f447 pop af ld [wCurPartySpecies], a ret -; 3f46f -GetBattleMonBackpic_DoAnim: ; 3f46f +GetBattleMonBackpic_DoAnim: ld a, [hBattleTurn] push af xor a @@ -8239,15 +7968,14 @@ GetBattleMonBackpic_DoAnim: ; 3f46f pop af ld [hBattleTurn], a ret -; 3f47c -GetEnemyMonFrontpic: ; 3f47c +GetEnemyMonFrontpic: ld a, [wEnemySubStatus4] bit SUBSTATUS_SUBSTITUTE, a ld hl, BattleAnimCmd_RaiseSub jr nz, GetEnemyMonFrontpic_DoAnim -DropEnemySub: ; 3f486 +DropEnemySub: ld a, [wEnemyMinimized] and a ld hl, BattleAnimCmd_MinimizeOpp @@ -8266,9 +7994,8 @@ DropEnemySub: ; 3f486 pop af ld [wCurPartySpecies], a ret -; 3f4b4 -GetEnemyMonFrontpic_DoAnim: ; 3f4b4 +GetEnemyMonFrontpic_DoAnim: ld a, [hBattleTurn] push af call SetEnemyTurn @@ -8277,9 +8004,8 @@ GetEnemyMonFrontpic_DoAnim: ; 3f4b4 pop af ld [hBattleTurn], a ret -; 3f4c1 -StartBattle: ; 3f4c1 +StartBattle: ; This check prevents you from entering a battle without any Pokemon. ; Those using walk-through-walls to bypass getting a Pokemon experience ; the effects of this check. @@ -8296,14 +8022,12 @@ StartBattle: ; 3f4c1 ld [wTimeOfDayPal], a scf ret -; 3f4d9 -Unreferenced_DoBattle: ; 3f4d9 +Unreferenced_DoBattle: call DoBattle ret -; 3f4dd -BattleIntro: ; 3f4dd +BattleIntro: farcall StubbedTrainerRankings_Battles ; mobile call LoadTrainerOrWildMonPic xor a @@ -8342,9 +8066,8 @@ BattleIntro: ; 3f4dd ld a, $1 ld [hBGMapMode], a ret -; 3f54e -LoadTrainerOrWildMonPic: ; 3f54e +LoadTrainerOrWildMonPic: ld a, [wOtherTrainerClass] and a jr nz, .Trainer @@ -8354,16 +8077,14 @@ LoadTrainerOrWildMonPic: ; 3f54e .Trainer: ld [wTempEnemyMonSpecies], a ret -; 3f55e -InitEnemy: ; 3f55e +InitEnemy: ld a, [wOtherTrainerClass] and a jp nz, InitEnemyTrainer ; trainer jp InitEnemyWildmon ; wild -; 3f568 -BackUpBGMap2: ; 3f568 +BackUpBGMap2: ld a, [rSVBK] push af ld a, BANK(wDecompressScratch) @@ -8385,9 +8106,8 @@ BackUpBGMap2: ; 3f568 pop af ld [rSVBK], a ret -; 3f594 -InitEnemyTrainer: ; 3f594 +InitEnemyTrainer: ld [wTrainerClass], a farcall StubbedTrainerRankings_TrainerBattles xor a @@ -8441,9 +8161,8 @@ InitEnemyTrainer: ; 3f594 jr .partyloop .done ret -; 3f607 -InitEnemyWildmon: ; 3f607 +InitEnemyWildmon: ld a, WILD_BATTLE ld [wBattleMode], a farcall StubbedTrainerRankings_WildBattles @@ -8476,9 +8195,8 @@ InitEnemyWildmon: ; 3f607 lb bc, 7, 7 predef PlaceGraphic ret -; 3f662 -Unreferenced_Function3f662: ; 3f662 +Unreferenced_Function3f662: ld hl, wEnemyMonMoves ld de, wListMoves_MoveIndicesBuffer ld b, NUM_MOVES @@ -8528,15 +8246,13 @@ Unreferenced_Function3f662: ; 3f662 dec b jr nz, .clear ret -; 3f69e -ExitBattle: ; 3f69e +ExitBattle: call .HandleEndOfBattle call CleanUpBattleRAM ret -; 3f6a5 -.HandleEndOfBattle: ; 3f6a5 +.HandleEndOfBattle: ld a, [wLinkMode] and a jr z, .not_linked @@ -8556,9 +8272,8 @@ ExitBattle: ; 3f69e predef EvolveAfterBattle farcall GivePokerusAndConvertBerries ret -; 3f6d0 -CleanUpBattleRAM: ; 3f6d0 +CleanUpBattleRAM: call BattleEnd_HandleRoamMons xor a ld [wLowHealthAlarm], a @@ -8589,9 +8304,8 @@ CleanUpBattleRAM: ; 3f6d0 jr nz, .loop call WaitSFX ret -; 3f71d -CheckPayDay: ; 3f71d +CheckPayDay: ld hl, wPayDayMoney ld a, [hli] or [hl] @@ -8625,9 +8339,8 @@ CheckPayDay: ; 3f71d call ClearTileMap call ClearBGPalettes ret -; 3f759 -ShowLinkBattleParticipantsAfterEnd: ; 3f759 +ShowLinkBattleParticipantsAfterEnd: farcall StubbedTrainerRankings_LinkBattles farcall BackupMobileEventIndex ld a, [wCurOTMon] @@ -8638,9 +8351,8 @@ ShowLinkBattleParticipantsAfterEnd: ; 3f759 call ClearTileMap farcall _ShowLinkBattleParticipants ret -; 3f77c -DisplayLinkBattleResult: ; 3f77c +DisplayLinkBattleResult: farcall CheckMobileBattleError jp c, .Mobile_InvalidBattle call IsMobileBattle2 @@ -8655,9 +8367,10 @@ DisplayLinkBattleResult: ; 3f77c .proceed ld a, [wBattleResult] and $f - cp $1 - jr c, .victory - jr z, .loss + cp LOSE + jr c, .victory ; WIN + jr z, .loss ; LOSE + ; DRAW farcall StubbedTrainerRankings_ColosseumDraws ld de, .Draw jr .store_result @@ -8698,7 +8411,6 @@ DisplayLinkBattleResult: ; 3f77c call DelayFrames call ClearTileMap ret -; 3f7f7 .Win: db "YOU WIN@" @@ -8706,9 +8418,8 @@ DisplayLinkBattleResult: ; 3f77c db "YOU LOSE@" .Draw: db " DRAW@" -; 3f80f -.Mobile_InvalidBattle: ; 3f80f +.Mobile_InvalidBattle: hlcoord 6, 8 ld de, .Invalid call PlaceString @@ -8716,19 +8427,16 @@ DisplayLinkBattleResult: ; 3f77c call DelayFrames call ClearTileMap ret -; 3f821 .Invalid: db "INVALID BATTLE@" -; 3f830 -IsMobileBattle2: ; 3f830 +IsMobileBattle2: ld a, [wLinkMode] cp LINK_MOBILE ret -; 3f836 -DisplayLinkRecord: ; 3f836 +_DisplayLinkRecord: ld a, BANK(sLinkBattleStats) call GetSRAMBank @@ -8747,9 +8455,8 @@ DisplayLinkRecord: ; 3f836 call DelayFrames call WaitPressAorB_BlinkCursor ret -; 3f85f -ReadAndPrintLinkBattleRecord: ; 3f85f +ReadAndPrintLinkBattleRecord: call ClearTileMap call ClearSprites call .PrintBattleRecord @@ -8866,30 +8573,27 @@ ReadAndPrintLinkBattleRecord: ; 3f85f call PlaceString scf ret -; 3f938 .Scores: db " 0 0 0@" -; 3f947 -.Format: ; 3f947 - db " --- <LNBRK>" +.Format: + db " --- <LF>" db " - - -@" -.Record: ; 3f964 +.Record: db "<PLAYER>'s RECORD@" -.Result: ; 3f96e +.Result: db "RESULT WIN LOSE DRAW@" -.Total: ; 3f983 +.Total: db "TOTAL WIN LOSE DRAW@" -; 3f998 -BattleEnd_HandleRoamMons: ; 3f998 +BattleEnd_HandleRoamMons: ld a, [wBattleType] cp BATTLETYPE_ROAMING jr nz, .not_roaming ld a, [wBattleResult] and $f - jr z, .caught_or_defeated_roam_mon + jr z, .caught_or_defeated_roam_mon ; WIN call GetRoamMonHP ld a, [wEnemyMonHP + 1] ld [hl], a @@ -8897,13 +8601,13 @@ BattleEnd_HandleRoamMons: ; 3f998 .caught_or_defeated_roam_mon call GetRoamMonHP - ld [hl], $0 + ld [hl], 0 call GetRoamMonMapGroup - ld [hl], $ff + ld [hl], GROUP_N_A call GetRoamMonMapNumber - ld [hl], $ff + ld [hl], MAP_N_A call GetRoamMonSpecies - ld [hl], $0 + ld [hl], 0 ret .not_roaming @@ -8914,9 +8618,8 @@ BattleEnd_HandleRoamMons: ; 3f998 .update_roam_mons callfar UpdateRoamMons ret -; 3f9d1 -GetRoamMonMapGroup: ; 3f9d1 +GetRoamMonMapGroup: ld a, [wTempEnemyMonSpecies] ld b, a ld a, [wRoamMon1Species] @@ -8929,9 +8632,8 @@ GetRoamMonMapGroup: ; 3f9d1 ret z ld hl, wRoamMon3MapGroup ret -; 3f9e9 -GetRoamMonMapNumber: ; 3f9e9 +GetRoamMonMapNumber: ld a, [wTempEnemyMonSpecies] ld b, a ld a, [wRoamMon1Species] @@ -8944,9 +8646,8 @@ GetRoamMonMapNumber: ; 3f9e9 ret z ld hl, wRoamMon3MapNumber ret -; 3fa01 -GetRoamMonHP: ; 3fa01 +GetRoamMonHP: ; output: hl = wRoamMonHP ld a, [wTempEnemyMonSpecies] ld b, a @@ -8960,9 +8661,8 @@ GetRoamMonHP: ; 3fa01 ret z ld hl, wRoamMon3HP ret -; 3fa19 -GetRoamMonDVs: ; 3fa19 +GetRoamMonDVs: ; output: hl = wRoamMonDVs ld a, [wTempEnemyMonSpecies] ld b, a @@ -8976,9 +8676,8 @@ GetRoamMonDVs: ; 3fa19 ret z ld hl, wRoamMon3DVs ret -; 3fa31 -GetRoamMonSpecies: ; 3fa31 +GetRoamMonSpecies: ld a, [wTempEnemyMonSpecies] ld hl, wRoamMon1Species cp [hl] @@ -8988,9 +8687,8 @@ GetRoamMonSpecies: ; 3fa31 ret z ld hl, wRoamMon3Species ret -; 3fa42 -AddLastMobileBattleToLinkRecord: ; 3fa42 +AddLastMobileBattleToLinkRecord: ld hl, wOTPlayerID ld de, wStringBuffer1 ld bc, 2 @@ -9045,15 +8743,15 @@ AddLastMobileBattleToLinkRecord: ; 3fa42 call .StoreResult call .FindOpponentAndAppendRecord ret -; 3faa0 -.StoreResult: ; 3faa0 +.StoreResult: ld a, [wBattleResult] and $f - cp $1 + cp LOSE ld bc, sLinkBattleWins + 1 - sLinkBattleResults - jr c, .okay + jr c, .okay ; WIN ld bc, sLinkBattleLosses + 1 - sLinkBattleResults - jr z, .okay + jr z, .okay ; LOSE + ; DRAW ld bc, sLinkBattleDraws + 1 - sLinkBattleResults .okay add hl, bc @@ -9064,9 +8762,8 @@ AddLastMobileBattleToLinkRecord: ; 3fa42 dec hl inc [hl] ret -; 3fabe -.CheckOverflow: ; 3fabe +.CheckOverflow: dec hl ld a, [hl] inc hl @@ -9075,9 +8772,8 @@ AddLastMobileBattleToLinkRecord: ; 3fa42 ld a, [hl] cp LOW(MAX_LINK_RECORD) ret -; 3fac8 -.FindOpponentAndAppendRecord: ; 3fac8 +.FindOpponentAndAppendRecord: ld b, 5 ld hl, sLinkBattleRecord + 17 ld de, wd002 @@ -9169,9 +8865,8 @@ AddLastMobileBattleToLinkRecord: ; 3fa42 pop de call CopyBytes ret -; 3fb54 -.LoadPointer: ; 3fb54 +.LoadPointer: ld e, $0 ld a, [hld] ld c, a @@ -9196,9 +8891,8 @@ AddLastMobileBattleToLinkRecord: ; 3fa42 ret nc inc e ret -; 3fb6c -InitBattleDisplay: ; 3fb6c +InitBattleDisplay: call .InitBackPic hlcoord 0, 12 ld b, 4 @@ -9241,9 +8935,8 @@ InitBattleDisplay: ; 3fb6c xor a ld [hSCX], a ret -; 3fbd6 -.BlankBGMap: ; 3fbd6 +.BlankBGMap: ld a, [rSVBK] push af ld a, BANK(wDecompressScratch) @@ -9262,15 +8955,13 @@ InitBattleDisplay: ; 3fb6c pop af ld [rSVBK], a ret -; 3fbf8 -.InitBackPic: ; 3fbf8 +.InitBackPic: call GetTrainerBackpic call CopyBackpic ret -; 3fbff -GetTrainerBackpic: ; 3fbff +GetTrainerBackpic: ; Load the player character's backpic (6x6) into VRAM starting from vTiles2 tile $31. ; Special exception for Dude. @@ -9282,10 +8973,10 @@ GetTrainerBackpic: ; 3fbff ; What gender are we? ld a, [wPlayerSpriteSetupFlags] - bit 2, a ; transformed to male + bit PLAYERSPRITESETUP_FEMALE_TO_MALE_F, a jr nz, .Chris ld a, [wPlayerGender] - bit 0, a + bit PLAYERGENDER_FEMALE_F, a jr z, .Chris ; It's a girl. @@ -9302,9 +8993,8 @@ GetTrainerBackpic: ; 3fbff ld c, 7 * 7 predef DecompressGet2bpp ret -; 3fc30 -CopyBackpic: ; 3fc30 +CopyBackpic: ld a, [rSVBK] push af ld a, BANK(wDecompressScratch) @@ -9324,9 +9014,8 @@ CopyBackpic: ; 3fc30 lb bc, 6, 6 predef PlaceGraphic ret -; 3fc5b -.LoadTrainerBackpicAsOAM: ; 3fc5b +.LoadTrainerBackpicAsOAM: ld hl, wVirtualOAMSprite00 xor a ld [hMapObjectIndexBuffer], a @@ -9360,9 +9049,8 @@ CopyBackpic: ; 3fc30 dec b jr nz, .outer_loop ret -; 3fc8b -BattleStartMessage: ; 3fc8b +BattleStartMessage: ld a, [wBattleMode] dec a jr z, .wild @@ -9443,4 +9131,3 @@ BattleStartMessage: ; 3fc8b farcall Mobile_PrintOpponentBattleMessage ret -; 3fd26 |