diff options
author | yenatch <yenatch@gmail.com> | 2018-02-03 17:15:20 -0500 |
---|---|---|
committer | GitHub <noreply@github.com> | 2018-02-03 17:15:20 -0500 |
commit | b35eb72290b964b98844afbe741bb7ede34b9ef3 (patch) | |
tree | 2cf2652bc9c3e69ae5f7b2a2632c02a12498615f /engine/battle | |
parent | 7547ad839cf1c8141b931d08ef16a894e7db68c9 (diff) | |
parent | 32ade4ac9bf113d630d904aab51f2c49c91bf8c2 (diff) |
Merge pull request #480 from luckytyphlosion/master
[Ready to merge] Prefix wram labels with w.
Diffstat (limited to 'engine/battle')
34 files changed, 2004 insertions, 2003 deletions
diff --git a/engine/battle/ai/items.asm b/engine/battle/ai/items.asm index d0867fb33..4d1eea2e8 100644 --- a/engine/battle/ai/items.asm +++ b/engine/battle/ai/items.asm @@ -12,7 +12,7 @@ AI_SwitchOrTryItem: ; 38000 farcall CheckEnemyLockedIn ret nz - ld a, [PlayerSubStatus5] + ld a, [wPlayerSubStatus5] bit SUBSTATUS_CANT_RUN, a jr nz, DontSwitch @@ -21,11 +21,11 @@ AI_SwitchOrTryItem: ; 38000 jr nz, DontSwitch ld hl, TrainerClassAttributes + TRNATTR_AI_ITEM_SWITCH - ld a, [InBattleTowerBattle] ; Load always the first TrainerClass for BattleTower-Trainers + ld a, [wInBattleTowerBattle] ; always load the first trainer class in wTrainerClass for BattleTower-Trainers and a jr nz, .ok - ld a, [TrainerClass] + ld a, [wTrainerClass] dec a ld bc, NUM_TRAINER_ATTRIBUTES call AddNTimes @@ -151,7 +151,7 @@ SwitchSometimes: ; 380c1 CheckSubstatusCantRun: ; 380ff - ld a, [EnemySubStatus5] + ld a, [wEnemySubStatus5] bit SUBSTATUS_CANT_RUN, a ret ; 38105 @@ -159,7 +159,7 @@ CheckSubstatusCantRun: ; 380ff AI_TryItem: ; 38105 ; items are not allowed in the BattleTower - ld a, [InBattleTowerBattle] + ld a, [wInBattleTowerBattle] and a ret nz @@ -172,7 +172,7 @@ AI_TryItem: ; 38105 call .IsHighestLevel ret nc - ld a, [TrainerClass] + ld a, [wTrainerClass] dec a ld hl, TrainerClassAttributes + TRNATTR_AI_ITEM_SWITCH ld bc, NUM_TRAINER_ATTRIBUTES @@ -226,29 +226,29 @@ AI_TryItem: ; 38105 inc a ld [wEnemyGoesFirst], a - ld hl, EnemySubStatus3 + ld hl, wEnemySubStatus3 res SUBSTATUS_BIDE, [hl] xor a - ld [EnemyFuryCutterCount], a - ld [EnemyProtectCount], a + ld [wEnemyFuryCutterCount], a + ld [wEnemyProtectCount], a ld [wEnemyRageCounter], a - ld hl, EnemySubStatus4 + ld hl, wEnemySubStatus4 res SUBSTATUS_RAGE, [hl] xor a - ld [LastEnemyCounterMove], a + ld [wLastEnemyCounterMove], a scf ret .IsHighestLevel: ; 38170 - ld a, [OTPartyCount] + ld a, [wOTPartyCount] ld d, a ld e, 0 - ld hl, OTPartyMon1Level + ld hl, wOTPartyMon1Level ld bc, PARTYMON_STRUCT_LENGTH .next ld a, [hl] @@ -260,8 +260,8 @@ AI_TryItem: ; 38105 dec d jr nz, .next - ld a, [CurOTMon] - ld hl, OTPartyMon1Level + ld a, [wCurOTMon] + ld hl, wOTPartyMon1Level call AddNTimes ld a, [hl] cp e @@ -302,7 +302,7 @@ AI_Items: ; 39196 ; 381ca .Status: ; 381ca (e:41ca) - ld a, [EnemyMonStatus] + ld a, [wEnemyMonStatus] and a jp z, .DontUse @@ -318,17 +318,17 @@ AI_Items: ; 39196 jp .DontUse .StatusCheckContext: - ld a, [EnemySubStatus5] + ld a, [wEnemySubStatus5] bit SUBSTATUS_TOXIC, a jr z, .FailToxicCheck - ld a, [EnemyToxicCount] + ld a, [wEnemyToxicCount] cp 4 jr c, .FailToxicCheck call Random cp 1 + 50 percent jp c, .Use .FailToxicCheck: - ld a, [EnemyMonStatus] + ld a, [wEnemyMonStatus] and 1 << FRZ | SLP jp z, .DontUse jp .Use @@ -419,8 +419,8 @@ AI_Items: ; 39196 callfar AICheckEnemyMaxHP jr c, .dont_use push bc - ld de, EnemyMonMaxHP + 1 - ld hl, EnemyMonHP + 1 + ld de, wEnemyMonMaxHP + 1 + ld hl, wEnemyMonHP + 1 ld a, [de] sub [hl] jr z, .check_40_percent @@ -509,7 +509,7 @@ AI_Items: ; 39196 ; 3834d .XItem: ; 3834d (e:434d) - ld a, [EnemyTurnsTaken] + ld a, [wEnemyTurnsTaken] and a jr nz, .notfirstturnout ld a, [bc] @@ -571,37 +571,37 @@ EnemyUsedFullHeal: ; 383a3 (e:43a3) EnemyUsedMaxPotion: ; 383ae (e:43ae) ld a, MAX_POTION - ld [CurEnemyItem], a + ld [wCurEnemyItem], a jr FullRestoreContinue EnemyUsedFullRestore: ; 383b5 (e:43b5) call AI_HealStatus ld a, FULL_RESTORE - ld [CurEnemyItem], a - ld hl, EnemySubStatus3 + ld [wCurEnemyItem], a + ld hl, wEnemySubStatus3 res SUBSTATUS_CONFUSED, [hl] xor a - ld [EnemyConfuseCount], a + ld [wEnemyConfuseCount], a FullRestoreContinue: ; 383c6 ld de, wCurHPAnimOldHP - ld hl, EnemyMonHP + 1 + ld hl, wEnemyMonHP + 1 ld a, [hld] ld [de], a inc de ld a, [hl] ld [de], a inc de - ld hl, EnemyMonMaxHP + 1 + ld hl, wEnemyMonMaxHP + 1 ld a, [hld] ld [de], a inc de ld [wCurHPAnimMaxHP], a - ld [EnemyMonHP + 1], a + ld [wEnemyMonHP + 1], a ld a, [hl] ld [de], a ld [wCurHPAnimMaxHP + 1], a - ld [EnemyMonHP], a + ld [wEnemyMonHP], a jr EnemyPotionFinish ; 383e8 (e:43e8) @@ -620,8 +620,8 @@ EnemyUsedHyperPotion: ; 383f4 (e:43f4) ld b, 200 EnemyPotionContinue: ; 383f8 - ld [CurEnemyItem], a - ld hl, EnemyMonHP + 1 + ld [wCurEnemyItem], a + ld hl, wEnemyMonHP + 1 ld a, [hl] ld [wCurHPAnimOldHP], a add b @@ -638,7 +638,7 @@ EnemyPotionContinue: ; 383f8 inc hl ld a, [hld] ld b, a - ld de, EnemyMonMaxHP + 1 + ld de, wEnemyMonMaxHP + 1 ld a, [de] dec de ld [wCurHPAnimMaxHP], a @@ -671,9 +671,9 @@ EnemyPotionFinish: ; 38436 AI_TrySwitch: ; 3844b ; Determine whether the AI can switch based on how many Pokemon are still alive. ; If it can switch, it will. - ld a, [OTPartyCount] + ld a, [wOTPartyCount] ld c, a - ld hl, OTPartyMon1HP + ld hl, wOTPartyMon1HP ld d, 0 .SwitchLoop: ld a, [hli] @@ -701,20 +701,20 @@ AI_Switch: ; 3846c ld a, $1 ld [wEnemyIsSwitching], a ld [wEnemyGoesFirst], a - ld hl, EnemySubStatus4 + ld hl, wEnemySubStatus4 res SUBSTATUS_RAGE, [hl] xor a ld [hBattleTurn], a callfar PursuitSwitch push af - ld a, [CurOTMon] - ld hl, OTPartyMon1Status + ld a, [wCurOTMon] + ld hl, wOTPartyMon1Status ld bc, PARTYMON_STRUCT_LENGTH call AddNTimes ld d, h ld e, l - ld hl, EnemyMonStatus + ld hl, wEnemyMonStatus ld bc, MON_MAXHP - MON_STATUS call CopyBytes pop af @@ -728,7 +728,7 @@ AI_Switch: ; 3846c ld [wBattleHasJustStarted], a callfar NewEnemyMonStatus callfar ResetEnemyStatLevels - ld hl, PlayerSubStatus1 + ld hl, wPlayerSubStatus1 res SUBSTATUS_IN_LOVE, [hl] farcall EnemySwitch farcall ResetBattleParticipants @@ -754,25 +754,25 @@ Function384d5: ; This appears to be unused ; 384e0 AI_HealStatus: ; 384e0 - ld a, [CurOTMon] - ld hl, OTPartyMon1Status + ld a, [wCurOTMon] + ld hl, wOTPartyMon1Status ld bc, PARTYMON_STRUCT_LENGTH call AddNTimes xor a ld [hl], a - ld [EnemyMonStatus], a + ld [wEnemyMonStatus], a ; Bug: this should reset SUBSTATUS_NIGHTMARE too ; Uncomment the lines below to fix - ; ld hl, EnemySubStatus1 + ; ld hl, wEnemySubStatus1 ; res SUBSTATUS_NIGHTMARE, [hl] - ld hl, EnemySubStatus5 + ld hl, wEnemySubStatus5 res SUBSTATUS_TOXIC, [hl] ret ; 384f7 EnemyUsedXAccuracy: ; 384f7 call AIUsedItemSound - ld hl, EnemySubStatus4 + ld hl, wEnemySubStatus4 set SUBSTATUS_X_ACCURACY, [hl] ld a, X_ACCURACY jp PrintText_UsedItemOn_AND_AIUpdateHUD @@ -780,7 +780,7 @@ EnemyUsedXAccuracy: ; 384f7 EnemyUsedGuardSpec: ; 38504 call AIUsedItemSound - ld hl, EnemySubStatus4 + ld hl, wEnemySubStatus4 set SUBSTATUS_MIST, [hl] ld a, GUARD_SPEC jp PrintText_UsedItemOn_AND_AIUpdateHUD @@ -788,7 +788,7 @@ EnemyUsedGuardSpec: ; 38504 EnemyUsedDireHit: ; 38511 call AIUsedItemSound - ld hl, EnemySubStatus4 + ld hl, wEnemySubStatus4 set SUBSTATUS_FOCUS_ENERGY, [hl] ld a, DIRE_HIT jp PrintText_UsedItemOn_AND_AIUpdateHUD @@ -796,7 +796,7 @@ EnemyUsedDireHit: ; 38511 Function3851e: ; This appears to be unused ld [hDivisor], a - ld hl, EnemyMonMaxHP + ld hl, wEnemyMonMaxHP ld a, [hli] ld [hDividend], a ld a, [hl] @@ -807,7 +807,7 @@ Function3851e: ; This appears to be unused ld c, a ld a, [hQuotient + 1] ld b, a - ld hl, EnemyMonHP + 1 + ld hl, wEnemyMonHP + 1 ld a, [hld] ld e, a ld a, [hl] @@ -847,7 +847,7 @@ EnemyUsedXSpecial: ; 38553 ; a = ITEM_CONSTANT ; b = BATTLE_CONSTANT (ATTACK, DEFENSE, SPEED, SP_ATTACK, SP_DEFENSE, ACCURACY, EVASION) EnemyUsedXItem: - ld [CurEnemyItem], a + ld [wCurEnemyItem], a push bc call PrintText_UsedItemOn pop bc @@ -859,16 +859,16 @@ EnemyUsedXItem: ; Parameter ; a = ITEM_CONSTANT PrintText_UsedItemOn_AND_AIUpdateHUD: ; 38568 - ld [CurEnemyItem], a + ld [wCurEnemyItem], a call PrintText_UsedItemOn jp AIUpdateHUD ; 38571 PrintText_UsedItemOn: ; 38571 - ld a, [CurEnemyItem] + ld a, [wCurEnemyItem] ld [wd265], a call GetItemName - ld hl, StringBuffer1 + ld hl, wStringBuffer1 ld de, wMonOrItemNameBuffer ld bc, ITEM_NAME_LENGTH call CopyBytes diff --git a/engine/battle/ai/move.asm b/engine/battle/ai/move.asm index 7ccb20972..b5ac966f8 100755 --- a/engine/battle/ai/move.asm +++ b/engine/battle/ai/move.asm @@ -1,5 +1,5 @@ AIChooseMove: ; 440ce -; Score each move in EnemyMonMoves starting from Buffer1. Lower is better. +; Score each move in wEnemyMonMoves starting from wBuffer1. Lower is better. ; Pick the move with the lowest score. ; Wildmons attack at random. @@ -18,18 +18,18 @@ AIChooseMove: ; 440ce ; The default score is 20. Unusable moves are given a score of 80. ld a, 20 - ld hl, Buffer1 + ld hl, wBuffer1 ld [hli], a ld [hli], a ld [hli], a ld [hl], a ; Don't pick disabled moves. - ld a, [EnemyDisabledMove] + ld a, [wEnemyDisabledMove] and a jr z, .CheckPP - ld hl, EnemyMonMoves + ld hl, wEnemyMonMoves ld c, 0 .CheckDisabledMove: cp [hl] @@ -38,20 +38,20 @@ AIChooseMove: ; 440ce inc hl jr .CheckDisabledMove .ScoreDisabledMove: - ld hl, Buffer1 + ld hl, wBuffer1 ld b, 0 add hl, bc ld [hl], 80 ; Don't pick moves with 0 PP. .CheckPP: - ld hl, Buffer1 - 1 - ld de, EnemyMonPP + ld hl, wBuffer1 - 1 + ld de, wEnemyMonPP ld b, 0 .CheckMovePP: inc b ld a, b - cp EnemyMonMovesEnd - EnemyMonMoves + 1 + cp wEnemyMonMovesEnd - wEnemyMonMoves + 1 jr z, .ApplyLayers inc hl ld a, [de] @@ -66,13 +66,13 @@ AIChooseMove: ; 440ce .ApplyLayers: ld hl, TrainerClassAttributes + TRNATTR_AI_MOVE_WEIGHTS - ; If we have a battle in BattleTower just load the Attributes of the first TrainerClass (Falkner) + ; If we have a battle in BattleTower just load the Attributes of the first trainer class in wTrainerClass (Falkner) ; so we have always the same AI, regardless of the loaded class of trainer - ld a, [InBattleTowerBattle] + ld a, [wInBattleTowerBattle] bit 0, a jr nz, .battle_tower_skip - ld a, [TrainerClass] + ld a, [wTrainerClass] dec a ld bc, 7 ; Trainer2AI - Trainer1AI call AddNTimes @@ -119,9 +119,9 @@ AIChooseMove: ; 440ce ; Decrement the scores of all moves one by one until one reaches 0. .DecrementScores: - ld hl, Buffer1 - ld de, EnemyMonMoves - ld c, EnemyMonMovesEnd - EnemyMonMoves + ld hl, wBuffer1 + ld de, wEnemyMonMoves + ld c, wEnemyMonMovesEnd - wEnemyMonMoves .DecrementNextScore: ; If the enemy has no moves, this will infinite. @@ -154,8 +154,8 @@ AIChooseMove: ; 440ce cp NUM_MOVES + 1 jr nz, .move_loop - ld hl, Buffer1 - ld de, EnemyMonMoves + ld hl, wBuffer1 + ld de, wEnemyMonMoves ld c, NUM_MOVES ; Give a score of 0 to a blank move @@ -184,7 +184,7 @@ AIChooseMove: ; 440ce ; Randomly choose one of the moves with a score of 1 .ChooseMove: - ld hl, Buffer1 + ld hl, wBuffer1 call Random maskbits NUM_MOVES ld c, a @@ -194,9 +194,9 @@ AIChooseMove: ; 440ce and a jr z, .ChooseMove - ld [CurEnemyMove], a + ld [wCurEnemyMove], a ld a, c - ld [CurEnemyMoveNum], a + ld [wCurEnemyMoveNum], a ret ; 441af diff --git a/engine/battle/ai/redundant.asm b/engine/battle/ai/redundant.asm index 2e8f7c6df..d09b4da73 100755 --- a/engine/battle/ai/redundant.asm +++ b/engine/battle/ai/redundant.asm @@ -47,95 +47,95 @@ AI_Redundant: ; 2c41a db -1 .LightScreen: ; 2c487 - ld a, [EnemyScreens] + ld a, [wEnemyScreens] bit SCREENS_LIGHT_SCREEN, a ret .Mist: ; 2c48d - ld a, [EnemySubStatus4] + ld a, [wEnemySubStatus4] bit SUBSTATUS_MIST, a ret .FocusEnergy: ; 2c493 - ld a, [EnemySubStatus4] + ld a, [wEnemySubStatus4] bit SUBSTATUS_FOCUS_ENERGY, a ret .Confuse: ; 2c499 - ld a, [PlayerSubStatus3] + ld a, [wPlayerSubStatus3] bit SUBSTATUS_CONFUSED, a ret nz - ld a, [PlayerScreens] + ld a, [wPlayerScreens] bit SCREENS_SAFEGUARD, a ret .Transform: ; 2c4a5 - ld a, [EnemySubStatus5] + ld a, [wEnemySubStatus5] bit SUBSTATUS_TRANSFORMED, a ret .Reflect: ; 2c4ab - ld a, [EnemyScreens] + ld a, [wEnemyScreens] bit SCREENS_REFLECT, a ret .Substitute: ; 2c4b1 - ld a, [EnemySubStatus4] + ld a, [wEnemySubStatus4] bit SUBSTATUS_SUBSTITUTE, a ret .LeechSeed: ; 2c4b7 - ld a, [PlayerSubStatus4] + ld a, [wPlayerSubStatus4] bit SUBSTATUS_LEECH_SEED, a ret .Disable: ; 2c4bd - ld a, [PlayerDisableCount] + ld a, [wPlayerDisableCount] and a ret .Encore: ; 2c4c2 - ld a, [PlayerSubStatus5] + ld a, [wPlayerSubStatus5] bit SUBSTATUS_ENCORED, a ret .Snore: .SleepTalk: ; 2c4c8 - ld a, [EnemyMonStatus] + ld a, [wEnemyMonStatus] and SLP jr z, .Redundant jr .NotRedundant .MeanLook: ; 2c4d1 - ld a, [EnemySubStatus5] + ld a, [wEnemySubStatus5] bit SUBSTATUS_CANT_RUN, a ret .Nightmare: ; 2c4d7 - ld a, [BattleMonStatus] + ld a, [wBattleMonStatus] and a jr z, .Redundant - ld a, [PlayerSubStatus1] + ld a, [wPlayerSubStatus1] bit SUBSTATUS_NIGHTMARE, a ret .Spikes: ; 2c4e3 - ld a, [PlayerScreens] + ld a, [wPlayerScreens] bit SCREENS_SPIKES, a ret .Foresight: ; 2c4e9 - ld a, [PlayerSubStatus1] + ld a, [wPlayerSubStatus1] bit SUBSTATUS_IDENTIFIED, a ret .PerishSong: ; 2c4ef - ld a, [PlayerSubStatus1] + ld a, [wPlayerSubStatus1] bit SUBSTATUS_PERISH, a ret .Sandstorm: ; 2c4f5 - ld a, [Weather] + ld a, [wBattleWeather] cp WEATHER_SANDSTORM jr z, .Redundant jr .NotRedundant @@ -143,40 +143,40 @@ AI_Redundant: ; 2c41a .Attract: ; 2c4fe farcall CheckOppositeGender jr c, .Redundant - ld a, [PlayerSubStatus1] + ld a, [wPlayerSubStatus1] bit SUBSTATUS_IN_LOVE, a ret .Safeguard: ; 2c50c - ld a, [EnemyScreens] + ld a, [wEnemyScreens] bit SCREENS_SAFEGUARD, a ret .RainDance: ; 2c512 - ld a, [Weather] + ld a, [wBattleWeather] cp WEATHER_RAIN jr z, .Redundant jr .NotRedundant .SunnyDay: ; 2c51b - ld a, [Weather] + ld a, [wBattleWeather] cp WEATHER_SUN jr z, .Redundant jr .NotRedundant .DreamEater: ; 2c524 - ld a, [BattleMonStatus] + ld a, [wBattleMonStatus] and SLP jr z, .Redundant jr .NotRedundant .Swagger: ; 2c52d - ld a, [PlayerSubStatus3] + ld a, [wPlayerSubStatus3] bit SUBSTATUS_CONFUSED, a ret .FutureSight: ; 2c533 - ld a, [EnemyScreens] + ld a, [wEnemyScreens] bit 5, a ret diff --git a/engine/battle/ai/scoring.asm b/engine/battle/ai/scoring.asm index 73284435a..b250128a4 100644 --- a/engine/battle/ai/scoring.asm +++ b/engine/battle/ai/scoring.asm @@ -5,9 +5,9 @@ AI_Basic: ; 38591 ; -Using status-only moves if the player can't be statused ; -Using moves that fail if they've already been used - ld hl, Buffer1 - 1 - ld de, EnemyMonMoves - ld b, EnemyMonMovesEnd - EnemyMonMoves + 1 + ld hl, wBuffer1 - 1 + ld de, wEnemyMonMoves + ld b, wEnemyMonMovesEnd - wEnemyMonMoves + 1 .checkmove dec b ret z @@ -49,12 +49,12 @@ AI_Basic: ; 38591 pop hl jr nc, .checkmove - ld a, [BattleMonStatus] + ld a, [wBattleMonStatus] and a jr nz, .discourage ; Dismiss Safeguard if it's already active. - ld a, [PlayerScreens] + ld a, [wPlayerScreens] bit SCREENS_SAFEGUARD, a jr z, .checkmove @@ -80,9 +80,9 @@ AI_Setup: ; 385e0 ; 50% chance to greatly encourage stat-down moves during the first turn of player's Pokemon. ; Almost 90% chance to greatly discourage stat-modifying moves otherwise. - ld hl, Buffer1 - 1 - ld de, EnemyMonMoves - ld b, EnemyMonMovesEnd - EnemyMonMoves + 1 + ld hl, wBuffer1 - 1 + ld de, wEnemyMonMoves + ld b, wEnemyMonMovesEnd - wEnemyMonMoves + 1 .checkmove dec b ret z @@ -120,14 +120,14 @@ AI_Setup: ; 385e0 jr .checkmove .statup - ld a, [EnemyTurnsTaken] + ld a, [wEnemyTurnsTaken] and a jr nz, .discourage jr .encourage .statdown - ld a, [PlayerTurnsTaken] + ld a, [wPlayerTurnsTaken] and a jr nz, .discourage @@ -156,9 +156,9 @@ AI_Types: ; 38635 ; Discourage not very effective moves unless ; all damaging moves are of the same type. - ld hl, Buffer1 - 1 - ld de, EnemyMonMoves - ld b, EnemyMonMovesEnd - EnemyMonMoves + 1 + ld hl, wBuffer1 - 1 + ld de, wEnemyMonMoves + ld b, wEnemyMonMovesEnd - wEnemyMonMoves + 1 .checkmove dec b ret z @@ -203,8 +203,8 @@ AI_Types: ; 38635 push bc ld a, [wEnemyMoveStruct + MOVE_TYPE] ld d, a - ld hl, EnemyMonMoves - ld b, EnemyMonMovesEnd - EnemyMonMoves + 1 + ld hl, wEnemyMonMoves + ld b, wEnemyMonMovesEnd - wEnemyMonMoves + 1 ld c, 0 .checkmove2 dec b @@ -245,9 +245,9 @@ AI_Types: ; 38635 AI_Offensive: ; 386a2 ; Greatly discourage non-damaging moves. - ld hl, Buffer1 - 1 - ld de, EnemyMonMoves - ld b, EnemyMonMovesEnd - EnemyMonMoves + 1 + ld hl, wBuffer1 - 1 + ld de, wEnemyMonMoves + ld b, wEnemyMonMovesEnd - wEnemyMonMoves + 1 .checkmove dec b ret z @@ -274,9 +274,9 @@ AI_Offensive: ; 386a2 AI_Smart: ; 386be ; Context-specific scoring. - ld hl, Buffer1 - ld de, EnemyMonMoves - ld b, EnemyMonMovesEnd - EnemyMonMoves + 1 + ld hl, wBuffer1 + ld de, wEnemyMonMoves + ld b, wEnemyMonMovesEnd - wEnemyMonMoves + 1 .checkmove dec b ret z @@ -462,7 +462,7 @@ AI_Smart_LeechHit: ; 387f7 AI_Smart_LockOn: ; 3881d - ld a, [PlayerSubStatus5] + ld a, [wPlayerSubStatus5] bit SUBSTATUS_LOCK_ON, a jr nz, .asm_38882 @@ -477,20 +477,20 @@ AI_Smart_LockOn: ; 3881d jr nc, .asm_38877 .asm_38834 - ld a, [PlayerEvaLevel] + ld a, [wPlayerEvaLevel] cp $a jr nc, .asm_3887a cp $8 jr nc, .asm_38875 - ld a, [EnemyAccLevel] + ld a, [wEnemyAccLevel] cp $5 jr c, .asm_3887a cp $7 jr c, .asm_38875 - ld hl, EnemyMonMoves - ld c, EnemyMonMovesEnd - EnemyMonMoves + 1 + ld hl, wEnemyMonMoves + ld c, wEnemyMonMovesEnd - wEnemyMonMoves + 1 .asm_3884f dec c jr z, .asm_38877 @@ -537,9 +537,9 @@ AI_Smart_LockOn: ; 3881d .asm_38882 push hl - ld hl, Buffer1 - 1 - ld de, EnemyMonMoves - ld c, EnemyMonMovesEnd - EnemyMonMoves + 1 + ld hl, wBuffer1 - 1 + ld de, wEnemyMonMoves + ld c, wEnemyMonMovesEnd - wEnemyMonMoves + 1 .asm_3888b inc hl @@ -622,7 +622,7 @@ AI_Smart_DreamEater: ; 388ca AI_Smart_EvasionUp: ; 388d4 ; Dismiss this move if enemy's evasion can't raise anymore. - ld a, [EnemyEvaLevel] + ld a, [wEnemyEvaLevel] cp $d jp nc, AIDiscourageMove @@ -631,7 +631,7 @@ AI_Smart_EvasionUp: ; 388d4 jr nc, .asm_388f2 ; ...greatly encourage this move if player is badly poisoned. - ld a, [PlayerSubStatus5] + ld a, [wPlayerSubStatus5] bit SUBSTATUS_TOXIC, a jr nz, .asm_388ef @@ -680,27 +680,27 @@ AI_Smart_EvasionUp: ; 388d4 ; 100% chance to end up here if enemy's HP is below 25%. ; In other words, we only end up here if the move has not been encouraged or dismissed. .asm_38911 - ld a, [PlayerSubStatus5] + ld a, [wPlayerSubStatus5] bit SUBSTATUS_TOXIC, a jr nz, .asm_38938 - ld a, [PlayerSubStatus4] + ld a, [wPlayerSubStatus4] bit SUBSTATUS_LEECH_SEED, a jr nz, .asm_38941 ; Discourage this move if enemy's evasion level is higher than player's accuracy level. - ld a, [EnemyEvaLevel] + ld a, [wEnemyEvaLevel] ld b, a - ld a, [PlayerAccLevel] + ld a, [wPlayerAccLevel] cp b jr c, .asm_38936 ; Greatly encourage this move if the player is in the middle of Fury Cutter or Rollout. - ld a, [PlayerFuryCutterCount] + ld a, [wPlayerFuryCutterCount] and a jr nz, .asm_388ef - ld a, [PlayerSubStatus1] + ld a, [wPlayerSubStatus1] bit SUBSTATUS_ROLLOUT, a jr nz, .asm_388ef @@ -736,12 +736,12 @@ AI_Smart_AlwaysHit: ; 38947 ; 80% chance to greatly encourage this move if either... ; ...enemy's accuracy level has been lowered three or more stages - ld a, [EnemyAccLevel] + ld a, [wEnemyAccLevel] cp $5 jr c, .asm_38954 ; ...or player's evasion level has been raised three or more stages. - ld a, [PlayerEvaLevel] + ld a, [wPlayerEvaLevel] cp $a ret c @@ -758,7 +758,7 @@ AI_Smart_AlwaysHit: ; 38947 AI_Smart_MirrorMove: ; 3895b ; If the player did not use any move last turn... - ld a, [LastPlayerCounterMove] + ld a, [wLastPlayerCounterMove] and a jr nz, .asm_38968 @@ -810,7 +810,7 @@ AI_Smart_AccuracyDown: ; 38985 jr nc, .asm_389a0 ; ...greatly encourage this move if player is badly poisoned. - ld a, [PlayerSubStatus5] + ld a, [wPlayerSubStatus5] bit SUBSTATUS_TOXIC, a jr nz, .asm_3899d @@ -855,27 +855,27 @@ AI_Smart_AccuracyDown: ; 38985 ; We only end up here if the move has not been already encouraged. .asm_389bf - ld a, [PlayerSubStatus5] + ld a, [wPlayerSubStatus5] bit SUBSTATUS_TOXIC, a jr nz, .asm_389e6 - ld a, [PlayerSubStatus4] + ld a, [wPlayerSubStatus4] bit SUBSTATUS_LEECH_SEED, a jr nz, .asm_389ef ; Discourage this move if enemy's evasion level is higher than player's accuracy level. - ld a, [EnemyEvaLevel] + ld a, [wEnemyEvaLevel] ld b, a - ld a, [PlayerAccLevel] + ld a, [wPlayerAccLevel] cp b jr c, .asm_389e4 ; Greatly encourage this move if the player is in the middle of Fury Cutter or Rollout. - ld a, [PlayerFuryCutterCount] + ld a, [wPlayerFuryCutterCount] and a jr nz, .asm_3899d - ld a, [PlayerSubStatus1] + ld a, [wPlayerSubStatus1] bit SUBSTATUS_ROLLOUT, a jr nz, .asm_3899d @@ -910,7 +910,7 @@ AI_Smart_ResetStats: ; 389f5 ; 85% chance to encourage this move if any of enemy's stat levels is lower than -2. push hl - ld hl, EnemyAtkLevel + ld hl, wEnemyAtkLevel ld c, $8 .asm_389fb dec c @@ -922,7 +922,7 @@ AI_Smart_ResetStats: ; 389f5 ; 85% chance to encourage this move if any of player's stat levels is higher than +2. .asm_38a05 - ld hl, PlayerAtkLevel + ld hl, wPlayerAtkLevel ld c, $8 .asm_38a0a dec c @@ -1034,9 +1034,9 @@ AI_Smart_Ohko: ; 38a60 ; Dismiss this move if player's level is higher than enemy's level. ; Else, discourage this move is player's HP is below 50%. - ld a, [BattleMonLevel] + ld a, [wBattleMonLevel] ld b, a - ld a, [EnemyMonLevel] + ld a, [wEnemyMonLevel] cp b jp c, AIDiscourageMove call AICheckPlayerHalfHP @@ -1056,16 +1056,16 @@ AI_Smart_TrapTarget: ; 38a71 ; 50% chance to greatly encourage this move if player is either ; badly poisoned, in love, identified, stuck in Rollout, or has a Nightmare. - ld a, [PlayerSubStatus5] + ld a, [wPlayerSubStatus5] bit SUBSTATUS_TOXIC, a jr nz, .asm_38a91 - ld a, [PlayerSubStatus1] + ld a, [wPlayerSubStatus1] and 1<<SUBSTATUS_IN_LOVE | 1<<SUBSTATUS_ROLLOUT | 1<<SUBSTATUS_IDENTIFIED | 1<<SUBSTATUS_NIGHTMARE jr nz, .asm_38a91 ; Else, 50% chance to greatly encourage this move if it's the player's Pokemon first turn. - ld a, [PlayerTurnsTaken] + ld a, [wPlayerTurnsTaken] and a jr z, .asm_38a91 @@ -1089,17 +1089,17 @@ AI_Smart_TrapTarget: ; 38a71 AI_Smart_RazorWind: AI_Smart_Unused2B: ; 38a9c - ld a, [EnemySubStatus1] + ld a, [wEnemySubStatus1] bit SUBSTATUS_PERISH, a jr z, .asm_38aaa - ld a, [EnemyPerishCount] + ld a, [wEnemyPerishCount] cp 3 jr c, .asm_38ad3 .asm_38aaa push hl - ld hl, PlayerUsedMoves + ld hl, wPlayerUsedMoves ld c, 4 .asm_38ab0 @@ -1117,7 +1117,7 @@ AI_Smart_Unused2B: ; 38a9c .asm_38ac1 pop hl - ld a, [EnemySubStatus3] + ld a, [wEnemySubStatus3] bit SUBSTATUS_CONFUSED, a jr nz, .asm_38acd @@ -1168,7 +1168,7 @@ AI_Smart_SpDefenseUp2: ; 38aed jr nc, .asm_38b10 ; Discourage this move if enemy's special defense level is higher than +3. - ld a, [EnemySDefLevel] + ld a, [wEnemySDefLevel] cp $b jr nc, .asm_38b10 @@ -1177,10 +1177,10 @@ AI_Smart_SpDefenseUp2: ; 38aed cp $9 ret nc - ld a, [BattleMonType1] + ld a, [wBattleMonType1] cp SPECIAL jr nc, .asm_38b09 - ld a, [BattleMonType2] + ld a, [wBattleMonType2] cp SPECIAL ret c @@ -1203,7 +1203,7 @@ AI_Smart_Fly: ; 38b12 ; Greatly encourage this move if the player is ; flying or underground, and slower than the enemy. - ld a, [PlayerSubStatus3] + ld a, [wPlayerSubStatus3] and 1 << SUBSTATUS_FLYING | 1 << SUBSTATUS_UNDERGROUND ret z @@ -1266,7 +1266,7 @@ AI_Smart_SpeedDownHit: ; 38b40 ret nz call AICheckEnemyQuarterHP ret nc - ld a, [PlayerTurnsTaken] + ld a, [wPlayerTurnsTaken] and a ret nz call AICompareSpeed @@ -1315,7 +1315,7 @@ AI_Smart_HyperBeam: ; 38b63 AI_Smart_Rage: ; 38b7f - ld a, [EnemySubStatus4] + ld a, [wEnemySubStatus4] bit SUBSTATUS_RAGE, a jr z, .asm_38b9b @@ -1355,7 +1355,7 @@ AI_Smart_Rage: ; 38b7f AI_Smart_Mimic: ; 38ba8 - ld a, [LastPlayerCounterMove] + ld a, [wLastPlayerCounterMove] and a jr z, .asm_38be9 @@ -1363,7 +1363,7 @@ AI_Smart_Mimic: ; 38ba8 jr nc, .asm_38bef push hl - ld a, [LastPlayerCounterMove] + ld a, [wLastPlayerCounterMove] call AIGetEnemyMove ld a, $1 @@ -1382,7 +1382,7 @@ AI_Smart_Mimic: ; 38ba8 dec [hl] .asm_38bd4 - ld a, [LastPlayerCounterMove] + ld a, [wLastPlayerCounterMove] push hl ld hl, UsefulMoves ld de, 1 @@ -1407,7 +1407,7 @@ AI_Smart_Mimic: ; 38ba8 AI_Smart_Counter: ; 38bf1 push hl - ld hl, PlayerUsedMoves + ld hl, wPlayerUsedMoves ld c, 4 ld b, 0 @@ -1440,7 +1440,7 @@ AI_Smart_Counter: ; 38bf1 cp $3 jr nc, .asm_38c30 - ld a, [LastPlayerCounterMove] + ld a, [wLastPlayerCounterMove] and a jr z, .asm_38c38 @@ -1475,7 +1475,7 @@ AI_Smart_Encore: ; 38c3b call AICompareSpeed jr nc, .asm_38c81 - ld a, [LastPlayerMove] + ld a, [wLastPlayerMove] and a jp z, AIDiscourageMove @@ -1487,7 +1487,7 @@ AI_Smart_Encore: ; 38c3b push hl ld a, [wEnemyMoveStruct + MOVE_TYPE] - ld hl, EnemyMonType1 + ld hl, wEnemyMonType1 predef CheckTypeMatchup pop hl @@ -1501,7 +1501,7 @@ AI_Smart_Encore: ; 38c3b .asm_38c68 push hl - ld a, [LastPlayerCounterMove] + ld a, [wLastPlayerCounterMove] ld hl, .EncoreMoves ld de, 1 call IsInArray @@ -1561,13 +1561,13 @@ AI_Smart_PainSplit: ; 38ca4 ; Discourage this move if [enemy's current HP * 2 > player's current HP]. push hl - ld hl, EnemyMonHP + ld hl, wEnemyMonHP ld b, [hl] inc hl ld c, [hl] sla c rl b - ld hl, BattleMonHP + 1 + ld hl, wBattleMonHP + 1 ld a, [hld] cp c ld a, [hl] @@ -1584,7 +1584,7 @@ AI_Smart_SleepTalk: ; 38cba ; Greatly encourage this move if enemy is fast asleep. ; Greatly discourage this move otherwise. - ld a, [EnemyMonStatus] + ld a, [wEnemyMonStatus] and $7 cp $1 jr z, .asm_38cc7 @@ -1606,7 +1606,7 @@ AI_Smart_DefrostOpponent: ; 38ccb ; Greatly encourage this move if enemy is frozen. ; No move has EFFECT_DEFROST_OPPONENT, so this layer is unused. - ld a, [EnemyMonStatus] + ld a, [wEnemyMonStatus] and $20 ret z dec [hl] @@ -1617,7 +1617,7 @@ AI_Smart_DefrostOpponent: ; 38ccb AI_Smart_Spite: ; 38cd5 - ld a, [LastPlayerCounterMove] + ld a, [wLastPlayerCounterMove] and a jr nz, .asm_38ce7 @@ -1633,8 +1633,8 @@ AI_Smart_Spite: ; 38cd5 push hl ld b, a ld c, 4 - ld hl, BattleMonMoves - ld de, BattleMonPP + ld hl, wBattleMonMoves + ld de, wBattleMonPP .asm_38cf1 ld a, [hli] @@ -1697,10 +1697,10 @@ AI_Smart_HealBell: ; 38d1f ; 50% chance to greatly encourage this move if the enemy is fast asleep or frozen. push hl - ld a, [OTPartyCount] + ld a, [wOTPartyCount] ld b, a ld c, 0 - ld hl, OTPartyMon1HP + ld hl, wOTPartyMon1HP ld de, PARTYMON_STRUCT_LENGTH .loop @@ -1728,7 +1728,7 @@ AI_Smart_HealBell: ; 38d1f and a jr z, .no_status - ld a, [EnemyMonStatus] + ld a, [wEnemyMonStatus] and a jr z, .ok dec [hl] @@ -1742,7 +1742,7 @@ AI_Smart_HealBell: ; 38d1f ret .no_status - ld a, [EnemyMonStatus] + ld a, [wEnemyMonStatus] and a ret nz jp AIDiscourageMove @@ -1755,7 +1755,7 @@ AI_Smart_PriorityHit: ; 38d5a ret c ; Dismiss this move if the player is flying or underground. - ld a, [PlayerSubStatus3] + ld a, [wPlayerSubStatus3] and 1 << SUBSTATUS_FLYING | 1 << SUBSTATUS_UNDERGROUND jp nz, AIDiscourageMove @@ -1767,13 +1767,13 @@ AI_Smart_PriorityHit: ; 38d5a callfar BattleCommand_DamageCalc callfar BattleCommand_Stab pop hl - ld a, [CurDamage + 1] + ld a, [wCurDamage + 1] ld c, a - ld a, [CurDamage] + ld a, [wCurDamage] ld b, a - ld a, [BattleMonHP + 1] + ld a, [wBattleMonHP + 1] cp c - ld a, [BattleMonHP] + ld a, [wBattleMonHP] sbc b ret nc dec [hl] @@ -1794,7 +1794,7 @@ AI_Smart_Thief: ; 38d93 AI_Smart_Conversion2: ; 38d98 - ld a, [LastPlayerMove] + ld a, [wLastPlayerMove] and a jr nz, .asm_38dc9 @@ -1839,7 +1839,7 @@ AI_Smart_Disable: ; 38dd1 jr nc, .asm_38df3 push hl - ld a, [LastPlayerCounterMove] + ld a, [wLastPlayerCounterMove] ld hl, UsefulMoves ld de, 1 call IsInArray @@ -1877,14 +1877,14 @@ AI_Smart_MeanLook: ; 38dfb jp z, AIDiscourageMove ; 80% chance to greatly encourage this move if the enemy is badly poisoned (buggy). -; Should check PlayerSubStatus5 instead. - ld a, [EnemySubStatus5] +; Should check wPlayerSubStatus5 instead. + ld a, [wEnemySubStatus5] bit SUBSTATUS_TOXIC, a jr nz, .asm_38e26 ; 80% chance to greatly encourage this move if the player is either ; in love, identified, stuck in Rollout, or has a Nightmare. - ld a, [PlayerSubStatus1] + ld a, [wPlayerSubStatus1] and 1<<SUBSTATUS_IN_LOVE | 1<<SUBSTATUS_ROLLOUT | 1<<SUBSTATUS_IDENTIFIED | 1<<SUBSTATUS_NIGHTMARE jr nz, .asm_38e26 @@ -1911,14 +1911,14 @@ AI_Smart_MeanLook: ; 38dfb AICheckLastPlayerMon: ; 38e2e - ld a, [PartyCount] + ld a, [wPartyCount] ld b, a ld c, 0 - ld hl, PartyMon1HP + ld hl, wPartyMon1HP ld de, PARTYMON_STRUCT_LENGTH .loop - ld a, [CurBattleMon] + ld a, [wCurBattleMon] cp c jr z, .asm_38e44 @@ -1952,7 +1952,7 @@ AI_Smart_Nightmare: ; 38e4a AI_Smart_FlameWheel: ; 38e50 ; Use this move if the enemy is frozen. - ld a, [EnemyMonStatus] + ld a, [wEnemyMonStatus] bit FRZ, a ret z rept 5 @@ -1963,28 +1963,28 @@ endr AI_Smart_Curse: ; 38e5c - ld a, [EnemyMonType1] + ld a, [wEnemyMonType1] cp GHOST jr z, .ghostcurse - ld a, [EnemyMonType2] + ld a, [wEnemyMonType2] cp GHOST jr z, .ghostcurse call AICheckEnemyHalfHP jr nc, .asm_38e93 - ld a, [EnemyAtkLevel] + ld a, [wEnemyAtkLevel] cp $b jr nc, .asm_38e93 cp $9 ret nc - ld a, [BattleMonType1] + ld a, [wBattleMonType1] cp GHOST jr z, .asm_38e92 cp SPECIAL ret nc - ld a, [BattleMonType2] + ld a, [wBattleMonType2] cp SPECIAL ret nc call AI_80_20 @@ -2003,7 +2003,7 @@ AI_Smart_Curse: ; 38e5c ret .ghostcurse - ld a, [PlayerSubStatus1] + ld a, [wPlayerSubStatus1] bit SUBSTATUS_CURSE, a jp nz, AIDiscourageMove @@ -2037,7 +2037,7 @@ AI_Smart_Curse: ; 38e5c call AICheckEnemyMaxHP ret nc - ld a, [PlayerTurnsTaken] + ld a, [wPlayerTurnsTaken] and a ret nz @@ -2052,36 +2052,36 @@ AI_Smart_Curse: ; 38e5c AI_Smart_Protect: ; 38ed2 - ld a, [EnemyProtectCount] + ld a, [wEnemyProtectCount] and a jr nz, .asm_38f13 - ld a, [PlayerSubStatus5] + ld a, [wPlayerSubStatus5] bit SUBSTATUS_LOCK_ON, a jr nz, .asm_38f14 - ld a, [PlayerFuryCutterCount] + ld a, [wPlayerFuryCutterCount] cp 3 jr nc, .asm_38f0d - ld a, [PlayerSubStatus3] + ld a, [wPlayerSubStatus3] bit SUBSTATUS_CHARGED, a jr nz, .asm_38f0d - ld a, [PlayerSubStatus5] + ld a, [wPlayerSubStatus5] bit SUBSTATUS_TOXIC, a jr nz, .asm_38f0d - ld a, [PlayerSubStatus4] + ld a, [wPlayerSubStatus4] bit SUBSTATUS_LEECH_SEED, a jr nz, .asm_38f0d - ld a, [PlayerSubStatus1] + ld a, [wPlayerSubStatus1] bit SUBSTATUS_CURSE, a jr nz, .asm_38f0d bit SUBSTATUS_ROLLOUT, a jr z, .asm_38f14 - ld a, [PlayerRolloutCount] + ld a, [wPlayerRolloutCount] cp 3 jr c, .asm_38f14 @@ -2105,17 +2105,17 @@ AI_Smart_Protect: ; 38ed2 AI_Smart_Foresight: ; 38f1d - ld a, [EnemyAccLevel] + ld a, [wEnemyAccLevel] cp $5 jr c, .asm_38f41 - ld a, [PlayerEvaLevel] + ld a, [wPlayerEvaLevel] cp $a jr nc, .asm_38f41 - ld a, [BattleMonType1] + ld a, [wBattleMonType1] cp GHOST jr z, .asm_38f41 - ld a, [BattleMonType2] + ld a, [wBattleMonType2] cp GHOST jr z, .asm_38f41 @@ -2141,7 +2141,7 @@ AI_Smart_PerishSong: ; 38f4a pop hl jr c, .no - ld a, [PlayerSubStatus5] + ld a, [wPlayerSubStatus5] bit SUBSTATUS_CANT_RUN, a jr nz, .yes @@ -2176,7 +2176,7 @@ AI_Smart_PerishSong: ; 38f4a AI_Smart_Sandstorm: ; 38f7a ; Greatly discourage this move if the player is immune to Sandstorm damage. - ld a, [BattleMonType1] + ld a, [wBattleMonType1] push hl ld hl, .SandstormImmuneTypes ld de, 1 @@ -2184,7 +2184,7 @@ AI_Smart_Sandstorm: ; 38f7a pop hl jr c, .asm_38fa5 - ld a, [BattleMonType2] + ld a, [wBattleMonType2] push hl ld hl, .SandstormImmuneTypes ld de, 1 @@ -2219,7 +2219,7 @@ AI_Smart_Sandstorm: ; 38f7a AI_Smart_Endure: ; 38fac - ld a, [EnemyProtectCount] + ld a, [wEnemyProtectCount] and a jr nz, .asm_38fd8 @@ -2242,7 +2242,7 @@ AI_Smart_Endure: ; 38fac ret .asm_38fcb - ld a, [EnemySubStatus5] + ld a, [wEnemySubStatus5] bit SUBSTATUS_LOCK_ON, a ret z @@ -2265,7 +2265,7 @@ AI_Smart_Endure: ; 38fac AI_Smart_FuryCutter: ; 38fdb ; Encourage this move based on Fury Cutter's count. - ld a, [EnemyFuryCutterCount] + ld a, [wEnemyFuryCutterCount] and a jr z, .end dec [hl] @@ -2291,15 +2291,15 @@ AI_Smart_Rollout: ; 38fef ; Rollout, Fury Cutter ; 80% chance to discourage this move if the enemy is in love, confused, or paralyzed. - ld a, [EnemySubStatus1] + ld a, [wEnemySubStatus1] bit SUBSTATUS_IN_LOVE, a jr nz, .asm_39020 - ld a, [EnemySubStatus3] + ld a, [wEnemySubStatus3] bit SUBSTATUS_CONFUSED, a jr nz, .asm_39020 - ld a, [EnemyMonStatus] + ld a, [wEnemyMonStatus] bit PAR, a jr nz, .asm_39020 @@ -2308,10 +2308,10 @@ AI_Smart_Rollout: ; 38fef call AICheckEnemyQuarterHP jr nc, .asm_39020 - ld a, [EnemyAccLevel] + ld a, [wEnemyAccLevel] cp 7 jr c, .asm_39020 - ld a, [PlayerEvaLevel] + ld a, [wPlayerEvaLevel] cp 8 jr nc, .asm_39020 @@ -2336,7 +2336,7 @@ AI_Smart_Attract: ; 39026 ; 80% chance to encourage this move during the first turn of player's Pokemon. ; 80% chance to discourage this move otherwise. - ld a, [PlayerTurnsTaken] + ld a, [wPlayerTurnsTaken] and a jr z, .first_turn @@ -2370,11 +2370,11 @@ AI_Smart_Magnitude: AI_Smart_Earthquake: ; 39044 ; Greatly encourage this move if the player is underground and the enemy is faster. - ld a, [LastPlayerCounterMove] + ld a, [wLastPlayerCounterMove] cp DIG ret nz - ld a, [PlayerSubStatus3] + ld a, [wPlayerSubStatus3] bit SUBSTATUS_UNDERGROUND, a jr z, .could_dig @@ -2442,11 +2442,11 @@ AI_Smart_RapidSpin: ; 39084 and a jr nz, .asm_39097 - ld a, [EnemySubStatus4] + ld a, [wEnemySubStatus4] bit SUBSTATUS_LEECH_SEED, a jr nz, .asm_39097 - ld a, [EnemyScreens] + ld a, [wEnemyScreens] bit SCREENS_SPIKES, a ret z @@ -2504,13 +2504,13 @@ AI_Smart_RainDance: ; 390cb ; Greatly discourage this move if it would favour the player type-wise. ; Particularly, if the player is a Water-type. - ld a, [BattleMonType1] + ld a, [wBattleMonType1] cp WATER jr z, AIBadWeatherType cp FIRE jr z, AIGoodWeatherType - ld a, [BattleMonType2] + ld a, [wBattleMonType2] cp WATER jr z, AIBadWeatherType cp FIRE @@ -2541,13 +2541,13 @@ AI_Smart_SunnyDay: ; 390f3 ; Greatly discourage this move if it would favour the player type-wise. ; Particularly, if the player is a Fire-type. - ld a, [BattleMonType1] + ld a, [wBattleMonType1] cp FIRE jr z, AIBadWeatherType cp WATER jr z, AIGoodWeatherType - ld a, [BattleMonType2] + ld a, [wBattleMonType2] cp FIRE jr z, AIBadWeatherType cp WATER @@ -2597,12 +2597,12 @@ AIGoodWeatherType: ; 39122 ; ...as long as one of the following conditions meet: ; It's the first turn of the player's Pokemon. - ld a, [PlayerTurnsTaken] + ld a, [wPlayerTurnsTaken] and a jr z, .good ; Or it's the first turn of the enemy's Pokemon. - ld a, [EnemyTurnsTaken] + ld a, [wEnemyTurnsTaken] and a ret nz @@ -2630,7 +2630,7 @@ AI_Smart_BellyDrum: ; 3913d ; Dismiss this move if enemy's attack is higher than +2 or if enemy's HP is below 50%. ; Else, discourage this move if enemy's HP is not full. - ld a, [EnemyAtkLevel] + ld a, [wEnemyAtkLevel] cp $a jr nc, .asm_3914d @@ -2652,7 +2652,7 @@ AI_Smart_BellyDrum: ; 3913d AI_Smart_PsychUp: ; 39152 push hl - ld hl, EnemyAtkLevel + ld hl, wEnemyAtkLevel ld b, $8 ld c, 100 @@ -2668,7 +2668,7 @@ AI_Smart_PsychUp: ; 39152 ; Calculate the sum of all player's stat level modifiers. Add 100 first to prevent underflow. ; Put the result in d. d will range between 58 and 142. - ld hl, PlayerAtkLevel + ld hl, wPlayerAtkLevel ld b, $8 ld d, 100 @@ -2687,12 +2687,12 @@ AI_Smart_PsychUp: ; 39152 jr nc, .asm_39188 ; Else, 80% chance to encourage this move unless player's accuracy level is lower than -1... - ld a, [PlayerAccLevel] + ld a, [wPlayerAccLevel] cp $6 ret c ; ...or enemy's evasion level is higher than +0. - ld a, [EnemyEvaLevel] + ld a, [wEnemyEvaLevel] cp $8 ret nc @@ -2711,7 +2711,7 @@ AI_Smart_PsychUp: ; 39152 AI_Smart_MirrorCoat: ; 3918b push hl - ld hl, PlayerUsedMoves + ld hl, wPlayerUsedMoves ld c, $4 ld b, $0 @@ -2744,7 +2744,7 @@ AI_Smart_MirrorCoat: ; 3918b cp $3 jr nc, .asm_391ca - ld a, [LastPlayerCounterMove] + ld a, [wLastPlayerCounterMove] and a jr z, .asm_391d2 @@ -2778,11 +2778,11 @@ AI_Smart_Twister: AI_Smart_Gust: ; 391d5 ; Greatly encourage this move if the player is flying and the enemy is faster. - ld a, [LastPlayerCounterMove] + ld a, [wLastPlayerCounterMove] cp FLY ret nz - ld a, [PlayerSubStatus3] + ld a, [wPlayerSubStatus3] bit SUBSTATUS_FLYING, a jr z, .couldFly @@ -2813,7 +2813,7 @@ AI_Smart_FutureSight: ; 391f3 call AICompareSpeed ret nc - ld a, [PlayerSubStatus3] + ld a, [wPlayerSubStatus3] and 1 << SUBSTATUS_FLYING | 1 << SUBSTATUS_UNDERGROUND ret z @@ -2842,7 +2842,7 @@ AI_Smart_Solarbeam: ; 3920b ; 80% chance to encourage this move when it's sunny. ; 90% chance to discourage this move when it's raining. - ld a, [Weather] + ld a, [wBattleWeather] cp WEATHER_SUN jr z, .asm_3921e @@ -2870,7 +2870,7 @@ AI_Smart_Solarbeam: ; 3920b AI_Smart_Thunder: ; 39225 ; 90% chance to discourage this move when it's sunny. - ld a, [Weather] + ld a, [wBattleWeather] cp WEATHER_SUN ret nz @@ -2887,13 +2887,13 @@ AICompareSpeed: ; 39233 ; Return carry if enemy is faster than player. push bc - ld a, [EnemyMonSpeed + 1] + ld a, [wEnemyMonSpeed + 1] ld b, a - ld a, [BattleMonSpeed + 1] + ld a, [wBattleMonSpeed + 1] cp b - ld a, [EnemyMonSpeed] + ld a, [wEnemyMonSpeed] ld b, a - ld a, [BattleMonSpeed] + ld a, [wBattleMonSpeed] sbc b pop bc ret @@ -2904,8 +2904,8 @@ AICheckPlayerMaxHP: ; 39246 push hl push de push bc - ld de, BattleMonHP - ld hl, BattleMonMaxHP + ld de, wBattleMonHP + ld hl, wBattleMonMaxHP jr AICheckMaxHP ; 39251 @@ -2914,8 +2914,8 @@ AICheckEnemyMaxHP: ; 39251 push hl push de push bc - ld de, EnemyMonHP - ld hl, EnemyMonMaxHP + ld de, wEnemyMonHP + ld hl, wEnemyMonMaxHP ; fallthrough ; 3925a @@ -2950,7 +2950,7 @@ AICheckMaxHP: ; 3925a AICheckPlayerHalfHP: ; 3926e push hl - ld hl, BattleMonHP + ld hl, wBattleMonHP ld b, [hl] inc hl ld c, [hl] @@ -2971,7 +2971,7 @@ AICheckEnemyHalfHP: ; 39281 push hl push de push bc - ld hl, EnemyMonHP + ld hl, wEnemyMonHP ld b, [hl] inc hl ld c, [hl] @@ -2994,7 +2994,7 @@ AICheckEnemyQuarterHP: ; 39298 push hl push de push bc - ld hl, EnemyMonHP + ld hl, wEnemyMonHP ld b, [hl] inc hl ld c, [hl] @@ -3017,7 +3017,7 @@ AICheckEnemyQuarterHP: ; 39298 AICheckPlayerQuarterHP: ; 392b3 push hl - ld hl, BattleMonHP + ld hl, wBattleMonHP ld b, [hl] inc hl ld c, [hl] @@ -3040,8 +3040,8 @@ AIHasMoveEffect: ; 392ca ; Return carry if the enemy has move b. push hl - ld hl, EnemyMonMoves - ld c, EnemyMonMovesEnd - EnemyMonMoves + ld hl, wEnemyMonMoves + ld c, wEnemyMonMovesEnd - wEnemyMonMoves .checkmove ld a, [hli] @@ -3082,8 +3082,8 @@ AIHasMoveInArray: ; 392e6 jr z, .done ld b, a - ld c, EnemyMonMovesEnd - EnemyMonMoves + 1 - ld de, EnemyMonMoves + ld c, wEnemyMonMovesEnd - wEnemyMonMoves + 1 + ld de, wEnemyMonMoves .check dec c @@ -3145,9 +3145,9 @@ AI_Opportunist: ; 39315 ret c .asm_39322 - ld hl, Buffer1 - 1 - ld de, EnemyMonMoves - ld c, EnemyMonMovesEnd - EnemyMonMoves + 1 + ld hl, wBuffer1 - 1 + ld de, wEnemyMonMoves + ld c, wEnemyMonMovesEnd - wEnemyMonMoves + 1 .checkmove inc hl dec c @@ -3222,13 +3222,13 @@ AI_Aggressive: ; 39369 ; no move will be discouraged ; Figure out which attack does the most damage and put it in c. - ld hl, EnemyMonMoves + ld hl, wEnemyMonMoves ld bc, 0 ld de, 0 .checkmove inc b ld a, b - cp EnemyMonMovesEnd - EnemyMonMoves + 1 + cp wEnemyMonMovesEnd - wEnemyMonMoves + 1 jr z, .gotstrongestmove ld a, [hli] @@ -3248,15 +3248,15 @@ AI_Aggressive: ; 39369 pop hl ; Update current move if damage is highest so far - ld a, [CurDamage + 1] + ld a, [wCurDamage + 1] cp e - ld a, [CurDamage] + ld a, [wCurDamage] sbc d jr c, .checkmove - ld a, [CurDamage + 1] + ld a, [wCurDamage + 1] ld e, a - ld a, [CurDamage] + ld a, [wCurDamage] ld d, a ld c, b jr .checkmove @@ -3274,13 +3274,13 @@ AI_Aggressive: ; 39369 jr z, .done ; Discourage moves that do less damage unless they're reckless too. - ld hl, Buffer1 - 1 - ld de, EnemyMonMoves + ld hl, wBuffer1 - 1 + ld de, wEnemyMonMoves ld b, 0 .checkmove2 inc b ld a, b - cp EnemyMonMovesEnd - EnemyMonMoves + 1 + cp wEnemyMonMovesEnd - wEnemyMonMoves + 1 jr z, .done ; Ignore this move if it is the highest damaging one. @@ -3357,13 +3357,13 @@ AIDamageCalc: ; 393e7 AI_Cautious: ; 39418 ; 90% chance to discourage moves with residual effects after the first turn. - ld a, [EnemyTurnsTaken] + ld a, [wEnemyTurnsTaken] and a ret z - ld hl, Buffer1 - 1 - ld de, EnemyMonMoves - ld c, EnemyMonMovesEnd - EnemyMonMoves + 1 + ld hl, wBuffer1 - 1 + ld de, wEnemyMonMoves + ld c, wEnemyMonMovesEnd - wEnemyMonMoves + 1 .asm_39425 inc hl dec c @@ -3414,9 +3414,9 @@ AI_Cautious: ; 39418 AI_Status: ; 39453 ; Dismiss status moves that don't affect the player. - ld hl, Buffer1 - 1 - ld de, EnemyMonMoves - ld b, EnemyMonMovesEnd - EnemyMonMoves + 1 + ld hl, wBuffer1 - 1 + ld de, wEnemyMonMoves + ld b, wEnemyMonMovesEnd - wEnemyMonMoves + 1 .checkmove dec b ret z @@ -3446,10 +3446,10 @@ AI_Status: ; 39453 jr .typeimmunity .poisonimmunity - ld a, [BattleMonType1] + ld a, [wBattleMonType1] cp POISON jr z, .immune - ld a, [BattleMonType2] + ld a, [wBattleMonType2] cp POISON jr z, .immune @@ -3479,9 +3479,9 @@ AI_Risky: ; 394a9 ; Use any move that will KO the target. ; Risky moves will often be an exception (see below). - ld hl, Buffer1 - 1 - ld de, EnemyMonMoves - ld c, EnemyMonMovesEnd - EnemyMonMoves + 1 + ld hl, wBuffer1 - 1 + ld de, wEnemyMonMoves + ld c, wEnemyMonMovesEnd - wEnemyMonMoves + 1 .checkmove inc hl dec c @@ -3519,13 +3519,13 @@ AI_Risky: ; 394a9 .checkko call AIDamageCalc - ld a, [CurDamage + 1] + ld a, [wCurDamage + 1] ld e, a - ld a, [CurDamage] + ld a, [wCurDamage] ld d, a - ld a, [BattleMonHP + 1] + ld a, [wBattleMonHP + 1] cp e - ld a, [BattleMonHP] + ld a, [wBattleMonHP] sbc d jr nc, .nextmove diff --git a/engine/battle/ai/switch.asm b/engine/battle/ai/switch.asm index c2f83fa1f..d397c8d32 100755 --- a/engine/battle/ai/switch.asm +++ b/engine/battle/ai/switch.asm @@ -7,7 +7,7 @@ CheckPlayerMoveTypeMatchups: ; 3484e push bc ld a, 10 ld [wEnemyAISwitchScore], a - ld hl, PlayerUsedMoves + ld hl, wPlayerUsedMoves ld a, [hl] and a jr z, .unknown_moves @@ -27,7 +27,7 @@ CheckPlayerMoveTypeMatchups: ; 3484e inc hl call GetMoveByte - ld hl, EnemyMonType + ld hl, wEnemyMonType call CheckTypeMatchup ld a, [wTypeMatchup] cp 10 + 1 ; 1.0 + 0.1 @@ -70,16 +70,16 @@ CheckPlayerMoveTypeMatchups: ; 3484e jr .done .unknown_moves - ld a, [BattleMonType1] + ld a, [wBattleMonType1] ld b, a - ld hl, EnemyMonType1 + ld hl, wEnemyMonType1 call CheckTypeMatchup ld a, [wTypeMatchup] cp 10 + 1 ; 1.0 + 0.1 jr c, .ok call .DecreaseScore .ok - ld a, [BattleMonType2] + ld a, [wBattleMonType2] cp b jr z, .ok2 call CheckTypeMatchup @@ -99,7 +99,7 @@ CheckPlayerMoveTypeMatchups: ; 3484e .CheckEnemyMoveMatchups: ; 348de - ld de, EnemyMonMoves + ld de, wEnemyMonMoves ld b, NUM_MOVES + 1 ld c, 0 @@ -122,7 +122,7 @@ CheckPlayerMoveTypeMatchups: ; 3484e inc hl call GetMoveByte - ld hl, BattleMonType1 + ld hl, wBattleMonType1 call CheckTypeMatchup ld a, [wTypeMatchup] @@ -183,11 +183,11 @@ CheckAbleToSwitch: ; 34941 call FindAliveEnemyMons ret c - ld a, [EnemySubStatus1] + ld a, [wEnemySubStatus1] bit SUBSTATUS_PERISH, a jr z, .no_perish - ld a, [EnemyPerishCount] + ld a, [wEnemyPerishCount] cp 1 jr nz, .no_perish @@ -229,7 +229,7 @@ CheckAbleToSwitch: ; 34941 cp 11 ret nc - ld a, [LastPlayerCounterMove] + ld a, [wLastPlayerCounterMove] and a jr z, .no_last_counter_move @@ -296,7 +296,7 @@ CheckAbleToSwitch: ; 34941 FindAliveEnemyMons: ; 349f4 - ld a, [OTPartyCount] + ld a, [wOTPartyCount] cp 2 jr c, .only_one @@ -304,10 +304,10 @@ FindAliveEnemyMons: ; 349f4 ld e, 0 ld b, 1 << (PARTY_LENGTH - 1) ld c, 0 - ld hl, OTPartyMon1HP + ld hl, wOTPartyMon1HP .loop - ld a, [CurOTMon] + ld a, [wCurOTMon] cp e jr z, .next @@ -348,8 +348,8 @@ FindAliveEnemyMons: ; 349f4 FindEnemyMonsImmuneToLastCounterMove: ; 34a2a - ld hl, OTPartyMon1 - ld a, [OTPartyCount] + ld hl, wOTPartyMon1 + ld a, [wOTPartyCount] ld b, a ld c, 1 << (PARTY_LENGTH - 1) ld d, 0 @@ -357,7 +357,7 @@ FindEnemyMonsImmuneToLastCounterMove: ; 34a2a ld [wEnemyAISwitchScore], a .loop - ld a, [CurOTMon] + ld a, [wCurOTMon] cp d push hl jr z, .next @@ -375,11 +375,11 @@ FindEnemyMonsImmuneToLastCounterMove: ; 34a2a jr z, .next ld a, [hl] - ld [CurSpecies], a + ld [wCurSpecies], a call GetBaseData ; the player's last move is damaging... - ld a, [LastPlayerCounterMove] + ld a, [wLastPlayerCounterMove] dec a ld hl, Moves + MOVE_POWER call GetMoveAttr @@ -389,7 +389,7 @@ FindEnemyMonsImmuneToLastCounterMove: ; 34a2a ; and the Pokemon is immune to it... inc hl call GetMoveByte - ld hl, BaseType + ld hl, wBaseType call CheckTypeMatchup ld a, [wTypeMatchup] and a @@ -417,9 +417,9 @@ FindEnemyMonsImmuneToLastCounterMove: ; 34a2a FindAliveEnemyMonsWithASuperEffectiveMove: ; 34a85 push bc - ld a, [OTPartyCount] + ld a, [wOTPartyCount] ld e, a - ld hl, OTPartyMon1HP + ld hl, wOTPartyMon1HP ld b, 1 << (PARTY_LENGTH - 1) ld c, 0 .loop @@ -434,7 +434,7 @@ FindAliveEnemyMonsWithASuperEffectiveMove: ; 34a85 .next srl b push bc - ld bc, PartyMon2HP - (PartyMon1HP + 1) + ld bc, wPartyMon2HP - (wPartyMon1HP + 1) add hl, bc pop bc dec e @@ -449,7 +449,7 @@ FindEnemyMonsWithASuperEffectiveMove: ; 34aa7 ld a, -1 ld [wEnemyAISwitchScore], a - ld hl, OTPartyMon1Moves + ld hl, wOTPartyMon1Moves ld b, 1 << (PARTY_LENGTH - 1) ld d, 0 ld e, 0 @@ -480,7 +480,7 @@ FindEnemyMonsWithASuperEffectiveMove: ; 34aa7 ; check type matchups inc hl call GetMoveByte - ld hl, BattleMonType1 + ld hl, wBattleMonType1 call CheckTypeMatchup ; if immune or not very effective: continue @@ -556,7 +556,7 @@ FindEnemyMonsWithASuperEffectiveMove: ; 34aa7 FindEnemyMonsThatResistPlayer: ; 34b20 push bc - ld hl, OTPartySpecies + ld hl, wOTPartySpecies ld b, 1 << (PARTY_LENGTH - 1) ld c, 0 @@ -566,9 +566,9 @@ FindEnemyMonsThatResistPlayer: ; 34b20 jr z, .done push hl - ld [CurSpecies], a + ld [wCurSpecies], a call GetBaseData - ld a, [LastPlayerCounterMove] + ld a, [wLastPlayerCounterMove] and a jr z, .skip_move @@ -583,16 +583,16 @@ FindEnemyMonsThatResistPlayer: ; 34b20 jr .check_type .skip_move - ld a, [BattleMonType1] - ld hl, BaseType + ld a, [wBattleMonType1] + ld hl, wBaseType call CheckTypeMatchup ld a, [wTypeMatchup] cp 10 + 1 jr nc, .dont_choose_mon - ld a, [BattleMonType2] + ld a, [wBattleMonType2] .check_type - ld hl, BaseType + ld hl, wBaseType call CheckTypeMatchup ld a, [wTypeMatchup] cp 10 + 1 @@ -618,10 +618,10 @@ FindEnemyMonsThatResistPlayer: ; 34b20 FindEnemyMonsWithAtLeastQuarterMaxHP: ; 34b77 push bc - ld de, OTPartySpecies + ld de, wOTPartySpecies ld b, 1 << (PARTY_LENGTH - 1) ld c, 0 - ld hl, OTPartyMon1HP + ld hl, wOTPartyMon1HP .loop ld a, [de] diff --git a/engine/battle/anim_hp_bar.asm b/engine/battle/anim_hp_bar.asm index 71276d27e..7d51a8629 100755 --- a/engine/battle/anim_hp_bar.asm +++ b/engine/battle/anim_hp_bar.asm @@ -275,10 +275,10 @@ HPBarAnim_UpdateHPRemaining: ; d784 ld [hld], a dec hl ld a, [wCurHPAnimOldHP] - ld [StringBuffer2 + 1], a + ld [wStringBuffer2 + 1], a ld a, [wCurHPAnimOldHP + 1] - ld [StringBuffer2], a - ld de, StringBuffer2 + ld [wStringBuffer2], a + ld de, wStringBuffer2 lb bc, 2, 3 call PrintNum pop hl @@ -311,7 +311,7 @@ HPBarAnim_BGMapUpdate: ; d7c9 jr z, .load_0 cp $1 jr z, .load_1 - ld a, [CurPartyMon] + ld a, [wCurPartyMon] cp $3 jr nc, .bottom_half_of_screen ld c, $0 diff --git a/engine/battle/battle_transition.asm b/engine/battle/battle_transition.asm index 452339e81..29b2d8663 100644 --- a/engine/battle/battle_transition.asm +++ b/engine/battle/battle_transition.asm @@ -198,12 +198,12 @@ BattleTransitionJumptable: ; 8c314 StartTrainerBattle_DetermineWhichAnimation: ; 8c365 (23:4365) ; The screen flashes a different number of times depending on the level of ; your lead Pokemon relative to the opponent's. -; BUG: BattleMonLevel and EnemyMonLevel are not set at this point, so whatever +; BUG: wBattleMonLevel and wEnemyMonLevel are not set at this point, so whatever ; values happen to be there will determine the animation. ld de, 0 - ld a, [BattleMonLevel] + ld a, [wBattleMonLevel] add 3 - ld hl, EnemyMonLevel + ld hl, wEnemyMonLevel cp [hl] jr nc, .okay set 0, e @@ -298,7 +298,7 @@ StartTrainerBattle_Flash: ; 8c3ab (23:43ab) StartTrainerBattle_SetUpForWavyOutro: ; 8c3e8 (23:43e8) farcall Function5602 - ld a, BANK(LYOverrides) + ld a, BANK(wLYOverrides) ld [rSVBK], a call StartTrainerBattle_NextScene @@ -334,8 +334,8 @@ StartTrainerBattle_SineWave: ; 8c408 (23:4408) ld d, [hl] add [hl] ld [hl], a - ld a, LYOverridesEnd - LYOverrides - ld bc, LYOverrides + ld a, wLYOverridesEnd - wLYOverrides + ld bc, wLYOverrides ld e, $0 .loop @@ -356,7 +356,7 @@ StartTrainerBattle_SineWave: ; 8c408 (23:4408) StartTrainerBattle_SetUpForSpinOutro: ; 8c43d (23:443d) farcall Function5602 - ld a, BANK(LYOverrides) + ld a, BANK(wLYOverrides) ld [rSVBK], a call StartTrainerBattle_NextScene xor a @@ -498,7 +498,7 @@ ENDM StartTrainerBattle_SetUpForRandomScatterOutro: ; 8c578 (23:4578) farcall Function5602 - ld a, BANK(LYOverrides) + ld a, BANK(wLYOverrides) ld [rSVBK], a call StartTrainerBattle_NextScene ld a, $10 @@ -566,13 +566,13 @@ StartTrainerBattle_SpeckleToBlack: ; 8c58f (23:458f) ret StartTrainerBattle_LoadPokeBallGraphics: ; 8c5dc (23:45dc) - ld a, [OtherTrainerClass] + ld a, [wOtherTrainerClass] and a jp z, .nextscene ; don't need to be here if wild xor a ld [hBGMapMode], a - hlcoord 0, 0, AttrMap + hlcoord 0, 0, wAttrMap ld bc, SCREEN_HEIGHT * SCREEN_WIDTH inc b inc c @@ -639,7 +639,7 @@ StartTrainerBattle_LoadPokeBallGraphics: ; 8c5dc (23:45dc) .cgb ld hl, .daypals - ld a, [TimeOfDayPal] + ld a, [wTimeOfDayPal] maskbits NUM_DAYTIMES cp DARKNESS_F jr nz, .daytime @@ -699,7 +699,7 @@ INCLUDE "gfx/overworld/trainer_battle_nite.pal" ; 8c6b1 .loadpokeballgfx - ld a, [OtherTrainerClass] + ld a, [wOtherTrainerClass] ld de, PokeBallTransition ret @@ -724,12 +724,12 @@ PokeBallTransition: WipeLYOverrides: ; 8c6d8 ld a, [rSVBK] push af - ld a, BANK(LYOverrides) + ld a, BANK(wLYOverrides) ld [rSVBK], a - ld hl, LYOverrides + ld hl, wLYOverrides call .wipe - ld hl, LYOverridesBackup + ld hl, wLYOverridesBackup call .wipe pop af diff --git a/engine/battle/checkbattlescene.asm b/engine/battle/checkbattlescene.asm index a33cc62e3..577c36e33 100644 --- a/engine/battle/checkbattlescene.asm +++ b/engine/battle/checkbattlescene.asm @@ -7,7 +7,7 @@ CheckBattleScene: ; 4ea44 cp LINK_MOBILE jr z, .mobile - ld a, [Options] + ld a, [wOptions] bit BATTLE_SCENE, a jr nz, .off diff --git a/engine/battle/consumehelditem.asm b/engine/battle/consumehelditem.asm index a6f7766fb..39ddbc27e 100644 --- a/engine/battle/consumehelditem.asm +++ b/engine/battle/consumehelditem.asm @@ -4,13 +4,13 @@ ConsumeHeldItem: ; 27192 push bc ld a, [hBattleTurn] and a - ld hl, OTPartyMon1Item - ld de, EnemyMonItem - ld a, [CurOTMon] + ld hl, wOTPartyMon1Item + ld de, wEnemyMonItem + ld a, [wCurOTMon] jr z, .theirturn - ld hl, PartyMon1Item - ld de, BattleMonItem - ld a, [CurBattleMon] + ld hl, wPartyMon1Item + ld de, wBattleMonItem + ld a, [wCurBattleMon] .theirturn push hl diff --git a/engine/battle/core.asm b/engine/battle/core.asm index 1a58b3df5..0fe77df40 100644 --- a/engine/battle/core.asm +++ b/engine/battle/core.asm @@ -4,11 +4,11 @@ DoBattle: ; 3c000 xor a ld [wBattleParticipantsNotFainted], a ld [wBattleParticipantsIncludingFainted], a - ld [wPlayerAction], a - ld [BattleEnded], a + ld [wBattlePlayerAction], a + ld [wBattleEnded], a inc a ld [wBattleHasJustStarted], a - ld hl, OTPartyMon1HP + ld hl, wOTPartyMon1HP ld bc, PARTYMON_STRUCT_LENGTH - 1 ld d, BATTLEACTION_SWITCH1 - 1 .loop @@ -52,33 +52,33 @@ DoBattle: ; 3c000 and a jp z, LostBattle call Call_LoadTempTileMapToTileMap - ld a, [BattleType] + ld a, [wBattleType] cp BATTLETYPE_DEBUG jp z, .tutorial_debug cp BATTLETYPE_TUTORIAL jp z, .tutorial_debug xor a - ld [CurPartyMon], a + ld [wCurPartyMon], a .loop2 call CheckIfCurPartyMonIsFitToFight jr nz, .alive2 - ld hl, CurPartyMon + ld hl, wCurPartyMon inc [hl] jr .loop2 .alive2 - ld a, [CurBattleMon] - ld [LastPlayerMon], a - ld a, [CurPartyMon] - ld [CurBattleMon], a + ld a, [wCurBattleMon] + ld [wLastPlayerMon], a + ld a, [wCurPartyMon] + ld [wCurBattleMon], a inc a - ld hl, PartySpecies - 1 + ld hl, wPartySpecies - 1 ld c, a ld b, 0 add hl, bc ld a, [hl] - ld [CurPartySpecies], a - ld [TempBattleMonSpecies], a + ld [wCurPartySpecies], a + ld [wTempBattleMonSpecies], a hlcoord 1, 5 ld a, 9 call SlideBattlePicOut @@ -154,7 +154,7 @@ WildFled_EnemyFled_LinkBattleCanceled: ; 3c0e5 .skip_sfx call SetPlayerTurn ld a, 1 - ld [BattleEnded], a + ld [wBattleEnded], a ret ; 3c12f @@ -170,8 +170,8 @@ BattleTurn: ; 3c12f ld [wBattleHasJustStarted], a ld [wPlayerJustGotFrozen], a ld [wEnemyJustGotFrozen], a - ld [CurDamage], a - ld [CurDamage + 1], a + ld [wCurDamage], a + ld [wCurDamage + 1], a call HandleBerserkGene call UpdateBattleMonInParty @@ -190,7 +190,7 @@ BattleTurn: ; 3c12f .loop1 call BattleMenu jr c, .quit - ld a, [BattleEnded] + ld a, [wBattleEnded] and a jr nz, .quit ld a, [wForcedSwitch] ; roared/whirlwinded/teleported @@ -217,12 +217,12 @@ BattleTurn: ; 3c12f and a jr nz, .quit - ld a, [BattleEnded] + ld a, [wBattleEnded] and a jr nz, .quit call HandleBetweenTurnEffects - ld a, [BattleEnded] + ld a, [wBattleEnded] and a jr nz, .quit jp .loop @@ -303,7 +303,7 @@ CheckFaint_PlayerThenEnemy: ; 3c23c call HasPlayerFainted jr nz, .PlayerNotFainted call HandlePlayerMonFaint - ld a, [BattleEnded] + ld a, [wBattleEnded] and a jr nz, .BattleIsOver @@ -311,7 +311,7 @@ CheckFaint_PlayerThenEnemy: ; 3c23c call HasEnemyFainted jr nz, .BattleContinues call HandleEnemyMonFaint - ld a, [BattleEnded] + ld a, [wBattleEnded] and a jr nz, .BattleIsOver @@ -328,7 +328,7 @@ CheckFaint_EnemyThenPlayer: ; 3c25c call HasEnemyFainted jr nz, .EnemyNotFainted call HandleEnemyMonFaint - ld a, [BattleEnded] + ld a, [wBattleEnded] and a jr nz, .BattleIsOver @@ -336,7 +336,7 @@ CheckFaint_EnemyThenPlayer: ; 3c25c call HasPlayerFainted jr nz, .BattleContinues call HandlePlayerMonFaint - ld a, [BattleEnded] + ld a, [wBattleEnded] and a jr nz, .BattleIsOver @@ -363,15 +363,15 @@ HandleBerserkGene: ; 3c27c .player call SetPlayerTurn - ld de, PartyMon1Item - ld a, [CurBattleMon] + ld de, wPartyMon1Item + ld a, [wCurBattleMon] ld b, a jr .go .enemy call SetEnemyTurn - ld de, OTPartyMon1Item - ld a, [CurOTMon] + ld de, wOTPartyMon1Item + ld a, [wCurOTMon] ld b, a ; jr .go @@ -404,8 +404,8 @@ HandleBerserkGene: ; 3c27c push af xor a ld [hl], a - ld [AttackMissed], a - ld [EffectFailed], a + ld [wAttackMissed], a + ld [wEffectFailed], a farcall BattleCommand_AttackUp2 pop af pop hl @@ -455,7 +455,7 @@ DetermineMoveOrder: ; 3c314 jr z, .use_move sub BATTLEACTION_SWITCH1 jr c, .use_move - ld a, [wPlayerAction] + ld a, [wBattlePlayerAction] cp $2 jr nz, .switch ld a, [hSerialConnectionStatus] @@ -480,7 +480,7 @@ DetermineMoveOrder: ; 3c314 jp .enemy_first .use_move - ld a, [wPlayerAction] + ld a, [wBattlePlayerAction] and a jp nz, .player_first call CompareMovePriority @@ -536,8 +536,8 @@ DetermineMoveOrder: ; 3c314 jr .speed_check .speed_check - ld de, BattleMonSpeed - ld hl, EnemyMonSpeed + ld de, wBattleMonSpeed + ld hl, wEnemyMonSpeed ld c, 2 call StringCmp jr z, .speed_tie @@ -568,7 +568,7 @@ DetermineMoveOrder: ; 3c314 ; 3c3f5 CheckContestBattleOver: ; 3c3f5 - ld a, [BattleType] + ld a, [wBattleType] cp BATTLETYPE_CONTEST jr nz, .contest_not_over ld a, [wParkBallsRemaining] @@ -587,20 +587,20 @@ CheckContestBattleOver: ; 3c3f5 ; 3c410 CheckPlayerLockedIn: ; 3c410 - ld a, [PlayerSubStatus4] + ld a, [wPlayerSubStatus4] and 1 << SUBSTATUS_RECHARGE jp nz, .quit - ld hl, EnemySubStatus3 + ld hl, wEnemySubStatus3 res SUBSTATUS_FLINCHED, [hl] - ld hl, PlayerSubStatus3 + ld hl, wPlayerSubStatus3 res SUBSTATUS_FLINCHED, [hl] ld a, [hl] and 1 << SUBSTATUS_CHARGED | 1 << SUBSTATUS_RAMPAGE jp nz, .quit - ld hl, PlayerSubStatus1 + ld hl, wPlayerSubStatus1 bit SUBSTATUS_ROLLOUT, [hl] jp nz, .quit @@ -615,31 +615,31 @@ CheckPlayerLockedIn: ; 3c410 ParsePlayerAction: ; 3c434 call CheckPlayerLockedIn jp c, .locked_in - ld hl, PlayerSubStatus5 + ld hl, wPlayerSubStatus5 bit SUBSTATUS_ENCORED, [hl] jr z, .not_encored - ld a, [LastPlayerMove] - ld [CurPlayerMove], a + ld a, [wLastPlayerMove] + ld [wCurPlayerMove], a jr .encored .not_encored - ld a, [wPlayerAction] + ld a, [wBattlePlayerAction] cp $2 jr z, .reset_rage and a jr nz, .reset_bide - ld a, [PlayerSubStatus3] + ld a, [wPlayerSubStatus3] and 1 << SUBSTATUS_BIDE jr nz, .locked_in xor a ld [wMoveSelectionMenuType], a inc a ; POUND - ld [FXAnimID], a + ld [wFXAnimID], a call MoveSelectionScreen push af call Call_LoadTempTileMapToTileMap call UpdateBattleHuds - ld a, [CurPlayerMove] + ld a, [wCurPlayerMove] cp STRUGGLE jr z, .struggle call PlayClickSFX @@ -659,13 +659,13 @@ ParsePlayerAction: ; 3c434 cp EFFECT_FURY_CUTTER jr z, .continue_fury_cutter xor a - ld [PlayerFuryCutterCount], a + ld [wPlayerFuryCutterCount], a .continue_fury_cutter ld a, [wPlayerMoveStruct + MOVE_EFFECT] cp EFFECT_RAGE jr z, .continue_rage - ld hl, PlayerSubStatus4 + ld hl, wPlayerSubStatus4 res SUBSTATUS_RAGE, [hl] xor a ld [wPlayerRageCounter], a @@ -677,19 +677,19 @@ ParsePlayerAction: ; 3c434 cp EFFECT_ENDURE jr z, .continue_protect xor a - ld [PlayerProtectCount], a + ld [wPlayerProtectCount], a jr .continue_protect .reset_bide - ld hl, PlayerSubStatus3 + ld hl, wPlayerSubStatus3 res SUBSTATUS_BIDE, [hl] .locked_in xor a - ld [PlayerFuryCutterCount], a - ld [PlayerProtectCount], a + ld [wPlayerFuryCutterCount], a + ld [wPlayerProtectCount], a ld [wPlayerRageCounter], a - ld hl, PlayerSubStatus4 + ld hl, wPlayerSubStatus4 res SUBSTATUS_RAGE, [hl] .continue_protect @@ -699,10 +699,10 @@ ParsePlayerAction: ; 3c434 .reset_rage xor a - ld [PlayerFuryCutterCount], a - ld [PlayerProtectCount], a + ld [wPlayerFuryCutterCount], a + ld [wPlayerProtectCount], a ld [wPlayerRageCounter], a - ld hl, PlayerSubStatus4 + ld hl, wPlayerSubStatus4 res SUBSTATUS_RAGE, [hl] xor a ret @@ -718,15 +718,15 @@ HandleEncore: ; 3c4df .player_1 call .do_enemy .do_player - ld hl, PlayerSubStatus5 + ld hl, wPlayerSubStatus5 bit SUBSTATUS_ENCORED, [hl] ret z - ld a, [PlayerEncoreCount] + ld a, [wPlayerEncoreCount] dec a - ld [PlayerEncoreCount], a + ld [wPlayerEncoreCount], a jr z, .end_player_encore - ld hl, BattleMonPP - ld a, [CurMoveNum] + ld hl, wBattleMonPP + ld a, [wCurMoveNum] ld c, a ld b, 0 add hl, bc @@ -735,22 +735,22 @@ HandleEncore: ; 3c4df ret nz .end_player_encore - ld hl, PlayerSubStatus5 + ld hl, wPlayerSubStatus5 res SUBSTATUS_ENCORED, [hl] call SetEnemyTurn ld hl, BattleText_TargetsEncoreEnded jp StdBattleTextBox .do_enemy - ld hl, EnemySubStatus5 + ld hl, wEnemySubStatus5 bit SUBSTATUS_ENCORED, [hl] ret z - ld a, [EnemyEncoreCount] + ld a, [wEnemyEncoreCount] dec a - ld [EnemyEncoreCount], a + ld [wEnemyEncoreCount], a jr z, .end_enemy_encore - ld hl, EnemyMonPP - ld a, [CurEnemyMoveNum] + ld hl, wEnemyMonPP + ld a, [wCurEnemyMoveNum] ld c, a ld b, 0 add hl, bc @@ -759,7 +759,7 @@ HandleEncore: ; 3c4df ret nz .end_enemy_encore - ld hl, EnemySubStatus5 + ld hl, wEnemySubStatus5 res SUBSTATUS_ENCORED, [hl] call SetPlayerTurn ld hl, BattleText_TargetsEncoreEnded @@ -771,7 +771,7 @@ TryEnemyFlee: ; 3c543 dec a jr nz, .Stay - ld a, [PlayerSubStatus5] + ld a, [wPlayerSubStatus5] bit SUBSTATUS_CANT_RUN, a jr nz, .Stay @@ -779,11 +779,11 @@ TryEnemyFlee: ; 3c543 and a jr nz, .Stay - ld a, [EnemyMonStatus] + ld a, [wEnemyMonStatus] and 1 << FRZ | SLP jr nz, .Stay - ld a, [TempEnemyMonSpecies] + ld a, [wTempEnemyMonSpecies] ld de, 1 ld hl, AlwaysFleeMons call IsInArray @@ -795,7 +795,7 @@ TryEnemyFlee: ; 3c543 jr nc, .Stay push bc - ld a, [TempEnemyMonSpecies] + ld a, [wTempEnemyMonSpecies] ld de, 1 ld hl, OftenFleeMons call IsInArray @@ -806,7 +806,7 @@ TryEnemyFlee: ; 3c543 cp 1 + (10 percent) jr nc, .Stay - ld a, [TempEnemyMonSpecies] + ld a, [wTempEnemyMonSpecies] ld de, 1 ld hl, SometimesFleeMons call IsInArray @@ -827,11 +827,11 @@ CompareMovePriority: ; 3c5b4 ; Compare the priority of the player and enemy's moves. ; Return carry if the player goes first, or z if they match. - ld a, [CurPlayerMove] + ld a, [wCurPlayerMove] call GetMovePriority ld b, a push bc - ld a, [CurEnemyMove] + ld a, [wCurEnemyMove] call GetMovePriority pop bc cp b @@ -920,7 +920,7 @@ Battle_EnemyFirst: ; 3c5fe jp z, HandlePlayerMonFaint call RefreshBattleHuds xor a - ld [wPlayerAction], a + ld [wBattlePlayerAction], a ret ; 3c664 @@ -970,7 +970,7 @@ Battle_PlayerFirst: ; 3c664 jp z, HandleEnemyMonFaint call RefreshBattleHuds xor a - ld [wPlayerAction], a + ld [wBattlePlayerAction], a ret ; 3c6cf @@ -1011,11 +1011,11 @@ HasUserFainted: ; 3c706 and a jr z, HasPlayerFainted HasEnemyFainted: ; 3c70b - ld hl, EnemyMonHP + ld hl, wEnemyMonHP jr CheckIfHPIsZero HasPlayerFainted: ; 3c710 - ld hl, BattleMonHP + ld hl, wBattleMonHP CheckIfHPIsZero: ; 3c713 ld a, [hli] @@ -1052,11 +1052,11 @@ ResidualDamage: ; 3c716 ld [wNumHits], a call Call_PlayBattleAnim_OnlyIfVisible call GetEighthMaxHP - ld de, PlayerToxicCount + ld de, wPlayerToxicCount ld a, [hBattleTurn] and a jr z, .check_toxic - ld de, EnemyToxicCount + ld de, wEnemyToxicCount .check_toxic ld a, BATTLE_VARS_SUBSTATUS5 @@ -1141,11 +1141,11 @@ ResidualDamage: ; 3c716 call StdBattleTextBox .not_cursed - ld hl, BattleMonHP + ld hl, wBattleMonHP ld a, [hBattleTurn] and a jr z, .check_fainted - ld hl, EnemyMonHP + ld hl, wEnemyMonHP .check_fainted ld a, [hli] @@ -1175,11 +1175,11 @@ HandlePerishSong: ; 3c801 call SetPlayerTurn .do_it - ld hl, PlayerPerishCount + ld hl, wPlayerPerishCount ld a, [hBattleTurn] and a jr z, .got_count - ld hl, EnemyPerishCount + ld hl, wEnemyPerishCount .got_count ld a, BATTLE_VARS_SUBSTATUS1 @@ -1200,12 +1200,12 @@ HandlePerishSong: ; 3c801 ld a, [hBattleTurn] and a jr nz, .kill_enemy - ld hl, BattleMonHP + ld hl, wBattleMonHP xor a ld [hli], a ld [hl], a - ld hl, PartyMon1HP - ld a, [CurBattleMon] + ld hl, wPartyMon1HP + ld a, [wCurBattleMon] call GetPartyLocation xor a ld [hli], a @@ -1213,15 +1213,15 @@ HandlePerishSong: ; 3c801 ret .kill_enemy - ld hl, EnemyMonHP + ld hl, wEnemyMonHP xor a ld [hli], a ld [hl], a ld a, [wBattleMode] dec a ret z - ld hl, OTPartyMon1HP - ld a, [CurOTMon] + ld hl, wOTPartyMon1HP + ld a, [wCurOTMon] call GetPartyLocation xor a ld [hli], a @@ -1264,7 +1264,7 @@ HandleWrap: ; 3c874 ld a, [de] ld [wd265], a - ld [FXAnimID], a + ld [wFXAnimID], a call GetMoveName dec [hl] jr z, .release_from_bounds @@ -1277,7 +1277,7 @@ HandleWrap: ; 3c874 call SwitchTurnCore xor a ld [wNumHits], a - ld [FXAnimID + 1], a + ld [wFXAnimID + 1], a predef PlayBattleAnim call SwitchTurnCore @@ -1324,11 +1324,11 @@ HandleLeftovers: ; 3c8eb cp HELD_LEFTOVERS ret nz - ld hl, BattleMonHP + ld hl, wBattleMonHP ld a, [hBattleTurn] and a jr z, .got_hp - ld hl, EnemyMonHP + ld hl, wEnemyMonHP .got_hp ; Don't restore if we're already at max HP @@ -1370,13 +1370,13 @@ HandleMysteryberry: ; 3c93c ld a, b cp HELD_RESTORE_PP jr nz, .quit - ld hl, PartyMon1PP - ld a, [CurBattleMon] + ld hl, wPartyMon1PP + ld a, [wCurBattleMon] call GetPartyLocation ld d, h ld e, l - ld hl, PartyMon1Moves - ld a, [CurBattleMon] + ld hl, wPartyMon1Moves + ld a, [wCurBattleMon] call GetPartyLocation ld a, [hBattleTurn] and a @@ -1386,13 +1386,13 @@ HandleMysteryberry: ; 3c93c ld a, [wBattleMode] dec a jr z, .wild - ld hl, OTPartyMon1PP - ld a, [CurOTMon] + ld hl, wOTPartyMon1PP + ld a, [wCurOTMon] call GetPartyLocation ld d, h ld e, l - ld hl, OTPartyMon1Moves - ld a, [CurOTMon] + ld hl, wOTPartyMon1Moves + ld a, [wCurOTMon] call GetPartyLocation .wild @@ -1429,13 +1429,13 @@ HandleMysteryberry: ; 3c93c push bc ld a, [hl] ld [wd265], a - ld de, BattleMonMoves - 1 - ld hl, BattleMonPP + ld de, wBattleMonMoves - 1 + ld hl, wBattleMonPP ld a, [hBattleTurn] and a jr z, .player_pp - ld de, EnemyMonMoves - 1 - ld hl, EnemyMonPP + ld de, wEnemyMonMoves - 1 + ld hl, wEnemyMonPP .player_pp inc de pop bc @@ -1453,9 +1453,9 @@ HandleMysteryberry: ; 3c93c jr nz, .skip_checks ld a, [hBattleTurn] and a - ld a, [PlayerSubStatus5] + ld a, [wPlayerSubStatus5] jr z, .check_transform - ld a, [EnemySubStatus5] + ld a, [wEnemySubStatus5] .check_transform bit SUBSTATUS_TRANSFORMED, a jr nz, .skip_checks @@ -1531,14 +1531,14 @@ HandleFutureSight: ; 3ca26 callfar UpdateMoveData xor a - ld [AttackMissed], a - ld [AlreadyDisobeyed], a + ld [wAttackMissed], a + ld [wAlreadyDisobeyed], a ld a, 10 - ld [TypeModifier], a + ld [wTypeModifier], a callfar DoMove xor a - ld [CurDamage], a - ld [CurDamage + 1], a + ld [wCurDamage], a + ld [wCurDamage + 1], a ld a, BATTLE_VARS_MOVE call GetBattleVarAddr @@ -1559,7 +1559,7 @@ HanleDefrost: ; 3ca8f .enemy_first call .do_enemy_turn .do_player_turn - ld a, [BattleMonStatus] + ld a, [wBattleMonStatus] bit FRZ, a ret z @@ -1571,9 +1571,9 @@ HanleDefrost: ; 3ca8f cp 10 percent ret nc xor a - ld [BattleMonStatus], a - ld a, [CurBattleMon] - ld hl, PartyMon1Status + ld [wBattleMonStatus], a + ld a, [wCurBattleMon] + ld hl, wPartyMon1Status call GetPartyLocation ld [hl], 0 call UpdateBattleHuds @@ -1582,7 +1582,7 @@ HanleDefrost: ; 3ca8f jp StdBattleTextBox .do_enemy_turn - ld a, [EnemyMonStatus] + ld a, [wEnemyMonStatus] bit FRZ, a ret z ld a, [wEnemyJustGotFrozen] @@ -1592,13 +1592,13 @@ HanleDefrost: ; 3ca8f cp 10 percent ret nc xor a - ld [EnemyMonStatus], a + ld [wEnemyMonStatus], a ld a, [wBattleMode] dec a jr z, .wild - ld a, [CurOTMon] - ld hl, OTPartyMon1Status + ld a, [wCurOTMon] + ld hl, wOTPartyMon1Status call GetPartyLocation ld [hl], 0 .wild @@ -1619,26 +1619,26 @@ HandleSafeguard: ; 3cafb .player1 call .CheckEnemy .CheckPlayer: - ld a, [PlayerScreens] + ld a, [wPlayerScreens] bit SCREENS_SAFEGUARD, a ret z - ld hl, PlayerSafeguardCount + ld hl, wPlayerSafeguardCount dec [hl] ret nz res SCREENS_SAFEGUARD, a - ld [PlayerScreens], a + ld [wPlayerScreens], a xor a jr .print .CheckEnemy: - ld a, [EnemyScreens] + ld a, [wEnemyScreens] bit SCREENS_SAFEGUARD, a ret z - ld hl, EnemySafeguardCount + ld hl, wEnemySafeguardCount dec [hl] ret nz res SCREENS_SAFEGUARD, a - ld [EnemyScreens], a + ld [wEnemyScreens], a ld a, $1 .print @@ -1660,16 +1660,16 @@ HandleScreens: ; 3cb36 call SetPlayerTurn ld de, .Your call .Copy - ld hl, PlayerScreens - ld de, PlayerLightScreenCount + ld hl, wPlayerScreens + ld de, wPlayerLightScreenCount jr .TickScreens .CheckEnemy: call SetEnemyTurn ld de, .Enemy call .Copy - ld hl, EnemyScreens - ld de, EnemyLightScreenCount + ld hl, wEnemyScreens + ld de, wEnemyLightScreenCount .TickScreens: bit SCREENS_LIGHT_SCREEN, [hl] @@ -1679,7 +1679,7 @@ HandleScreens: ; 3cb36 ret .Copy: - ld hl, StringBuffer1 + ld hl, wStringBuffer1 jp CopyName2 ; 3cb75 @@ -1716,18 +1716,18 @@ HandleScreens: ; 3cb36 ; 3cb9e HandleWeather: ; 3cb9e - ld a, [Weather] + ld a, [wBattleWeather] cp WEATHER_NONE ret z - ld hl, WeatherCount + ld hl, wWeatherCount dec [hl] jr z, .ended ld hl, .WeatherMessages call .PrintWeatherMessage - ld a, [Weather] + ld a, [wBattleWeather] cp WEATHER_SANDSTORM ret nz @@ -1752,11 +1752,11 @@ HandleWeather: ; 3cb9e bit SUBSTATUS_UNDERGROUND, a ret nz - ld hl, BattleMonType1 + ld hl, wBattleMonType1 ld a, [hBattleTurn] and a jr z, .ok - ld hl, EnemyMonType1 + ld hl, wEnemyMonType1 .ok ld a, [hli] cp ROCK @@ -1790,11 +1790,11 @@ HandleWeather: ; 3cb9e ld hl, .WeatherEndedMessages call .PrintWeatherMessage xor a - ld [Weather], a + ld [wBattleWeather], a ret .PrintWeatherMessage: - ld a, [Weather] + ld a, [wBattleWeather] dec a ld c, a ld b, 0 @@ -1828,34 +1828,34 @@ SubtractHPFromUser: ; 3cc3f ; 3cc45 SubtractHP: ; 3cc45 - ld hl, BattleMonHP + ld hl, wBattleMonHP ld a, [hBattleTurn] and a jr z, .ok - ld hl, EnemyMonHP + ld hl, wEnemyMonHP .ok inc hl ld a, [hl] - ld [Buffer3], a + ld [wBuffer3], a sub c ld [hld], a - ld [Buffer5], a + ld [wBuffer5], a ld a, [hl] - ld [Buffer4], a + ld [wBuffer4], a sbc b ld [hl], a - ld [Buffer6], a + ld [wBuffer6], a ret nc - ld a, [Buffer3] + ld a, [wBuffer3] ld c, a - ld a, [Buffer4] + ld a, [wBuffer4] ld b, a xor a ld [hli], a ld [hl], a - ld [Buffer5], a - ld [Buffer6], a + ld [wBuffer5], a + ld [wBuffer6], a ret ; 3cc76 @@ -1926,30 +1926,30 @@ GetHalfMaxHP: ; 3cc9f ; 3ccac GetMaxHP: ; 3ccac -; output: bc, Buffer1-2 +; output: bc, wBuffer1-2 - ld hl, BattleMonMaxHP + ld hl, wBattleMonMaxHP ld a, [hBattleTurn] and a jr z, .ok - ld hl, EnemyMonMaxHP + ld hl, wEnemyMonMaxHP .ok ld a, [hli] - ld [Buffer2], a + ld [wBuffer2], a ld b, a ld a, [hl] - ld [Buffer1], a + ld [wBuffer1], a ld c, a ret ; 3ccc2 Unreferenced_GetHalfHP: ; 3ccc2 - ld hl, BattleMonHP + ld hl, wBattleMonHP ld a, [hBattleTurn] and a jr z, .ok - ld hl, EnemyMonHP + ld hl, wEnemyMonHP .ok ld a, [hli] ld b, a @@ -1958,18 +1958,18 @@ Unreferenced_GetHalfHP: ; 3ccc2 srl b rr c ld a, [hli] - ld [Buffer2], a + ld [wBuffer2], a ld a, [hl] - ld [Buffer1], a + ld [wBuffer1], a ret ; 3ccde CheckUserHasEnoughHP: ; 3ccde - ld hl, BattleMonHP + 1 + ld hl, wBattleMonHP + 1 ld a, [hBattleTurn] and a jr z, .ok - ld hl, EnemyMonHP + 1 + ld hl, wEnemyMonHP + 1 .ok ld a, c sub [hl] @@ -1980,43 +1980,43 @@ CheckUserHasEnoughHP: ; 3ccde ; 3ccef RestoreHP ; 3ccef - ld hl, EnemyMonMaxHP + ld hl, wEnemyMonMaxHP ld a, [hBattleTurn] and a jr z, .ok - ld hl, BattleMonMaxHP + ld hl, wBattleMonMaxHP .ok ld a, [hli] - ld [Buffer2], a + ld [wBuffer2], a ld a, [hld] - ld [Buffer1], a + ld [wBuffer1], a dec hl ld a, [hl] - ld [Buffer3], a + ld [wBuffer3], a add c ld [hld], a - ld [Buffer5], a + ld [wBuffer5], a ld a, [hl] - ld [Buffer4], a + ld [wBuffer4], a adc b ld [hli], a - ld [Buffer6], a + ld [wBuffer6], a - ld a, [Buffer1] + ld a, [wBuffer1] ld c, a ld a, [hld] sub c - ld a, [Buffer2] + ld a, [wBuffer2] ld b, a ld a, [hl] sbc b jr c, .asm_3cd2d ld a, b ld [hli], a - ld [Buffer6], a + ld [wBuffer6], a ld a, c ld [hl], a - ld [Buffer5], a + ld [wBuffer5], a .asm_3cd2d call SwitchTurnCore @@ -2047,7 +2047,7 @@ UpdateHPBar: ; 3cd3c HandleEnemyMonFaint: ; 3cd55 call FaintEnemyPokemon - ld hl, BattleMonHP + ld hl, wBattleMonHP ld a, [hli] or [hl] call z, FaintYourPokemon @@ -2059,7 +2059,7 @@ HandleEnemyMonFaint: ; 3cd55 and a jp z, LostBattle - ld hl, BattleMonHP + ld hl, wBattleMonHP ld a, [hli] or [hl] call nz, UpdatePlayerHUD @@ -2074,14 +2074,14 @@ HandleEnemyMonFaint: ; 3cd55 jr nz, .trainer ld a, 1 - ld [BattleEnded], a + ld [wBattleEnded], a ret .trainer call CheckEnemyTrainerDefeated jp z, WinTrainerBattle - ld hl, BattleMonHP + ld hl, wBattleMonHP ld a, [hli] or [hl] jr nz, .player_mon_not_fainted @@ -2090,7 +2090,7 @@ HandleEnemyMonFaint: ; 3cd55 jr nc, .dont_flee ld a, 1 - ld [BattleEnded], a + ld [wBattleEnded], a ret .dont_flee @@ -2099,18 +2099,18 @@ HandleEnemyMonFaint: ; 3cd55 jp c, WildFled_EnemyFled_LinkBattleCanceled ld a, $1 - ld [wPlayerAction], a + ld [wBattlePlayerAction], a call HandleEnemySwitch jp z, WildFled_EnemyFled_LinkBattleCanceled jr DoubleSwitch .player_mon_not_fainted ld a, $1 - ld [wPlayerAction], a + ld [wBattlePlayerAction], a call HandleEnemySwitch jp z, WildFled_EnemyFled_LinkBattleCanceled xor a - ld [wPlayerAction], a + ld [wBattlePlayerAction], a ret ; 3cdca @@ -2128,19 +2128,19 @@ DoubleSwitch: ; 3cdca jr .done .player_1 - ld a, [CurPartyMon] + ld a, [wCurPartyMon] push af ld a, $1 call EnemyPartyMonEntrance call ClearSprites call LoadTileMapToTempTileMap pop af - ld [CurPartyMon], a + ld [wCurPartyMon], a call PlayerPartyMonEntrance .done xor a - ld [wPlayerAction], a + ld [wBattlePlayerAction], a ret ; 3ce01 @@ -2149,18 +2149,18 @@ UpdateBattleStateAndExperienceAfterEnemyFaint: ; 3ce01 ld a, [wBattleMode] dec a jr z, .wild - ld a, [CurOTMon] - ld hl, OTPartyMon1HP + ld a, [wCurOTMon] + ld hl, wOTPartyMon1HP call GetPartyLocation xor a ld [hli], a ld [hl], a .wild - ld hl, PlayerSubStatus3 + ld hl, wPlayerSubStatus3 res SUBSTATUS_IN_LOOP, [hl] xor a - ld hl, EnemyDamageTaken + ld hl, wEnemyDamageTaken ld [hli], a ld [hl], a call NewEnemyMonStatus @@ -2173,10 +2173,10 @@ UpdateBattleStateAndExperienceAfterEnemyFaint: ; 3ce01 .wild2 call StopDangerSound ld a, $1 - ld [wDanger], a + ld [wBattleLowHealthAlarm], a .trainer - ld hl, BattleMonHP + ld hl, wBattleMonHP ld a, [hli] or [hl] jr nz, .player_mon_did_not_faint @@ -2200,8 +2200,8 @@ UpdateBattleStateAndExperienceAfterEnemyFaint: ; 3ce01 ld [wBattleResult], a call IsAnyMonHoldingExpShare jr z, .skip_exp - ld hl, EnemyMonBaseStats - ld b, EnemyMonEnd - EnemyMonBaseStats + ld hl, wEnemyMonBaseStats + ld b, wEnemyMonEnd - wEnemyMonBaseStats .loop srl [hl] inc hl @@ -2209,9 +2209,9 @@ UpdateBattleStateAndExperienceAfterEnemyFaint: ; 3ce01 jr nz, .loop .skip_exp - ld hl, EnemyMonBaseStats + ld hl, wEnemyMonBaseStats ld de, wBackupEnemyMonBaseStats - ld bc, EnemyMonEnd - EnemyMonBaseStats + ld bc, wEnemyMonEnd - wEnemyMonBaseStats call CopyBytes xor a ld [wGivingExperienceToExpShareHolders], a @@ -2224,8 +2224,8 @@ UpdateBattleStateAndExperienceAfterEnemyFaint: ; 3ce01 ld a, d ld [wBattleParticipantsNotFainted], a ld hl, wBackupEnemyMonBaseStats - ld de, EnemyMonBaseStats - ld bc, EnemyMonEnd - EnemyMonBaseStats + ld de, wEnemyMonBaseStats + ld bc, wEnemyMonEnd - wEnemyMonBaseStats call CopyBytes ld a, $1 ld [wGivingExperienceToExpShareHolders], a @@ -2236,9 +2236,9 @@ UpdateBattleStateAndExperienceAfterEnemyFaint: ; 3ce01 ; 3ceaa IsAnyMonHoldingExpShare: ; 3ceaa - ld a, [PartyCount] + ld a, [wPartyCount] ld b, a - ld hl, PartyMon1 + ld hl, wPartyMon1 ld c, 1 ld d, 0 .loop @@ -2293,7 +2293,7 @@ IsAnyMonHoldingExpShare: ; 3ceaa StopDangerSound: ; 3ceec xor a - ld [Danger], a + ld [wLowHealthAlarm], a ret ; 3cef1 @@ -2301,8 +2301,8 @@ FaintYourPokemon: ; 3cef1 call StopDangerSound call WaitSFX ld a, $f0 - ld [CryTracks], a - ld a, [BattleMonSpecies] + ld [wCryTracks], a + ld a, [wBattleMonSpecies] call PlayStereoCry call PlayerMonFaintedAnimation hlcoord 9, 7 @@ -2327,10 +2327,10 @@ FaintEnemyPokemon: ; 3cf14 ; 3cf35 CheckEnemyTrainerDefeated: ; 3cf35 - ld a, [OTPartyCount] + ld a, [wOTPartyCount] ld b, a xor a - ld hl, OTPartyMon1HP + ld hl, wOTPartyMon1HP ld de, PARTYMON_STRUCT_LENGTH .loop @@ -2347,7 +2347,7 @@ CheckEnemyTrainerDefeated: ; 3cf35 ; 3cf4a HandleEnemySwitch: ; 3cf4a - ld hl, EnemyHPPal + ld hl, wEnemyHPPal ld e, HP_BAR_LENGTH_PX call UpdateHPPal call WaitBGMap @@ -2364,7 +2364,7 @@ HandleEnemySwitch: ; 3cf4a call Call_LoadTempTileMapToTileMap .not_linked - ld hl, BattleMonHP + ld hl, wBattleMonHP ld a, [hli] or [hl] ld a, $0 @@ -2394,7 +2394,7 @@ EnemyPartyMonEntrance: ; 3cf78 call SpikesDamage xor a ld [wEnemyMoveStruct + MOVE_ANIM], a - ld [wPlayerAction], a + ld [wBattlePlayerAction], a inc a ret ; 3cfa4 @@ -2403,8 +2403,8 @@ WinTrainerBattle: ; 3cfa4 ; Player won the battle call StopDangerSound ld a, $1 - ld [wDanger], a - ld [BattleEnded], a + ld [wBattleLowHealthAlarm], a + ld [wBattleEnded], a ld a, [wLinkMode] and a ld a, b @@ -2419,14 +2419,14 @@ WinTrainerBattle: ; 3cfa4 and a ret nz - ld a, [InBattleTowerBattle] + ld a, [wInBattleTowerBattle] bit 0, a jr nz, .battle_tower call BattleWinSlideInEnemyTrainerFrontpic ld c, 40 call DelayFrames - ld a, [BattleType] + ld a, [wBattleType] cp BATTLETYPE_CANLOSE jr nz, .skip_heal predef HealParty @@ -2535,7 +2535,7 @@ WinTrainerBattle: ; 3cfa4 .AddMoneyToWallet: ; 3d08d push bc ld hl, wBattleReward + 2 - ld de, Money + 2 + ld de, wMoney + 2 call AddBattleMoneyToAccount pop bc ret @@ -2652,7 +2652,7 @@ IsGymLeader: ; 0x3d128 ld hl, GymLeaders IsGymLeaderCommon: push de - ld a, [OtherTrainerClass] + ld a, [wOtherTrainerClass] ld de, $1 call IsInArray pop de @@ -2663,7 +2663,7 @@ INCLUDE "data/trainers/leaders.asm" HandlePlayerMonFaint: ; 3d14e call FaintYourPokemon - ld hl, EnemyMonHP + ld hl, wEnemyMonHP ld a, [hli] or [hl] call z, FaintEnemyPokemon @@ -2674,7 +2674,7 @@ HandlePlayerMonFaint: ; 3d14e ld a, d and a jp z, LostBattle - ld hl, EnemyMonHP + ld hl, wEnemyMonHP ld a, [hli] or [hl] jr nz, .notfainted @@ -2683,7 +2683,7 @@ HandlePlayerMonFaint: ; 3d14e dec a jr nz, .trainer ld a, $1 - ld [BattleEnded], a + ld [wBattleEnded], a ret .trainer @@ -2694,7 +2694,7 @@ HandlePlayerMonFaint: ; 3d14e call AskUseNextPokemon jr nc, .switch ld a, $1 - ld [BattleEnded], a + ld [wBattleEnded], a ret .switch @@ -2705,40 +2705,40 @@ HandlePlayerMonFaint: ; 3d14e and a ret nz ld a, $1 - ld [wPlayerAction], a + ld [wBattlePlayerAction], a call HandleEnemySwitch jp z, WildFled_EnemyFled_LinkBattleCanceled jp DoubleSwitch ; 3d1aa PlayerMonFaintHappinessMod: ; 3d1aa - ld a, [CurBattleMon] + ld a, [wCurBattleMon] ld c, a ld hl, wBattleParticipantsNotFainted ld b, RESET_FLAG predef SmallFarFlagAction - ld hl, EnemySubStatus3 + ld hl, wEnemySubStatus3 res SUBSTATUS_IN_LOOP, [hl] xor a - ld [Danger], a - ld hl, PlayerDamageTaken + ld [wLowHealthAlarm], a + ld hl, wPlayerDamageTaken ld [hli], a ld [hl], a - ld [BattleMonStatus], a + ld [wBattleMonStatus], a call UpdateBattleMonInParty ld c, HAPPINESS_FAINTED ; If TheirLevel > (YourLevel + 30), use a different parameter - ld a, [BattleMonLevel] + ld a, [wBattleMonLevel] add 30 ld b, a - ld a, [EnemyMonLevel] + ld a, [wEnemyMonLevel] cp b jr c, .got_param ld c, HAPPINESS_BEATENBYSTRONGFOE .got_param - ld a, [CurBattleMon] - ld [CurPartyMon], a + ld a, [wCurBattleMon] + ld [wCurPartyMon], a callfar ChangeHappiness ld a, [wBattleResult] and %11000000 @@ -2774,8 +2774,8 @@ AskUseNextPokemon: ; 3d1f8 ld a, [wMenuCursorY] cp $1 ; YES jr z, .loop - ld hl, PartyMon1Speed - ld de, EnemyMonSpeed + ld hl, wPartyMon1Speed + ld de, wEnemyMonSpeed jp TryToRunAwayFromBattle ; 3d227 @@ -2788,15 +2788,15 @@ ForcePlayerMonChoice: ; 3d227 and a jr z, .skip_link ld a, $1 - ld [wPlayerAction], a + ld [wBattlePlayerAction], a call LinkBattleSendReceiveAction .skip_link xor a - ld [wPlayerAction], a + ld [wBattlePlayerAction], a call CheckMobileBattleError jr c, .enemy_fainted_mobile_error - ld hl, EnemyMonHP + ld hl, wEnemyMonHP ld a, [hli] or [hl] jr nz, .send_out_pokemon @@ -2816,10 +2816,10 @@ ForcePlayerMonChoice: ; 3d227 .send_out_pokemon call ClearSprites - ld a, [CurBattleMon] - ld [LastPlayerMon], a - ld a, [CurPartyMon] - ld [CurBattleMon], a + ld a, [wCurBattleMon] + ld [wLastPlayerMon], a + ld a, [wCurPartyMon] + ld [wCurBattleMon], a call AddBattleParticipant call InitBattleMon call ResetPlayerStatLevels @@ -2844,10 +2844,10 @@ ForcePlayerMonChoice: ; 3d227 ; 3d2b3 PlayerPartyMonEntrance: ; 3d2b3 - ld a, [CurBattleMon] - ld [LastPlayerMon], a - ld a, [CurPartyMon] - ld [CurBattleMon], a + ld a, [wCurBattleMon] + ld [wLastPlayerMon], a + ld a, [wCurPartyMon] + ld [wCurBattleMon], a call AddBattleParticipant call InitBattleMon call ResetPlayerStatLevels @@ -2918,7 +2918,7 @@ SelectBattleMon: ; 3d329 PickPartyMonInBattle: ; 3d33c .loop ld a, PARTYMENUACTION_SWITCH ; Which PKMN? - ld [PartyMenuActionText], a + ld [wPartyMenuActionText], a call JumpToPartyMenuAndPrintText call SelectBattleMon ret c @@ -2929,8 +2929,8 @@ PickPartyMonInBattle: ; 3d33c ; 3d34f SwitchMonAlreadyOut: ; 3d34f - ld hl, CurBattleMon - ld a, [CurPartyMon] + ld hl, wCurBattleMon + ld a, [wCurPartyMon] cp [hl] jr nz, .notout @@ -2985,13 +2985,13 @@ ForcePickSwitchMonInBattle: ; 3d380 LostBattle: ; 3d38e ld a, 1 - ld [BattleEnded], a + ld [wBattleEnded], a - ld a, [InBattleTowerBattle] + ld a, [wInBattleTowerBattle] bit 0, a jr nz, .battle_tower - ld a, [BattleType] + ld a, [wBattleType] cp BATTLETYPE_CANLOSE jr nz, .not_canlose @@ -3229,7 +3229,7 @@ EnemySwitch: ; 3d4e1 xor a ld [wBattleParticipantsNotFainted], a ld [wBattleParticipantsIncludingFainted], a - ld [wPlayerAction], a + ld [wBattlePlayerAction], a inc a ld [wEnemyIsSwitching], a call LoadTileMapToTempTileMap @@ -3288,10 +3288,10 @@ CheckWhetherSwitchmonIsPredetermined: ; 3d533 ResetEnemyBattleVars: ; 3d557 ; and draw empty TextBox xor a - ld [LastPlayerCounterMove], a - ld [LastEnemyCounterMove], a - ld [LastEnemyMove], a - ld [CurEnemyMove], a + ld [wLastPlayerCounterMove], a + ld [wLastEnemyCounterMove], a + ld [wLastEnemyMove], a + ld [wCurEnemyMove], a dec a ld [wEnemyItemState], a xor a @@ -3308,7 +3308,7 @@ ResetBattleParticipants: ; 3d57a ld [wBattleParticipantsNotFainted], a ld [wBattleParticipantsIncludingFainted], a AddBattleParticipant: ; 3d581 - ld a, [CurBattleMon] + ld a, [wCurBattleMon] ld c, a ld hl, wBattleParticipantsNotFainted ld b, SET_FLAG @@ -3322,21 +3322,21 @@ AddBattleParticipant: ; 3d581 FindPkmnInOTPartyToSwitchIntoBattle: ; 3d599 ld b, $ff ld a, $1 - ld [Buffer1], a - ld [Buffer2], a + ld [wBuffer1], a + ld [wBuffer2], a .loop - ld hl, Buffer1 + ld hl, wBuffer1 sla [hl] inc hl sla [hl] inc b - ld a, [OTPartyCount] + ld a, [wOTPartyCount] cp b jp z, ScoreMonTypeMatchups - ld a, [CurOTMon] + ld a, [wCurOTMon] cp b jr z, .discourage - ld hl, OTPartyMon1HP + ld hl, wOTPartyMon1HP push bc ld a, b call GetPartyLocation @@ -3351,14 +3351,14 @@ FindPkmnInOTPartyToSwitchIntoBattle: ; 3d599 jr .loop .discourage - ld hl, Buffer2 + ld hl, wBuffer2 set 0, [hl] jr .loop ; 3d5d7 LookUpTheEffectivenessOfEveryMove: ; 3d5d7 push bc - ld hl, OTPartyMon1Moves + ld hl, wOTPartyMon1Moves ld a, b call GetPartyLocation pop bc @@ -3387,7 +3387,7 @@ LookUpTheEffectivenessOfEveryMove: ; 3d5d7 ld a, [wd265] ; Get The Effectiveness Modifier cp 10 + 1 ; 1.0 + 0.1 jr c, .loop - ld hl, Buffer1 + ld hl, wBuffer1 set 0, [hl] ret .done @@ -3398,7 +3398,7 @@ IsThePlayerPkmnTypesEffectiveAgainstOTPkmn: ; 3d618 ; Calculates the effectiveness of the types of the PlayerPkmn ; against the OTPkmn push bc - ld hl, OTPartyCount + ld hl, wOTPartyCount ld a, b inc a ld c, a @@ -3409,18 +3409,18 @@ IsThePlayerPkmnTypesEffectiveAgainstOTPkmn: ; 3d618 ld hl, BaseData + BASE_TYPES ld bc, BASE_DATA_SIZE call AddNTimes - ld de, EnemyMonType + ld de, wEnemyMonType ld bc, BASE_CATCH_RATE - BASE_TYPES ld a, BANK(BaseData) call FarCopyBytes - ld a, [BattleMonType1] + ld a, [wBattleMonType1] ld [wPlayerMoveStruct + MOVE_TYPE], a call SetPlayerTurn callfar BattleCheckTypeMatchup ld a, [wd265] cp 10 + 1 ; 1.0 + 0.1 jr nc, .super_effective - ld a, [BattleMonType2] + ld a, [wBattleMonType2] ld [wPlayerMoveStruct + MOVE_TYPE], a callfar BattleCheckTypeMatchup ld a, [wd265] @@ -3431,7 +3431,7 @@ IsThePlayerPkmnTypesEffectiveAgainstOTPkmn: ; 3d618 .super_effective pop bc - ld hl, Buffer1 + ld hl, wBuffer1 bit 0, [hl] jr nz, .reset inc hl @@ -3445,12 +3445,12 @@ IsThePlayerPkmnTypesEffectiveAgainstOTPkmn: ; 3d618 ScoreMonTypeMatchups: ; 3d672 .loop1 - ld hl, Buffer1 + ld hl, wBuffer1 sla [hl] inc hl sla [hl] jr nc, .loop1 - ld a, [OTPartyCount] + ld a, [wOTPartyCount] ld b, a ld c, [hl] .loop2 @@ -3461,7 +3461,7 @@ ScoreMonTypeMatchups: ; 3d672 jr .loop2 .okay - ld a, [Buffer1] + ld a, [wBuffer1] and a jr z, .okay2 ld b, $ff @@ -3474,7 +3474,7 @@ ScoreMonTypeMatchups: ; 3d672 .okay2 ld b, $ff - ld a, [Buffer2] + ld a, [wBuffer2] ld c, a .loop4 inc b @@ -3483,17 +3483,17 @@ ScoreMonTypeMatchups: ; 3d672 jr .quit .loop5 - ld a, [OTPartyCount] + ld a, [wOTPartyCount] ld b, a call BattleRandom and $7 cp b jr nc, .loop5 ld b, a - ld a, [CurOTMon] + ld a, [wCurOTMon] cp b jr z, .loop5 - ld hl, OTPartyMon1HP + ld hl, wOTPartyMon1HP push bc ld a, b call GetPartyLocation @@ -3511,35 +3511,35 @@ ScoreMonTypeMatchups: ; 3d672 LoadEnemyPkmnToSwitchTo: ; 3d6ca ; 'b' contains the PartyNr of the Pkmn the AI will switch to ld a, b - ld [CurPartyMon], a - ld hl, OTPartyMon1Level + ld [wCurPartyMon], a + ld hl, wOTPartyMon1Level call GetPartyLocation ld a, [hl] - ld [CurPartyLevel], a - ld a, [CurPartyMon] + ld [wCurPartyLevel], a + ld a, [wCurPartyMon] inc a - ld hl, OTPartyCount + ld hl, wOTPartyCount ld c, a ld b, 0 add hl, bc ld a, [hl] - ld [TempEnemyMonSpecies], a - ld [CurPartySpecies], a + ld [wTempEnemyMonSpecies], a + ld [wCurPartySpecies], a call LoadEnemyMon - ld a, [CurPartySpecies] + ld a, [wCurPartySpecies] cp UNOWN jr nz, .skip_unown ld a, [wFirstUnownSeen] and a jr nz, .skip_unown - ld hl, EnemyMonDVs + ld hl, wEnemyMonDVs predef GetUnownLetter - ld a, [UnownLetter] + ld a, [wUnownLetter] ld [wFirstUnownSeen], a .skip_unown - ld hl, EnemyMonHP + ld hl, wEnemyMonHP ld a, [hli] ld [wEnemyHPAtTimeOfPlayerSwitch], a ld a, [hl] @@ -3551,23 +3551,23 @@ CheckWhetherToAskSwitch: ; 3d714 ld a, [wBattleHasJustStarted] dec a jp z, .return_nc - ld a, [PartyCount] + ld a, [wPartyCount] dec a jp z, .return_nc ld a, [wLinkMode] and a jp nz, .return_nc - ld a, [Options] + ld a, [wOptions] bit BATTLE_SHIFT, a jr nz, .return_nc - ld a, [CurPartyMon] + ld a, [wCurPartyMon] push af - ld a, [CurBattleMon] - ld [CurPartyMon], a + ld a, [wCurBattleMon] + ld [wCurPartyMon], a farcall CheckCurPartyMonFainted pop bc ld a, b - ld [CurPartyMon], a + ld [wCurPartyMon], a jr c, .return_nc scf ret @@ -3578,7 +3578,7 @@ CheckWhetherToAskSwitch: ; 3d714 ; 3d74b OfferSwitch: ; 3d74b - ld a, [CurPartyMon] + ld a, [wCurPartyMon] push af callfar Battle_GetTrainerName ld hl, BattleText_EnemyIsAboutToUseWillPlayerChangePkmn @@ -3591,18 +3591,18 @@ OfferSwitch: ; 3d74b call SetUpBattlePartyMenu_NoLoop call PickSwitchMonInBattle jr c, .canceled_switch - ld a, [CurBattleMon] - ld [LastPlayerMon], a - ld a, [CurPartyMon] - ld [CurBattleMon], a + ld a, [wCurBattleMon] + ld [wLastPlayerMon], a + ld a, [wCurPartyMon] + ld [wCurBattleMon], a call ClearPalettes call DelayFrame call _LoadHPBar pop af - ld [CurPartyMon], a + ld [wCurPartyMon], a xor a - ld [CurEnemyMove], a - ld [CurPlayerMove], a + ld [wCurEnemyMove], a + ld [wCurPlayerMove], a and a ret @@ -3613,7 +3613,7 @@ OfferSwitch: ; 3d74b .said_no pop af - ld [CurPartyMon], a + ld [wCurPartyMon], a scf ret ; 3d7a0 @@ -3638,12 +3638,12 @@ Function_BattleTextEnemySentOut: ; 3d7b8 ; 3d7c7 Function_SetEnemyPkmnAndSendOutAnimation: ; 3d7c7 - ld a, [TempEnemyMonSpecies] - ld [CurPartySpecies], a - ld [CurSpecies], a + ld a, [wTempEnemyMonSpecies] + ld [wCurPartySpecies], a + ld [wCurSpecies], a call GetBaseData ld a, OTPARTYMON - ld [MonType], a + ld [wMonType], a predef CopyPkmnToTempMon call GetEnemyMonFrontpic @@ -3662,7 +3662,7 @@ Function_SetEnemyPkmnAndSendOutAnimation: ; 3d7c7 call Call_PlayBattleAnim .not_shiny - ld bc, TempMonSpecies + ld bc, wTempMonSpecies farcall CheckFaintedFrzSlp jr c, .skip_cry farcall CheckBattleScene @@ -3675,8 +3675,8 @@ Function_SetEnemyPkmnAndSendOutAnimation: ; 3d7c7 .cry_no_anim ld a, $f - ld [CryTracks], a - ld a, [TempEnemyMonSpecies] + ld [wCryTracks], a + ld a, [wTempEnemyMonSpecies] call PlayStereoCry .skip_cry @@ -3688,24 +3688,24 @@ Function_SetEnemyPkmnAndSendOutAnimation: ; 3d7c7 NewEnemyMonStatus: ; 3d834 xor a - ld [LastPlayerCounterMove], a - ld [LastEnemyCounterMove], a - ld [LastEnemyMove], a - ld hl, EnemySubStatus1 + ld [wLastPlayerCounterMove], a + ld [wLastEnemyCounterMove], a + ld [wLastEnemyMove], a + ld hl, wEnemySubStatus1 rept 4 ld [hli], a endr ld [hl], a - ld [EnemyDisableCount], a - ld [EnemyFuryCutterCount], a - ld [EnemyProtectCount], a + ld [wEnemyDisableCount], a + ld [wEnemyFuryCutterCount], a + ld [wEnemyProtectCount], a ld [wEnemyRageCounter], a - ld [EnemyDisabledMove], a + ld [wEnemyDisabledMove], a ld [wEnemyMinimized], a ld [wPlayerWrapCount], a ld [wEnemyWrapCount], a - ld [EnemyTurnsTaken], a - ld hl, PlayerSubStatus5 + ld [wEnemyTurnsTaken], a + ld hl, wPlayerSubStatus5 res SUBSTATUS_CANT_RUN, [hl] ret ; 3d867 @@ -3713,7 +3713,7 @@ endr ResetEnemyStatLevels: ; 3d867 ld a, BASE_STAT_LEVEL ld b, NUM_LEVEL_STATS - ld hl, EnemyStatLevels + ld hl, wEnemyStatLevels .loop ld [hli], a dec b @@ -3723,11 +3723,11 @@ ResetEnemyStatLevels: ; 3d867 CheckPlayerPartyForFitPkmn: ; 3d873 ; Has the player any Pkmn in his Party that can fight? - ld a, [PartyCount] + ld a, [wPartyCount] ld e, a xor a - ld hl, PartyMon1HP - ld bc, PartyMon2 - (PartyMon1 + 1) + ld hl, wPartyMon1HP + ld bc, wPartyMon2 - (wPartyMon1 + 1) .loop or [hl] inc hl @@ -3740,8 +3740,8 @@ CheckPlayerPartyForFitPkmn: ; 3d873 ; 3d887 CheckIfCurPartyMonIsFitToFight: ; 3d887 - ld a, [CurPartyMon] - ld hl, PartyMon1HP + ld a, [wCurPartyMon] + ld hl, wPartyMon1HP call GetPartyLocation ld a, [hli] or [hl] @@ -3750,8 +3750,8 @@ CheckIfCurPartyMonIsFitToFight: ; 3d887 ld a, [wBattleHasJustStarted] and a jr nz, .finish_fail - ld hl, PartySpecies - ld a, [CurPartyMon] + ld hl, wPartySpecies + ld a, [wCurPartyMon] ld c, a ld b, 0 add hl, bc @@ -3772,7 +3772,7 @@ CheckIfCurPartyMonIsFitToFight: ; 3d887 TryToRunAwayFromBattle: ; 3d8b3 ; Run away from battle, with or without item - ld a, [BattleType] + ld a, [wBattleType] cp BATTLETYPE_DEBUG jp z, .can_escape cp BATTLETYPE_CONTEST @@ -3794,7 +3794,7 @@ TryToRunAwayFromBattle: ; 3d8b3 dec a jp nz, .cant_run_from_trainer - ld a, [EnemySubStatus5] + ld a, [wEnemySubStatus5] bit SUBSTATUS_CANT_RUN, a jp nz, .cant_escape @@ -3804,7 +3804,7 @@ TryToRunAwayFromBattle: ; 3d8b3 push hl push de - ld a, [BattleMonItem] + ld a, [wBattleMonItem] ld [wd265], a ld b, a callfar GetItemHeldEffect @@ -3883,7 +3883,7 @@ TryToRunAwayFromBattle: ; 3d8b3 cp b jr nc, .can_escape ld a, $1 - ld [wPlayerAction], a + ld [wBattlePlayerAction], a ld hl, BattleText_CantEscape2 jr .print_inescapable_text @@ -3909,11 +3909,11 @@ TryToRunAwayFromBattle: ; 3d8b3 jr z, .fled call LoadTileMapToTempTileMap xor a - ld [wPlayerAction], a + ld [wBattlePlayerAction], a ld a, $f - ld [CurMoveNum], a + ld [wCurMoveNum], a xor a - ld [CurPlayerMove], a + ld [wCurPlayerMove], a call LinkBattleSendReceiveAction call Call_LoadTempTileMapToTileMap call CheckMobileBattleError @@ -3962,37 +3962,37 @@ TryToRunAwayFromBattle: ; 3d8b3 InitBattleMon: ; 3da0d ld a, MON_SPECIES call GetPartyParamLocation - ld de, BattleMonSpecies + ld de, wBattleMonSpecies ld bc, MON_ID call CopyBytes ld bc, MON_DVS - MON_ID add hl, bc - ld de, BattleMonDVs + ld de, wBattleMonDVs ld bc, MON_PKRUS - MON_DVS call CopyBytes inc hl inc hl inc hl - ld de, BattleMonLevel + ld de, wBattleMonLevel ld bc, PARTYMON_STRUCT_LENGTH - MON_LEVEL call CopyBytes - ld a, [BattleMonSpecies] - ld [TempBattleMonSpecies], a - ld [CurPartySpecies], a - ld [CurSpecies], a + ld a, [wBattleMonSpecies] + ld [wTempBattleMonSpecies], a + ld [wCurPartySpecies], a + ld [wCurSpecies], a call GetBaseData - ld a, [BaseType1] - ld [BattleMonType1], a - ld a, [BaseType2] - ld [BattleMonType2], a - ld hl, PartyMonNicknames - ld a, [CurBattleMon] + ld a, [wBaseType1] + ld [wBattleMonType1], a + ld a, [wBaseType2] + ld [wBattleMonType2], a + ld hl, wPartyMonNicknames + ld a, [wCurBattleMon] call SkipNames - ld de, BattleMonNick + ld de, wBattleMonNick ld bc, MON_NAME_LENGTH call CopyBytes - ld hl, BattleMonAttack - ld de, PlayerStats + ld hl, wBattleMonAttack + ld de, wPlayerStats ld bc, PARTYMON_STRUCT_LENGTH - MON_ATK call CopyBytes call ApplyStatusEffectOnPlayerStats @@ -4015,33 +4015,33 @@ BattleCheckShininess: ; 3da7c ; 3da85 GetPartyMonDVs: ; 3da85 - ld hl, BattleMonDVs - ld a, [PlayerSubStatus5] + ld hl, wBattleMonDVs + ld a, [wPlayerSubStatus5] bit SUBSTATUS_TRANSFORMED, a ret z - ld hl, PartyMon1DVs - ld a, [CurBattleMon] + ld hl, wPartyMon1DVs + ld a, [wCurBattleMon] jp GetPartyLocation ; 3da97 GetEnemyMonDVs: ; 3da97 - ld hl, EnemyMonDVs - ld a, [EnemySubStatus5] + ld hl, wEnemyMonDVs + ld a, [wEnemySubStatus5] bit SUBSTATUS_TRANSFORMED, a ret z ld hl, wEnemyBackupDVs ld a, [wBattleMode] dec a ret z - ld hl, OTPartyMon1DVs - ld a, [CurOTMon] + ld hl, wOTPartyMon1DVs + ld a, [wCurOTMon] jp GetPartyLocation ; 3dab1 ResetPlayerStatLevels: ; 3dab1 ld a, BASE_STAT_LEVEL ld b, NUM_LEVEL_STATS - ld hl, PlayerStatLevels + ld hl, wPlayerStatLevels .loop ld [hli], a dec b @@ -4050,46 +4050,46 @@ ResetPlayerStatLevels: ; 3dab1 ; 3dabd InitEnemyMon: ; 3dabd - ld a, [CurPartyMon] - ld hl, OTPartyMon1Species + ld a, [wCurPartyMon] + ld hl, wOTPartyMon1Species call GetPartyLocation - ld de, EnemyMonSpecies + ld de, wEnemyMonSpecies ld bc, MON_ID call CopyBytes ld bc, MON_DVS - MON_ID add hl, bc - ld de, EnemyMonDVs + ld de, wEnemyMonDVs ld bc, MON_PKRUS - MON_DVS call CopyBytes inc hl inc hl inc hl - ld de, EnemyMonLevel + ld de, wEnemyMonLevel ld bc, PARTYMON_STRUCT_LENGTH - MON_LEVEL call CopyBytes - ld a, [EnemyMonSpecies] - ld [CurSpecies], a + ld a, [wEnemyMonSpecies] + ld [wCurSpecies], a call GetBaseData - ld hl, OTPartyMonNicknames - ld a, [CurPartyMon] + ld hl, wOTPartyMonNicknames + ld a, [wCurPartyMon] call SkipNames - ld de, EnemyMonNick + ld de, wEnemyMonNick ld bc, MON_NAME_LENGTH call CopyBytes - ld hl, EnemyMonAttack - ld de, EnemyStats + ld hl, wEnemyMonAttack + ld de, wEnemyStats ld bc, PARTYMON_STRUCT_LENGTH - MON_ATK call CopyBytes call ApplyStatusEffectOnEnemyStats - ld hl, BaseType1 - ld de, EnemyMonType1 + ld hl, wBaseType1 + ld de, wEnemyMonType1 ld a, [hli] ld [de], a inc de ld a, [hl] ld [de], a - ld hl, BaseStats - ld de, EnemyMonBaseStats + ld hl, wBaseStats + ld de, wEnemyMonBaseStats ld b, 5 .loop ld a, [hli] @@ -4097,17 +4097,17 @@ InitEnemyMon: ; 3dabd inc de dec b jr nz, .loop - ld a, [CurPartyMon] - ld [CurOTMon], a + ld a, [wCurPartyMon] + ld [wCurOTMon], a ret ; 3db32 SwitchPlayerMon: ; 3db32 call ClearSprites - ld a, [CurBattleMon] - ld [LastPlayerMon], a - ld a, [CurPartyMon] - ld [CurBattleMon], a + ld a, [wCurBattleMon] + ld [wLastPlayerMon], a + ld a, [wCurPartyMon] + ld [wCurBattleMon], a call AddBattleParticipant call InitBattleMon call ResetPlayerStatLevels @@ -4116,14 +4116,14 @@ SwitchPlayerMon: ; 3db32 call SendOutPlayerMon call EmptyBattleTextBox call LoadTileMapToTempTileMap - ld hl, EnemyMonHP + ld hl, wEnemyMonHP ld a, [hli] or [hl] ret ; 3db5f SendOutPlayerMon: ; 3db5f - ld hl, BattleMonDVs + ld hl, wBattleMonDVs predef GetUnownLetter hlcoord 1, 5 ld b, 7 @@ -4136,12 +4136,12 @@ SendOutPlayerMon: ; 3db5f xor a ld [hGraphicStartTile], a ld [wBattleMenuCursorBuffer], a - ld [CurMoveNum], a - ld [TypeModifier], a + ld [wCurMoveNum], a + ld [wTypeModifier], a ld [wPlayerMoveStruct + MOVE_ANIM], a - ld [LastPlayerCounterMove], a - ld [LastEnemyCounterMove], a - ld [LastPlayerMove], a + ld [wLastPlayerCounterMove], a + ld [wLastEnemyCounterMove], a + ld [wLastPlayerMove], a call CheckAmuletCoin call FinishBattleAnim xor a @@ -4167,8 +4167,8 @@ SendOutPlayerMon: ; 3db5f farcall CheckFaintedFrzSlp jr c, .statused ld a, $f0 - ld [CryTracks], a - ld a, [CurPartySpecies] + ld [wCryTracks], a + ld a, [wCurPartySpecies] call PlayStereoCry .statused @@ -4180,50 +4180,50 @@ SendOutPlayerMon: ; 3db5f NewBattleMonStatus: ; 3dbde xor a - ld [LastPlayerCounterMove], a - ld [LastEnemyCounterMove], a - ld [LastPlayerMove], a - ld hl, PlayerSubStatus1 + ld [wLastPlayerCounterMove], a + ld [wLastEnemyCounterMove], a + ld [wLastPlayerMove], a + ld hl, wPlayerSubStatus1 rept 4 ld [hli], a endr ld [hl], a - ld hl, PlayerUsedMoves + ld hl, wPlayerUsedMoves ld [hli], a ld [hli], a ld [hli], a ld [hl], a - ld [PlayerDisableCount], a - ld [PlayerFuryCutterCount], a - ld [PlayerProtectCount], a + ld [wPlayerDisableCount], a + ld [wPlayerFuryCutterCount], a + ld [wPlayerProtectCount], a ld [wPlayerRageCounter], a - ld [DisabledMove], a + ld [wDisabledMove], a ld [wPlayerMinimized], a ld [wEnemyWrapCount], a ld [wPlayerWrapCount], a - ld [PlayerTurnsTaken], a - ld hl, EnemySubStatus5 + ld [wPlayerTurnsTaken], a + ld hl, wEnemySubStatus5 res SUBSTATUS_CANT_RUN, [hl] ret ; 3dc18 BreakAttraction: ; 3dc18 - ld hl, PlayerSubStatus1 + ld hl, wPlayerSubStatus1 res SUBSTATUS_IN_LOVE, [hl] - ld hl, EnemySubStatus1 + ld hl, wEnemySubStatus1 res SUBSTATUS_IN_LOVE, [hl] ret ; 3dc23 SpikesDamage: ; 3dc23 - ld hl, PlayerScreens - ld de, BattleMonType + ld hl, wPlayerScreens + ld de, wBattleMonType ld bc, UpdatePlayerHUD ld a, [hBattleTurn] and a jr z, .ok - ld hl, EnemyScreens - ld de, EnemyMonType + ld hl, wEnemyScreens + ld de, wEnemyMonType ld bc, UpdateEnemyHUD .ok @@ -4265,7 +4265,7 @@ PursuitSwitch: ; 3dc5b cp EFFECT_PURSUIT jr nz, .done - ld a, [CurBattleMon] + ld a, [wCurBattleMon] push af ld hl, DoPlayerTurn @@ -4273,8 +4273,8 @@ PursuitSwitch: ; 3dc5b and a jr z, .do_turn ld hl, DoEnemyTurn - ld a, [LastPlayerMon] - ld [CurBattleMon], a + ld a, [wLastPlayerMon] + ld [wCurBattleMon], a .do_turn ld a, BANK(DoPlayerTurn) rst FarCall @@ -4285,24 +4285,24 @@ PursuitSwitch: ; 3dc5b ld [hl], a pop af - ld [CurBattleMon], a + ld [wCurBattleMon], a ld a, [hBattleTurn] and a jr z, .check_enemy_fainted - ld a, [LastPlayerMon] + ld a, [wLastPlayerMon] call UpdateBattleMon - ld hl, BattleMonHP + ld hl, wBattleMonHP ld a, [hli] or [hl] jr nz, .done ld a, $f0 - ld [CryTracks], a - ld a, [BattleMonSpecies] + ld [wCryTracks], a + ld a, [wBattleMonSpecies] call PlayStereoCry - ld a, [LastPlayerMon] + ld a, [wLastPlayerMon] ld c, a ld hl, wBattleParticipantsNotFainted ld b, RESET_FLAG @@ -4312,7 +4312,7 @@ PursuitSwitch: ; 3dc5b jr .done_fainted .check_enemy_fainted - ld hl, EnemyMonHP + ld hl, wEnemyMonHP ld a, [hli] or [hl] jr nz, .done @@ -4378,26 +4378,26 @@ HandleHPHealingItem: ; 3dd2f ld a, b cp HELD_BERRY ret nz - ld de, EnemyMonHP + 1 - ld hl, EnemyMonMaxHP + ld de, wEnemyMonHP + 1 + ld hl, wEnemyMonMaxHP ld a, [hBattleTurn] and a jr z, .go - ld de, BattleMonHP + 1 - ld hl, BattleMonMaxHP + ld de, wBattleMonHP + 1 + ld hl, wBattleMonMaxHP .go ; If, and only if, Pokemon's HP is less than half max, use the item. ; Store current HP in Buffer 3/4 push bc ld a, [de] - ld [Buffer3], a + ld [wBuffer3], a add a ld c, a dec de ld a, [de] inc de - ld [Buffer4], a + ld [wBuffer4], a adc a ld b, a ld a, b @@ -4416,19 +4416,19 @@ HandleHPHealingItem: ; 3dd2f .less call ItemRecoveryAnim - ; store max HP in Buffer1/2 + ; store max HP in wBuffer1/2 ld a, [hli] - ld [Buffer2], a + ld [wBuffer2], a ld a, [hl] - ld [Buffer1], a + ld [wBuffer1], a ld a, [de] add c - ld [Buffer5], a + ld [wBuffer5], a ld c, a dec de ld a, [de] adc $0 - ld [Buffer6], a + ld [wBuffer6], a ld b, a ld a, [hld] cp c @@ -4436,15 +4436,15 @@ HandleHPHealingItem: ; 3dd2f sbc b jr nc, .okay ld a, [hli] - ld [Buffer6], a + ld [wBuffer6], a ld a, [hl] - ld [Buffer5], a + ld [wBuffer5], a .okay - ld a, [Buffer6] + ld a, [wBuffer6] ld [de], a inc de - ld a, [Buffer5] + ld a, [wBuffer5] ld [de], a ld a, [hBattleTurn] ld [wWhichHPBar], a @@ -4473,11 +4473,11 @@ ItemRecoveryAnim: ; 3ddc8 push bc call EmptyBattleTextBox ld a, RECOVER - ld [FXAnimID], a + ld [wFXAnimID], a call SwitchTurnCore xor a ld [wNumHits], a - ld [FXAnimID + 1], a + ld [wFXAnimID + 1], a predef PlayBattleAnim call SwitchTurnCore pop bc @@ -4646,7 +4646,7 @@ HandleStatBoostingHeldItems: ; 3de97 rst FarCall pop bc pop de - ld a, [FailedMessage] + ld a, [wFailedMessage] and a ret nz xor a @@ -4676,18 +4676,18 @@ HandleStatBoostingHeldItems: ; 3de97 ; 3df12 GetPartymonItem: ; 3df12 - ld hl, PartyMon1Item - ld a, [CurBattleMon] + ld hl, wPartyMon1Item + ld a, [wCurBattleMon] call GetPartyLocation - ld bc, BattleMonItem + ld bc, wBattleMonItem ret ; 3df1f GetOTPartymonItem: ; 3df1f - ld hl, OTPartyMon1Item - ld a, [CurOTMon] + ld hl, wOTPartyMon1Item + ld a, [wCurOTMon] call GetPartyLocation - ld bc, EnemyMonItem + ld bc, wEnemyMonItem ret ; 3df2c @@ -4696,11 +4696,11 @@ UpdateBattleHUDs: ; 3df2c push de push bc call DrawPlayerHUD - ld hl, PlayerHPPal + ld hl, wPlayerHPPal call SetHPPal call CheckDanger call DrawEnemyHUD - ld hl, EnemyHPPal + ld hl, wEnemyHPPal call SetHPPal pop bc pop de @@ -4740,19 +4740,19 @@ DrawPlayerHUD: ; 3df58 hlcoord 10, 9 ld b, 1 xor a ; PARTYMON - ld [MonType], a + ld [wMonType], a predef DrawPlayerHP ; Exp bar push de - ld a, [CurBattleMon] - ld hl, PartyMon1Exp + 2 + ld a, [wCurBattleMon] + ld hl, wPartyMon1Exp + 2 call GetPartyLocation ld d, h ld e, l hlcoord 10, 11 - ld a, [TempMonLevel] + ld a, [wTempMonLevel] ld b, a call FillInExpBar pop de @@ -4760,29 +4760,29 @@ DrawPlayerHUD: ; 3df58 ; 3df98 UpdatePlayerHPPal: ; 3df98 - ld hl, PlayerHPPal + ld hl, wPlayerHPPal jp UpdateHPPal ; 3df9e CheckDanger: ; 3df9e - ld hl, BattleMonHP + ld hl, wBattleMonHP ld a, [hli] or [hl] jr z, .no_danger - ld a, [wDanger] + ld a, [wBattleLowHealthAlarm] and a jr nz, .done - ld a, [PlayerHPPal] + ld a, [wPlayerHPPal] cp HP_RED jr z, .danger .no_danger - ld hl, Danger + ld hl, wLowHealthAlarm res DANGER_ON_F, [hl] jr .done .danger - ld hl, Danger + ld hl, wLowHealthAlarm set DANGER_ON_F, [hl] .done @@ -4790,39 +4790,39 @@ CheckDanger: ; 3df9e ; 3dfbf PrintPlayerHUD: ; 3dfbf - ld de, BattleMonNick + ld de, wBattleMonNick hlcoord 10, 7 call ret_3e138 call PlaceString push bc - ld a, [CurBattleMon] - ld hl, PartyMon1DVs + ld a, [wCurBattleMon] + ld hl, wPartyMon1DVs call GetPartyLocation - ld de, TempMonDVs + ld de, wTempMonDVs ld a, [hli] ld [de], a inc de ld a, [hl] ld [de], a - ld hl, BattleMonLevel - ld de, TempMonLevel + ld hl, wBattleMonLevel + ld de, wTempMonLevel ld bc, $11 call CopyBytes - ld a, [CurBattleMon] - ld hl, PartyMon1Species + ld a, [wCurBattleMon] + ld hl, wPartyMon1Species call GetPartyLocation ld a, [hl] - ld [CurPartySpecies], a - ld [CurSpecies], a + ld [wCurPartySpecies], a + ld [wCurSpecies], a call GetBaseData pop hl dec hl ld a, TEMPMON - ld [MonType], a + ld [wMonType], a callfar GetGender ld a, " " jr c, .got_gender_char @@ -4836,7 +4836,7 @@ PrintPlayerHUD: ; 3dfbf hlcoord 14, 8 push af ; back up gender push hl - ld de, BattleMonStatus + ld de, wBattleMonStatus predef PlaceNonFaintStatus pop hl pop bc @@ -4847,8 +4847,8 @@ PrintPlayerHUD: ; 3dfbf dec hl ; genderless .copy_level - ld a, [BattleMonLevel] - ld [TempMonLevel], a + ld a, [wBattleMonLevel] + ld [wTempMonLevel], a jp PrintLevel ; 3e036 @@ -4874,11 +4874,11 @@ DrawEnemyHUD: ; 3e043 farcall DrawEnemyHUDBorder - ld a, [TempEnemyMonSpecies] - ld [CurSpecies], a - ld [CurPartySpecies], a + ld a, [wTempEnemyMonSpecies] + ld [wCurSpecies], a + ld [wCurPartySpecies], a call GetBaseData - ld de, EnemyMonNick + ld de, wEnemyMonNick hlcoord 1, 0 call ret_3e138 call PlaceString @@ -4886,9 +4886,9 @@ DrawEnemyHUD: ; 3e043 ld l, c dec hl - ld hl, EnemyMonDVs - ld de, TempMonDVs - ld a, [EnemySubStatus5] + ld hl, wEnemyMonDVs + ld de, wTempMonDVs + ld a, [wEnemySubStatus5] bit SUBSTATUS_TRANSFORMED, a jr z, .ok ld hl, wEnemyBackupDVs @@ -4900,7 +4900,7 @@ DrawEnemyHUD: ; 3e043 ld [de], a ld a, TEMPMON - ld [MonType], a + ld [wMonType], a callfar GetGender ld a, " " jr c, .got_gender @@ -4915,7 +4915,7 @@ DrawEnemyHUD: ; 3e043 hlcoord 6, 1 push af push hl - ld de, EnemyMonStatus + ld de, wEnemyMonStatus predef PlaceNonFaintStatus pop hl pop bc @@ -4925,12 +4925,12 @@ DrawEnemyHUD: ; 3e043 jr nz, .print_level dec hl .print_level - ld a, [EnemyMonLevel] - ld [TempMonLevel], a + ld a, [wEnemyMonLevel] + ld [wTempMonLevel], a call PrintLevel .skip_level - ld hl, EnemyMonHP + ld hl, wEnemyMonHP ld a, [hli] ld [hMultiplicand + 1], a ld a, [hld] @@ -4949,7 +4949,7 @@ DrawEnemyHUD: ; 3e043 ld a, HP_BAR_LENGTH_PX ld [hMultiplier], a call Multiply - ld hl, EnemyMonMaxHP + ld hl, wEnemyMonMaxHP ld a, [hli] ld b, a ld a, [hl] @@ -4998,7 +4998,7 @@ DrawEnemyHUD: ; 3e043 ; 3e127 UpdateEnemyHPPal: ; 3e127 - ld hl, EnemyHPPal + ld hl, wEnemyHPPal call UpdateHPPal ret ; 3e12e @@ -5021,7 +5021,7 @@ BattleMenu: ; 3e139 ld [hBGMapMode], a call LoadTempTileMapToTileMap - ld a, [BattleType] + ld a, [wBattleType] cp BATTLETYPE_DEBUG jr z, .ok cp BATTLETYPE_TUTORIAL @@ -5033,7 +5033,7 @@ BattleMenu: ; 3e139 .ok .loop - ld a, [BattleType] + ld a, [wBattleType] cp BATTLETYPE_CONTEST jr nz, .not_contest farcall ContestBattleMenu @@ -5041,7 +5041,7 @@ BattleMenu: ; 3e139 .not_contest ; Auto input: choose "ITEM" - ld a, [InputType] + ld a, [wInputType] or a jr z, .skip_dude_pack_select farcall _DudeAutoInput_DownA @@ -5103,20 +5103,20 @@ BattleMenu_Pack: ; 3e1c7 and a jp nz, .ItemsCantBeUsed - ld a, [InBattleTowerBattle] + ld a, [wInBattleTowerBattle] and a jp nz, .ItemsCantBeUsed call LoadStandardMenuDataHeader - ld a, [BattleType] + ld a, [wBattleType] cp BATTLETYPE_TUTORIAL jr z, .tutorial cp BATTLETYPE_CONTEST jr z, .contest farcall BattlePack - ld a, [wPlayerAction] + ld a, [wBattlePlayerAction] and a jr z, .didnt_use_item jr .got_item @@ -5124,13 +5124,13 @@ BattleMenu_Pack: ; 3e1c7 .tutorial farcall TutorialPack ld a, POKE_BALL - ld [CurItem], a + ld [wCurItem], a call DoItemEffect jr .got_item .contest ld a, PARK_BALL - ld [CurItem], a + ld [wCurItem], a call DoItemEffect .got_item @@ -5171,7 +5171,7 @@ BattleMenu_Pack: ; 3e1c7 ld [hBGMapMode], a call _LoadBattleFontsHPBar call ClearSprites - ld a, [BattleType] + ld a, [wBattleType] cp BATTLETYPE_TUTORIAL jr z, .tutorial2 call GetBattleMonBackpic @@ -5210,7 +5210,7 @@ BattleMenuPKMN_ReturnFromStats: BattleMenuPKMN_Loop: call SetUpBattlePartyMenu xor a - ld [PartyMenuActionText], a + ld [wPartyMenuActionText], a call JumpToPartyMenuAndPrintText call SelectBattleMon jr c, .Cancel @@ -5280,7 +5280,7 @@ Battle_StatsScreen: ; 3e308 call ClearSprites call LowVolume xor a ; PARTYMON - ld [MonType], a + ld [wMonType], a farcall BattleStatsScreenInit call MaxVolume @@ -5301,9 +5301,9 @@ Battle_StatsScreen: ; 3e308 ; 3e358 TryPlayerSwitch: ; 3e358 - ld a, [CurBattleMon] + ld a, [wCurBattleMon] ld d, a - ld a, [CurPartyMon] + ld a, [wCurPartyMon] cp d jr nz, .check_trapped ld hl, BattleText_PkmnIsAlreadyOut @@ -5314,7 +5314,7 @@ TryPlayerSwitch: ; 3e358 ld a, [wPlayerWrapCount] and a jr nz, .trapped - ld a, [EnemySubStatus5] + ld a, [wEnemySubStatus5] bit SUBSTATUS_CANT_RUN, a jr z, .try_switch @@ -5326,10 +5326,10 @@ TryPlayerSwitch: ; 3e358 .try_switch call CheckIfCurPartyMonIsFitToFight jp z, BattleMenuPKMN_Loop - ld a, [CurBattleMon] - ld [LastPlayerMon], a + ld a, [wCurBattleMon] + ld [wLastPlayerMon], a ld a, $2 - ld [wPlayerAction], a + ld [wBattlePlayerAction], a call ClearPalettes call DelayFrame call ClearSprites @@ -5337,8 +5337,8 @@ TryPlayerSwitch: ; 3e358 call CloseWindow call GetMemSGBLayout call SetPalettes - ld a, [CurPartyMon] - ld [CurBattleMon], a + ld a, [wCurPartyMon] + ld [wCurBattleMon], a PlayerSwitch: ; 3e3ad ld a, 1 ld [wPlayerIsSwitching], a @@ -5401,7 +5401,7 @@ BattleMonEntrance: ; 3e40b ld c, 50 call DelayFrames - ld hl, PlayerSubStatus4 + ld hl, wPlayerSubStatus4 res SUBSTATUS_RAGE, [hl] call SetEnemyTurn @@ -5414,8 +5414,8 @@ BattleMonEntrance: ; 3e40b lb bc, 5, 11 call ClearBox - ld a, [CurBattleMon] - ld [CurPartyMon], a + ld a, [wCurBattleMon] + ld [wCurPartyMon], a call AddBattleParticipant call InitBattleMon call ResetPlayerStatLevels @@ -5440,8 +5440,8 @@ PassedBattleMonEntrance: ; 3e459 lb bc, 5, 11 call ClearBox - ld a, [CurPartyMon] - ld [CurBattleMon], a + ld a, [wCurPartyMon] + ld [wCurBattleMon], a call AddBattleParticipant call InitBattleMon xor a @@ -5458,20 +5458,20 @@ BattleMenu_Run: ; 3e489 call Call_LoadTempTileMapToTileMap ld a, $3 ld [wMenuCursorY], a - ld hl, BattleMonSpeed - ld de, EnemyMonSpeed + ld hl, wBattleMonSpeed + ld de, wEnemyMonSpeed call TryToRunAwayFromBattle ld a, $0 ld [wFailedToFlee], a ret c - ld a, [wPlayerAction] + ld a, [wBattlePlayerAction] and a ret nz jp BattleMenu ; 3e4a8 CheckAmuletCoin: ; 3e4a8 - ld a, [BattleMonItem] + ld a, [wBattleMonItem] ld b, a callfar GetItemHeldEffect ld a, b @@ -5489,7 +5489,7 @@ MoveSelectionScreen: ; 3e4bc ret .not_mobile - ld hl, EnemyMonMoves + ld hl, wEnemyMonMoves ld a, [wMoveSelectionMenuType] dec a jr z, .got_menu_type @@ -5497,7 +5497,7 @@ MoveSelectionScreen: ; 3e4bc jr z, .ether_elixer_menu call CheckPlayerHasUsableMoves ret z ; use Struggle - ld hl, BattleMonMoves + ld hl, wBattleMonMoves jr .got_menu_type .ether_elixer_menu @@ -5530,7 +5530,7 @@ MoveSelectionScreen: ; 3e4bc hlcoord 6, 17 - NUM_MOVES - 4 .got_start_coord ld a, SCREEN_WIDTH - ld [Buffer1], a + ld [wBuffer1], a predef ListMoves ld b, 5 @@ -5548,7 +5548,7 @@ MoveSelectionScreen: ; 3e4bc ld a, [wMoveSelectionMenuType] cp $1 jr z, .skip_inc - ld a, [CurMoveNum] + ld a, [wCurMoveNum] inc a .skip_inc @@ -5634,7 +5634,7 @@ MoveSelectionScreen: ; 3e4bc .not_enemy_moves_process_b dec a ld a, b - ld [CurMoveNum], a + ld [wCurMoveNum], a jr nz, .use_move pop af @@ -5644,7 +5644,7 @@ MoveSelectionScreen: ; 3e4bc pop af ret nz - ld hl, BattleMonPP + ld hl, wBattleMonPP ld a, [wMenuCursorY] ld c, a ld b, 0 @@ -5652,7 +5652,7 @@ MoveSelectionScreen: ; 3e4bc ld a, [hl] and PP_MASK jr z, .no_pp_left - ld a, [PlayerDisableCount] + ld a, [wPlayerDisableCount] swap a and $f dec a @@ -5662,14 +5662,14 @@ MoveSelectionScreen: ; 3e4bc and a jr nz, .skip2 ld a, [wMenuCursorY] - ld hl, BattleMonMoves + ld hl, wBattleMonMoves ld c, a ld b, 0 add hl, bc ld a, [hl] .skip2 - ld [CurPlayerMove], a + ld [wCurPlayerMove], a xor a ret @@ -5717,11 +5717,11 @@ MoveSelectionScreen: ; 3e4bc ld a, [wMoveSwapBuffer] and a jr z, .start_swap - ld hl, BattleMonMoves + ld hl, wBattleMonMoves call .swap_bytes - ld hl, BattleMonPP + ld hl, wBattleMonPP call .swap_bytes - ld hl, PlayerDisableCount + ld hl, wPlayerDisableCount ld a, [hl] swap a and $f @@ -5752,11 +5752,11 @@ MoveSelectionScreen: ; 3e4bc .swap_moves_in_party_struct ; Fixes the COOLTRAINER glitch - ld a, [PlayerSubStatus5] + ld a, [wPlayerSubStatus5] bit SUBSTATUS_TRANSFORMED, a jr nz, .transformed - ld hl, PartyMon1Moves - ld a, [CurBattleMon] + ld hl, wPartyMon1Moves + ld a, [wCurBattleMon] call GetPartyLocation push hl call .swap_bytes @@ -5808,7 +5808,7 @@ MoveInfoBox: ; 3e6c8 call TextBox call MobileTextBorder - ld a, [PlayerDisableCount] + ld a, [wPlayerDisableCount] and a jr z, .not_disabled @@ -5828,29 +5828,29 @@ MoveInfoBox: ; 3e6c8 ld hl, wMenuCursorY dec [hl] call SetPlayerTurn - ld hl, BattleMonMoves + ld hl, wBattleMonMoves ld a, [wMenuCursorY] ld c, a ld b, 0 add hl, bc ld a, [hl] - ld [CurPlayerMove], a + ld [wCurPlayerMove], a - ld a, [CurBattleMon] - ld [CurPartyMon], a + ld a, [wCurBattleMon] + ld [wCurPartyMon], a ld a, WILDMON - ld [MonType], a + ld [wMonType], a callfar GetMaxPPOfMove ld hl, wMenuCursorY ld c, [hl] inc [hl] ld b, 0 - ld hl, BattleMonPP + ld hl, wBattleMonPP add hl, bc ld a, [hl] and PP_MASK - ld [StringBuffer1], a + ld [wStringBuffer1], a call .PrintPP hlcoord 1, 9 @@ -5884,7 +5884,7 @@ MoveInfoBox: ; 3e6c8 hlcoord 5, 11 .ok push hl - ld de, StringBuffer1 + ld de, wStringBuffer1 lb bc, 1, 2 call PrintNum pop hl @@ -5900,10 +5900,10 @@ MoveInfoBox: ; 3e6c8 CheckPlayerHasUsableMoves: ; 3e786 ld a, STRUGGLE - ld [CurPlayerMove], a - ld a, [PlayerDisableCount] + ld [wCurPlayerMove], a + ld a, [wPlayerDisableCount] and a - ld hl, BattleMonPP + ld hl, wBattleMonPP jr nz, .disabled ld a, [hli] @@ -5955,7 +5955,7 @@ ParseEnemyAction: ; 3e7c1 jr z, .not_linked call EmptyBattleTextBox call LoadTileMapToTempTileMap - ld a, [wPlayerAction] + ld a, [wBattlePlayerAction] and a call z, LinkBattleSendReceiveAction call Call_LoadTempTileMapToTileMap @@ -5966,30 +5966,30 @@ ParseEnemyAction: ; 3e7c1 jp z, .battle_action_d cp BATTLEACTION_SWITCH1 jp nc, ResetVarsForSubstatusRage - ld [CurEnemyMoveNum], a + ld [wCurEnemyMoveNum], a ld c, a - ld a, [EnemySubStatus1] + ld a, [wEnemySubStatus1] bit SUBSTATUS_ROLLOUT, a jp nz, .skip_load - ld a, [EnemySubStatus3] + ld a, [wEnemySubStatus3] and 1 << SUBSTATUS_CHARGED | 1 << SUBSTATUS_RAMPAGE | 1 << SUBSTATUS_BIDE jp nz, .skip_load - ld hl, EnemySubStatus5 + ld hl, wEnemySubStatus5 bit SUBSTATUS_ENCORED, [hl] - ld a, [LastEnemyMove] + ld a, [wLastEnemyMove] jp nz, .finish - ld hl, EnemyMonMoves + ld hl, wEnemyMonMoves ld b, 0 add hl, bc ld a, [hl] jp .finish .not_linked - ld hl, EnemySubStatus5 + ld hl, wEnemySubStatus5 bit SUBSTATUS_ENCORED, [hl] jr z, .skip_encore - ld a, [LastEnemyMove] + ld a, [wLastEnemyMove] jp .finish .skip_encore @@ -6002,14 +6002,14 @@ ParseEnemyAction: ; 3e7c1 jr .finish .continue - ld hl, EnemyMonMoves - ld de, EnemyMonPP + ld hl, wEnemyMonMoves + ld de, wEnemyMonPP ld b, NUM_MOVES .loop ld a, [hl] and a jp z, .struggle - ld a, [EnemyDisabledMove] + ld a, [wEnemyDisabledMove] cp [hl] jr z, .disabled ld a, [de] @@ -6029,13 +6029,13 @@ ParseEnemyAction: ; 3e7c1 jr nz, .skip_load ; wild .loop2 - ld hl, EnemyMonMoves + ld hl, wEnemyMonMoves call BattleRandom maskbits NUM_MOVES ld c, a ld b, 0 add hl, bc - ld a, [EnemyDisableCount] + ld a, [wEnemyDisableCount] swap a and $f dec a @@ -6044,18 +6044,18 @@ ParseEnemyAction: ; 3e7c1 ld a, [hl] and a jr z, .loop2 - ld hl, EnemyMonPP + ld hl, wEnemyMonPP add hl, bc ld b, a ld a, [hl] and PP_MASK jr z, .loop2 ld a, c - ld [CurEnemyMoveNum], a + ld [wCurEnemyMoveNum], a ld a, b .finish - ld [CurEnemyMove], a + ld [wCurEnemyMove], a .skip_load call SetEnemyTurn @@ -6070,13 +6070,13 @@ ParseEnemyAction: ; 3e7c1 cp EFFECT_FURY_CUTTER jr z, .fury_cutter xor a - ld [EnemyFuryCutterCount], a + ld [wEnemyFuryCutterCount], a .fury_cutter ld a, [wEnemyMoveStruct + MOVE_EFFECT] cp EFFECT_RAGE jr z, .no_rage - ld hl, EnemySubStatus4 + ld hl, wEnemySubStatus4 res SUBSTATUS_RAGE, [hl] xor a ld [wEnemyRageCounter], a @@ -6088,7 +6088,7 @@ ParseEnemyAction: ; 3e7c1 cp EFFECT_ENDURE ret z xor a - ld [EnemyProtectCount], a + ld [wEnemyProtectCount], a ret .struggle @@ -6098,25 +6098,25 @@ ParseEnemyAction: ; 3e7c1 ResetVarsForSubstatusRage: ; 3e8c1 xor a - ld [EnemyFuryCutterCount], a - ld [EnemyProtectCount], a + ld [wEnemyFuryCutterCount], a + ld [wEnemyProtectCount], a ld [wEnemyRageCounter], a - ld hl, EnemySubStatus4 + ld hl, wEnemySubStatus4 res SUBSTATUS_RAGE, [hl] ret ; 3e8d1 CheckEnemyLockedIn: ; 3e8d1 - ld a, [EnemySubStatus4] + ld a, [wEnemySubStatus4] and 1 << SUBSTATUS_RECHARGE ret nz - ld hl, EnemySubStatus3 + ld hl, wEnemySubStatus3 ld a, [hl] and 1 << SUBSTATUS_CHARGED | 1 << SUBSTATUS_RAMPAGE | 1 << SUBSTATUS_BIDE ret nz - ld hl, EnemySubStatus1 + ld hl, wEnemySubStatus1 bit SUBSTATUS_ROLLOUT, [hl] ret ; 3e8e4 @@ -6128,15 +6128,15 @@ LinkBattleSendReceiveAction: ; 3e8e4 LoadEnemyMon: ; 3e8eb ; Initialize enemy monster parameters -; To do this we pull the species from TempEnemyMonSpecies +; To do this we pull the species from wTempEnemyMonSpecies ; Notes: ; BattleRandom is used to ensure sync between Game Boys -; Clear the whole EnemyMon struct +; Clear the whole enemy mon struct (wEnemyMon) xor a - ld hl, EnemyMonSpecies - ld bc, EnemyMonEnd - EnemyMon + ld hl, wEnemyMonSpecies + ld bc, wEnemyMonEnd - wEnemyMon call ByteFill ; We don't need to be here if we're in a link battle @@ -6145,15 +6145,15 @@ LoadEnemyMon: ; 3e8eb jp nz, InitEnemyMon ; and also not in a BattleTower-Battle - ld a, [InBattleTowerBattle] ; ???? + ld a, [wInBattleTowerBattle] ; ???? bit 0, a jp nz, InitEnemyMon ; Make sure everything knows what species we're working with - ld a, [TempEnemyMonSpecies] - ld [EnemyMonSpecies], a - ld [CurSpecies], a - ld [CurPartySpecies], a + ld a, [wTempEnemyMonSpecies] + ld [wEnemyMonSpecies], a + ld [wCurSpecies], a + ld [wCurPartySpecies], a ; Grab the BaseData for this species call GetBaseData @@ -6166,9 +6166,9 @@ LoadEnemyMon: ; 3e8eb jr z, .WildItem ; If we're in a trainer battle, the item is in the party struct - ld a, [CurPartyMon] - ld hl, OTPartyMon1Item - call GetPartyLocation ; bc = PartyMon[CurPartyMon] - PartyMons + ld a, [wCurPartyMon] + ld hl, wOTPartyMon1Item + call GetPartyLocation ; bc = PartyMon[wCurPartyMon] - wPartyMons ld a, [hl] jr .UpdateItem @@ -6177,9 +6177,9 @@ LoadEnemyMon: ; 3e8eb ; Force Item1 ; Used for Ho-Oh, Lugia and Snorlax encounters - ld a, [BattleType] + ld a, [wBattleType] cp BATTLETYPE_FORCEITEM - ld a, [BaseItems] + ld a, [wBaseItems] jr z, .UpdateItem ; Failing that, it's all up to chance @@ -6197,12 +6197,12 @@ LoadEnemyMon: ; 3e8eb ; From there, an 8% chance for Item2 call BattleRandom cp 8 percent ; 8% of 25% = 2% Item2 - ld a, [BaseItems] + ld a, [wBaseItems] jr nc, .UpdateItem - ld a, [BaseItems+1] + ld a, [wBaseItems+1] .UpdateItem: - ld [EnemyMonItem], a + ld [wEnemyMonItem], a ; Initialize DVs @@ -6211,13 +6211,13 @@ LoadEnemyMon: ; 3e8eb and a jr z, .InitDVs - ld a, [EnemySubStatus5] + ld a, [wEnemySubStatus5] bit SUBSTATUS_TRANSFORMED, a jr z, .InitDVs ; Unknown ld hl, wEnemyBackupDVs - ld de, EnemyMonDVs + ld de, wEnemyMonDVs ld a, [hli] ld [de], a inc de @@ -6242,7 +6242,7 @@ LoadEnemyMon: ; 3e8eb ; Roaming monsters (Entei, Raikou) work differently ; They have their own structs, which are shorter than normal - ld a, [BattleType] + ld a, [wBattleType] cp BATTLETYPE_ROAMING jr nz, .NotRoaming @@ -6280,7 +6280,7 @@ LoadEnemyMon: ; 3e8eb jr .UpdateDVs .NotRoaming: -; Register a contains BattleType +; Register a contains wBattleType ; Forced shiny battle type ; Used by Red Gyarados at Lake of Rage @@ -6300,7 +6300,7 @@ LoadEnemyMon: ; 3e8eb .UpdateDVs: ; Input DVs in register bc - ld hl, EnemyMonDVs + ld hl, wEnemyMonDVs ld a, b ld [hli], a ld [hl], c @@ -6313,12 +6313,12 @@ LoadEnemyMon: ; 3e8eb ; Species-specfic: ; Unown - ld a, [TempEnemyMonSpecies] + ld a, [wTempEnemyMonSpecies] cp UNOWN jr nz, .Magikarp ; Get letter based on DVs - ld hl, EnemyMonDVs + ld hl, wEnemyMonDVs predef GetUnownLetter ; Can't use any letters that haven't been unlocked ; If combined with forced shiny battletype, causes an infinite loop @@ -6334,13 +6334,13 @@ LoadEnemyMon: ; 3e8eb ; by targeting those 1600 mm (= 5'3") or larger. ; After the conversion to feet, it is unable to target any, ; since the largest possible Magikarp is 5'3", and $0503 = 1283 mm. - ld a, [TempEnemyMonSpecies] + ld a, [wTempEnemyMonSpecies] cp MAGIKARP jr nz, .Happiness ; Get Magikarp's length - ld de, EnemyMonDVs - ld bc, PlayerID + ld de, wEnemyMonDVs + ld bc, wPlayerID callfar CalcMagikarpLength ; No reason to keep going if length > 1536 mm (i.e. if HIGH(length) > 6 feet) @@ -6380,10 +6380,10 @@ LoadEnemyMon: ; 3e8eb ; Moreover, due to the check not being translated to feet+inches, all Magikarp ; smaller than 4'0" may be caught by the filter, a lot more than intended. - ld a, [MapGroup] + ld a, [wMapGroup] cp GROUP_LAKE_OF_RAGE jr z, .Happiness - ld a, [MapNumber] + ld a, [wMapNumber] cp MAP_LAKE_OF_RAGE jr z, .Happiness ; 40% chance of not flooring @@ -6400,14 +6400,14 @@ LoadEnemyMon: ; 3e8eb .Happiness: ; Set happiness ld a, BASE_HAPPINESS - ld [EnemyMonHappiness], a + ld [wEnemyMonHappiness], a ; Set level - ld a, [CurPartyLevel] - ld [EnemyMonLevel], a + ld a, [wCurPartyLevel] + ld [wEnemyMonLevel], a ; Fill stats - ld de, EnemyMonMaxHP + ld de, wEnemyMonMaxHP ld b, FALSE - ld hl, EnemyMonDVs - (MON_DVS - MON_STAT_EXP + 1) ; LinkBattleRNs + 7 ; ? + ld hl, wEnemyMonDVs - (MON_DVS - MON_STAT_EXP + 1) ; wLinkBattleRNs + 7 ; ? predef CalcPkmnStats ; If we're in a trainer battle, @@ -6420,7 +6420,7 @@ LoadEnemyMon: ; 3e8eb and a jr z, .TreeMon - ld a, [EnemySubStatus5] + ld a, [wEnemySubStatus5] bit SUBSTATUS_TRANSFORMED, a jp nz, .Moves @@ -6433,7 +6433,7 @@ LoadEnemyMon: ; 3e8eb xor a .UpdateStatus: - ld hl, EnemyMonStatus + ld hl, wEnemyMonStatus ld [hli], a ; Unused byte @@ -6441,13 +6441,13 @@ LoadEnemyMon: ; 3e8eb ld [hli], a ; Full HP.. - ld a, [EnemyMonMaxHP] + ld a, [wEnemyMonMaxHP] ld [hli], a - ld a, [EnemyMonMaxHP + 1] + ld a, [wEnemyMonMaxHP + 1] ld [hl], a ; ..unless it's a RoamMon - ld a, [BattleType] + ld a, [wBattleType] cp BATTLETYPE_ROAMING jr nz, .Moves @@ -6459,38 +6459,38 @@ LoadEnemyMon: ; 3e8eb jr z, .InitRoamHP ; Update from the struct if it has ld a, [hl] - ld [EnemyMonHP + 1], a + ld [wEnemyMonHP + 1], a jr .Moves .InitRoamHP: ; HP only uses the lo byte in the RoamMon struct since ; Raikou/Entei/Suicune will have < 256 hp at level 40 - ld a, [EnemyMonHP + 1] + ld a, [wEnemyMonHP + 1] ld [hl], a jr .Moves .OpponentParty: ; Get HP from the party struct - ld hl, (OTPartyMon1HP + 1) - ld a, [CurPartyMon] + ld hl, (wOTPartyMon1HP + 1) + ld a, [wCurPartyMon] call GetPartyLocation ld a, [hld] - ld [EnemyMonHP + 1], a + ld [wEnemyMonHP + 1], a ld a, [hld] - ld [EnemyMonHP], a + ld [wEnemyMonHP], a ; Make sure everything knows which monster the opponent is using - ld a, [CurPartyMon] - ld [CurOTMon], a + ld a, [wCurPartyMon] + ld [wCurOTMon], a ; Get status from the party struct dec hl ld a, [hl] ; OTPartyMonStatus - ld [EnemyMonStatus], a + ld [wEnemyMonStatus], a .Moves: - ld hl, BaseType1 - ld de, EnemyMonType1 + ld hl, wBaseType1 + ld de, wEnemyMonType1 ld a, [hli] ld [de], a inc de @@ -6498,21 +6498,21 @@ LoadEnemyMon: ; 3e8eb ld [de], a ; Get moves - ld de, EnemyMonMoves + ld de, wEnemyMonMoves ; Are we in a trainer battle? ld a, [wBattleMode] cp TRAINER_BATTLE jr nz, .WildMoves ; Then copy moves from the party struct - ld hl, OTPartyMon1Moves - ld a, [CurPartyMon] + ld hl, wOTPartyMon1Moves + ld a, [wCurPartyMon] call GetPartyLocation ld bc, NUM_MOVES call CopyBytes jr .PP .WildMoves: -; Clear EnemyMonMoves +; Clear wEnemyMonMoves xor a ld h, d ld l, e @@ -6532,25 +6532,25 @@ LoadEnemyMon: ; 3e8eb jr z, .TrainerPP ; Fill wild PP - ld hl, EnemyMonMoves - ld de, EnemyMonPP + ld hl, wEnemyMonMoves + ld de, wEnemyMonPP predef FillPP jr .Finish .TrainerPP: ; Copy PP from the party struct - ld hl, OTPartyMon1PP - ld a, [CurPartyMon] + ld hl, wOTPartyMon1PP + ld a, [wCurPartyMon] call GetPartyLocation - ld de, EnemyMonPP + ld de, wEnemyMonPP ld bc, NUM_MOVES call CopyBytes .Finish: ; Only the first five base stats are copied.. - ld hl, BaseStats - ld de, EnemyMonBaseStats - ld b, BaseSpecialDefense - BaseStats + ld hl, wBaseStats + ld de, wEnemyMonBaseStats + ld b, wBaseSpecialDefense - wBaseStats .loop ld a, [hli] ld [de], a @@ -6558,14 +6558,14 @@ LoadEnemyMon: ; 3e8eb dec b jr nz, .loop - ld a, [BaseCatchRate] + ld a, [wBaseCatchRate] ld [de], a inc de - ld a, [BaseExp] + ld a, [wBaseExp] ld [de], a - ld a, [TempEnemyMonSpecies] + ld a, [wTempEnemyMonSpecies] ld [wd265], a call GetPokemonName @@ -6576,22 +6576,22 @@ LoadEnemyMon: ; 3e8eb ret z ; Update enemy nick - ld hl, StringBuffer1 - ld de, EnemyMonNick + ld hl, wStringBuffer1 + ld de, wEnemyMonNick ld bc, MON_NAME_LENGTH call CopyBytes ; Saw this mon - ld a, [TempEnemyMonSpecies] + ld a, [wTempEnemyMonSpecies] dec a ld c, a ld b, SET_FLAG - ld hl, PokedexSeen + ld hl, wPokedexSeen predef SmallFarFlagAction - ld hl, EnemyMonStats - ld de, EnemyStats - ld bc, EnemyMonStatsEnd - EnemyMonStats + ld hl, wEnemyMonStats + ld de, wEnemyStats + ld bc, wEnemyMonStatsEnd - wEnemyMonStats call CopyBytes ret @@ -6602,13 +6602,13 @@ CheckSleepingTreeMon: ; 3eb38 ; for the current time of day ; Don't do anything if this isn't a tree encounter - ld a, [BattleType] + ld a, [wBattleType] cp BATTLETYPE_TREE jr nz, .NotSleeping ; Get list for the time of day ld hl, AsleepTreeMonsMorn - ld a, [TimeOfDay] + ld a, [wTimeOfDay] cp DAY_F jr c, .Check ld hl, AsleepTreeMonsDay @@ -6616,7 +6616,7 @@ CheckSleepingTreeMon: ; 3eb38 ld hl, AsleepTreeMonsNite .Check: - ld a, [TempEnemyMonSpecies] + ld a, [wTempEnemyMonSpecies] ld de, 1 ; length of species id call IsInArray ; If it's a match, the opponent is asleep @@ -6649,7 +6649,7 @@ CheckUnownLetter: ; 3eb75 ld l, a push de - ld a, [UnownLetter] + ld a, [wUnownLetter] ld de, 1 push bc call IsInArray @@ -6698,22 +6698,22 @@ CheckUnownLetter: ; 3eb75 Unreferenced_SwapBattlerLevels: ; 3ebc7 push bc - ld a, [BattleMonLevel] + ld a, [wBattleMonLevel] ld b, a - ld a, [EnemyMonLevel] - ld [BattleMonLevel], a + ld a, [wEnemyMonLevel] + ld [wBattleMonLevel], a ld a, b - ld [EnemyMonLevel], a + ld [wEnemyMonLevel], a pop bc ret ; 3ebd8 BattleWinSlideInEnemyTrainerFrontpic: ; 3ebd8 xor a - ld [TempEnemyMonSpecies], a + ld [wTempEnemyMonSpecies], a call FinishBattleAnim - ld a, [OtherTrainerClass] - ld [TrainerClass], a + ld a, [wOtherTrainerClass] + ld [wTrainerClass], a ld de, vTiles2 callfar GetTrainerPic hlcoord 19, 0 @@ -6789,10 +6789,10 @@ ApplyPrzEffectOnSpeed: ; 3ec39 ld a, [hBattleTurn] and a jr z, .enemy - ld a, [BattleMonStatus] + ld a, [wBattleMonStatus] and 1 << PAR ret z - ld hl, BattleMonSpeed + 1 + ld hl, wBattleMonSpeed + 1 ld a, [hld] ld b, a ld a, [hl] @@ -6810,10 +6810,10 @@ ApplyPrzEffectOnSpeed: ; 3ec39 ret .enemy - ld a, [EnemyMonStatus] + ld a, [wEnemyMonStatus] and 1 << PAR ret z - ld hl, EnemyMonSpeed + 1 + ld hl, wEnemyMonSpeed + 1 ld a, [hld] ld b, a ld a, [hl] @@ -6835,10 +6835,10 @@ ApplyBrnEffectOnAttack: ; 3ec76 ld a, [hBattleTurn] and a jr z, .enemy - ld a, [BattleMonStatus] + ld a, [wBattleMonStatus] and 1 << BRN ret z - ld hl, BattleMonAttack + 1 + ld hl, wBattleMonAttack + 1 ld a, [hld] ld b, a ld a, [hl] @@ -6854,10 +6854,10 @@ ApplyBrnEffectOnAttack: ; 3ec76 ret .enemy - ld a, [EnemyMonStatus] + ld a, [wEnemyMonStatus] and 1 << BRN ret z - ld hl, EnemyMonAttack + 1 + ld hl, wEnemyMonAttack + 1 ld a, [hld] ld b, a ld a, [hl] @@ -6891,13 +6891,13 @@ ApplyStatLevelMultiplier: ; 3ecb7 ld a, [wd265] and a ld a, c - ld hl, BattleMonAttack - ld de, PlayerStats - ld bc, PlayerAtkLevel + ld hl, wBattleMonAttack + ld de, wPlayerStats + ld bc, wPlayerAtkLevel jr z, .got_pointers - ld hl, EnemyMonAttack - ld de, EnemyStats - ld bc, EnemyAtkLevel + ld hl, wEnemyMonAttack + ld de, wEnemyStats + ld bc, wEnemyAtkLevel .got_pointers add c @@ -6989,7 +6989,8 @@ ApplyStatLevelMultiplier: ; 3ecb7 ; 3ed45 BadgeStatBoosts: ; 3ed45 -; Raise BattleMon stats depending on which badges have been obtained. +; Raise the stats of the battle mon in wBattleMon +; depending on which badges have been obtained. ; Every other badge boosts a stat, starting from the first. @@ -7005,7 +7006,7 @@ BadgeStatBoosts: ; 3ed45 and a ret nz - ld a, [InBattleTowerBattle] + ld a, [wInBattleTowerBattle] and a ret nz @@ -7028,7 +7029,7 @@ BadgeStatBoosts: ; 3ed45 or c ld b, a - ld hl, BattleMonAttack + ld hl, wBattleMonAttack ld c, 4 .CheckBadge: ld a, b @@ -7124,13 +7125,13 @@ _BattleRandom:: ; 3edd8 ; Which value are we trying to pull? push hl push bc - ld a, [LinkBattleRNCount] + ld a, [wLinkBattleRNCount] ld c, a ld b, 0 - ld hl, LinkBattleRNs + ld hl, wLinkBattleRNs add hl, bc inc a - ld [LinkBattleRNCount], a + ld [wLinkBattleRNCount], a ; If we haven't hit the end yet, we're good cp 10 - 1 ; Exclude last value. See the closing comment @@ -7147,8 +7148,8 @@ _BattleRandom:: ; 3edd8 ; Reset count to 0 xor a - ld [LinkBattleRNCount], a - ld hl, LinkBattleRNs + ld [wLinkBattleRNCount], a + ld hl, wLinkBattleRNs ld b, 10 ; number of seeds ; Generate next number in the sequence for each seed @@ -7188,9 +7189,9 @@ Call_PlayBattleAnim_OnlyIfVisible: ; 3ee0f Call_PlayBattleAnim: ; 3ee17 ld a, e - ld [FXAnimID], a + ld [wFXAnimID], a ld a, d - ld [FXAnimID + 1], a + ld [wFXAnimID + 1], a call WaitBGMap predef_jump PlayBattleAnim ; 3ee27 @@ -7218,14 +7219,14 @@ GiveExperiencePoints: ; 3ee3b and a ret nz - ld a, [InBattleTowerBattle] + ld a, [wInBattleTowerBattle] bit 0, a ret nz call .EvenlyDivideExpAmongParticipants xor a - ld [CurPartyMon], a - ld bc, PartyMon1Species + ld [wCurPartyMon], a + ld bc, wPartyMon1Species .loop ld hl, MON_HP @@ -7236,7 +7237,7 @@ GiveExperiencePoints: ; 3ee3b push bc ld hl, wBattleParticipantsNotFainted - ld a, [CurPartyMon] + ld a, [wCurPartyMon] ld c, a ld b, CHECK_FLAG ld d, $0 @@ -7251,7 +7252,7 @@ GiveExperiencePoints: ; 3ee3b add hl, bc ld d, h ld e, l - ld hl, EnemyMonBaseStats - 1 + ld hl, wEnemyMonBaseStats - 1 push bc ld c, $5 .loop1 @@ -7303,9 +7304,9 @@ GiveExperiencePoints: ; 3ee3b xor a ld [hMultiplicand + 0], a ld [hMultiplicand + 1], a - ld a, [EnemyMonBaseExp] + ld a, [wEnemyMonBaseExp] ld [hMultiplicand + 2], a - ld a, [EnemyMonLevel] + ld a, [wEnemyMonLevel] ld [hMultiplier], a call Multiply ld a, 7 @@ -7316,11 +7317,11 @@ GiveExperiencePoints: ; 3ee3b pop bc ld hl, MON_ID add hl, bc - ld a, [PlayerID] + ld a, [wPlayerID] cp [hl] jr nz, .boosted inc hl - ld a, [PlayerID + 1] + ld a, [wPlayerID + 1] cp [hl] ld a, $0 jr z, .no_boost @@ -7331,7 +7332,7 @@ GiveExperiencePoints: ; 3ee3b .no_boost ; Boost experience for a Trainer Battle - ld [StringBuffer2 + 2], a + ld [wStringBuffer2 + 2], a ld a, [wBattleMode] dec a call nz, BoostExp @@ -7343,17 +7344,17 @@ GiveExperiencePoints: ; 3ee3b cp LUCKY_EGG call z, BoostExp ld a, [hQuotient + 2] - ld [StringBuffer2 + 1], a + ld [wStringBuffer2 + 1], a ld a, [hQuotient + 1] - ld [StringBuffer2], a - ld a, [CurPartyMon] - ld hl, PartyMonNicknames + ld [wStringBuffer2], a + ld a, [wCurPartyMon] + ld hl, wPartyMonNicknames call GetNick ld hl, Text_PkmnGainedExpPoint call BattleTextBox - ld a, [StringBuffer2 + 1] + ld a, [wStringBuffer2 + 1] ld [hQuotient + 2], a - ld a, [StringBuffer2] + ld a, [wStringBuffer2] ld [hQuotient + 1], a pop bc call AnimateExpBar @@ -7380,13 +7381,13 @@ GiveExperiencePoints: ; 3ee3b ld [hl], a .skip2 - ld a, [CurPartyMon] + ld a, [wCurPartyMon] ld e, a ld d, $0 - ld hl, PartySpecies + ld hl, wPartySpecies add hl, de ld a, [hl] - ld [CurSpecies], a + ld [wCurSpecies], a call GetBaseData push bc ld d, MAX_LEVEL @@ -7417,7 +7418,7 @@ GiveExperiencePoints: ; 3ee3b .not_max_exp xor a ; PARTYMON - ld [MonType], a + ld [wMonType], a predef CopyPkmnToTempMon callfar CalcLevel pop bc @@ -7430,15 +7431,15 @@ GiveExperiencePoints: ; 3ee3b jp z, .skip_stats ; <NICKNAME> grew to level ##! ld [wTempLevel], a - ld a, [CurPartyLevel] + ld a, [wCurPartyLevel] push af ld a, d - ld [CurPartyLevel], a + ld [wCurPartyLevel], a ld [hl], a ld hl, MON_SPECIES add hl, bc ld a, [hl] - ld [CurSpecies], a + ld [wCurSpecies], a ld [wd265], a call GetBaseData ld hl, MON_MAXHP + 1 @@ -7473,18 +7474,18 @@ GiveExperiencePoints: ; 3ee3b ld a, [hl] adc d ld [hl], a - ld a, [CurBattleMon] + ld a, [wCurBattleMon] ld d, a - ld a, [CurPartyMon] + ld a, [wCurPartyMon] cp d jr nz, .skip_animation - ld de, BattleMonHP + ld de, wBattleMonHP ld a, [hli] ld [de], a inc de ld a, [hli] ld [de], a - ld de, BattleMonMaxHP + ld de, wBattleMonMaxHP push bc ld bc, PARTYMON_STRUCT_LENGTH - MON_MAXHP call CopyBytes @@ -7492,13 +7493,13 @@ GiveExperiencePoints: ; 3ee3b ld hl, MON_LEVEL add hl, bc ld a, [hl] - ld [BattleMonLevel], a - ld a, [PlayerSubStatus5] + ld [wBattleMonLevel], a + ld a, [wPlayerSubStatus5] bit SUBSTATUS_TRANSFORMED, a jr nz, .transformed ld hl, MON_ATK add hl, bc - ld de, PlayerStats + ld de, wPlayerStats ld bc, PARTYMON_STRUCT_LENGTH - MON_ATK call CopyBytes @@ -7516,9 +7517,9 @@ GiveExperiencePoints: ; 3ee3b .skip_animation farcall LevelUpHappinessMod - ld a, [CurBattleMon] + ld a, [wCurBattleMon] ld b, a - ld a, [CurPartyMon] + ld a, [wCurPartyMon] cp b jr z, .skip_animation2 ld de, SFX_HIT_END_OF_EXP_BAR @@ -7530,7 +7531,7 @@ GiveExperiencePoints: ; 3ee3b .skip_animation2 xor a ; PARTYMON - ld [MonType], a + ld [wMonType], a predef CopyPkmnToTempMon hlcoord 9, 0 ld b, $a @@ -7544,10 +7545,10 @@ GiveExperiencePoints: ; 3ee3b call WaitPressAorB_BlinkCursor call Call_LoadTempTileMapToTileMap xor a ; PARTYMON - ld [MonType], a - ld a, [CurSpecies] + ld [wMonType], a + ld a, [wCurSpecies] ld [wd265], a - ld a, [CurPartyLevel] + ld a, [wCurPartyLevel] push af ld c, a ld a, [wTempLevel] @@ -7556,7 +7557,7 @@ GiveExperiencePoints: ; 3ee3b .level_loop inc b ld a, b - ld [CurPartyLevel], a + ld [wCurPartyLevel], a push bc predef LearnLevelMoves pop bc @@ -7564,23 +7565,23 @@ GiveExperiencePoints: ; 3ee3b cp c jr nz, .level_loop pop af - ld [CurPartyLevel], a - ld hl, EvolvableFlags - ld a, [CurPartyMon] + ld [wCurPartyLevel], a + ld hl, wEvolvableFlags + ld a, [wCurPartyMon] ld c, a ld b, SET_FLAG predef SmallFarFlagAction pop af - ld [CurPartyLevel], a + ld [wCurPartyLevel], a .skip_stats - ld a, [PartyCount] + ld a, [wPartyCount] ld b, a - ld a, [CurPartyMon] + ld a, [wCurPartyMon] inc a cp b jr z, .done - ld [CurPartyMon], a + ld [wCurPartyMon], a ld a, MON_SPECIES call GetPartyParamLocation ld b, h @@ -7608,8 +7609,8 @@ GiveExperiencePoints: ; 3ee3b ret c ld [wd265], a - ld hl, EnemyMonBaseStats - ld c, EnemyMonEnd - EnemyMonBaseStats + ld hl, wEnemyMonBaseStats + ld c, wEnemyMonEnd - wEnemyMonBaseStats .count_loop2 xor a ld [hDividend + 0], a @@ -7651,7 +7652,7 @@ Text_PkmnGainedExpPoint: ; 3f11b text_jump Text_Gained start_asm ld hl, TextJump_StringBuffer2ExpPoints - ld a, [StringBuffer2 + 2] ; IsTradedMon + ld a, [wStringBuffer2 + 2] ; IsTradedMon and a ret z @@ -7672,12 +7673,12 @@ TextJump_StringBuffer2ExpPoints: ; 3f131 AnimateExpBar: ; 3f136 push bc - ld hl, CurPartyMon - ld a, [CurBattleMon] + ld hl, wCurPartyMon + ld a, [wCurBattleMon] cp [hl] jp nz, .finish - ld a, [BattleMonLevel] + ld a, [wBattleMonLevel] cp MAX_LEVEL jp nc, .finish @@ -7690,16 +7691,16 @@ AnimateExpBar: ; 3f136 xor a ld [wd002], a xor a ; PARTYMON - ld [MonType], a + ld [wMonType], a predef CopyPkmnToTempMon - ld a, [TempMonLevel] + ld a, [wTempMonLevel] ld b, a ld e, a push de - ld de, TempMonExp + 2 + ld de, wTempMonExp + 2 call CalcExpBar push bc - ld hl, TempMonExp + 2 + ld hl, wTempMonExp + 2 ld a, [wd004] add [hl] ld [hld], a @@ -7723,7 +7724,7 @@ AnimateExpBar: ; 3f136 ld c, a ld a, [hProduct + 3] ld d, a - ld hl, TempMonExp + 2 + ld hl, wTempMonExp + 2 ld a, [hld] sub d ld a, [hld] @@ -7756,16 +7757,16 @@ AnimateExpBar: ; 3f136 cp d jr z, .FinishExpBar inc a - ld [TempMonLevel], a - ld [CurPartyLevel], a - ld [BattleMonLevel], a + ld [wTempMonLevel], a + ld [wCurPartyLevel], a + ld [wBattleMonLevel], a push de call .PlayExpBarSound ld c, $40 call .LoopBarAnimation call PrintPlayerHUD - ld hl, BattleMonNick - ld de, StringBuffer1 + ld hl, wBattleMonNick + ld de, wStringBuffer1 ld bc, MON_NAME_LENGTH call CopyBytes call TerminateExpBarSound @@ -7783,7 +7784,7 @@ AnimateExpBar: ; 3f136 .FinishExpBar: push bc ld b, d - ld de, TempMonExp + 2 + ld de, wTempMonExp + 2 call CalcExpBar ld a, b pop bc @@ -7868,7 +7869,7 @@ SendOutPkmnText: ; 3f26d .not_linked ; Depending on the HP of the enemy Pkmn, the game prints a different text - ld hl, EnemyMonHP + ld hl, wEnemyMonHP ld a, [hli] or [hl] ld hl, JumpText_GoPkmn @@ -7877,7 +7878,7 @@ SendOutPkmnText: ; 3f26d ; compute enemy helth remaining as a percentage xor a ld [hMultiplicand + 0], a - ld hl, EnemyMonHP + ld hl, wEnemyMonHP ld a, [hli] ld [wEnemyHPAtTimeOfPlayerSwitch], a ld [hMultiplicand + 1], a @@ -7887,7 +7888,7 @@ SendOutPkmnText: ; 3f26d ld a, 25 ld [hMultiplier], a call Multiply - ld hl, EnemyMonMaxHP + ld hl, wEnemyMonMaxHP ld a, [hli] ld b, [hl] srl a @@ -7959,7 +7960,7 @@ WithdrawPkmnText: ; 3f2f4 ; depending on HP the message is different push de push bc - ld hl, EnemyMonHP + 1 + ld hl, wEnemyMonHP + 1 ld de, wEnemyHPAtTimeOfPlayerSwitch + 1 ld b, [hl] dec hl @@ -7974,7 +7975,7 @@ WithdrawPkmnText: ; 3f2f4 ld a, 25 ld [hMultiplier], a call Multiply - ld hl, EnemyMonMaxHP + ld hl, wEnemyMonMaxHP ld a, [hli] ld b, [hl] srl a @@ -8048,11 +8049,11 @@ Unreferenced_HandleSafariAngerEatingStatus: ld hl, BattleText_WildPkmnIsAngry jr nz, .finish push hl - ld a, [EnemyMonSpecies] - ld [CurSpecies], a + ld a, [wEnemyMonSpecies] + ld [wCurSpecies], a call GetBaseData - ld a, [BaseCatchRate] - ld [EnemyMonCatchRate], a + ld a, [wBaseCatchRate] + ld [wEnemyMonCatchRate], a pop hl .finish @@ -8205,7 +8206,7 @@ PlaceExpBar: ; 3f41c ; 3f43d GetBattleMonBackpic: ; 3f43d - ld a, [PlayerSubStatus4] + ld a, [wPlayerSubStatus4] bit SUBSTATUS_SUBSTITUTE, a ld hl, BattleAnimCmd_RaiseSub jr nz, GetBattleMonBackpic_DoAnim ; substitute @@ -8215,16 +8216,16 @@ DropPlayerSub: ; 3f447 and a ld hl, BattleAnimCmd_MinimizeOpp jr nz, GetBattleMonBackpic_DoAnim - ld a, [CurPartySpecies] + ld a, [wCurPartySpecies] push af - ld a, [BattleMonSpecies] - ld [CurPartySpecies], a - ld hl, BattleMonDVs + ld a, [wBattleMonSpecies] + ld [wCurPartySpecies], a + ld hl, wBattleMonDVs predef GetUnownLetter ld de, vTiles2 tile $31 predef GetMonBackpic pop af - ld [CurPartySpecies], a + ld [wCurPartySpecies], a ret ; 3f46f @@ -8241,7 +8242,7 @@ GetBattleMonBackpic_DoAnim: ; 3f46f ; 3f47c GetEnemyMonFrontpic: ; 3f47c - ld a, [EnemySubStatus4] + ld a, [wEnemySubStatus4] bit SUBSTATUS_SUBSTITUTE, a ld hl, BattleAnimCmd_RaiseSub jr nz, GetEnemyMonFrontpic_DoAnim @@ -8252,18 +8253,18 @@ DropEnemySub: ; 3f486 ld hl, BattleAnimCmd_MinimizeOpp jr nz, GetEnemyMonFrontpic_DoAnim - ld a, [CurPartySpecies] + ld a, [wCurPartySpecies] push af - ld a, [EnemyMonSpecies] - ld [CurSpecies], a - ld [CurPartySpecies], a + ld a, [wEnemyMonSpecies] + ld [wCurSpecies], a + ld [wCurPartySpecies], a call GetBaseData - ld hl, EnemyMonDVs + ld hl, wEnemyMonDVs predef GetUnownLetter ld de, vTiles2 predef GetAnimatedFrontpic pop af - ld [CurPartySpecies], a + ld [wCurPartySpecies], a ret ; 3f4b4 @@ -8282,17 +8283,17 @@ StartBattle: ; 3f4c1 ; 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. - ld a, [PartyCount] + ld a, [wPartyCount] and a ret z - ld a, [TimeOfDayPal] + ld a, [wTimeOfDayPal] push af call BattleIntro call DoBattle call ExitBattle pop af - ld [TimeOfDayPal], a + ld [wTimeOfDayPal], a scf ret ; 3f4d9 @@ -8306,7 +8307,7 @@ BattleIntro: ; 3f4dd farcall StubbedTrainerRankings_Battles ; mobile call LoadTrainerOrWildMonPic xor a - ld [TempBattleMonSpecies], a + ld [wTempBattleMonSpecies], a ld [wBattleMenuCursorBuffer], a xor a ld [hMapAnims], a @@ -8344,19 +8345,19 @@ BattleIntro: ; 3f4dd ; 3f54e LoadTrainerOrWildMonPic: ; 3f54e - ld a, [OtherTrainerClass] + ld a, [wOtherTrainerClass] and a jr nz, .Trainer - ld a, [TempWildMonSpecies] - ld [CurPartySpecies], a + ld a, [wTempWildMonSpecies] + ld [wCurPartySpecies], a .Trainer: - ld [TempEnemyMonSpecies], a + ld [wTempEnemyMonSpecies], a ret ; 3f55e InitEnemy: ; 3f55e - ld a, [OtherTrainerClass] + ld a, [wOtherTrainerClass] and a jp nz, InitEnemyTrainer ; trainer jp InitEnemyWildmon ; wild @@ -8387,19 +8388,19 @@ BackUpBGMap2: ; 3f568 ; 3f594 InitEnemyTrainer: ; 3f594 - ld [TrainerClass], a + ld [wTrainerClass], a farcall StubbedTrainerRankings_TrainerBattles xor a - ld [TempEnemyMonSpecies], a + ld [wTempEnemyMonSpecies], a callfar GetTrainerAttributes callfar ReadTrainerParty ; RIVAL1's first mon has no held item - ld a, [TrainerClass] + ld a, [wTrainerClass] cp RIVAL1 jr nz, .ok xor a - ld [OTPartyMon1Item], a + ld [wOTPartyMon1Item], a .ok ld de, vTiles2 @@ -8412,15 +8413,15 @@ InitEnemyTrainer: ; 3f594 lb bc, 7, 7 predef PlaceGraphic ld a, -1 - ld [CurOTMon], a + ld [wCurOTMon], a ld a, TRAINER_BATTLE ld [wBattleMode], a call IsGymLeader jr nc, .done xor a - ld [CurPartyMon], a - ld a, [PartyCount] + ld [wCurPartyMon], a + ld a, [wPartyCount] ld b, a .partyloop push bc @@ -8435,7 +8436,7 @@ InitEnemyTrainer: ; 3f594 pop bc dec b jr z, .done - ld hl, CurPartyMon + ld hl, wCurPartyMon inc [hl] jr .partyloop .done @@ -8447,29 +8448,29 @@ InitEnemyWildmon: ; 3f607 ld [wBattleMode], a farcall StubbedTrainerRankings_WildBattles call LoadEnemyMon - ld hl, EnemyMonMoves + ld hl, wEnemyMonMoves ld de, wWildMonMoves ld bc, NUM_MOVES call CopyBytes - ld hl, EnemyMonPP + ld hl, wEnemyMonPP ld de, wWildMonPP ld bc, NUM_MOVES call CopyBytes - ld hl, EnemyMonDVs + ld hl, wEnemyMonDVs predef GetUnownLetter - ld a, [CurPartySpecies] + ld a, [wCurPartySpecies] cp UNOWN jr nz, .skip_unown ld a, [wFirstUnownSeen] and a jr nz, .skip_unown - ld a, [UnownLetter] + ld a, [wUnownLetter] ld [wFirstUnownSeen], a .skip_unown ld de, vTiles2 predef GetAnimatedFrontpic xor a - ld [TrainerClass], a + ld [wTrainerClass], a ld [hGraphicStartTile], a hlcoord 12, 0 lb bc, 7, 7 @@ -8478,7 +8479,7 @@ InitEnemyWildmon: ; 3f607 ; 3f662 Unreferenced_Function3f662: ; 3f662 - ld hl, EnemyMonMoves + ld hl, wEnemyMonMoves ld de, wListMoves_MoveIndicesBuffer ld b, NUM_MOVES .loop @@ -8500,7 +8501,7 @@ Unreferenced_Function3f662: ; 3f662 call GetFarByte pop hl - ld bc, EnemyMonPP - (EnemyMonMoves + 1) + ld bc, wEnemyMonPP - (wEnemyMonMoves + 1) add hl, bc ld [hl], a @@ -8518,7 +8519,7 @@ Unreferenced_Function3f662: ; 3f662 .clearpp push bc push hl - ld bc, EnemyMonPP - (EnemyMonMoves + 1) + ld bc, wEnemyMonPP - (wEnemyMonMoves + 1) add hl, bc xor a ld [hl], a @@ -8560,12 +8561,12 @@ ExitBattle: ; 3f69e CleanUpBattleRAM: ; 3f6d0 call BattleEnd_HandleRoamMons xor a - ld [Danger], a + ld [wLowHealthAlarm], a ld [wBattleMode], a - ld [BattleType], a - ld [AttackMissed], a - ld [TempWildMonSpecies], a - ld [OtherTrainerClass], a + ld [wBattleType], a + ld [wAttackMissed], a + ld [wTempWildMonSpecies], a + ld [wOtherTrainerClass], a ld [wFailedToFlee], a ld [wNumFleeAttempts], a ld [wForcedSwitch], a @@ -8573,15 +8574,15 @@ CleanUpBattleRAM: ; 3f6d0 ld [wKeyItemsPocketCursor], a ld [wItemsPocketCursor], a ld [wBattleMenuCursorBuffer], a - ld [CurMoveNum], a + ld [wCurMoveNum], a ld [wBallsPocketCursor], a ld [wLastPocket], a ld [wMenuScrollPosition], a ld [wKeyItemsPocketScrollPosition], a ld [wItemsPocketScrollPosition], a ld [wBallsPocketScrollPosition], a - ld hl, PlayerSubStatus1 - ld b, EnemyFuryCutterCount - PlayerSubStatus1 + ld hl, wPlayerSubStatus1 + ld b, wEnemyFuryCutterCount - wPlayerSubStatus1 .loop ld [hli], a dec b @@ -8614,11 +8615,11 @@ CheckPayDay: ; 3f71d .okay ld hl, wPayDayMoney + 2 - ld de, Money + 2 + ld de, wMoney + 2 call AddBattleMoneyToAccount ld hl, BattleText_PlayerPickedUpPayDayMoney call StdBattleTextBox - ld a, [InBattleTowerBattle] + ld a, [wInBattleTowerBattle] bit 0, a ret z call ClearTileMap @@ -8629,10 +8630,10 @@ CheckPayDay: ; 3f71d ShowLinkBattleParticipantsAfterEnd: ; 3f759 farcall StubbedTrainerRankings_LinkBattles farcall BackupMobileEventIndex - ld a, [CurOTMon] - ld hl, OTPartyMon1Status + ld a, [wCurOTMon] + ld hl, wOTPartyMon1Status call GetPartyLocation - ld a, [EnemyMonStatus] + ld a, [wEnemyMonStatus] ld [hl], a call ClearTileMap farcall _ShowLinkBattleParticipants @@ -8734,7 +8735,7 @@ DisplayLinkRecord: ; 3f836 call ReadAndPrintLinkBattleRecord call CloseSRAM - hlcoord 0, 0, AttrMap + hlcoord 0, 0, wAttrMap xor a ld bc, SCREEN_WIDTH * SCREEN_HEIGHT call ByteFill @@ -8883,14 +8884,14 @@ ReadAndPrintLinkBattleRecord: ; 3f85f ; 3f998 BattleEnd_HandleRoamMons: ; 3f998 - ld a, [BattleType] + ld a, [wBattleType] cp BATTLETYPE_ROAMING jr nz, .not_roaming ld a, [wBattleResult] and $f jr z, .caught_or_defeated_roam_mon call GetRoamMonHP - ld a, [EnemyMonHP + 1] + ld a, [wEnemyMonHP + 1] ld [hl], a jr .update_roam_mons @@ -8916,7 +8917,7 @@ BattleEnd_HandleRoamMons: ; 3f998 ; 3f9d1 GetRoamMonMapGroup: ; 3f9d1 - ld a, [TempEnemyMonSpecies] + ld a, [wTempEnemyMonSpecies] ld b, a ld a, [wRoamMon1Species] cp b @@ -8931,7 +8932,7 @@ GetRoamMonMapGroup: ; 3f9d1 ; 3f9e9 GetRoamMonMapNumber: ; 3f9e9 - ld a, [TempEnemyMonSpecies] + ld a, [wTempEnemyMonSpecies] ld b, a ld a, [wRoamMon1Species] cp b @@ -8947,7 +8948,7 @@ GetRoamMonMapNumber: ; 3f9e9 GetRoamMonHP: ; 3fa01 ; output: hl = wRoamMonHP - ld a, [TempEnemyMonSpecies] + ld a, [wTempEnemyMonSpecies] ld b, a ld a, [wRoamMon1Species] cp b @@ -8963,7 +8964,7 @@ GetRoamMonHP: ; 3fa01 GetRoamMonDVs: ; 3fa19 ; output: hl = wRoamMonDVs - ld a, [TempEnemyMonSpecies] + ld a, [wTempEnemyMonSpecies] ld b, a ld a, [wRoamMon1Species] cp b @@ -8978,7 +8979,7 @@ GetRoamMonDVs: ; 3fa19 ; 3fa31 GetRoamMonSpecies: ; 3fa31 - ld a, [TempEnemyMonSpecies] + ld a, [wTempEnemyMonSpecies] ld hl, wRoamMon1Species cp [hl] ret z @@ -8990,11 +8991,11 @@ GetRoamMonSpecies: ; 3fa31 ; 3fa42 AddLastMobileBattleToLinkRecord: ; 3fa42 - ld hl, OTPlayerID - ld de, StringBuffer1 + ld hl, wOTPlayerID + ld de, wStringBuffer1 ld bc, 2 call CopyBytes - ld hl, OTPlayerName + ld hl, wOTPlayerName ld bc, NAME_LENGTH - 1 call CopyBytes ld hl, sLinkBattleResults @@ -9012,7 +9013,7 @@ AddLastMobileBattleToLinkRecord: ; 3fa42 jr z, .copy push de ld bc, 12 - ld de, StringBuffer1 + ld de, wStringBuffer1 call CompareLong pop de pop hl @@ -9028,7 +9029,7 @@ AddLastMobileBattleToLinkRecord: ; 3fa42 .copy ld d, h ld e, l - ld hl, StringBuffer1 + ld hl, wStringBuffer1 ld bc, 12 call CopyBytes ld b, 6 @@ -9275,7 +9276,7 @@ GetTrainerBackpic: ; 3fbff ; Special exception for Dude. ld b, BANK(DudeBackpic) ld hl, DudeBackpic - ld a, [BattleType] + ld a, [wBattleType] cp BATTLETYPE_TUTORIAL jr z, .Decompress @@ -9326,7 +9327,7 @@ CopyBackpic: ; 3fc30 ; 3fc5b .LoadTrainerBackpicAsOAM: ; 3fc5b - ld hl, Sprite01 + ld hl, wVirtualOAMSprite00 xor a ld [hMapObjectIndexBuffer], a ld b, 6 @@ -9406,12 +9407,12 @@ BattleStartMessage: ; 3fc8b .cry_no_anim ld a, $0f - ld [CryTracks], a - ld a, [TempEnemyMonSpecies] + ld [wCryTracks], a + ld a, [wTempEnemyMonSpecies] call PlayStereoCry .skip_cry - ld a, [BattleType] + ld a, [wBattleType] cp BATTLETYPE_FISH jr nz, .NotFishing diff --git a/engine/battle/effect_commands.asm b/engine/battle/effect_commands.asm index c1bc3752a..48efba8fa 100644 --- a/engine/battle/effect_commands.asm +++ b/engine/battle/effect_commands.asm @@ -1,7 +1,7 @@ DoPlayerTurn: ; 34000 call SetPlayerTurn - ld a, [wPlayerAction] + ld a, [wBattlePlayerAction] and a ret nz @@ -56,7 +56,7 @@ DoMove: ; 3402c ld a, BANK(MoveEffectsPointers) call GetFarHalfword - ld de, BattleScriptBuffer + ld de, wBattleScriptBuffer .GetMoveEffect: ld a, BANK(MoveEffects) @@ -68,27 +68,27 @@ DoMove: ; 3402c jr nz, .GetMoveEffect ; Start at the first command. - ld hl, BattleScriptBuffer + ld hl, wBattleScriptBuffer ld a, l - ld [BattleScriptBufferAddress], a + ld [wBattleScriptBufferAddress], a ld a, h - ld [BattleScriptBufferAddress + 1], a + ld [wBattleScriptBufferAddress + 1], a .ReadMoveEffectCommand: -; ld a, [BattleScriptBufferAddress++] - ld a, [BattleScriptBufferAddress] +; ld a, [wBattleScriptBufferAddress++] + ld a, [wBattleScriptBufferAddress] ld l, a - ld a, [BattleScriptBufferAddress + 1] + ld a, [wBattleScriptBufferAddress + 1] ld h, a ld a, [hli] push af ld a, l - ld [BattleScriptBufferAddress], a + ld [wBattleScriptBufferAddress], a ld a, h - ld [BattleScriptBufferAddress + 1], a + ld [wBattleScriptBufferAddress + 1], a pop af ; endturn_command (-2) is used to terminate branches without ending the read cycle. @@ -131,15 +131,15 @@ BattleCommand_CheckTurn: ; 34084 jp z, EndTurn xor a - ld [AttackMissed], a - ld [EffectFailed], a + ld [wAttackMissed], a + ld [wEffectFailed], a ld [wKickCounter], a - ld [AlreadyDisobeyed], a - ld [AlreadyFailed], a + ld [wAlreadyDisobeyed], a + ld [wAlreadyFailed], a ld [wSomeoneIsRampaging], a ld a, EFFECTIVE - ld [TypeModifier], a + ld [wTypeModifier], a ld a, [hBattleTurn] and a @@ -148,7 +148,7 @@ BattleCommand_CheckTurn: ; 34084 CheckPlayerTurn: - ld hl, PlayerSubStatus4 + ld hl, wPlayerSubStatus4 bit SUBSTATUS_RECHARGE, [hl] jr z, .no_recharge @@ -161,13 +161,13 @@ CheckPlayerTurn: .no_recharge - ld hl, BattleMonStatus + ld hl, wBattleMonStatus ld a, [hl] and SLP jr z, .not_asleep dec a - ld [BattleMonStatus], a + ld [wBattleMonStatus], a and SLP jr z, .woke_up @@ -186,7 +186,7 @@ CheckPlayerTurn: call CallBattleCore ld a, $1 ld [hBGMapMode], a - ld hl, PlayerSubStatus1 + ld hl, wPlayerSubStatus1 res SUBSTATUS_NIGHTMARE, [hl] jr .not_asleep @@ -195,7 +195,7 @@ CheckPlayerTurn: call StdBattleTextBox ; Snore and Sleep Talk bypass sleep. - ld a, [CurPlayerMove] + ld a, [wCurPlayerMove] cp SNORE jr z, .not_asleep cp SLEEP_TALK @@ -207,12 +207,12 @@ CheckPlayerTurn: .not_asleep - ld hl, BattleMonStatus + ld hl, wBattleMonStatus bit FRZ, [hl] jr z, .not_frozen ; Flame Wheel and Sacred Fire thaw the user. - ld a, [CurPlayerMove] + ld a, [wCurPlayerMove] cp FLAME_WHEEL jr z, .not_frozen cp SACRED_FIRE @@ -227,7 +227,7 @@ CheckPlayerTurn: .not_frozen - ld hl, PlayerSubStatus3 + ld hl, wPlayerSubStatus3 bit SUBSTATUS_FLINCHED, [hl] jr z, .not_flinched @@ -241,7 +241,7 @@ CheckPlayerTurn: .not_flinched - ld hl, PlayerDisableCount + ld hl, wPlayerDisableCount ld a, [hl] and a jr z, .not_disabled @@ -252,21 +252,21 @@ CheckPlayerTurn: jr nz, .not_disabled ld [hl], a - ld [DisabledMove], a + ld [wDisabledMove], a ld hl, DisabledNoMoreText call StdBattleTextBox .not_disabled - ld a, [PlayerSubStatus3] + ld a, [wPlayerSubStatus3] add a jr nc, .not_confused - ld hl, PlayerConfuseCount + ld hl, wPlayerConfuseCount dec [hl] jr nz, .confused - ld hl, PlayerSubStatus3 + ld hl, wPlayerSubStatus3 res SUBSTATUS_CONFUSED, [hl] ld hl, ConfusedNoMoreText call StdBattleTextBox @@ -286,7 +286,7 @@ CheckPlayerTurn: jr nc, .not_confused ; clear confusion-dependent substatus - ld hl, PlayerSubStatus3 + ld hl, wPlayerSubStatus3 ld a, [hl] and 1 << SUBSTATUS_CONFUSED ld [hl], a @@ -298,7 +298,7 @@ CheckPlayerTurn: .not_confused - ld a, [PlayerSubStatus1] + ld a, [wPlayerSubStatus1] add a ; bit SUBSTATUS_ATTRACT jr nc, .not_infatuated @@ -323,12 +323,12 @@ CheckPlayerTurn: ; We can't disable a move that doesn't exist. - ld a, [DisabledMove] + ld a, [wDisabledMove] and a jr z, .no_disabled_move ; Are we using the disabled move? - ld hl, CurPlayerMove + ld hl, wCurPlayerMove cp [hl] jr nz, .no_disabled_move @@ -339,7 +339,7 @@ CheckPlayerTurn: .no_disabled_move - ld hl, BattleMonStatus + ld hl, wBattleMonStatus bit PAR, [hl] ret z @@ -397,7 +397,7 @@ OpponentCantMove: ; 34216 CheckEnemyTurn: ; 3421f - ld hl, EnemySubStatus4 + ld hl, wEnemySubStatus4 bit SUBSTATUS_RECHARGE, [hl] jr z, .no_recharge @@ -410,13 +410,13 @@ CheckEnemyTurn: ; 3421f .no_recharge - ld hl, EnemyMonStatus + ld hl, wEnemyMonStatus ld a, [hl] and SLP jr z, .not_asleep dec a - ld [EnemyMonStatus], a + ld [wEnemyMonStatus], a and a jr z, .woke_up @@ -437,13 +437,13 @@ CheckEnemyTurn: ; 3421f call CallBattleCore ld a, $1 ld [hBGMapMode], a - ld hl, EnemySubStatus1 + ld hl, wEnemySubStatus1 res SUBSTATUS_NIGHTMARE, [hl] jr .not_asleep .fast_asleep ; Snore and Sleep Talk bypass sleep. - ld a, [CurEnemyMove] + ld a, [wCurEnemyMove] cp SNORE jr z, .not_asleep cp SLEEP_TALK @@ -454,12 +454,12 @@ CheckEnemyTurn: ; 3421f .not_asleep - ld hl, EnemyMonStatus + ld hl, wEnemyMonStatus bit FRZ, [hl] jr z, .not_frozen ; Flame Wheel and Sacred Fire thaw the user. - ld a, [CurEnemyMove] + ld a, [wCurEnemyMove] cp FLAME_WHEEL jr z, .not_frozen cp SACRED_FIRE @@ -473,7 +473,7 @@ CheckEnemyTurn: ; 3421f .not_frozen - ld hl, EnemySubStatus3 + ld hl, wEnemySubStatus3 bit SUBSTATUS_FLINCHED, [hl] jr z, .not_flinched @@ -487,7 +487,7 @@ CheckEnemyTurn: ; 3421f .not_flinched - ld hl, EnemyDisableCount + ld hl, wEnemyDisableCount ld a, [hl] and a jr z, .not_disabled @@ -498,7 +498,7 @@ CheckEnemyTurn: ; 3421f jr nz, .not_disabled ld [hl], a - ld [EnemyDisabledMove], a + ld [wEnemyDisabledMove], a ld hl, DisabledNoMoreText call StdBattleTextBox @@ -506,15 +506,15 @@ CheckEnemyTurn: ; 3421f .not_disabled - ld a, [EnemySubStatus3] + ld a, [wEnemySubStatus3] add a ; bit SUBSTATUS_CONFUSED jr nc, .not_confused - ld hl, EnemyConfuseCount + ld hl, wEnemyConfuseCount dec [hl] jr nz, .confused - ld hl, EnemySubStatus3 + ld hl, wEnemySubStatus3 res SUBSTATUS_CONFUSED, [hl] ld hl, ConfusedNoMoreText call StdBattleTextBox @@ -536,7 +536,7 @@ CheckEnemyTurn: ; 3421f jr nc, .not_confused ; clear confusion-dependent substatus - ld hl, EnemySubStatus3 + ld hl, wEnemySubStatus3 ld a, [hl] and 1 << SUBSTATUS_CONFUSED ld [hl], a @@ -565,7 +565,7 @@ CheckEnemyTurn: ; 3421f .not_confused - ld a, [EnemySubStatus1] + ld a, [wEnemySubStatus1] add a ; bit SUBSTATUS_ATTRACT jr nc, .not_infatuated @@ -590,12 +590,12 @@ CheckEnemyTurn: ; 3421f ; We can't disable a move that doesn't exist. - ld a, [EnemyDisabledMove] + ld a, [wEnemyDisabledMove] and a jr z, .no_disabled_move ; Are we using the disabled move? - ld hl, CurEnemyMove + ld hl, wCurEnemyMove cp [hl] jr nz, .no_disabled_move @@ -607,7 +607,7 @@ CheckEnemyTurn: ; 3421f .no_disabled_move - ld hl, EnemyMonStatus + ld hl, wEnemyMonStatus bit PAR, [hl] ret z @@ -656,7 +656,7 @@ HitConfusion: ; 343a5 call StdBattleTextBox xor a - ld [CriticalHit], a + ld [wCriticalHit], a call HitSelfInConfusion call BattleCommand_DamageCalc @@ -695,12 +695,12 @@ BattleCommand_CheckObedience: ; 343db ret nz ; If we've already checked this turn - ld a, [AlreadyDisobeyed] + ld a, [wAlreadyDisobeyed] and a ret nz xor a - ld [AlreadyDisobeyed], a + ld [wAlreadyDisobeyed], a ; No obedience in link battles ; (since no handling exists for enemy) @@ -708,7 +708,7 @@ BattleCommand_CheckObedience: ; 343db and a ret nz - ld a, [InBattleTowerBattle] + ld a, [wInBattleTowerBattle] and a ret nz @@ -717,11 +717,11 @@ BattleCommand_CheckObedience: ; 343db ld a, MON_ID call BattlePartyAttr - ld a, [PlayerID] + ld a, [wPlayerID] cp [hl] jr nz, .obeylevel inc hl - ld a, [PlayerID + 1] + ld a, [wPlayerID + 1] cp [hl] ret z @@ -762,7 +762,7 @@ BattleCommand_CheckObedience: ; 343db ld b, a ld c, a - ld a, [BattleMonLevel] + ld a, [wBattleMonLevel] ld d, a add b @@ -839,7 +839,7 @@ BattleCommand_CheckObedience: ; 343db and SLP jr z, .Nap - ld [BattleMonStatus], a + ld [wBattleMonStatus], a ld hl, BeganToNapText jr .Print @@ -872,18 +872,18 @@ BattleCommand_CheckObedience: ; 343db .UseInstead: ; Can't use another move if the monster only has one! - ld a, [BattleMonMoves + 1] + ld a, [wBattleMonMoves + 1] and a jr z, .DoNothing ; Don't bother trying to handle Disable. - ld a, [DisabledMove] + ld a, [wDisabledMove] and a jr nz, .DoNothing - ld hl, BattleMonPP - ld de, BattleMonMoves + ld hl, wBattleMonPP + ld de, wBattleMonMoves ld b, 0 ld c, NUM_MOVES @@ -904,8 +904,8 @@ BattleCommand_CheckObedience: ; 343db .CheckMovePP: - ld hl, BattleMonPP - ld a, [CurMoveNum] + ld hl, wBattleMonPP + ld a, [wCurMoveNum] ld e, a ld d, 0 add hl, de @@ -919,13 +919,13 @@ BattleCommand_CheckObedience: ; 343db ; Make sure we can actually use the move once we get there. ld a, 1 - ld [AlreadyDisobeyed], a + ld [wAlreadyDisobeyed], a ld a, [w2DMenuNumRows] ld b, a ; Save the move we originally picked for afterward. - ld a, [CurMoveNum] + ld a, [wCurMoveNum] ld c, a push af @@ -942,8 +942,8 @@ BattleCommand_CheckObedience: ; 343db jr z, .RandomMove ; Make sure it has PP. - ld [CurMoveNum], a - ld hl, BattleMonPP + ld [wCurMoveNum], a + ld hl, wBattleMonPP ld e, a ld d, 0 add hl, de @@ -953,13 +953,13 @@ BattleCommand_CheckObedience: ; 343db ; Use it. - ld a, [CurMoveNum] + ld a, [wCurMoveNum] ld c, a ld b, 0 - ld hl, BattleMonMoves + ld hl, wBattleMonMoves add hl, bc ld a, [hl] - ld [CurPlayerMove], a + ld [wCurPlayerMove], a call SetPlayerTurn call UpdateMoveData @@ -968,19 +968,19 @@ BattleCommand_CheckObedience: ; 343db ; Restore original move choice. pop af - ld [CurMoveNum], a + ld [wCurMoveNum], a .EndDisobedience: xor a - ld [LastPlayerMove], a - ld [LastPlayerCounterMove], a + ld [wLastPlayerMove], a + ld [wLastPlayerCounterMove], a ; Break Encore too. - ld hl, PlayerSubStatus5 + ld hl, wPlayerSubStatus5 res SUBSTATUS_ENCORED, [hl] xor a - ld [PlayerEncoreCount], a + ld [wPlayerEncoreCount], a jp EndMoveEffect @@ -1044,17 +1044,17 @@ BattleCommand_DoTurn: ; 34555 call CheckUserIsCharging ret nz - ld hl, BattleMonPP - ld de, PlayerSubStatus3 - ld bc, PlayerTurnsTaken + ld hl, wBattleMonPP + ld de, wPlayerSubStatus3 + ld bc, wPlayerTurnsTaken ld a, [hBattleTurn] and a jr z, .proceed - ld hl, EnemyMonPP - ld de, EnemySubStatus3 - ld bc, EnemyTurnsTaken + ld hl, wEnemyMonPP + ld de, wEnemySubStatus3 + ld bc, wEnemyTurnsTaken .proceed @@ -1088,8 +1088,8 @@ BattleCommand_DoTurn: ; 34555 ld a, [hBattleTurn] and a - ld hl, PartyMon1PP - ld a, [CurBattleMon] + ld hl, wPartyMon1PP + ld a, [wCurBattleMon] jr z, .player ; mimic this part entirely if wildbattle @@ -1097,8 +1097,8 @@ BattleCommand_DoTurn: ; 34555 dec a jr z, .wild - ld hl, OTPartyMon1PP - ld a, [CurOTMon] + ld hl, wOTPartyMon1PP + ld a, [wCurOTMon] .player call GetPartyLocation @@ -1110,9 +1110,9 @@ BattleCommand_DoTurn: ; 34555 .consume_pp ld a, [hBattleTurn] and a - ld a, [CurMoveNum] + ld a, [wCurMoveNum] jr z, .okay - ld a, [CurEnemyMoveNum] + ld a, [wCurEnemyMoveNum] .okay ld c, a @@ -1126,8 +1126,8 @@ BattleCommand_DoTurn: ; 34555 ret .wild - ld hl, EnemyMonMoves - ld a, [CurEnemyMoveNum] + ld hl, wEnemyMonMoves + ld a, [wCurEnemyMoveNum] ld c, a ld b, 0 add hl, bc @@ -1182,9 +1182,9 @@ BattleCommand_DoTurn: ; 34555 CheckMimicUsed: ; 3460b ld a, [hBattleTurn] and a - ld a, [CurMoveNum] + ld a, [wCurMoveNum] jr z, .player - ld a, [CurEnemyMoveNum] + ld a, [wCurEnemyMoveNum] .player ld c, a @@ -1218,7 +1218,7 @@ BattleCommand_Critical: ; 34631 ; Determine whether this attack's hit will be critical. xor a - ld [CriticalHit], a + ld [wCriticalHit], a ld a, BATTLE_VARS_MOVE_POWER call GetBattleVar @@ -1227,11 +1227,11 @@ BattleCommand_Critical: ; 34631 ld a, [hBattleTurn] and a - ld hl, EnemyMonItem - ld a, [EnemyMonSpecies] + ld hl, wEnemyMonItem + ld a, [wEnemyMonSpecies] jr nz, .Item - ld hl, BattleMonItem - ld a, [BattleMonSpecies] + ld hl, wBattleMonItem + ld a, [wBattleMonSpecies] .Item: ld c, 0 @@ -1299,7 +1299,7 @@ BattleCommand_Critical: ; 34631 cp [hl] ret nc ld a, 1 - ld [CriticalHit], a + ld [wCriticalHit], a ret INCLUDE "data/battle/critical_hits.asm" @@ -1312,7 +1312,7 @@ BattleCommand_TripleKick: ; 346b2 ld a, [wKickCounter] ld b, a inc b - ld hl, CurDamage + 1 + ld hl, wCurDamage + 1 ld a, [hld] ld e, a ld a, [hli] @@ -1354,11 +1354,11 @@ BattleCommand_Stab: ; 346d2 cp STRUGGLE ret z - ld hl, BattleMonType1 + ld hl, wBattleMonType1 ld a, [hli] ld b, a ld c, [hl] - ld hl, EnemyMonType1 + ld hl, wEnemyMonType1 ld a, [hli] ld d, a ld e, [hl] @@ -1367,11 +1367,11 @@ BattleCommand_Stab: ; 346d2 and a jr z, .go ; Who Attacks and who Defends - ld hl, EnemyMonType1 + ld hl, wEnemyMonType1 ld a, [hli] ld b, a ld c, [hl] - ld hl, BattleMonType1 + ld hl, wBattleMonType1 ld a, [hli] ld d, a ld e, [hl] @@ -1404,7 +1404,7 @@ BattleCommand_Stab: ; 346d2 jr .SkipStab .stab - ld hl, CurDamage + 1 + ld hl, wCurDamage + 1 ld a, [hld] ld h, [hl] ld l, a @@ -1416,11 +1416,11 @@ BattleCommand_Stab: ; 346d2 add hl, bc ld a, h - ld [CurDamage], a + ld [wCurDamage], a ld a, l - ld [CurDamage + 1], a + ld [wCurDamage + 1], a - ld hl, TypeModifier + ld hl, wTypeModifier set 7, [hl] .SkipStab: @@ -1459,7 +1459,7 @@ BattleCommand_Stab: ; 346d2 push hl push bc inc hl - ld a, [TypeModifier] + ld a, [wTypeModifier] and %10000000 ld b, a ; If the target is immune to the move, treat it as a miss and calculate the damage as 0 @@ -1467,17 +1467,17 @@ BattleCommand_Stab: ; 346d2 and a jr nz, .NotImmune inc a - ld [AttackMissed], a + ld [wAttackMissed], a xor a .NotImmune: ld [hMultiplier], a add b - ld [TypeModifier], a + ld [wTypeModifier], a xor a ld [hMultiplicand + 0], a - ld hl, CurDamage + ld hl, wCurDamage ld a, [hli] ld [hMultiplicand + 1], a ld a, [hld] @@ -1525,21 +1525,21 @@ BattleCommand_Stab: ; 346d2 call BattleCheckTypeMatchup ld a, [wTypeMatchup] ld b, a - ld a, [TypeModifier] + ld a, [wTypeModifier] and %10000000 or b - ld [TypeModifier], a + ld [wTypeModifier], a ret ; 347c8 BattleCheckTypeMatchup: ; 347c8 - ld hl, EnemyMonType1 + ld hl, wEnemyMonType1 ld a, [hBattleTurn] and a jr z, CheckTypeMatchup - ld hl, BattleMonType1 + ld hl, wBattleMonType1 CheckTypeMatchup: ; 347d3 ; There is an incorrect assumption about this function made in the AI related code: when ; the AI calls CheckTypeMatchup (not BattleCheckTypeMatchup), it assumes that placing @@ -1626,9 +1626,9 @@ BattleCommand_ResetTypeMatchup: ; 34833 jr nz, .reset call ResetDamage xor a - ld [TypeModifier], a + ld [wTypeModifier], a inc a - ld [AttackMissed], a + ld [wAttackMissed], a ret .reset @@ -1652,7 +1652,7 @@ BattleCommand_DamageVariation: ; 34cfd ; No point in reducing 1 or 0 damage. - ld hl, CurDamage + ld hl, wCurDamage ld a, [hli] and a jr nz, .go @@ -1688,7 +1688,7 @@ BattleCommand_DamageVariation: ; 34cfd ; ...to get .85-1.00x damage. ld a, [hQuotient + 1] - ld hl, CurDamage + ld hl, wCurDamage ld [hli], a ld a, [hQuotient + 2] ld [hl], a @@ -1776,7 +1776,7 @@ BattleCommand_CheckHit: ; 34d32 .Missed: ld a, 1 - ld [AttackMissed], a + ld [wAttackMissed], a ret @@ -1908,7 +1908,7 @@ BattleCommand_CheckHit: ; 34d32 cp EFFECT_THUNDER ret nz - ld a, [Weather] + ld a, [wBattleWeather] cp WEATHER_RAIN ret @@ -1927,17 +1927,17 @@ BattleCommand_CheckHit: ; 34d32 ; load the user's accuracy into b and the opponent's evasion into c. ld hl, wPlayerMoveStruct + MOVE_ACC - ld a, [PlayerAccLevel] + ld a, [wPlayerAccLevel] ld b, a - ld a, [EnemyEvaLevel] + ld a, [wEnemyEvaLevel] ld c, a jr z, .got_acc_eva ld hl, wEnemyMoveStruct + MOVE_ACC - ld a, [EnemyAccLevel] + ld a, [wEnemyAccLevel] ld b, a - ld a, [PlayerEvaLevel] + ld a, [wPlayerEvaLevel] ld c, a .got_acc_eva @@ -2020,7 +2020,7 @@ BattleCommand_EffectChance: ; 34ecc ; effectchance xor a - ld [EffectFailed], a + ld [wEffectFailed], a call CheckSubstituteOpp jr nz, .failed @@ -2039,7 +2039,7 @@ BattleCommand_EffectChance: ; 34ecc .failed ld a, 1 - ld [EffectFailed], a + ld [wEffectFailed], a and a ret @@ -2085,7 +2085,7 @@ BattleCommand_LowerSub: ; 34eee xor a ld [wNumHits], a - ld [FXAnimID + 1], a + ld [wFXAnimID + 1], a inc a ld [wKickCounter], a ld a, SUBSTITUTE @@ -2127,16 +2127,16 @@ BattleCommand_HitTarget: ; 34f57 BattleCommand_HitTargetNoSub: ; 34f60 - ld a, [AttackMissed] + ld a, [wAttackMissed] and a jp nz, BattleCommand_MoveDelay ld a, [hBattleTurn] and a - ld de, PlayerRolloutCount + ld de, wPlayerRolloutCount ld a, BATTLEANIM_ENEMY_DAMAGE jr z, .got_rollout_count - ld de, EnemyRolloutCount + ld de, wEnemyRolloutCount ld a, BATTLEANIM_PLAYER_DAMAGE .got_rollout_count @@ -2200,7 +2200,7 @@ BattleCommand_HitTargetNoSub: ; 34f60 BattleCommand_StatUpAnim: ; 34fd1 - ld a, [AttackMissed] + ld a, [wAttackMissed] and a jp nz, BattleCommand_MoveDelay @@ -2211,7 +2211,7 @@ BattleCommand_StatUpAnim: ; 34fd1 BattleCommand_StatDownAnim: ; 34fdb - ld a, [AttackMissed] + ld a, [wAttackMissed] and a jp nz, BattleCommand_MoveDelay @@ -2262,7 +2262,7 @@ BattleCommand_RaiseSub: ; 35004 xor a ld [wNumHits], a - ld [FXAnimID + 1], a + ld [wFXAnimID + 1], a ld a, $2 ld [wKickCounter], a ld a, SUBSTITUTE @@ -2276,7 +2276,7 @@ BattleCommand_FailureText: ; 35023 ; If the move missed or failed, load the appropriate ; text, and end the effects of multi-turn or multi- ; hit moves. - ld a, [AttackMissed] + ld a, [wAttackMissed] and a ret z @@ -2380,20 +2380,20 @@ BattleCommand_CheckFaint: ; 3505e bit SUBSTATUS_SUBSTITUTE, a ret nz - ld de, PlayerDamageTaken + 1 + ld de, wPlayerDamageTaken + 1 ld a, [hBattleTurn] and a jr nz, .damage_taken - ld de, EnemyDamageTaken + 1 + ld de, wEnemyDamageTaken + 1 .damage_taken - ld a, [CurDamage + 1] + ld a, [wCurDamage + 1] ld b, a ld a, [de] add b ld [de], a dec de - ld a, [CurDamage] + ld a, [wCurDamage] ld b, a ld a, [de] adc b @@ -2411,7 +2411,7 @@ BattleCommand_CheckFaint: ; 3505e GetFailureResultText: ; 350e4 ld hl, DoesntAffectText ld de, DoesntAffectText - ld a, [TypeModifier] + ld a, [wTypeModifier] and $7f jr z, .got_text ld a, BATTLE_VARS_MOVE_EFFECT @@ -2422,25 +2422,25 @@ GetFailureResultText: ; 350e4 jr z, .got_text ld hl, AttackMissedText ld de, AttackMissed2Text - ld a, [CriticalHit] + ld a, [wCriticalHit] cp -1 jr nz, .got_text ld hl, UnaffectedText .got_text call FailText_CheckOpponentProtect xor a - ld [CriticalHit], a + ld [wCriticalHit], a ld a, BATTLE_VARS_MOVE_EFFECT call GetBattleVar cp EFFECT_JUMP_KICK ret nz - ld a, [TypeModifier] + ld a, [wTypeModifier] and $7f ret z - ld hl, CurDamage + ld hl, wCurDamage ld a, [hli] ld b, [hl] rept 3 @@ -2480,11 +2480,11 @@ FailText_CheckOpponentProtect: ; 35157 BattleCommanda5: ; 35165 - ld a, [AttackMissed] + ld a, [wAttackMissed] and a ret z - ld a, [TypeModifier] + ld a, [wTypeModifier] and $7f jp z, PrintDoesntAffect jp PrintButItFailed @@ -2497,7 +2497,7 @@ BattleCommand_CriticalText: ; 35175 ; Prints the message for critical hits or one-hit KOs. ; If there is no message to be printed, wait 20 frames. - ld a, [CriticalHit] + ld a, [wCriticalHit] and a jr z, .wait @@ -2513,7 +2513,7 @@ BattleCommand_CriticalText: ; 35175 call StdBattleTextBox xor a - ld [CriticalHit], a + ld [wCriticalHit], a .wait ld c, 20 @@ -2528,11 +2528,11 @@ BattleCommand_CriticalText: ; 35175 BattleCommand_StartLoop: ; 35197 ; startloop - ld hl, PlayerRolloutCount + ld hl, wPlayerRolloutCount ld a, [hBattleTurn] and a jr z, .ok - ld hl, EnemyRolloutCount + ld hl, wEnemyRolloutCount .ok xor a ld [hl], a @@ -2556,7 +2556,7 @@ BattleCommand_SuperEffectiveLoopText: ; 351a5 BattleCommand_SuperEffectiveText: ; 351ad ; supereffectivetext - ld a, [TypeModifier] + ld a, [wTypeModifier] and $7f cp 10 ; 1.0 ret z @@ -2574,11 +2574,11 @@ BattleCommand_CheckDestinyBond: ; 351c0 ; Faint the user if it fainted an opponent using Destiny Bond. - ld hl, EnemyMonHP + ld hl, wEnemyMonHP ld a, [hBattleTurn] and a jr z, .got_hp - ld hl, BattleMonHP + ld hl, wBattleMonHP .got_hp ld a, [hli] @@ -2595,30 +2595,30 @@ BattleCommand_CheckDestinyBond: ; 351c0 ld a, [hBattleTurn] and a - ld hl, EnemyMonMaxHP + 1 + ld hl, wEnemyMonMaxHP + 1 bccoord 2, 2 ; hp bar ld a, 0 jr nz, .got_max_hp - ld hl, BattleMonMaxHP + 1 + ld hl, wBattleMonMaxHP + 1 bccoord 10, 9 ; hp bar ld a, 1 .got_max_hp ld [wWhichHPBar], a ld a, [hld] - ld [Buffer1], a + ld [wBuffer1], a ld a, [hld] - ld [Buffer2], a + ld [wBuffer2], a ld a, [hl] - ld [Buffer3], a + ld [wBuffer3], a xor a ld [hld], a ld a, [hl] - ld [Buffer4], a + ld [wBuffer4], a xor a ld [hl], a - ld [Buffer5], a - ld [Buffer6], a + ld [wBuffer5], a + ld [wBuffer6], a ld h, b ld l, c predef AnimateHPBar @@ -2627,7 +2627,7 @@ BattleCommand_CheckDestinyBond: ; 351c0 call BattleCommand_SwitchTurn xor a ld [wNumHits], a - ld [FXAnimID + 1], a + ld [wFXAnimID + 1], a inc a ld [wKickCounter], a ld a, DESTINY_BOND @@ -2665,7 +2665,7 @@ BattleCommand_BuildOpponentRage: ; 35250 jp .start .start - ld a, [AttackMissed] + ld a, [wAttackMissed] and a ret nz @@ -2696,10 +2696,10 @@ BattleCommand_BuildOpponentRage: ; 35250 BattleCommand_RageDamage: ; 3527b ; ragedamage - ld a, [CurDamage] + ld a, [wCurDamage] ld h, a ld b, a - ld a, [CurDamage + 1] + ld a, [wCurDamage + 1] ld l, a ld c, a ld a, [hBattleTurn] @@ -2716,18 +2716,18 @@ BattleCommand_RageDamage: ; 3527b ld hl, -1 .done ld a, h - ld [CurDamage], a + ld [wCurDamage], a ld a, l - ld [CurDamage + 1], a + ld [wCurDamage + 1], a ret ; 352a3 EndMoveEffect: ; 352a3 - ld a, [BattleScriptBufferAddress] + ld a, [wBattleScriptBufferAddress] ld l, a - ld a, [BattleScriptBufferAddress + 1] + ld a, [wBattleScriptBufferAddress + 1] ld h, a ld a, $ff ld [hli], a @@ -2745,7 +2745,7 @@ DittoMetalPowder: ; 352b1 and a ld a, [hl] jr nz, .Ditto - ld a, [TempEnemyMonSpecies] + ld a, [wTempEnemyMonSpecies] .Ditto: cp DITTO @@ -2804,51 +2804,51 @@ PlayerAttackDamage: ; 352e2 jr nc, .special .physical - ld hl, EnemyMonDefense + ld hl, wEnemyMonDefense ld a, [hli] ld b, a ld c, [hl] - ld a, [EnemyScreens] + ld a, [wEnemyScreens] bit SCREENS_REFLECT, a jr z, .physicalcrit sla c rl b .physicalcrit - ld hl, BattleMonAttack + ld hl, wBattleMonAttack call GetDamageStatsCritical jr c, .thickclub - ld hl, EnemyDefense + ld hl, wEnemyDefense ld a, [hli] ld b, a ld c, [hl] - ld hl, PlayerAttack + ld hl, wPlayerAttack jr .thickclub .special - ld hl, EnemyMonSpclDef + ld hl, wEnemyMonSpclDef ld a, [hli] ld b, a ld c, [hl] - ld a, [EnemyScreens] + ld a, [wEnemyScreens] bit SCREENS_LIGHT_SCREEN, a jr z, .specialcrit sla c rl b .specialcrit - ld hl, BattleMonSpclAtk + ld hl, wBattleMonSpclAtk call GetDamageStatsCritical jr c, .lightball - ld hl, EnemySpDef + ld hl, wEnemySpDef ld a, [hli] ld b, a ld c, [hl] - ld hl, PlayerSpAtk + ld hl, wPlayerSpAtk .lightball ; Note: Returns player special attack at hl in hl. @@ -2862,7 +2862,7 @@ PlayerAttackDamage: ; 352e2 .done call TruncateHL_BC - ld a, [BattleMonLevel] + ld a, [wBattleMonLevel] ld e, a call DittoMetalPowder @@ -2924,7 +2924,7 @@ TruncateHL_BC: ; 3534d GetDamageStatsCritical: ; 35378 ; Return carry if non-critical. - ld a, [CriticalHit] + ld a, [wCriticalHit] and a scf ret z @@ -2945,28 +2945,28 @@ GetDamageStats: ; 3537e ld a, [wPlayerMoveStructType] cp SPECIAL ; special - ld a, [PlayerSAtkLevel] + ld a, [wPlayerSAtkLevel] ld b, a - ld a, [EnemySDefLevel] + ld a, [wEnemySDefLevel] jr nc, .end ; physical - ld a, [PlayerAtkLevel] + ld a, [wPlayerAtkLevel] ld b, a - ld a, [EnemyDefLevel] + ld a, [wEnemyDefLevel] jr .end .enemy ld a, [wEnemyMoveStructType] cp SPECIAL ; special - ld a, [EnemySAtkLevel] + ld a, [wEnemySAtkLevel] ld b, a - ld a, [PlayerSDefLevel] + ld a, [wPlayerSDefLevel] jr nc, .end ; physical - ld a, [EnemyAtkLevel] + ld a, [wEnemyAtkLevel] ld b, a - ld a, [PlayerDefLevel] + ld a, [wPlayerDefLevel] .end cp b pop bc @@ -3030,7 +3030,7 @@ SpeciesItemBoost: ; 353d1 and a ld a, [hl] jr z, .CompareSpecies - ld a, [TempEnemyMonSpecies] + ld a, [wTempEnemyMonSpecies] .CompareSpecies: pop hl @@ -3070,50 +3070,50 @@ EnemyAttackDamage: ; 353f6 jr nc, .Special .physical - ld hl, BattleMonDefense + ld hl, wBattleMonDefense ld a, [hli] ld b, a ld c, [hl] - ld a, [PlayerScreens] + ld a, [wPlayerScreens] bit SCREENS_REFLECT, a jr z, .physicalcrit sla c rl b .physicalcrit - ld hl, EnemyMonAttack + ld hl, wEnemyMonAttack call GetDamageStatsCritical jr c, .thickclub - ld hl, PlayerDefense + ld hl, wPlayerDefense ld a, [hli] ld b, a ld c, [hl] - ld hl, EnemyAttack + ld hl, wEnemyAttack jr .thickclub .Special: - ld hl, BattleMonSpclDef + ld hl, wBattleMonSpclDef ld a, [hli] ld b, a ld c, [hl] - ld a, [PlayerScreens] + ld a, [wPlayerScreens] bit SCREENS_LIGHT_SCREEN, a jr z, .specialcrit sla c rl b .specialcrit - ld hl, EnemyMonSpclAtk + ld hl, wEnemyMonSpclAtk call GetDamageStatsCritical jr c, .lightball - ld hl, PlayerSpDef + ld hl, wPlayerSpDef ld a, [hli] ld b, a ld c, [hl] - ld hl, EnemySpAtk + ld hl, wEnemySpAtk .lightball call LightBallBoost @@ -3125,7 +3125,7 @@ EnemyAttackDamage: ; 353f6 .done call TruncateHL_BC - ld a, [EnemyMonLevel] + ld a, [wEnemyMonLevel] ld e, a call DittoMetalPowder @@ -3143,27 +3143,27 @@ BattleCommand_BeatUp: ; 35461 ld a, [hBattleTurn] and a jp nz, .enemy_beats_up - ld a, [PlayerSubStatus3] + ld a, [wPlayerSubStatus3] bit SUBSTATUS_IN_LOOP, a jr nz, .next_mon ld c, 20 call DelayFrames xor a - ld [PlayerRolloutCount], a + ld [wPlayerRolloutCount], a ld [wd002], a ld [wBeatUpHitAtLeastOnce], a jr .got_mon .next_mon - ld a, [PlayerRolloutCount] + ld a, [wPlayerRolloutCount] ld b, a - ld a, [PartyCount] + ld a, [wPartyCount] sub b ld [wd002], a .got_mon ld a, [wd002] - ld hl, PartyMonNicknames + ld hl, wPartyMonNicknames call GetNick ld a, MON_HP call GetBeatupMonLocation @@ -3172,11 +3172,11 @@ BattleCommand_BeatUp: ; 35461 jp z, .beatup_fail ; fainted ld a, [wd002] ld c, a - ld a, [CurBattleMon] + ld a, [wCurBattleMon] ; BUG: this can desynchronize link battles ; Change "cp [hl]" to "cp c" to fix cp [hl] - ld hl, BattleMonStatus + ld hl, wBattleMonStatus jr z, .active_mon ld a, MON_STATUS call GetBeatupMonLocation @@ -3189,18 +3189,18 @@ BattleCommand_BeatUp: ; 35461 ld [wBeatUpHitAtLeastOnce], a ld hl, BeatUpAttackText call StdBattleTextBox - ld a, [EnemyMonSpecies] - ld [CurSpecies], a + ld a, [wEnemyMonSpecies] + ld [wCurSpecies], a call GetBaseData - ld a, [BaseDefense] + ld a, [wBaseDefense] ld c, a push bc ld a, MON_SPECIES call GetBeatupMonLocation ld a, [hl] - ld [CurSpecies], a + ld [wCurSpecies], a call GetBaseData - ld a, [BaseAttack] + ld a, [wBaseAttack] pop bc ld b, a push bc @@ -3214,20 +3214,20 @@ BattleCommand_BeatUp: ; 35461 ret .enemy_beats_up - ld a, [EnemySubStatus3] + ld a, [wEnemySubStatus3] bit SUBSTATUS_IN_LOOP, a jr nz, .not_first_enemy_beatup xor a - ld [EnemyRolloutCount], a + ld [wEnemyRolloutCount], a ld [wd002], a ld [wBeatUpHitAtLeastOnce], a jr .enemy_continue .not_first_enemy_beatup - ld a, [EnemyRolloutCount] + ld a, [wEnemyRolloutCount] ld b, a - ld a, [OTPartyCount] + ld a, [wOTPartyCount] sub b ld [wd002], a .enemy_continue @@ -3239,14 +3239,14 @@ BattleCommand_BeatUp: ; 35461 and a jr nz, .link_or_tower - ld a, [InBattleTowerBattle] + ld a, [wInBattleTowerBattle] and a jr nz, .link_or_tower ld a, [wd002] ld c, a ld b, 0 - ld hl, OTPartySpecies + ld hl, wOTPartySpecies add hl, bc ld a, [hl] ld [wNamedObjectIndexBuffer], a @@ -3255,10 +3255,10 @@ BattleCommand_BeatUp: ; 35461 .link_or_tower ld a, [wd002] - ld hl, OTPartyMonNicknames + ld hl, wOTPartyMonNicknames ld bc, NAME_LENGTH call AddNTimes - ld de, StringBuffer1 + ld de, wStringBuffer1 call CopyBytes .got_enemy_nick ld a, MON_HP @@ -3268,9 +3268,9 @@ BattleCommand_BeatUp: ; 35461 jp z, .beatup_fail ld a, [wd002] ld b, a - ld a, [CurOTMon] + ld a, [wCurOTMon] cp b - ld hl, EnemyMonStatus + ld hl, wEnemyMonStatus jr z, .active_enemy ld a, MON_STATUS @@ -3285,7 +3285,7 @@ BattleCommand_BeatUp: ; 35461 jr .finish_beatup .wild - ld a, [EnemyMonSpecies] + ld a, [wEnemyMonSpecies] ld [wNamedObjectIndexBuffer], a call GetPokemonName ld hl, BeatUpAttackText @@ -3295,18 +3295,18 @@ BattleCommand_BeatUp: ; 35461 .finish_beatup ld hl, BeatUpAttackText call StdBattleTextBox - ld a, [BattleMonSpecies] - ld [CurSpecies], a + ld a, [wBattleMonSpecies] + ld [wCurSpecies], a call GetBaseData - ld a, [BaseDefense] + ld a, [wBaseDefense] ld c, a push bc ld a, MON_SPECIES call GetBeatupMonLocation ld a, [hl] - ld [CurSpecies], a + ld [wCurSpecies], a call GetBaseData - ld a, [BaseAttack] + ld a, [wBaseAttack] pop bc ld b, a push bc @@ -3345,9 +3345,9 @@ GetBeatupMonLocation: ; 355bd ld b, 0 ld a, [hBattleTurn] and a - ld hl, PartyMon1Species + ld hl, wPartyMon1Species jr z, .got_species - ld hl, OTPartyMon1Species + ld hl, wOTPartyMon1Species .got_species ld a, [wd002] @@ -3359,7 +3359,7 @@ GetBeatupMonLocation: ; 355bd BattleCommand_ClearMissDamage: ; 355d5 ; clearmissdamage - ld a, [AttackMissed] + ld a, [wAttackMissed] and a ret z @@ -3372,14 +3372,14 @@ HitSelfInConfusion: ; 355dd call ResetDamage ld a, [hBattleTurn] and a - ld hl, BattleMonDefense - ld de, PlayerScreens - ld a, [BattleMonLevel] + ld hl, wBattleMonDefense + ld de, wPlayerScreens + ld a, [wBattleMonLevel] jr z, .got_it - ld hl, EnemyMonDefense - ld de, EnemyScreens - ld a, [EnemyMonLevel] + ld hl, wEnemyMonDefense + ld de, wEnemyScreens + ld a, [wEnemyMonLevel] .got_it push af ld a, [hli] @@ -3536,8 +3536,8 @@ BattleCommand_DamageCalc: ; 35612 call .CriticalMultiplier -; Update CurDamage (capped at 997). - ld hl, CurDamage +; Update wCurDamage (capped at 997). + ld hl, wCurDamage ld b, [hl] ld a, [hProduct + 3] add b @@ -3617,7 +3617,7 @@ BattleCommand_DamageCalc: ; 35612 .CriticalMultiplier: - ld a, [CriticalHit] + ld a, [wCriticalHit] and a ret z @@ -3648,11 +3648,11 @@ INCLUDE "data/battle/type_boost_items.asm" BattleCommand_ConstantDamage: ; 35726 ; constantdamage - ld hl, BattleMonLevel + ld hl, wBattleMonLevel ld a, [hBattleTurn] and a jr z, .got_turn - ld hl, EnemyMonLevel + ld hl, wEnemyMonLevel .got_turn ld a, BATTLE_VARS_MOVE_EFFECT @@ -3695,11 +3695,11 @@ BattleCommand_ConstantDamage: ; 35726 jr .got_power .super_fang - ld hl, EnemyMonHP + ld hl, wEnemyMonHP ld a, [hBattleTurn] and a jr z, .got_hp - ld hl, BattleMonHP + ld hl, wBattleMonHP .got_hp ld a, [hli] srl a @@ -3718,17 +3718,17 @@ BattleCommand_ConstantDamage: ; 35726 jr .got_power .got_power - ld hl, CurDamage + ld hl, wCurDamage ld [hli], a ld [hl], b ret .reversal - ld hl, BattleMonHP + ld hl, wBattleMonHP ld a, [hBattleTurn] and a jr z, .reversal_got_hp - ld hl, EnemyMonHP + ld hl, wEnemyMonHP .reversal_got_hp xor a ld [hDividend], a @@ -3818,7 +3818,7 @@ BattleCommand_Counter: ; 35813 ; counter ld a, 1 - ld [AttackMissed], a + ld [wAttackMissed], a ld a, BATTLE_VARS_LAST_COUNTER_MOVE_OPP call GetBattleVar and a @@ -3841,18 +3841,18 @@ BattleCommand_Counter: ; 35813 ld a, BATTLE_VARS_LAST_COUNTER_MOVE_OPP call GetBattleVar dec a - ld de, StringBuffer1 + ld de, wStringBuffer1 call GetMoveData - ld a, [StringBuffer1 + MOVE_POWER] + ld a, [wStringBuffer1 + MOVE_POWER] and a ret z - ld a, [StringBuffer1 + MOVE_TYPE] + ld a, [wStringBuffer1 + MOVE_TYPE] cp SPECIAL ret nc - ld hl, CurDamage + ld hl, wCurDamage ld a, [hli] or [hl] ret z @@ -3870,7 +3870,7 @@ BattleCommand_Counter: ; 35813 .capped xor a - ld [AttackMissed], a + ld [wAttackMissed], a ret ; 35864 @@ -3879,13 +3879,13 @@ BattleCommand_Counter: ; 35813 BattleCommand_Encore: ; 35864 ; encore - ld hl, EnemyMonMoves - ld de, EnemyEncoreCount + ld hl, wEnemyMonMoves + ld de, wEnemyEncoreCount ld a, [hBattleTurn] and a jr z, .ok - ld hl, BattleMonMoves - ld de, PlayerEncoreCount + ld hl, wBattleMonMoves + ld de, wPlayerEncoreCount .ok ld a, BATTLE_VARS_LAST_MOVE_OPP call GetBattleVar @@ -3904,12 +3904,12 @@ BattleCommand_Encore: ; 35864 cp b jr nz, .got_move - ld bc, BattleMonPP - BattleMonMoves - 1 + ld bc, wBattleMonPP - wBattleMonMoves - 1 add hl, bc ld a, [hl] and PP_MASK jp z, .failed - ld a, [AttackMissed] + ld a, [wAttackMissed] and a jp nz, .failed ld a, BATTLE_VARS_SUBSTATUS5_OPP @@ -3930,10 +3930,10 @@ BattleCommand_Encore: ; 35864 jr z, .force_last_enemy_move push hl - ld a, [LastPlayerMove] + ld a, [wLastPlayerMove] ld b, a ld c, 0 - ld hl, BattleMonMoves + ld hl, wBattleMonMoves .find_player_move ld a, [hli] cp b @@ -3951,9 +3951,9 @@ BattleCommand_Encore: ; 35864 .got_player_move pop hl ld a, c - ld [CurMoveNum], a + ld [wCurMoveNum], a ld a, b - ld [CurPlayerMove], a + ld [wCurPlayerMove], a dec a ld de, wPlayerMoveStruct call GetMoveData @@ -3961,10 +3961,10 @@ BattleCommand_Encore: ; 35864 .force_last_enemy_move push hl - ld a, [LastEnemyMove] + ld a, [wLastEnemyMove] ld b, a ld c, 0 - ld hl, EnemyMonMoves + ld hl, wEnemyMonMoves .find_enemy_move ld a, [hli] cp b @@ -3982,9 +3982,9 @@ BattleCommand_Encore: ; 35864 .got_enemy_move pop hl ld a, c - ld [CurEnemyMoveNum], a + ld [wCurEnemyMoveNum], a ld a, b - ld [CurEnemyMove], a + ld [wCurEnemyMove], a dec a ld de, wEnemyMoveStruct call GetMoveData @@ -4003,28 +4003,28 @@ BattleCommand_Encore: ; 35864 BattleCommand_PainSplit: ; 35926 ; painsplit - ld a, [AttackMissed] + ld a, [wAttackMissed] and a jp nz, .ButItFailed call CheckSubstituteOpp jp nz, .ButItFailed call AnimateCurrentMove - ld hl, BattleMonMaxHP + 1 - ld de, EnemyMonMaxHP + 1 + ld hl, wBattleMonMaxHP + 1 + ld de, wEnemyMonMaxHP + 1 call .PlayerShareHP ld a, $1 ld [wWhichHPBar], a hlcoord 10, 9 predef AnimateHPBar - ld hl, EnemyMonHP + ld hl, wEnemyMonHP ld a, [hli] - ld [Buffer4], a + ld [wBuffer4], a ld a, [hli] - ld [Buffer3], a + ld [wBuffer3], a ld a, [hli] - ld [Buffer2], a + ld [wBuffer2], a ld a, [hl] - ld [Buffer1], a + ld [wBuffer1], a call .EnemyShareHP xor a ld [wWhichHPBar], a @@ -4038,28 +4038,28 @@ BattleCommand_PainSplit: ; 35926 .PlayerShareHP: ld a, [hld] - ld [Buffer1], a + ld [wBuffer1], a ld a, [hld] - ld [Buffer2], a + ld [wBuffer2], a ld a, [hld] ld b, a - ld [Buffer3], a + ld [wBuffer3], a ld a, [hl] - ld [Buffer4], a + ld [wBuffer4], a dec de dec de ld a, [de] dec de add b - ld [CurDamage + 1], a + ld [wCurDamage + 1], a ld b, [hl] ld a, [de] adc b srl a - ld [CurDamage], a - ld a, [CurDamage + 1] + ld [wCurDamage], a + ld a, [wCurDamage + 1] rr a - ld [CurDamage + 1], a + ld [wCurDamage + 1], a inc hl inc hl inc hl @@ -4070,25 +4070,25 @@ BattleCommand_PainSplit: ; 35926 .EnemyShareHP: ; 359ac ld c, [hl] dec hl - ld a, [CurDamage + 1] + ld a, [wCurDamage + 1] sub c ld b, [hl] dec hl - ld a, [CurDamage] + ld a, [wCurDamage] sbc b jr nc, .skip - ld a, [CurDamage] + ld a, [wCurDamage] ld b, a - ld a, [CurDamage + 1] + ld a, [wCurDamage + 1] ld c, a .skip ld a, c ld [hld], a - ld [Buffer5], a + ld [wBuffer5], a ld a, b ld [hli], a - ld [Buffer6], a + ld [wBuffer6], a ret ; 359cd @@ -4107,7 +4107,7 @@ BattleCommand_Snore: ; 359d0 ret nz call ResetDamage ld a, $1 - ld [AttackMissed], a + ld [wAttackMissed], a call FailSnore jp EndMoveEffect @@ -4117,14 +4117,14 @@ BattleCommand_Snore: ; 359d0 BattleCommand_Conversion2: ; 359e6 ; conversion2 - ld a, [AttackMissed] + ld a, [wAttackMissed] and a jr nz, .failed - ld hl, BattleMonType1 + ld hl, wBattleMonType1 ld a, [hBattleTurn] and a jr z, .got_type - ld hl, EnemyMonType1 + ld hl, wEnemyMonType1 .got_type ld a, BATTLE_VARS_LAST_COUNTER_MOVE_OPP call GetBattleVar @@ -4188,7 +4188,7 @@ BattleCommand_LockOn: ; 35a53 call CheckSubstituteOpp jr nz, .fail - ld a, [AttackMissed] + ld a, [wAttackMissed] and a jr nz, .fail @@ -4235,11 +4235,11 @@ BattleCommand_Sketch: ; 35a74 ld d, h ld e, l ; Get the battle move structs. - ld hl, BattleMonMoves + ld hl, wBattleMonMoves ld a, [hBattleTurn] and a jr z, .get_last_move - ld hl, EnemyMonMoves + ld hl, wEnemyMonMoves .get_last_move ld a, BATTLE_VARS_LAST_COUNTER_MOVE_OPP call GetBattleVar @@ -4278,7 +4278,7 @@ BattleCommand_Sketch: ; 35a74 ld hl, Moves + MOVE_PP call GetMoveAttr pop hl - ld bc, BattleMonPP - BattleMonMoves + ld bc, wBattleMonPP - wBattleMonMoves add hl, bc ld [hl], a pop bc @@ -4361,17 +4361,17 @@ BattleCommand_SleepTalk: ; 35b33 ; sleeptalk call ClearLastMove - ld a, [AttackMissed] + ld a, [wAttackMissed] and a jr nz, .fail ld a, [hBattleTurn] and a - ld hl, BattleMonMoves + 1 - ld a, [DisabledMove] + ld hl, wBattleMonMoves + 1 + ld a, [wDisabledMove] ld d, a jr z, .got_moves - ld hl, EnemyMonMoves + 1 - ld a, [EnemyDisabledMove] + ld hl, wEnemyMonMoves + 1 + ld a, [wEnemyDisabledMove] ld d, a .got_moves ld a, BATTLE_VARS_STATUS @@ -4438,10 +4438,10 @@ BattleCommand_SleepTalk: ; 35b33 .check_has_usable_move ld a, [hBattleTurn] and a - ld a, [DisabledMove] + ld a, [wDisabledMove] jr z, .got_move_2 - ld a, [EnemyDisabledMove] + ld a, [wEnemyDisabledMove] .got_move_2 ld b, a ld a, BATTLE_VARS_MOVE @@ -4520,15 +4520,15 @@ BattleCommand_DestinyBond: ; 35bff BattleCommand_Spite: ; 35c0f ; spite - ld a, [AttackMissed] + ld a, [wAttackMissed] and a jp nz, .failed ld bc, PARTYMON_STRUCT_LENGTH ; ???? - ld hl, EnemyMonMoves + ld hl, wEnemyMonMoves ld a, [hBattleTurn] and a jr z, .got_moves - ld hl, BattleMonMoves + ld hl, wBattleMonMoves .got_moves ld a, BATTLE_VARS_LAST_COUNTER_MOVE_OPP call GetBattleVar @@ -4547,7 +4547,7 @@ BattleCommand_Spite: ; 35c0f dec hl ld b, 0 push bc - ld c, BattleMonPP - BattleMonMoves + ld c, wBattleMonPP - wBattleMonMoves add hl, bc pop bc ld a, [hl] @@ -4610,13 +4610,13 @@ BattleCommand_Spite: ; 35c0f BattleCommand_FalseSwipe: ; 35c94 ; falseswipe - ld hl, EnemyMonHP + ld hl, wEnemyMonHP ld a, [hBattleTurn] and a jr z, .got_hp - ld hl, BattleMonHP + ld hl, wBattleMonHP .got_hp - ld de, CurDamage + ld de, wCurDamage ld c, 2 push hl push de @@ -4637,11 +4637,11 @@ BattleCommand_FalseSwipe: ; 35c94 dec a ld [de], a .okay - ld a, [CriticalHit] + ld a, [wCriticalHit] cp 2 jr nz, .carry xor a - ld [CriticalHit], a + ld [wCriticalHit], a .carry scf ret @@ -4659,11 +4659,11 @@ BattleCommand_HealBell: ; 35cc9 ld a, BATTLE_VARS_SUBSTATUS1 call GetBattleVarAddr res SUBSTATUS_NIGHTMARE, [hl] - ld de, PartyMon1Status + ld de, wPartyMon1Status ld a, [hBattleTurn] and a jr z, .got_status - ld de, OTPartyMon1Status + ld de, wOTPartyMon1Status .got_status ld a, BATTLE_VARS_STATUS call GetBattleVarAddr @@ -4704,9 +4704,9 @@ FarPlayBattleAnimation: ; 35d00 PlayFXAnimID: ; 35d08 ld a, e - ld [FXAnimID], a + ld [wFXAnimID], a ld a, d - ld [FXAnimID + 1], a + ld [wFXAnimID + 1], a ld c, 3 call DelayFrames @@ -4719,7 +4719,7 @@ PlayFXAnimID: ; 35d08 EnemyHurtItself: ; 35d1c - ld hl, CurDamage + ld hl, wCurDamage ld a, [hli] ld b, a ld a, [hl] @@ -4730,46 +4730,46 @@ EnemyHurtItself: ; 35d1c and a jr nz, .mimic_sub_check - ld a, [EnemySubStatus4] + ld a, [wEnemySubStatus4] bit SUBSTATUS_SUBSTITUTE, a jp nz, SelfInflictDamageToSubstitute .mimic_sub_check ld a, [hld] ld b, a - ld a, [EnemyMonHP + 1] - ld [Buffer3], a + ld a, [wEnemyMonHP + 1] + ld [wBuffer3], a sub b - ld [EnemyMonHP + 1], a + ld [wEnemyMonHP + 1], a ld a, [hl] ld b, a - ld a, [EnemyMonHP] - ld [Buffer4], a + ld a, [wEnemyMonHP] + ld [wBuffer4], a sbc b - ld [EnemyMonHP], a + ld [wEnemyMonHP], a jr nc, .mimic_faint - ld a, [Buffer4] + ld a, [wBuffer4] ld [hli], a - ld a, [Buffer3] + ld a, [wBuffer3] ld [hl], a xor a - ld hl, EnemyMonHP + ld hl, wEnemyMonHP ld [hli], a ld [hl], a .mimic_faint - ld hl, EnemyMonMaxHP + ld hl, wEnemyMonMaxHP ld a, [hli] - ld [Buffer2], a + ld [wBuffer2], a ld a, [hl] - ld [Buffer1], a - ld hl, EnemyMonHP + ld [wBuffer1], a + ld hl, wEnemyMonHP ld a, [hli] - ld [Buffer6], a + ld [wBuffer6], a ld a, [hl] - ld [Buffer5], a + ld [wBuffer5], a hlcoord 2, 2 xor a ld [wWhichHPBar], a @@ -4781,7 +4781,7 @@ EnemyHurtItself: ; 35d1c PlayerHurtItself: ; 35d7e - ld hl, CurDamage + ld hl, wCurDamage ld a, [hli] ld b, a ld a, [hl] @@ -4792,44 +4792,44 @@ PlayerHurtItself: ; 35d7e and a jr nz, .mimic_sub_check - ld a, [PlayerSubStatus4] + ld a, [wPlayerSubStatus4] bit SUBSTATUS_SUBSTITUTE, a jp nz, SelfInflictDamageToSubstitute .mimic_sub_check ld a, [hld] ld b, a - ld a, [BattleMonHP + 1] - ld [Buffer3], a + ld a, [wBattleMonHP + 1] + ld [wBuffer3], a sub b - ld [BattleMonHP + 1], a - ld [Buffer5], a + ld [wBattleMonHP + 1], a + ld [wBuffer5], a ld b, [hl] - ld a, [BattleMonHP] - ld [Buffer4], a + ld a, [wBattleMonHP] + ld [wBuffer4], a sbc b - ld [BattleMonHP], a - ld [Buffer6], a + ld [wBattleMonHP], a + ld [wBuffer6], a jr nc, .mimic_faint - ld a, [Buffer4] + ld a, [wBuffer4] ld [hli], a - ld a, [Buffer3] + ld a, [wBuffer3] ld [hl], a xor a - ld hl, BattleMonHP + ld hl, wBattleMonHP ld [hli], a ld [hl], a - ld hl, Buffer5 + ld hl, wBuffer5 ld [hli], a ld [hl], a .mimic_faint - ld hl, BattleMonMaxHP + ld hl, wBattleMonMaxHP ld a, [hli] - ld [Buffer2], a + ld [wBuffer2], a ld a, [hl] - ld [Buffer1], a + ld [wBuffer1], a hlcoord 10, 9 ld a, $1 ld [wWhichHPBar], a @@ -4845,14 +4845,14 @@ SelfInflictDamageToSubstitute: ; 35de0 ld hl, SubTookDamageText call StdBattleTextBox - ld de, EnemySubstituteHP + ld de, wEnemySubstituteHP ld a, [hBattleTurn] and a jr z, .got_hp - ld de, PlayerSubstituteHP + ld de, wPlayerSubstituteHP .got_hp - ld hl, CurDamage + ld hl, wCurDamage ld a, [hli] and a jr nz, .broke @@ -4910,7 +4910,7 @@ UpdateMoveData: ; 35e40 ld a, BATTLE_VARS_MOVE call GetBattleVar - ld [CurMove], a + ld [wCurMove], a ld [wNamedObjectIndexBuffer], a dec a @@ -4945,7 +4945,7 @@ BattleCommand_SleepTarget: ; 35e5c ld hl, AlreadyAsleepText jr nz, .fail - ld a, [AttackMissed] + ld a, [wAttackMissed] and a jp nz, PrintDidntAffect2 @@ -4962,7 +4962,7 @@ BattleCommand_SleepTarget: ; 35e5c call AnimateCurrentMove ld b, $7 - ld a, [InBattleTowerBattle] + ld a, [wInBattleTowerBattle] and a jr z, .random_loop ld b, $3 @@ -5006,12 +5006,12 @@ BattleCommand_SleepTarget: ; 35e5c and a jr nz, .dont_fail - ld a, [InBattleTowerBattle] + ld a, [wInBattleTowerBattle] and a jr nz, .dont_fail ; Not locked-on by the enemy - ld a, [PlayerSubStatus5] + ld a, [wPlayerSubStatus5] bit SUBSTATUS_LOCK_ON, a jr nz, .dont_fail @@ -5035,7 +5035,7 @@ BattleCommand_PoisonTarget: ; 35eee call GetBattleVarAddr and a ret nz - ld a, [TypeModifier] + ld a, [wTypeModifier] and $7f ret z call CheckIfTargetIsPoisonType @@ -5044,7 +5044,7 @@ BattleCommand_PoisonTarget: ; 35eee ld a, b cp HELD_PREVENT_POISON ret z - ld a, [EffectFailed] + ld a, [wEffectFailed] and a ret nz call SafeCheckSafeguard @@ -5068,7 +5068,7 @@ BattleCommand_Poison: ; 35f2c ; poison ld hl, DoesntAffectText - ld a, [TypeModifier] + ld a, [wTypeModifier] and $7f jp z, .failed @@ -5107,11 +5107,11 @@ BattleCommand_Poison: ; 35f2c and a jr nz, .mimic_random - ld a, [InBattleTowerBattle] + ld a, [wInBattleTowerBattle] and a jr nz, .mimic_random - ld a, [PlayerSubStatus5] + ld a, [wPlayerSubStatus5] bit SUBSTATUS_LOCK_ON, a jr nz, .mimic_random @@ -5122,7 +5122,7 @@ BattleCommand_Poison: ; 35f2c .mimic_random call CheckSubstituteOpp jr nz, .failed - ld a, [AttackMissed] + ld a, [wAttackMissed] and a jr nz, .failed call .check_toxic @@ -5168,9 +5168,9 @@ BattleCommand_Poison: ; 35f2c call GetBattleVarAddr ld a, [hBattleTurn] and a - ld de, EnemyToxicCount + ld de, wEnemyToxicCount jr z, .ok - ld de, PlayerToxicCount + ld de, wPlayerToxicCount .ok ld a, BATTLE_VARS_MOVE_EFFECT call GetBattleVar @@ -5181,11 +5181,11 @@ BattleCommand_Poison: ; 35f2c CheckIfTargetIsPoisonType: ; 35fe1 - ld de, EnemyMonType1 + ld de, wEnemyMonType1 ld a, [hBattleTurn] and a jr z, .ok - ld de, BattleMonType1 + ld de, wBattleMonType1 .ok ld a, [de] inc de @@ -5226,7 +5226,7 @@ BattleCommand_EatDream: ; 36008 SapHealth: ; 36011 - ld hl, CurDamage + ld hl, wCurDamage ld a, [hli] srl a ld [hDividend], a @@ -5239,15 +5239,15 @@ SapHealth: ; 36011 ld a, $1 ld [hDividend + 1], a .ok1 - ld hl, BattleMonHP - ld de, BattleMonMaxHP + ld hl, wBattleMonHP + ld de, wBattleMonMaxHP ld a, [hBattleTurn] and a jr z, .battlemonhp - ld hl, EnemyMonHP - ld de, EnemyMonMaxHP + ld hl, wEnemyMonHP + ld de, wEnemyMonMaxHP .battlemonhp - ld bc, Buffer4 + ld bc, wBuffer4 ld a, [hli] ld [bc], a ld a, [hl] @@ -5264,12 +5264,12 @@ SapHealth: ; 36011 ld b, [hl] add b ld [hld], a - ld [Buffer5], a + ld [wBuffer5], a ld a, [hDividend] ld b, [hl] adc b ld [hli], a - ld [Buffer6], a + ld [wBuffer6], a jr c, .okay2 ld a, [hld] ld b, a @@ -5285,11 +5285,11 @@ SapHealth: ; 36011 .okay2 ld a, [de] ld [hld], a - ld [Buffer5], a + ld [wBuffer5], a dec de ld a, [de] ld [hli], a - ld [Buffer6], a + ld [wBuffer6], a inc de .okay3 ld a, [hBattleTurn] @@ -5319,7 +5319,7 @@ BattleCommand_BurnTarget: ; 3608c call GetBattleVarAddr and a jp nz, Defrost - ld a, [TypeModifier] + ld a, [wTypeModifier] and $7f ret z call CheckMoveTypeMatchesTarget ; Don't burn a Fire-type @@ -5328,7 +5328,7 @@ BattleCommand_BurnTarget: ; 3608c ld a, b cp HELD_PREVENT_BURN ret z - ld a, [EffectFailed] + ld a, [wEffectFailed] and a ret nz call SafeCheckSafeguard @@ -5362,11 +5362,11 @@ Defrost: ; 360dd ld a, [hBattleTurn] and a - ld a, [CurOTMon] - ld hl, OTPartyMon1Status + ld a, [wCurOTMon] + ld hl, wOTPartyMon1Status jr z, .ok - ld hl, PartyMon1Status - ld a, [CurBattleMon] + ld hl, wPartyMon1Status + ld a, [wCurBattleMon] .ok call GetPartyLocation @@ -5391,10 +5391,10 @@ BattleCommand_FreezeTarget: ; 36102 call GetBattleVarAddr and a ret nz - ld a, [TypeModifier] + ld a, [wTypeModifier] and $7f ret z - ld a, [Weather] + ld a, [wBattleWeather] cp WEATHER_SUN ret z call CheckMoveTypeMatchesTarget ; Don't freeze an Ice-type @@ -5403,7 +5403,7 @@ BattleCommand_FreezeTarget: ; 36102 ld a, b cp HELD_PREVENT_FREEZE ret z - ld a, [EffectFailed] + ld a, [wEffectFailed] and a ret nz call SafeCheckSafeguard @@ -5447,14 +5447,14 @@ BattleCommand_ParalyzeTarget: ; 36165 call GetBattleVarAddr and a ret nz - ld a, [TypeModifier] + ld a, [wTypeModifier] and $7f ret z call GetOpponentItem ld a, b cp HELD_PREVENT_PARALYZE ret z - ld a, [EffectFailed] + ld a, [wEffectFailed] and a ret nz call SafeCheckSafeguard @@ -5548,7 +5548,7 @@ BattleCommand_EvasionUp2: ; 361e0 BattleCommand_StatUp: ; 361e4 ; statup call CheckIfStatCanBeRaised - ld a, [FailedMessage] + ld a, [wFailedMessage] and a ret nz jp StatUpAnimation @@ -5558,20 +5558,20 @@ BattleCommand_StatUp: ; 361e4 CheckIfStatCanBeRaised: ; 361ef ld a, b - ld [LoweredStat], a - ld hl, PlayerStatLevels + ld [wLoweredStat], a + ld hl, wPlayerStatLevels ld a, [hBattleTurn] and a jr z, .got_stat_levels - ld hl, EnemyStatLevels + ld hl, wEnemyStatLevels .got_stat_levels - ld a, [AttackMissed] + ld a, [wAttackMissed] and a jp nz, .stat_raise_failed - ld a, [EffectFailed] + ld a, [wEffectFailed] and a jp nz, .stat_raise_failed - ld a, [LoweredStat] + ld a, [wLoweredStat] and $f ld c, a ld b, 0 @@ -5581,7 +5581,7 @@ CheckIfStatCanBeRaised: ; 361ef ld a, $d cp b jp c, .cant_raise_stat - ld a, [LoweredStat] + ld a, [wLoweredStat] and $f0 jr z, .got_num_stages inc b @@ -5595,13 +5595,13 @@ CheckIfStatCanBeRaised: ; 361ef ld a, c cp $5 jr nc, .done_calcing_stats - ld hl, BattleMonStats + 1 - ld de, PlayerStats + ld hl, wBattleMonStats + 1 + ld de, wPlayerStats ld a, [hBattleTurn] and a jr z, .got_stats_pointer - ld hl, EnemyMonStats + 1 - ld de, EnemyStats + ld hl, wEnemyMonStats + 1 + ld de, wEnemyStats .got_stats_pointer push bc sla c @@ -5632,7 +5632,7 @@ CheckIfStatCanBeRaised: ; 361ef .done_calcing_stats pop hl xor a - ld [FailedMessage], a + ld [wFailedMessage], a ret ; 3626e @@ -5647,9 +5647,9 @@ CheckIfStatCanBeRaised: ; 361ef .cant_raise_stat ; 36270 ld a, $2 - ld [FailedMessage], a + ld [wFailedMessage], a ld a, $1 - ld [AttackMissed], a + ld [wAttackMissed], a ret ; 3627b @@ -5657,7 +5657,7 @@ CheckIfStatCanBeRaised: ; 361ef .stat_raise_failed ; 3627b ld a, $1 - ld [FailedMessage], a + ld [wFailedMessage], a ret ; 36281 @@ -5763,20 +5763,20 @@ BattleCommand_EvasionDown2: ; 362e1 BattleCommand_StatDown: ; 362e3 ; statdown - ld [LoweredStat], a + ld [wLoweredStat], a call CheckMist jp nz, .Mist - ld hl, EnemyStatLevels + ld hl, wEnemyStatLevels ld a, [hBattleTurn] and a jr z, .GetStatLevel - ld hl, PlayerStatLevels + ld hl, wPlayerStatLevels .GetStatLevel: ; Attempt to lower the stat. - ld a, [LoweredStat] + ld a, [wLoweredStat] and $f ld c, a ld b, 0 @@ -5786,7 +5786,7 @@ BattleCommand_StatDown: ; 362e3 jp z, .CantLower ; Sharply lower the stat if applicable. - ld a, [LoweredStat] + ld a, [wLoweredStat] and $f0 jr z, .ComputerMiss dec b @@ -5803,12 +5803,12 @@ BattleCommand_StatDown: ; 362e3 and a jr nz, .DidntMiss - ld a, [InBattleTowerBattle] + ld a, [wInBattleTowerBattle] and a jr nz, .DidntMiss ; Lock-On still always works. - ld a, [PlayerSubStatus5] + ld a, [wPlayerSubStatus5] bit SUBSTATUS_LOCK_ON, a jr nz, .DidntMiss @@ -5826,11 +5826,11 @@ BattleCommand_StatDown: ; 362e3 call CheckSubstituteOpp jr nz, .Failed - ld a, [AttackMissed] + ld a, [wAttackMissed] and a jr nz, .Failed - ld a, [EffectFailed] + ld a, [wEffectFailed] and a jr nz, .Failed @@ -5844,13 +5844,13 @@ BattleCommand_StatDown: ; 362e3 jr nc, .Hit push hl - ld hl, EnemyMonAttack + 1 - ld de, EnemyStats + ld hl, wEnemyMonAttack + 1 + ld de, wEnemyStats ld a, [hBattleTurn] and a jr z, .do_enemy - ld hl, BattleMonAttack + 1 - ld de, PlayerStats + ld hl, wBattleMonAttack + 1 + ld de, wPlayerStats .do_enemy call TryLowerStat pop hl @@ -5858,29 +5858,29 @@ BattleCommand_StatDown: ; 362e3 .Hit: xor a - ld [FailedMessage], a + ld [wFailedMessage], a ret .CouldntLower: inc [hl] .CantLower: ld a, 3 - ld [FailedMessage], a + ld [wFailedMessage], a ld a, 1 - ld [AttackMissed], a + ld [wAttackMissed], a ret .Failed: ld a, 1 - ld [FailedMessage], a - ld [AttackMissed], a + ld [wFailedMessage], a + ld [wAttackMissed], a ret .Mist: ld a, 2 - ld [FailedMessage], a + ld [wFailedMessage], a ld a, 1 - ld [AttackMissed], a + ld [wAttackMissed], a ret ; 36391 @@ -5915,10 +5915,10 @@ CheckMist: ; 36391 BattleCommand_StatUpMessage: ; 363b8 - ld a, [FailedMessage] + ld a, [wFailedMessage] and a ret nz - ld a, [LoweredStat] + ld a, [wLoweredStat] and $f ld b, a inc b @@ -5930,7 +5930,7 @@ BattleCommand_StatUpMessage: ; 363b8 text_jump UnknownText_0x1c0cc6 start_asm ld hl, .up - ld a, [LoweredStat] + ld a, [wLoweredStat] and $f0 ret z ld hl, .wayup @@ -5948,10 +5948,10 @@ BattleCommand_StatUpMessage: ; 363b8 BattleCommand_StatDownMessage: ; 363e9 - ld a, [FailedMessage] + ld a, [wFailedMessage] and a ret nz - ld a, [LoweredStat] + ld a, [wLoweredStat] and $f ld b, a inc b @@ -5963,7 +5963,7 @@ BattleCommand_StatDownMessage: ; 363e9 text_jump UnknownText_0x1c0ceb start_asm ld hl, .fell - ld a, [LoweredStat] + ld a, [wLoweredStat] and $f0 ret z ld hl, .sharplyfell @@ -6027,7 +6027,7 @@ TryLowerStat: ; 3641a BattleCommand_StatUpFailText: ; 3644c ; statupfailtext - ld a, [FailedMessage] + ld a, [wFailedMessage] and a ret z push af @@ -6035,7 +6035,7 @@ BattleCommand_StatUpFailText: ; 3644c pop af dec a jp z, TryPrintButItFailed - ld a, [LoweredStat] + ld a, [wLoweredStat] and $f ld b, a inc b @@ -6048,7 +6048,7 @@ BattleCommand_StatUpFailText: ; 3644c BattleCommand_StatDownFailText: ; 3646a ; statdownfailtext - ld a, [FailedMessage] + ld a, [wFailedMessage] and a ret z push af @@ -6059,7 +6059,7 @@ BattleCommand_StatDownFailText: ; 3646a dec a ld hl, ProtectedByMistText jp z, StdBattleTextBox - ld a, [LoweredStat] + ld a, [wLoweredStat] and $f ld b, a inc b @@ -6083,8 +6083,8 @@ GetStatName: ; 3648f jr .GetName .Copy: - ld de, StringBuffer2 - ld bc, StringBuffer3 - StringBuffer2 + ld de, wStringBuffer2 + ld bc, wStringBuffer3 - wStringBuffer2 jp CopyBytes INCLUDE "data/battle/stat_names.asm" @@ -6125,23 +6125,23 @@ BattleCommand_AllStatsUp: ; 36500 ResetMiss: ; 3652d xor a - ld [AttackMissed], a + ld [wAttackMissed], a ret ; 36532 LowerStat: ; 36532 - ld [LoweredStat], a + ld [wLoweredStat], a - ld hl, PlayerStatLevels + ld hl, wPlayerStatLevels ld a, [hBattleTurn] and a jr z, .got_target - ld hl, EnemyStatLevels + ld hl, wEnemyStatLevels .got_target - ld a, [LoweredStat] + ld a, [wLoweredStat] and $f ld c, a ld b, 0 @@ -6150,7 +6150,7 @@ LowerStat: ; 36532 dec b jr z, .cant_lower_anymore - ld a, [LoweredStat] + ld a, [wLoweredStat] and $f0 jr z, .got_num_stages dec b @@ -6164,13 +6164,13 @@ LowerStat: ; 36532 jr nc, .accuracy_evasion push hl - ld hl, BattleMonStats + 1 - ld de, PlayerStats + ld hl, wBattleMonStats + 1 + ld de, wPlayerStats ld a, [hBattleTurn] and a jr z, .got_target_2 - ld hl, EnemyMonStats + 1 - ld de, EnemyStats + ld hl, wEnemyMonStats + 1 + ld de, wEnemyStats .got_target_2 call TryLowerStat @@ -6191,7 +6191,7 @@ LowerStat: ; 36532 .finish xor a - ld [FailedMessage], a + ld [wFailedMessage], a ret .failed @@ -6199,7 +6199,7 @@ LowerStat: ; 36532 .cant_lower_anymore ld a, 2 - ld [FailedMessage], a + ld [wFailedMessage], a ret ; 3658f @@ -6269,9 +6269,9 @@ BattleCommand_LowerSubNoAnim: ; 365c3 CalcPlayerStats: ; 365d7 - ld hl, PlayerAtkLevel - ld de, PlayerStats - ld bc, BattleMonAttack + ld hl, wPlayerAtkLevel + ld de, wPlayerStats + ld bc, wBattleMonAttack ld a, 5 call CalcStats @@ -6293,9 +6293,9 @@ CalcPlayerStats: ; 365d7 CalcEnemyStats: ; 365fd - ld hl, EnemyAtkLevel - ld de, EnemyStats - ld bc, EnemyMonAttack + ld hl, wEnemyAtkLevel + ld de, wEnemyStats + ld bc, wEnemyMonAttack ld a, 5 call CalcStats @@ -6393,11 +6393,11 @@ BattleCommand_StoreEnergy: ; 36671 bit SUBSTATUS_BIDE, a ret z - ld hl, PlayerRolloutCount + ld hl, wPlayerRolloutCount ld a, [hBattleTurn] and a jr z, .check_still_storing_energy - ld hl, EnemyRolloutCount + ld hl, wEnemyRolloutCount .check_still_storing_energy dec [hl] jr nz, .still_storing @@ -6413,30 +6413,30 @@ BattleCommand_StoreEnergy: ; 36671 call GetBattleVarAddr ld a, 1 ld [hl], a - ld hl, PlayerDamageTaken + 1 + ld hl, wPlayerDamageTaken + 1 ld de, wPlayerCharging ; player ld a, [hBattleTurn] and a jr z, .player - ld hl, EnemyDamageTaken + 1 + ld hl, wEnemyDamageTaken + 1 ld de, wEnemyCharging ; enemy .player ld a, [hld] add a ld b, a - ld [CurDamage + 1], a + ld [wCurDamage + 1], a ld a, [hl] rl a - ld [CurDamage], a + ld [wCurDamage], a jr nc, .not_maxed ld a, $ff - ld [CurDamage], a - ld [CurDamage + 1], a + ld [wCurDamage], a + ld [wCurDamage + 1], a .not_maxed or b jr nz, .built_up_something ld a, 1 - ld [AttackMissed], a + ld [wAttackMissed], a .built_up_something xor a ld [hli], a @@ -6462,13 +6462,13 @@ BattleCommand_StoreEnergy: ; 36671 BattleCommand_UnleashEnergy: ; 366e5 ; unleashenergy - ld de, PlayerDamageTaken - ld bc, PlayerRolloutCount + ld de, wPlayerDamageTaken + ld bc, wPlayerRolloutCount ld a, [hBattleTurn] and a jr z, .got_damage - ld de, EnemyDamageTaken - ld bc, EnemyRolloutCount + ld de, wEnemyDamageTaken + ld bc, wEnemyRolloutCount .got_damage ld a, BATTLE_VARS_SUBSTATUS3 call GetBattleVarAddr @@ -6495,11 +6495,11 @@ BattleCommand_UnleashEnergy: ; 366e5 BattleCommand_CheckRampage: ; 3671a ; checkrampage - ld de, PlayerRolloutCount + ld de, wPlayerRolloutCount ld a, [hBattleTurn] and a jr z, .player - ld de, EnemyRolloutCount + ld de, wEnemyRolloutCount .player ld a, BATTLE_VARS_SUBSTATUS3 call GetBattleVarAddr @@ -6541,11 +6541,11 @@ BattleCommand_Rampage: ; 36751 and SLP ret nz - ld de, PlayerRolloutCount + ld de, wPlayerRolloutCount ld a, [hBattleTurn] and a jr z, .ok - ld de, EnemyRolloutCount + ld de, wEnemyRolloutCount .ok ld a, BATTLE_VARS_SUBSTATUS3 call GetBattleVarAddr @@ -6565,7 +6565,7 @@ BattleCommand_Rampage: ; 36751 BattleCommand_Teleport: ; 36778 ; teleport - ld a, [BattleType] + ld a, [wBattleType] cp BATTLETYPE_SHINY jr z, .failed cp BATTLETYPE_TRAP @@ -6588,9 +6588,9 @@ BattleCommand_Teleport: ; 36778 dec a jr nz, .failed ; If your level is greater than the opponent's, you run without fail. - ld a, [CurPartyLevel] + ld a, [wCurPartyLevel] ld b, a - ld a, [BattleMonLevel] + ld a, [wBattleMonLevel] cp b jr nc, .run_away ; Generate a number between 0 and (YourLevel + TheirLevel). @@ -6615,9 +6615,9 @@ BattleCommand_Teleport: ; 36778 ld a, [wBattleMode] dec a jr nz, .failed - ld a, [BattleMonLevel] + ld a, [wBattleMonLevel] ld b, a - ld a, [CurPartyLevel] + ld a, [wCurPartyLevel] cp b jr nc, .run_away add b @@ -6668,7 +6668,7 @@ SetBattleDraw: ; 36804 BattleCommand_ForceSwitch: ; 3680f ; forceswitch - ld a, [BattleType] + ld a, [wBattleType] cp BATTLETYPE_SHINY jp z, .fail cp BATTLETYPE_TRAP @@ -6680,15 +6680,15 @@ BattleCommand_ForceSwitch: ; 3680f ld a, [hBattleTurn] and a jp nz, .force_player_switch - ld a, [AttackMissed] + ld a, [wAttackMissed] and a jr nz, .missed ld a, [wBattleMode] dec a jr nz, .trainer - ld a, [CurPartyLevel] + ld a, [wCurPartyLevel] ld b, a - ld a, [BattleMonLevel] + ld a, [wBattleMonLevel] cp b jr nc, .wild_force_flee add b @@ -6732,9 +6732,9 @@ BattleCommand_ForceSwitch: ; 3680f call ClearBox ld c, 20 call DelayFrames - ld a, [OTPartyCount] + ld a, [wOTPartyCount] ld b, a - ld a, [CurOTMon] + ld a, [wCurOTMon] ld c, a ; select a random enemy mon to switch to .random_loop_trainer @@ -6746,7 +6746,7 @@ BattleCommand_ForceSwitch: ; 3680f jr z, .random_loop_trainer push af push bc - ld hl, OTPartyMon1HP + ld hl, wOTPartyMon1HP call GetPartyLocation ld a, [hli] or [hl] @@ -6768,7 +6768,7 @@ BattleCommand_ForceSwitch: ; 3680f jp .fail .force_player_switch - ld a, [AttackMissed] + ld a, [wAttackMissed] and a jr nz, .player_miss @@ -6776,9 +6776,9 @@ BattleCommand_ForceSwitch: ; 3680f dec a jr nz, .vs_trainer - ld a, [BattleMonLevel] + ld a, [wBattleMonLevel] ld b, a - ld a, [CurPartyLevel] + ld a, [wCurPartyLevel] cp b jr nc, .wild_succeed_playeristarget @@ -6827,9 +6827,9 @@ BattleCommand_ForceSwitch: ; 3680f call ClearBox ld c, 20 call DelayFrames - ld a, [PartyCount] + ld a, [wPartyCount] ld b, a - ld a, [CurBattleMon] + ld a, [wCurBattleMon] ld c, a .random_loop_trainer_playeristarget call BattleRandom @@ -6842,7 +6842,7 @@ BattleCommand_ForceSwitch: ; 3680f push af push bc - ld hl, PartyMon1HP + ld hl, wPartyMon1HP call GetPartyLocation ld a, [hli] or [hl] @@ -6851,7 +6851,7 @@ BattleCommand_ForceSwitch: ; 3680f jr z, .random_loop_trainer_playeristarget ld a, d - ld [CurPartyMon], a + ld [wCurPartyMon], a ld hl, SwitchPlayerMon call CallBattleCore @@ -6888,17 +6888,17 @@ BattleCommand_ForceSwitch: ; 3680f CheckPlayerHasMonToSwitchTo: ; 36994 - ld a, [PartyCount] + ld a, [wPartyCount] ld d, a ld e, 0 ld bc, PARTYMON_STRUCT_LENGTH .loop - ld a, [CurBattleMon] + ld a, [wCurBattleMon] cp e jr z, .next ld a, e - ld hl, PartyMon1HP + ld hl, wPartyMon1HP call AddNTimes ld a, [hli] or [hl] @@ -6924,13 +6924,13 @@ BattleCommand_EndLoop: ; 369b6 ; Loop back to the command before 'critical'. - ld de, PlayerRolloutCount - ld bc, PlayerDamageTaken + ld de, wPlayerRolloutCount + ld bc, wPlayerDamageTaken ld a, [hBattleTurn] and a jr z, .got_addrs - ld de, EnemyRolloutCount - ld bc, EnemyDamageTaken + ld de, wEnemyRolloutCount + ld bc, wEnemyDamageTaken .got_addrs ld a, BATTLE_VARS_SUBSTATUS3 @@ -6965,7 +6965,7 @@ BattleCommand_EndLoop: ; 369b6 ld a, [hBattleTurn] and a jr nz, .check_ot_beat_up - ld a, [PartyCount] + ld a, [wPartyCount] cp 1 jp z, .only_one_beatup dec a @@ -6975,7 +6975,7 @@ BattleCommand_EndLoop: ; 369b6 ld a, [wBattleMode] cp WILD_BATTLE jp z, .only_one_beatup - ld a, [OTPartyCount] + ld a, [wOTPartyCount] cp 1 jp z, .only_one_beatup dec a @@ -7039,9 +7039,9 @@ BattleCommand_EndLoop: ; 369b6 ; Loop back to the command before 'critical'. .loop_back_to_critical - ld a, [BattleScriptBufferAddress + 1] + ld a, [wBattleScriptBufferAddress + 1] ld h, a - ld a, [BattleScriptBufferAddress] + ld a, [wBattleScriptBufferAddress] ld l, a .not_critical ld a, [hld] @@ -7049,16 +7049,16 @@ BattleCommand_EndLoop: ; 369b6 jr nz, .not_critical inc hl ld a, h - ld [BattleScriptBufferAddress + 1], a + ld [wBattleScriptBufferAddress + 1], a ld a, l - ld [BattleScriptBufferAddress], a + ld [wBattleScriptBufferAddress], a ret ; 36a82 BattleCommand_FakeOut: ; 36a82 - ld a, [AttackMissed] + ld a, [wAttackMissed] and a ret nz @@ -7075,7 +7075,7 @@ BattleCommand_FakeOut: ; 36a82 .fail ld a, 1 - ld [AttackMissed], a + ld [wAttackMissed], a ret ; 36aa0 @@ -7093,7 +7093,7 @@ BattleCommand_FlinchTarget: ; 36aa0 call CheckOpponentWentFirst ret nz - ld a, [EffectFailed] + ld a, [wEffectFailed] and a ret nz @@ -7127,7 +7127,7 @@ CheckOpponentWentFirst: ; 36abf BattleCommand_HeldFlinch: ; 36ac9 ; kingsrock - ld a, [AttackMissed] + ld a, [wAttackMissed] and a ret nz @@ -7159,11 +7159,11 @@ BattleCommand_OHKO: ; 36af3 ; ohko call ResetDamage - ld a, [TypeModifier] + ld a, [wTypeModifier] and $7f jr z, .no_effect - ld hl, EnemyMonLevel - ld de, BattleMonLevel + ld hl, wEnemyMonLevel + ld de, wBattleMonLevel ld bc, wPlayerMoveStruct + MOVE_ACC ld a, [hBattleTurn] and a @@ -7186,19 +7186,19 @@ BattleCommand_OHKO: ; 36af3 .finish_ohko ld [bc], a call BattleCommand_CheckHit - ld hl, CurDamage + ld hl, wCurDamage ld a, $ff ld [hli], a ld [hl], a ld a, $2 - ld [CriticalHit], a + ld [wCriticalHit], a ret .no_effect ld a, $ff - ld [CriticalHit], a + ld [wCriticalHit], a ld a, $1 - ld [AttackMissed], a + ld [wAttackMissed], a ret ; 36b3a @@ -7240,7 +7240,7 @@ BattleCommand_Charge: ; 36b4d set SUBSTATUS_CHARGED, [hl] ld hl, IgnoredOrders2Text - ld a, [AlreadyDisobeyed] + ld a, [wAlreadyDisobeyed] and a call nz, StdBattleTextBox @@ -7373,7 +7373,7 @@ BattleCommand3c: ; 36c2c BattleCommand_TrapTarget: ; 36c2d ; traptarget - ld a, [AttackMissed] + ld a, [wAttackMissed] and a ret nz ld hl, wEnemyWrapCount @@ -7469,19 +7469,19 @@ BattleCommand_FocusEnergy: ; 36c98 BattleCommand_Recoil: ; 36cb2 ; recoil - ld hl, BattleMonMaxHP + ld hl, wBattleMonMaxHP ld a, [hBattleTurn] and a jr z, .got_hp - ld hl, EnemyMonMaxHP + ld hl, wEnemyMonMaxHP .got_hp ld a, BATTLE_VARS_MOVE_ANIM call GetBattleVar ld d, a ; get 1/4 damage or 1 HP, whichever is higher - ld a, [CurDamage] + ld a, [wCurDamage] ld b, a - ld a, [CurDamage + 1] + ld a, [wCurDamage + 1] ld c, a srl b rr c @@ -7493,26 +7493,26 @@ BattleCommand_Recoil: ; 36cb2 inc c .min_damage ld a, [hli] - ld [Buffer2], a + ld [wBuffer2], a ld a, [hl] - ld [Buffer1], a + ld [wBuffer1], a dec hl dec hl ld a, [hl] - ld [Buffer3], a + ld [wBuffer3], a sub c ld [hld], a - ld [Buffer5], a + ld [wBuffer5], a ld a, [hl] - ld [Buffer4], a + ld [wBuffer4], a sbc b ld [hl], a - ld [Buffer6], a + ld [wBuffer6], a jr nc, .dont_ko xor a ld [hli], a ld [hl], a - ld hl, Buffer5 + ld hl, wBuffer5 ld [hli], a ld [hl], a .dont_ko @@ -7540,7 +7540,7 @@ BattleCommand_ConfuseTarget: ; 36d1d ld a, b cp HELD_PREVENT_CONFUSE ret z - ld a, [EffectFailed] + ld a, [wEffectFailed] and a ret nz call SafeCheckSafeguard @@ -7580,15 +7580,15 @@ BattleCommand_Confuse: ; 36d3b .not_already_confused call CheckSubstituteOpp jr nz, BattleCommand_Confuse_CheckSnore_Swagger_ConfuseHit - ld a, [AttackMissed] + ld a, [wAttackMissed] and a jr nz, BattleCommand_Confuse_CheckSnore_Swagger_ConfuseHit BattleCommand_FinishConfusingTarget: ; 36d70 - ld bc, EnemyConfuseCount + ld bc, wEnemyConfuseCount ld a, [hBattleTurn] and a jr z, .got_confuse_count - ld bc, PlayerConfuseCount + ld bc, wPlayerConfuseCount .got_confuse_count set SUBSTATUS_CONFUSED, [hl] @@ -7649,7 +7649,7 @@ BattleCommand_Paralyze: ; 36dc7 call GetBattleVar bit PAR, a jr nz, .paralyzed - ld a, [TypeModifier] + ld a, [wTypeModifier] and $7f jr z, .didnt_affect call GetOpponentItem @@ -7672,11 +7672,11 @@ BattleCommand_Paralyze: ; 36dc7 and a jr nz, .dont_sample_failure - ld a, [InBattleTowerBattle] + ld a, [wInBattleTowerBattle] and a jr nz, .dont_sample_failure - ld a, [PlayerSubStatus5] + ld a, [wPlayerSubStatus5] bit SUBSTATUS_LOCK_ON, a jr nz, .dont_sample_failure @@ -7689,7 +7689,7 @@ BattleCommand_Paralyze: ; 36dc7 call GetBattleVarAddr and a jr nz, .failed - ld a, [AttackMissed] + ld a, [wAttackMissed] and a jr nz, .failed call CheckSubstituteOpp @@ -7732,11 +7732,11 @@ CheckMoveTypeMatchesTarget: ; 36e5b push hl - ld hl, EnemyMonType1 + ld hl, wEnemyMonType1 ld a, [hBattleTurn] and a jr z, .ok - ld hl, BattleMonType1 + ld hl, wBattleMonType1 .ok ld a, BATTLE_VARS_MOVE_TYPE @@ -7767,13 +7767,13 @@ BattleCommand_Substitute: ; 36e7c ; substitute call BattleCommand_MoveDelay - ld hl, BattleMonMaxHP - ld de, PlayerSubstituteHP + ld hl, wBattleMonMaxHP + ld de, wPlayerSubstituteHP ld a, [hBattleTurn] and a jr z, .got_hp - ld hl, EnemyMonMaxHP - ld de, EnemySubstituteHP + ld hl, wEnemyMonMaxHP + ld de, wEnemySubstituteHP .got_hp ld a, BATTLE_VARS_SUBSTATUS4 @@ -7826,7 +7826,7 @@ BattleCommand_Substitute: ; 36e7c xor a ld [wNumHits], a - ld [FXAnimID + 1], a + ld [wFXAnimID + 1], a ld [wKickCounter], a ld a, SUBSTITUTE call LoadAnim @@ -7908,7 +7908,7 @@ BattleCommand_DoubleUndergroundDamage: ; 36f2f DoubleDamage: ; 36f37 - ld hl, CurDamage + 1 + ld hl, wCurDamage + 1 sla [hl] dec hl rl [hl] @@ -7928,14 +7928,14 @@ BattleCommand_Mimic: ; 36f46 call ClearLastMove call BattleCommand_MoveDelay - ld a, [AttackMissed] + ld a, [wAttackMissed] and a jr nz, .fail - ld hl, BattleMonMoves + ld hl, wBattleMonMoves ld a, [hBattleTurn] and a jr z, .player_turn - ld hl, EnemyMonMoves + ld hl, wEnemyMonMoves .player_turn call CheckHiddenOpponent jr nz, .fail @@ -7963,7 +7963,7 @@ BattleCommand_Mimic: ; 36f46 call GetBattleVar ld [hl], a ld [wNamedObjectIndexBuffer], a - ld bc, BattleMonPP - BattleMonMoves + ld bc, wBattleMonPP - wBattleMonMoves add hl, bc ld [hl], 5 call GetMoveName @@ -7979,17 +7979,17 @@ BattleCommand_Mimic: ; 36f46 BattleCommand_LeechSeed: ; 36f9d ; leechseed - ld a, [AttackMissed] + ld a, [wAttackMissed] and a jr nz, .evaded call CheckSubstituteOpp jr nz, .evaded - ld de, EnemyMonType1 + ld de, wEnemyMonType1 ld a, [hBattleTurn] and a jr z, .ok - ld de, BattleMonType1 + ld de, wBattleMonType1 .ok ld a, [de] @@ -8032,17 +8032,17 @@ BattleCommand_Splash: ; 36fe1 BattleCommand_Disable: ; 36fed ; disable - ld a, [AttackMissed] + ld a, [wAttackMissed] and a jr nz, .failed - ld de, EnemyDisableCount - ld hl, EnemyMonMoves + ld de, wEnemyDisableCount + ld hl, wEnemyMonMoves ld a, [hBattleTurn] and a jr z, .got_moves - ld de, PlayerDisableCount - ld hl, BattleMonMoves + ld de, wPlayerDisableCount + ld hl, wBattleMonMoves .got_moves ld a, [de] @@ -8066,9 +8066,9 @@ BattleCommand_Disable: ; 36fed ld a, [hBattleTurn] and a - ld hl, EnemyMonPP + ld hl, wEnemyMonPP jr z, .got_pp - ld hl, BattleMonPP + ld hl, wBattleMonPP .got_pp ld b, 0 add hl, bc @@ -8085,7 +8085,7 @@ BattleCommand_Disable: ; 36fed add c ld [de], a call AnimateCurrentMove - ld hl, DisabledMove + ld hl, wDisabledMove ld a, [hBattleTurn] and a jr nz, .got_disabled_move_pointer @@ -8109,14 +8109,14 @@ BattleCommand_PayDay: ; 3705c ; payday xor a - ld hl, StringBuffer1 + ld hl, wStringBuffer1 ld [hli], a ld a, [hBattleTurn] and a - ld a, [BattleMonLevel] + ld a, [wBattleMonLevel] jr z, .ok - ld a, [EnemyMonLevel] + ld a, [wEnemyMonLevel] .ok add a @@ -8138,17 +8138,17 @@ BattleCommand_PayDay: ; 3705c BattleCommand_Conversion: ; 3707f ; conversion - ld hl, BattleMonMoves - ld de, BattleMonType1 + ld hl, wBattleMonMoves + ld de, wBattleMonType1 ld a, [hBattleTurn] and a jr z, .got_moves - ld hl, EnemyMonMoves - ld de, EnemyMonType1 + ld hl, wEnemyMonMoves + ld de, wEnemyMonType1 .got_moves push de ld c, 0 - ld de, StringBuffer1 + ld de, wStringBuffer1 .loop push hl ld b, 0 @@ -8178,7 +8178,7 @@ BattleCommand_Conversion: ; 3707f inc de ld [de], a pop de - ld hl, StringBuffer1 + ld hl, wStringBuffer1 .loop2 ld a, [hl] cp -1 @@ -8207,7 +8207,7 @@ BattleCommand_Conversion: ; 3707f maskbits NUM_MOVES ld c, a ld b, 0 - ld hl, StringBuffer1 + ld hl, wStringBuffer1 add hl, bc ld a, [hl] cp -1 @@ -8239,9 +8239,9 @@ BattleCommand_ResetStats: ; 3710e ; resetstats ld a, 7 ; neutral - ld hl, PlayerStatLevels + ld hl, wPlayerStatLevels call .Fill - ld hl, EnemyStatLevels + ld hl, wEnemyStatLevels call .Fill ld a, [hBattleTurn] @@ -8261,7 +8261,7 @@ BattleCommand_ResetStats: ; 3710e jp StdBattleTextBox .Fill: - ld b, PlayerStatLevelsEnd - PlayerStatLevels + ld b, wPlayerStatLevelsEnd - wPlayerStatLevels .next ld [hli], a dec b @@ -8274,13 +8274,13 @@ BattleCommand_ResetStats: ; 3710e BattleCommand_Heal: ; 3713e ; heal - ld de, BattleMonHP - ld hl, BattleMonMaxHP + ld de, wBattleMonHP + ld hl, wBattleMonMaxHP ld a, [hBattleTurn] and a jr z, .got_hp - ld de, EnemyMonHP - ld hl, EnemyMonMaxHP + ld de, wEnemyMonHP + ld hl, wEnemyMonMaxHP .got_hp ld a, BATTLE_VARS_MOVE_ANIM call GetBattleVar @@ -8403,14 +8403,14 @@ ResetActorDisable: ; 372e7 jr z, .player xor a - ld [EnemyDisableCount], a - ld [EnemyDisabledMove], a + ld [wEnemyDisableCount], a + ld [wEnemyDisabledMove], a ret .player xor a - ld [PlayerDisableCount], a - ld [DisabledMove], a + ld [wPlayerDisableCount], a + ld [wDisabledMove], a ret ; 372fc @@ -8419,13 +8419,13 @@ ResetActorDisable: ; 372e7 BattleCommand_Screen: ; 372fc ; screen - ld hl, PlayerScreens - ld bc, PlayerLightScreenCount + ld hl, wPlayerScreens + ld bc, wPlayerLightScreenCount ld a, [hBattleTurn] and a jr z, .got_screens_pointer - ld hl, EnemyScreens - ld bc, EnemyLightScreenCount + ld hl, wEnemyScreens + ld bc, wEnemyLightScreenCount .got_screens_pointer ld a, BATTLE_VARS_MOVE_EFFECT @@ -8481,7 +8481,7 @@ PrintNothingHappened: ; 37343 TryPrintButItFailed: ; 37349 - ld a, [AlreadyFailed] + ld a, [wAlreadyFailed] and a ret nz @@ -8590,11 +8590,11 @@ INCLUDE "engine/battle/effect_commands/metronome.asm" CheckUserMove: ; 37462 ; Return z if the user has move a. ld b, a - ld de, BattleMonMoves + ld de, wBattleMonMoves ld a, [hBattleTurn] and a jr z, .ok - ld de, EnemyMonMoves + ld de, wEnemyMonMoves .ok ld c, NUM_MOVES @@ -8624,7 +8624,7 @@ ResetTurn: ; 3747b .player ld [hl], 1 xor a - ld [AlreadyDisobeyed], a + ld [wAlreadyDisobeyed], a call DoMove jp EndMoveEffect @@ -8727,14 +8727,14 @@ BattleCommand5d: ; 37791 BattleCommand_FuryCutter: ; 37792 ; furycutter - ld hl, PlayerFuryCutterCount + ld hl, wPlayerFuryCutterCount ld a, [hBattleTurn] and a jr z, .go - ld hl, EnemyFuryCutterCount + ld hl, wEnemyFuryCutterCount .go - ld a, [AttackMissed] + ld a, [wAttackMissed] and a jp nz, ResetFuryCutterCount @@ -8752,7 +8752,7 @@ BattleCommand_FuryCutter: ; 37792 ret z ; Double the damage - ld hl, CurDamage + 1 + ld hl, wCurDamage + 1 sla [hl] dec hl rl [hl] @@ -8771,11 +8771,11 @@ ResetFuryCutterCount: ; 377be push hl - ld hl, PlayerFuryCutterCount + ld hl, wPlayerFuryCutterCount ld a, [hBattleTurn] and a jr z, .reset - ld hl, EnemyFuryCutterCount + ld hl, wEnemyFuryCutterCount .reset xor a @@ -8792,11 +8792,11 @@ INCLUDE "engine/battle/effect_commands/attract.asm" BattleCommand_HappinessPower: ; 3784b ; happinesspower push bc - ld hl, BattleMonHappiness + ld hl, wBattleMonHappiness ld a, [hBattleTurn] and a jr z, .ok - ld hl, EnemyMonHappiness + ld hl, wEnemyMonHappiness .ok xor a ld [hMultiplicand + 0], a @@ -8824,11 +8824,11 @@ BattleCommand_FrustrationPower: ; 3790e ; frustrationpower push bc - ld hl, BattleMonHappiness + ld hl, wBattleMonHappiness ld a, [hBattleTurn] and a jr z, .got_happiness - ld hl, EnemyMonHappiness + ld hl, wEnemyMonHappiness .got_happiness ld a, $ff sub [hl] @@ -8854,13 +8854,13 @@ BattleCommand_FrustrationPower: ; 3790e BattleCommand_Safeguard: ; 37939 ; safeguard - ld hl, PlayerScreens - ld de, PlayerSafeguardCount + ld hl, wPlayerScreens + ld de, wPlayerSafeguardCount ld a, [hBattleTurn] and a jr z, .ok - ld hl, EnemyScreens - ld de, EnemySafeguardCount + ld hl, wEnemyScreens + ld de, wEnemySafeguardCount .ok bit SCREENS_SAFEGUARD, [hl] jr nz, .failed @@ -8880,11 +8880,11 @@ BattleCommand_Safeguard: ; 37939 SafeCheckSafeguard: ; 37962 push hl - ld hl, EnemyScreens + ld hl, wEnemyScreens ld a, [hBattleTurn] and a jr z, .got_turn - ld hl, PlayerScreens + ld hl, wPlayerScreens .got_turn bit SCREENS_SAFEGUARD, [hl] @@ -8896,16 +8896,16 @@ SafeCheckSafeguard: ; 37962 BattleCommand_CheckSafeguard: ; 37972 ; checksafeguard - ld hl, EnemyScreens + ld hl, wEnemyScreens ld a, [hBattleTurn] and a jr z, .got_turn - ld hl, PlayerScreens + ld hl, wPlayerScreens .got_turn bit SCREENS_SAFEGUARD, [hl] ret z ld a, 1 - ld [AttackMissed], a + ld [wAttackMissed], a call BattleCommand_MoveDelay ld hl, SafeguardProtectText call StdBattleTextBox @@ -9046,7 +9046,7 @@ BatonPass_LinkPlayerSwitch: ; 37a67 ret z ld a, 1 - ld [wPlayerAction], a + ld [wBattlePlayerAction], a call LoadStandardMenuDataHeader ld hl, LinkBattleSendReceiveAction @@ -9054,7 +9054,7 @@ BatonPass_LinkPlayerSwitch: ; 37a67 call CloseWindow xor a - ld [wPlayerAction], a + ld [wBattlePlayerAction], a ret ; 37a82 @@ -9069,7 +9069,7 @@ BatonPass_LinkEnemySwitch: ; 37a82 ld hl, LinkBattleSendReceiveAction call CallBattleCore - ld a, [OTPartyCount] + ld a, [wOTPartyCount] add BATTLEACTION_SWITCH1 ld b, a ld a, [wBattleAction] @@ -9079,7 +9079,7 @@ BatonPass_LinkEnemySwitch: ; 37a82 jr c, .switch .baton_pass - ld a, [CurOTMon] + ld a, [wCurOTMon] add BATTLEACTION_SWITCH1 ld [wBattleAction], a .switch @@ -9113,11 +9113,11 @@ ResetBatonPassStatus: ; 37ab1 call ResetActorDisable ; Attraction isn't passed. - ld hl, PlayerSubStatus1 + ld hl, wPlayerSubStatus1 res SUBSTATUS_IN_LOVE, [hl] - ld hl, EnemySubStatus1 + ld hl, wEnemySubStatus1 res SUBSTATUS_IN_LOVE, [hl] - ld hl, PlayerSubStatus5 + ld hl, wPlayerSubStatus5 ld a, BATTLE_VARS_SUBSTATUS5 call GetBattleVarAddr @@ -9138,10 +9138,10 @@ ResetBatonPassStatus: ; 37ab1 CheckAnyOtherAlivePartyMons: ; 37ae9 - ld hl, PartyMon1HP - ld a, [PartyCount] + ld hl, wPartyMon1HP + ld a, [wPartyCount] ld d, a - ld a, [CurBattleMon] + ld a, [wCurBattleMon] ld e, a jr CheckAnyOtherAliveMons @@ -9149,10 +9149,10 @@ CheckAnyOtherAlivePartyMons: ; 37ae9 CheckAnyOtherAliveEnemyMons: ; 37af6 - ld hl, OTPartyMon1HP - ld a, [OTPartyCount] + ld hl, wOTPartyMon1HP + ld a, [wOTPartyCount] ld d, a - ld a, [CurOTMon] + ld a, [wCurOTMon] ld e, a ; fallthrough @@ -9211,7 +9211,7 @@ BattleCommand_Pursuit: ; 37b1d and a ret z - ld hl, CurDamage + 1 + ld hl, wCurDamage + 1 sla [hl] dec hl rl [hl] @@ -9237,12 +9237,12 @@ BattleCommand_ClearHazards: ; 37b39 call StdBattleTextBox .not_leeched - ld hl, PlayerScreens + ld hl, wPlayerScreens ld de, wPlayerWrapCount ld a, [hBattleTurn] and a jr z, .got_screens_wrap - ld hl, EnemyScreens + ld hl, wEnemyScreens ld de, wEnemyWrapCount .got_screens_wrap bit SCREENS_SPIKES, [hl] @@ -9288,13 +9288,13 @@ BattleCommand_HealNite: ; 37b7c BattleCommand_TimeBasedHealContinue: ; 37b7e ; Time- and weather-sensitive heal. - ld hl, BattleMonMaxHP - ld de, BattleMonHP + ld hl, wBattleMonMaxHP + ld de, wBattleMonHP ld a, [hBattleTurn] and a jr z, .start - ld hl, EnemyMonMaxHP - ld de, EnemyMonHP + ld hl, wEnemyMonMaxHP + ld de, wEnemyMonHP .start ; Index for .Multipliers @@ -9310,15 +9310,15 @@ BattleCommand_TimeBasedHealContinue: ; 37b7e ; Don't factor in time of day in link battles. ld a, [wLinkMode] and a - jr nz, .Weather + jr nz, .checkWeather - ld a, [TimeOfDay] + ld a, [wTimeOfDay] cp b - jr z, .Weather + jr z, .checkWeather dec c ; double -.Weather: - ld a, [Weather] +.checkWeather: + ld a, [wBattleWeather] and a jr z, .Heal @@ -9372,7 +9372,7 @@ BattleCommand_TimeBasedHealContinue: ; 37b7e BattleCommand_HiddenPower: ; 37be8 ; hiddenpower - ld a, [AttackMissed] + ld a, [wAttackMissed] and a ret nz farcall HiddenPowerDamage @@ -9384,9 +9384,9 @@ BattleCommand_HiddenPower: ; 37be8 BattleCommand_StartRain: ; 37bf4 ; startrain ld a, WEATHER_RAIN - ld [Weather], a + ld [wBattleWeather], a ld a, 5 - ld [WeatherCount], a + ld [wWeatherCount], a call AnimateCurrentMove ld hl, DownpourText jp StdBattleTextBox @@ -9397,9 +9397,9 @@ BattleCommand_StartRain: ; 37bf4 BattleCommand_StartSun: ; 37c07 ; startsun ld a, WEATHER_SUN - ld [Weather], a + ld [wBattleWeather], a ld a, 5 - ld [WeatherCount], a + ld [wWeatherCount], a call AnimateCurrentMove ld hl, SunGotBrightText jp StdBattleTextBox @@ -9413,7 +9413,7 @@ BattleCommand_BellyDrum: ; 37c1a ; before checking that it has enough HP to use the move. ; Swap the order of these two blocks to fix. call BattleCommand_AttackUp2 - ld a, [AttackMissed] + ld a, [wAttackMissed] and a jr nz, .failed @@ -9448,8 +9448,8 @@ BattleCommand_BellyDrum: ; 37c1a BattleCommand_PsychUp: ; 37c55 ; psychup - ld hl, EnemyStatLevels - ld de, PlayerStatLevels + ld hl, wEnemyStatLevels + ld de, wPlayerStatLevels ld a, [hBattleTurn] and a jr z, .pointers_correct @@ -9502,7 +9502,7 @@ BattleCommand_MirrorCoat: ; 37c95 ; mirrorcoat ld a, 1 - ld [AttackMissed], a + ld [wAttackMissed], a ld a, BATTLE_VARS_LAST_COUNTER_MOVE_OPP call GetBattleVar @@ -9526,18 +9526,18 @@ BattleCommand_MirrorCoat: ; 37c95 ld a, BATTLE_VARS_LAST_COUNTER_MOVE_OPP call GetBattleVar dec a - ld de, StringBuffer1 + ld de, wStringBuffer1 call GetMoveData - ld a, [StringBuffer1 + 2] + ld a, [wStringBuffer1 + 2] and a ret z - ld a, [StringBuffer1 + 3] + ld a, [wStringBuffer1 + 3] cp SPECIAL ret c - ld hl, CurDamage + ld hl, wCurDamage ld a, [hli] or [hl] ret z @@ -9555,7 +9555,7 @@ BattleCommand_MirrorCoat: ; 37c95 .capped xor a - ld [AttackMissed], a + ld [wAttackMissed], a ret ; 37ce6 @@ -9573,7 +9573,7 @@ BattleCommand_DoubleMinimizeDamage: ; 37ce6 ld a, [hl] and a ret z - ld hl, CurDamage + 1 + ld hl, wCurDamage + 1 sla [hl] dec hl rl [hl] @@ -9588,7 +9588,7 @@ BattleCommand_DoubleMinimizeDamage: ; 37ce6 BattleCommand_SkipSunCharge: ; 37d02 ; mimicsuncharge - ld a, [Weather] + ld a, [wBattleWeather] cp WEATHER_SUN ret nz ld b, charge_command @@ -9618,9 +9618,9 @@ BattleCommand_CheckFutureSight: ; 37d0d ld [hl], 0 ld a, [de] inc de - ld [CurDamage], a + ld [wCurDamage], a ld a, [de] - ld [CurDamage + 1], a + ld [wCurDamage + 1], a ld b, futuresight_command jp SkipToBattleCommand @@ -9663,7 +9663,7 @@ BattleCommand_FutureSight: ; 37d34 jr z, .StoreDamage ld de, wEnemyFutureSightDamage .StoreDamage: - ld hl, CurDamage + ld hl, wCurDamage ld a, [hl] ld [de], a ld [hl], 0 @@ -9690,7 +9690,7 @@ BattleCommand_ThunderAccuracy: ; 37d94 ld a, BATTLE_VARS_MOVE_TYPE call GetBattleVarAddr inc hl - ld a, [Weather] + ld a, [wBattleWeather] cp WEATHER_RAIN jr z, .rain cp WEATHER_SUN @@ -9718,11 +9718,11 @@ CheckHiddenOpponent: ; 37daa GetUserItem: ; 37db2 ; Return the effect of the user's item in bc, and its id at hl. - ld hl, BattleMonItem + ld hl, wBattleMonItem ld a, [hBattleTurn] and a jr z, .go - ld hl, EnemyMonItem + ld hl, wEnemyMonItem .go ld b, [hl] jp GetItemHeldEffect @@ -9732,11 +9732,11 @@ GetUserItem: ; 37db2 GetOpponentItem: ; 37dc1 ; Return the effect of the opponent's item in bc, and its id at hl. - ld hl, EnemyMonItem + ld hl, wEnemyMonItem ld a, [hBattleTurn] and a jr z, .go - ld hl, BattleMonItem + ld hl, wBattleMonItem .go ld b, [hl] jp GetItemHeldEffect @@ -9807,14 +9807,14 @@ AnimateCurrentMove: ; 37e01 PlayDamageAnim: ; 37e19 xor a - ld [FXAnimID + 1], a + ld [wFXAnimID + 1], a ld a, BATTLE_VARS_MOVE_ANIM call GetBattleVar and a ret z - ld [FXAnimID], a + ld [wFXAnimID], a ld a, [hBattleTurn] and a @@ -9833,7 +9833,7 @@ PlayDamageAnim: ; 37e19 LoadMoveAnim: ; 37e36 xor a ld [wNumHits], a - ld [FXAnimID + 1], a + ld [wFXAnimID + 1], a ld a, BATTLE_VARS_MOVE_ANIM call GetBattleVar @@ -9846,7 +9846,7 @@ LoadMoveAnim: ; 37e36 LoadAnim: ; 37e44 - ld [FXAnimID], a + ld [wFXAnimID], a ; fallthrough ; 37e47 @@ -9867,9 +9867,9 @@ PlayUserBattleAnim: ; 37e47 PlayOpponentBattleAnim: ; 37e54 ld a, e - ld [FXAnimID], a + ld [wFXAnimID], a ld a, d - ld [FXAnimID + 1], a + ld [wFXAnimID + 1], a xor a ld [wNumHits], a @@ -9928,9 +9928,9 @@ BattleCommand_ClearText: ; 37e85 SkipToBattleCommand: ; 37e8c ; Skip over commands until reaching command b. - ld a, [BattleScriptBufferAddress + 1] + ld a, [wBattleScriptBufferAddress + 1] ld h, a - ld a, [BattleScriptBufferAddress] + ld a, [wBattleScriptBufferAddress] ld l, a .loop ld a, [hli] @@ -9938,9 +9938,9 @@ SkipToBattleCommand: ; 37e8c jr nz, .loop ld a, h - ld [BattleScriptBufferAddress + 1], a + ld [wBattleScriptBufferAddress + 1], a ld a, l - ld [BattleScriptBufferAddress], a + ld [wBattleScriptBufferAddress], a ret ; 37ea1 diff --git a/engine/battle/effect_commands/attract.asm b/engine/battle/effect_commands/attract.asm index 0a6d7c975..da6a9c0e9 100755 --- a/engine/battle/effect_commands/attract.asm +++ b/engine/battle/effect_commands/attract.asm @@ -1,6 +1,6 @@ BattleCommand_Attract: ; 377ce ; attract - ld a, [AttackMissed] + ld a, [wAttackMissed] and a jr nz, .failed call CheckOppositeGender @@ -28,12 +28,12 @@ CheckOppositeGender: ; 377f5 ld a, MON_SPECIES call BattlePartyAttr ld a, [hl] - ld [CurPartySpecies], a + ld [wCurPartySpecies], a - ld a, [CurBattleMon] - ld [CurPartyMon], a + ld a, [wCurBattleMon] + ld [wCurPartyMon], a xor a - ld [MonType], a + ld [wMonType], a farcall GetGender jr c, .genderless_samegender @@ -44,20 +44,20 @@ CheckOppositeGender: ; 377f5 .got_gender push bc - ld a, [TempEnemyMonSpecies] - ld [CurPartySpecies], a - ld hl, EnemyMonDVs - ld a, [EnemySubStatus5] + ld a, [wTempEnemyMonSpecies] + ld [wCurPartySpecies], a + ld hl, wEnemyMonDVs + ld a, [wEnemySubStatus5] bit SUBSTATUS_TRANSFORMED, a jr z, .not_transformed ld hl, wEnemyBackupDVs .not_transformed ld a, [hli] - ld [TempMonDVs], a + ld [wTempMonDVs], a ld a, [hl] - ld [TempMonDVs + 1], a + ld [wTempMonDVs + 1], a ld a, 3 - ld [MonType], a + ld [wMonType], a farcall GetGender pop bc jr c, .genderless_samegender diff --git a/engine/battle/effect_commands/curse.asm b/engine/battle/effect_commands/curse.asm index dceb3b8d5..b11b9f3fb 100644 --- a/engine/battle/effect_commands/curse.asm +++ b/engine/battle/effect_commands/curse.asm @@ -1,13 +1,13 @@ BattleCommand_Curse: ; 37588 ; curse - ld de, BattleMonType1 - ld bc, PlayerStatLevels + ld de, wBattleMonType1 + ld bc, wPlayerStatLevels ld a, [hBattleTurn] and a jr z, .go - ld de, EnemyMonType1 - ld bc, EnemyStatLevels + ld de, wEnemyMonType1 + ld bc, wEnemyStatLevels .go diff --git a/engine/battle/effect_commands/foresight.asm b/engine/battle/effect_commands/foresight.asm index 6f4f97cd2..006e3b3d7 100644 --- a/engine/battle/effect_commands/foresight.asm +++ b/engine/battle/effect_commands/foresight.asm @@ -1,7 +1,7 @@ BattleCommand_Foresight: ; 376a0 ; foresight - ld a, [AttackMissed] + ld a, [wAttackMissed] and a jr nz, .failed diff --git a/engine/battle/effect_commands/perish_song.asm b/engine/battle/effect_commands/perish_song.asm index ac491ef6b..8c88c8739 100644 --- a/engine/battle/effect_commands/perish_song.asm +++ b/engine/battle/effect_commands/perish_song.asm @@ -2,8 +2,8 @@ BattleCommand_PerishSong: ; 376c2 ; perishsong - ld hl, PlayerSubStatus1 - ld de, EnemySubStatus1 + ld hl, wPlayerSubStatus1 + ld de, wEnemySubStatus1 bit SUBSTATUS_PERISH, [hl] jr z, .ok @@ -17,7 +17,7 @@ BattleCommand_PerishSong: ; 376c2 set SUBSTATUS_PERISH, [hl] ld a, 4 - ld [PlayerPerishCount], a + ld [wPlayerPerishCount], a .enemy ld a, [de] @@ -27,7 +27,7 @@ BattleCommand_PerishSong: ; 376c2 set SUBSTATUS_PERISH, a ld [de], a ld a, 4 - ld [EnemyPerishCount], a + ld [wEnemyPerishCount], a .done call AnimateCurrentMove diff --git a/engine/battle/effect_commands/present.asm b/engine/battle/effect_commands/present.asm index 2b358e8b9..f0cf8006d 100755 --- a/engine/battle/effect_commands/present.asm +++ b/engine/battle/effect_commands/present.asm @@ -20,7 +20,7 @@ BattleCommand_Present: ; 37874 ld a, [wTypeMatchup] and a jp z, AnimateFailedMove - ld a, [AttackMissed] + ld a, [wAttackMissed] and a jp nz, AnimateFailedMove diff --git a/engine/battle/effect_commands/protect.asm b/engine/battle/effect_commands/protect.asm index 568ac00f8..6c65e0ed1 100644 --- a/engine/battle/effect_commands/protect.asm +++ b/engine/battle/effect_commands/protect.asm @@ -16,11 +16,11 @@ BattleCommand_Protect: ; 37618 ProtectChance: ; 3762c - ld de, PlayerProtectCount + ld de, wPlayerProtectCount ld a, [hBattleTurn] and a jr z, .asm_37637 - ld de, EnemyProtectCount + ld de, wEnemyProtectCount .asm_37637 call CheckOpponentWentFirst diff --git a/engine/battle/effect_commands/rollout.asm b/engine/battle/effect_commands/rollout.asm index 4ce9ab3d8..f6966c48a 100644 --- a/engine/battle/effect_commands/rollout.asm +++ b/engine/battle/effect_commands/rollout.asm @@ -4,11 +4,11 @@ MAX_ROLLOUT_COUNT EQU 5 BattleCommand_CheckCurl: ; 37718 ; checkcurl - ld de, PlayerRolloutCount + ld de, wPlayerRolloutCount ld a, [hBattleTurn] and a jr z, .ok - ld de, EnemyRolloutCount + ld de, wEnemyRolloutCount .ok ld a, BATTLE_VARS_SUBSTATUS1 call GetBattleVar @@ -33,11 +33,11 @@ BattleCommand_RolloutPower: ; 37734 and SLP ret nz - ld hl, PlayerRolloutCount + ld hl, wPlayerRolloutCount ld a, [hBattleTurn] and a jr z, .got_rollout_count - ld hl, EnemyRolloutCount + ld hl, wEnemyRolloutCount .got_rollout_count ld a, [hl] @@ -47,7 +47,7 @@ BattleCommand_RolloutPower: ; 37734 ld [wSomeoneIsRampaging], a .skip_set_rampage - ld a, [AttackMissed] + ld a, [wAttackMissed] and a jr z, .hit @@ -84,7 +84,7 @@ BattleCommand_RolloutPower: ; 37734 dec b jr z, .done_damage - ld hl, CurDamage + 1 + ld hl, wCurDamage + 1 sla [hl] dec hl rl [hl] diff --git a/engine/battle/effect_commands/sandstorm.asm b/engine/battle/effect_commands/sandstorm.asm index 27b8e8e2c..5aaa61deb 100644 --- a/engine/battle/effect_commands/sandstorm.asm +++ b/engine/battle/effect_commands/sandstorm.asm @@ -1,14 +1,14 @@ BattleCommand_StartSandstorm: ; 376f8 ; startsandstorm - ld a, [Weather] + ld a, [wBattleWeather] cp WEATHER_SANDSTORM jr z, .failed ld a, WEATHER_SANDSTORM - ld [Weather], a + ld [wBattleWeather], a ld a, 5 - ld [WeatherCount], a + ld [wWeatherCount], a call AnimateCurrentMove ld hl, SandstormBrewedText jp StdBattleTextBox diff --git a/engine/battle/effect_commands/spikes.asm b/engine/battle/effect_commands/spikes.asm index 3d15e4cfd..a5e22a706 100644 --- a/engine/battle/effect_commands/spikes.asm +++ b/engine/battle/effect_commands/spikes.asm @@ -1,11 +1,11 @@ BattleCommand_Spikes: ; 37683 ; spikes - ld hl, EnemyScreens + ld hl, wEnemyScreens ld a, [hBattleTurn] and a jr z, .asm_3768e - ld hl, PlayerScreens + ld hl, wPlayerScreens .asm_3768e ; Fails if spikes are already down! diff --git a/engine/battle/effect_commands/thief.asm b/engine/battle/effect_commands/thief.asm index 6d32d68d4..5397c2bdf 100644 --- a/engine/battle/effect_commands/thief.asm +++ b/engine/battle/effect_commands/thief.asm @@ -26,7 +26,7 @@ BattleCommand_Thief: ; 37492 farcall ItemIsMail ret c - ld a, [EffectFailed] + ld a, [wEffectFailed] and a ret nz @@ -74,7 +74,7 @@ BattleCommand_Thief: ; 37492 farcall ItemIsMail ret c - ld a, [EffectFailed] + ld a, [wEffectFailed] and a ret nz @@ -103,7 +103,7 @@ BattleCommand_Thief: ; 37492 call BattlePartyAttr ld d, h ld e, l - ld hl, BattleMonItem + ld hl, wBattleMonItem ret .enemyitem @@ -111,6 +111,6 @@ BattleCommand_Thief: ; 37492 call OTPartyAttr ld d, h ld e, l - ld hl, EnemyMonItem + ld hl, wEnemyMonItem ret ; 37517 diff --git a/engine/battle/effect_commands/transform.asm b/engine/battle/effect_commands/transform.asm index 65c3f3e60..5ae7c1511 100755 --- a/engine/battle/effect_commands/transform.asm +++ b/engine/battle/effect_commands/transform.asm @@ -11,7 +11,7 @@ BattleCommand_Transform: ; 371cd jp nz, BattleEffect_ButItFailed xor a ld [wNumHits], a - ld [FXAnimID + 1], a + ld [wFXAnimID + 1], a ld a, $1 ld [wKickCounter], a ld a, BATTLE_VARS_SUBSTATUS4 @@ -28,15 +28,15 @@ BattleCommand_Transform: ; 371cd call GetBattleVarAddr set SUBSTATUS_TRANSFORMED, [hl] call ResetActorDisable - ld hl, BattleMonSpecies - ld de, EnemyMonSpecies + ld hl, wBattleMonSpecies + ld de, wEnemyMonSpecies ld a, [hBattleTurn] and a jr nz, .got_mon_species - ld hl, EnemyMonSpecies - ld de, BattleMonSpecies + ld hl, wEnemyMonSpecies + ld de, wBattleMonSpecies xor a - ld [CurMoveNum], a + ld [wCurMoveNum], a .got_mon_species push hl ld a, [hli] @@ -64,7 +64,7 @@ BattleCommand_Transform: ; 371cd ld [de], a inc de ; move pointer to stats - ld bc, BattleMonStats - BattleMonPP + ld bc, wBattleMonStats - wBattleMonPP add hl, bc push hl ld h, d @@ -73,16 +73,16 @@ BattleCommand_Transform: ; 371cd ld d, h ld e, l pop hl - ld bc, BattleMonStructEnd - BattleMonStats + ld bc, wBattleMonStructEnd - wBattleMonStats call CopyBytes ; init the power points - ld bc, BattleMonMoves - BattleMonStructEnd + ld bc, wBattleMonMoves - wBattleMonStructEnd add hl, bc push de ld d, h ld e, l pop hl - ld bc, BattleMonPP - BattleMonStructEnd + ld bc, wBattleMonPP - wBattleMonStructEnd add hl, bc ld b, NUM_MOVES .pp_loop @@ -102,12 +102,12 @@ BattleCommand_Transform: ; 371cd ld a, [hl] ld [wNamedObjectIndexBuffer], a call GetPokemonName - ld hl, EnemyStats - ld de, PlayerStats + ld hl, wEnemyStats + ld de, wPlayerStats ld bc, 2 * 5 call BattleSideCopy - ld hl, EnemyStatLevels - ld de, PlayerStatLevels + ld hl, wEnemyStatLevels + ld de, wPlayerStatLevels ld bc, 8 call BattleSideCopy call _CheckBattleScene @@ -129,7 +129,7 @@ BattleCommand_Transform: ; 371cd .after_anim xor a ld [wNumHits], a - ld [FXAnimID + 1], a + ld [wFXAnimID + 1], a ld a, $2 ld [wKickCounter], a pop af diff --git a/engine/battle/hidden_power.asm b/engine/battle/hidden_power.asm index a1d3957e4..9d9a8dc0e 100644 --- a/engine/battle/hidden_power.asm +++ b/engine/battle/hidden_power.asm @@ -1,11 +1,11 @@ HiddenPowerDamage: ; fbced ; Override Hidden Power's type and power based on the user's DVs. - ld hl, BattleMonDVs + ld hl, wBattleMonDVs ld a, [hBattleTurn] and a jr z, .got_dvs - ld hl, EnemyMonDVs + ld hl, wEnemyMonDVs .got_dvs diff --git a/engine/battle/link_result.asm b/engine/battle/link_result.asm index cf6102acc..8f456da9b 100755 --- a/engine/battle/link_result.asm +++ b/engine/battle/link_result.asm @@ -1,9 +1,9 @@ DetermineLinkBattleResult: ; 2b930 farcall UpdateEnemyMonInParty - ld hl, PartyMon1HP + ld hl, wPartyMon1HP call .CountMonsRemaining push bc - ld hl, OTPartyMon1HP + ld hl, wOTPartyMon1HP call .CountMonsRemaining ld a, c pop bc @@ -20,10 +20,10 @@ DetermineLinkBattleResult: ; 2b930 jr z, .victory cp $2 jr z, .defeat - ld hl, PartyMon1HP + ld hl, wPartyMon1HP call .CalcPercentHPRemaining push de - ld hl, OTPartyMon1HP + ld hl, wOTPartyMon1HP call .CalcPercentHPRemaining pop hl ld a, d @@ -118,16 +118,16 @@ DetermineLinkBattleResult: ; 2b930 ret .BothSides_CheckNumberMonsAtFullHealth: ; 2b9e1 - ld hl, PartyMon1HP + ld hl, wPartyMon1HP call .CheckFaintedOrFullHealth jr nz, .finish ; we have a pokemon that's neither fainted nor at full health - ld hl, OTPartyMon1HP + ld hl, wOTPartyMon1HP call .CheckFaintedOrFullHealth ld e, $1 ret .finish - ld hl, OTPartyMon1HP + ld hl, wOTPartyMon1HP call .CheckFaintedOrFullHealth ld e, $0 ret nz ; we both have pokemon that are neither fainted nor at full health diff --git a/engine/battle/misc.asm b/engine/battle/misc.asm index a41d31d9a..b79c274b9 100644 --- a/engine/battle/misc.asm +++ b/engine/battle/misc.asm @@ -53,7 +53,7 @@ GetPlayerBackpicCoords: ; fbd9d (3e:7d9d) DoWeatherModifiers: ; fbda4 ld de, .WeatherTypeModifiers - ld a, [Weather] + ld a, [wBattleWeather] ld b, a ld a, [wd265] ; move type ld c, a @@ -105,7 +105,7 @@ DoWeatherModifiers: ; fbda4 .ApplyModifier: xor a ld [hMultiplicand + 0], a - ld hl, CurDamage + ld hl, wCurDamage ld a, [hli] ld [hMultiplicand + 1], a ld a, [hl] @@ -138,9 +138,9 @@ DoWeatherModifiers: ; fbda4 .Update: ld a, b - ld [CurDamage], a + ld [wCurDamage], a ld a, c - ld [CurDamage + 1], a + ld [wCurDamage + 1], a .done ret @@ -163,7 +163,7 @@ DoBadgeTypeBoosts: ; fbe24 and a ret nz - ld a, [InBattleTowerBattle] + ld a, [wInBattleTowerBattle] and a ret nz @@ -199,10 +199,10 @@ DoBadgeTypeBoosts: ; fbe24 jr .CheckBadge .ApplyBoost: - ld a, [CurDamage] + ld a, [wCurDamage] ld h, a ld d, a - ld a, [CurDamage + 1] + ld a, [wCurDamage + 1] ld l, a ld e, a @@ -226,9 +226,9 @@ DoBadgeTypeBoosts: ; fbe24 .Update: ld a, h - ld [CurDamage], a + ld [wCurDamage], a ld a, l - ld [CurDamage + 1], a + ld [wCurDamage + 1], a .done pop bc diff --git a/engine/battle/read_trainer_attributes.asm b/engine/battle/read_trainer_attributes.asm index dfb8d3682..0b9507e0d 100644 --- a/engine/battle/read_trainer_attributes.asm +++ b/engine/battle/read_trainer_attributes.asm @@ -1,18 +1,18 @@ GetTrainerClassName: ; 3952d - ld hl, RivalName + ld hl, wRivalName ld a, c cp RIVAL1 jr z, .rival - ld [CurSpecies], a + ld [wCurSpecies], a ld a, TRAINER_NAME ld [wNamedObjectTypeBuffer], a call GetName - ld de, StringBuffer1 + ld de, wStringBuffer1 ret .rival - ld de, StringBuffer1 + ld de, wStringBuffer1 push de ld bc, NAME_LENGTH call CopyBytes @@ -20,35 +20,35 @@ GetTrainerClassName: ; 3952d ret GetOTName: ; 39550 - ld hl, OTPlayerName + ld hl, wOTPlayerName ld a, [wLinkMode] and a jr nz, .ok - ld hl, RivalName + ld hl, wRivalName ld a, c cp RIVAL1 jr z, .ok - ld [CurSpecies], a + ld [wCurSpecies], a ld a, TRAINER_NAME ld [wNamedObjectTypeBuffer], a call GetName - ld hl, StringBuffer1 + ld hl, wStringBuffer1 .ok ld bc, TRAINER_CLASS_NAME_LENGTH - ld de, OTClassName + ld de, wOTClassName push de call CopyBytes pop de ret GetTrainerAttributes: ; 3957b - ld a, [TrainerClass] + ld a, [wTrainerClass] ld c, a call GetOTName - ld a, [TrainerClass] + ld a, [wTrainerClass] dec a ld hl, TrainerClassAttributes + TRNATTR_ITEM1 ld bc, NUM_TRAINER_ATTRIBUTES diff --git a/engine/battle/read_trainer_dvs.asm b/engine/battle/read_trainer_dvs.asm index d7c0ff50b..c021e8e8c 100644 --- a/engine/battle/read_trainer_dvs.asm +++ b/engine/battle/read_trainer_dvs.asm @@ -1,8 +1,8 @@ GetTrainerDVs: ; 270c4 -; Return the DVs of OtherTrainerClass in bc +; Return the DVs of wOtherTrainerClass in bc push hl - ld a, [OtherTrainerClass] + ld a, [wOtherTrainerClass] dec a ld c, a ld b, 0 diff --git a/engine/battle/read_trainer_party.asm b/engine/battle/read_trainer_party.asm index a09c6dd08..9f7a4a4a8 100755 --- a/engine/battle/read_trainer_party.asm +++ b/engine/battle/read_trainer_party.asm @@ -1,5 +1,5 @@ ReadTrainerParty: ; 39771 - ld a, [InBattleTowerBattle] + ld a, [wInBattleTowerBattle] bit 0, a ret nz @@ -7,24 +7,24 @@ ReadTrainerParty: ; 39771 and a ret nz - ld hl, OTPartyCount + ld hl, wOTPartyCount xor a ld [hli], a dec a ld [hl], a - ld hl, OTPartyMons - ld bc, OTPartyMonsEnd - OTPartyMons + ld hl, wOTPartyMons + ld bc, wOTPartyMonsEnd - wOTPartyMons xor a call ByteFill - ld a, [OtherTrainerClass] + ld a, [wOtherTrainerClass] cp CAL jr nz, .not_cal2 - ld a, [OtherTrainerID] + ld a, [wOtherTrainerID] cp CAL2 jr z, .cal2 - ld a, [OtherTrainerClass] + ld a, [wOtherTrainerClass] .not_cal2 dec a @@ -37,7 +37,7 @@ ReadTrainerParty: ; 39771 ld h, [hl] ld l, a - ld a, [OtherTrainerID] + ld a, [wOtherTrainerID] ld b, a .skip_trainer dec b @@ -97,11 +97,11 @@ TrainerType1: ; 397eb cp $ff ret z - ld [CurPartyLevel], a + ld [wCurPartyLevel], a ld a, [hli] - ld [CurPartySpecies], a + ld [wCurPartySpecies], a ld a, OTPARTYMON - ld [MonType], a + ld [wMonType], a push hl predef TryAddMonToParty pop hl @@ -117,17 +117,17 @@ TrainerType2: ; 39806 cp $ff ret z - ld [CurPartyLevel], a + ld [wCurPartyLevel], a ld a, [hli] - ld [CurPartySpecies], a + ld [wCurPartySpecies], a ld a, OTPARTYMON - ld [MonType], a + ld [wMonType], a push hl predef TryAddMonToParty - ld a, [OTPartyCount] + ld a, [wOTPartyCount] dec a - ld hl, OTPartyMon1Moves + ld hl, wOTPartyMon1Moves ld bc, PARTYMON_STRUCT_LENGTH call AddNTimes ld d, h @@ -144,9 +144,9 @@ TrainerType2: ; 39806 push hl - ld a, [OTPartyCount] + ld a, [wOTPartyCount] dec a - ld hl, OTPartyMon1Species + ld hl, wOTPartyMon1Species ld bc, PARTYMON_STRUCT_LENGTH call AddNTimes ld d, h @@ -194,16 +194,16 @@ TrainerType3: ; 39871 cp $ff ret z - ld [CurPartyLevel], a + ld [wCurPartyLevel], a ld a, [hli] - ld [CurPartySpecies], a + ld [wCurPartySpecies], a ld a, OTPARTYMON - ld [MonType], a + ld [wMonType], a push hl predef TryAddMonToParty - ld a, [OTPartyCount] + ld a, [wOTPartyCount] dec a - ld hl, OTPartyMon1Item + ld hl, wOTPartyMon1Item ld bc, PARTYMON_STRUCT_LENGTH call AddNTimes ld d, h @@ -223,18 +223,18 @@ TrainerType4: ; 3989d cp $ff ret z - ld [CurPartyLevel], a + ld [wCurPartyLevel], a ld a, [hli] - ld [CurPartySpecies], a + ld [wCurPartySpecies], a ld a, OTPARTYMON - ld [MonType], a + ld [wMonType], a push hl predef TryAddMonToParty - ld a, [OTPartyCount] + ld a, [wOTPartyCount] dec a - ld hl, OTPartyMon1Item + ld hl, wOTPartyMon1Item ld bc, PARTYMON_STRUCT_LENGTH call AddNTimes ld d, h @@ -245,9 +245,9 @@ TrainerType4: ; 3989d ld [de], a push hl - ld a, [OTPartyCount] + ld a, [wOTPartyCount] dec a - ld hl, OTPartyMon1Moves + ld hl, wOTPartyMon1Moves ld bc, PARTYMON_STRUCT_LENGTH call AddNTimes ld d, h @@ -264,9 +264,9 @@ TrainerType4: ; 3989d push hl - ld a, [OTPartyCount] + ld a, [wOTPartyCount] dec a - ld hl, OTPartyMon1 + ld hl, wOTPartyMon1 ld bc, PARTYMON_STRUCT_LENGTH call AddNTimes ld d, h @@ -314,7 +314,7 @@ ComputeTrainerReward: ; 3991b (e:591b) ld [hli], a ld a, [wEnemyTrainerBaseReward] ld [hli], a - ld a, [CurPartyLevel] + ld a, [wCurPartyLevel] ld [hl], a call Multiply ld hl, wBattleReward @@ -328,14 +328,14 @@ ComputeTrainerReward: ; 3991b (e:591b) Battle_GetTrainerName:: ; 39939 - ld a, [InBattleTowerBattle] + ld a, [wInBattleTowerBattle] bit 0, a - ld hl, OTPlayerName + ld hl, wOTPlayerName jp nz, CopyTrainerName - ld a, [OtherTrainerID] + ld a, [wOtherTrainerID] ld b, a - ld a, [OtherTrainerClass] + ld a, [wOtherTrainerClass] ld c, a GetTrainerName:: ; 3994c @@ -379,7 +379,7 @@ GetTrainerName:: ; 3994c jr .loop CopyTrainerName: ; 39984 - ld de, StringBuffer1 + ld de, wStringBuffer1 push de ld bc, NAME_LENGTH call CopyBytes @@ -389,7 +389,7 @@ CopyTrainerName: ; 39984 Function39990: ; 39990 ; This function is useless. - ld de, StringBuffer1 + ld de, wStringBuffer1 push de ld bc, NAME_LENGTH pop de diff --git a/engine/battle/returntobattle_useball.asm b/engine/battle/returntobattle_useball.asm index e6e33f900..b63881b2c 100644 --- a/engine/battle/returntobattle_useball.asm +++ b/engine/battle/returntobattle_useball.asm @@ -1,7 +1,7 @@ _ReturnToBattle_UseBall: ; 2715c call ClearBGPalettes call ClearTileMap - ld a, [BattleType] + ld a, [wBattleType] cp BATTLETYPE_TUTORIAL jr z, .gettutorialbackpic farcall GetBattleMonBackpic diff --git a/engine/battle/sliding_intro.asm b/engine/battle/sliding_intro.asm index 418454283..667f18191 100755 --- a/engine/battle/sliding_intro.asm +++ b/engine/battle/sliding_intro.asm @@ -1,7 +1,7 @@ BattleIntroSlidingPics: ; 4e980 ld a, [rSVBK] push af - ld a, BANK(LYOverrides) + ld a, BANK(wLYOverrides) ld [rSVBK], a call .subfunction1 ld a, rSCX - $ff00 @@ -60,7 +60,7 @@ BattleIntroSlidingPics: ; 4e980 ; 4e9d6 .subfunction3 ; 4e9d6 - ld hl, Sprite01XCoord + ld hl, wVirtualOAMSprite00XCoord ld c, $12 ; 18 ld de, SPRITEOAMSTRUCT_LENGTH .loop3 @@ -73,7 +73,7 @@ BattleIntroSlidingPics: ; 4e980 ; 4e9e5 .subfunction4 ; 4e9e5 - ld hl, LYOverrides + ld hl, wLYOverrides ld a, $90 ld bc, SCREEN_HEIGHT_PX call ByteFill @@ -81,7 +81,7 @@ BattleIntroSlidingPics: ; 4e980 ; 4e9f1 .subfunction5 ; 4e9f1 - ld hl, LYOverrides + ld hl, wLYOverrides ld a, d ld c, $3e ; 62 .loop4 diff --git a/engine/battle/start_battle.asm b/engine/battle/start_battle.asm index e1377eec0..84cd1e858 100644 --- a/engine/battle/start_battle.asm +++ b/engine/battle/start_battle.asm @@ -17,7 +17,7 @@ FindFirstAliveMonAndStartBattle: ; 2ee2f ld [hMapAnims], a call DelayFrame ld b, 6 - ld hl, PartyMon1HP + ld hl, wPartyMon1HP ld de, PARTYMON_STRUCT_LENGTH - 1 .loop @@ -32,7 +32,7 @@ FindFirstAliveMonAndStartBattle: ; 2ee2f ld de, MON_LEVEL - MON_HP add hl, de ld a, [hl] - ld [BattleMonLevel], a + ld [wBattleMonLevel], a predef DoBattleTransition farcall _LoadBattleFontsHPBar ld a, 1 @@ -52,13 +52,13 @@ PlayBattleMusic: ; 2ee6c push bc xor a - ld [MusicFade], a + ld [wMusicFade], a ld de, MUSIC_NONE call PlayMusic call DelayFrame call MaxVolume - ld a, [BattleType] + ld a, [wBattleType] cp BATTLETYPE_SUICUNE ld de, MUSIC_SUICUNE_BATTLE jp z, .done @@ -66,7 +66,7 @@ PlayBattleMusic: ; 2ee6c jp z, .done ; Are we fighting a trainer? - ld a, [OtherTrainerClass] + ld a, [wOtherTrainerClass] and a jr nz, .trainermusic @@ -76,7 +76,7 @@ PlayBattleMusic: ; 2ee6c jr nz, .kantowild ld de, MUSIC_JOHTO_WILD_BATTLE - ld a, [TimeOfDay] + ld a, [wTimeOfDay] cp NITE_F jr nz, .done ld de, MUSIC_JOHTO_WILD_BATTLE_NIGHT @@ -111,13 +111,13 @@ PlayBattleMusic: ; 2ee6c jr c, .done ld de, MUSIC_RIVAL_BATTLE - ld a, [OtherTrainerClass] + ld a, [wOtherTrainerClass] cp RIVAL1 jr z, .done cp RIVAL2 jr nz, .othertrainer - ld a, [OtherTrainerID] + ld a, [wOtherTrainerID] cp RIVAL2_2_CHIKORITA ; Rival in Indigo Plateau jr c, .done ld de, MUSIC_CHAMPION_BATTLE @@ -150,7 +150,7 @@ PlayBattleMusic: ; 2ee6c ClearBattleRAM: ; 2ef18 xor a - ld [wPlayerAction], a + ld [wBattlePlayerAction], a ld [wBattleResult], a ld hl, wPartyMenuCursor @@ -160,25 +160,25 @@ ClearBattleRAM: ; 2ef18 ld [hl], a ld [wMenuScrollPosition], a - ld [CriticalHit], a - ld [BattleMonSpecies], a + ld [wCriticalHit], a + ld [wBattleMonSpecies], a ld [wBattleParticipantsNotFainted], a - ld [CurBattleMon], a + ld [wCurBattleMon], a ld [wForcedSwitch], a - ld [TimeOfDayPal], a - ld [PlayerTurnsTaken], a - ld [EnemyTurnsTaken], a - ld [EvolvableFlags], a + ld [wTimeOfDayPal], a + ld [wPlayerTurnsTaken], a + ld [wEnemyTurnsTaken], a + ld [wEvolvableFlags], a - ld hl, PlayerHPPal + ld hl, wPlayerHPPal ld [hli], a ld [hl], a - ld hl, BattleMonDVs + ld hl, wBattleMonDVs ld [hli], a ld [hl], a - ld hl, EnemyMonDVs + ld hl, wEnemyMonDVs ld [hli], a ld [hl], a diff --git a/engine/battle/trainer_huds.asm b/engine/battle/trainer_huds.asm index 317e72214..0a18098ed 100755 --- a/engine/battle/trainer_huds.asm +++ b/engine/battle/trainer_huds.asm @@ -18,8 +18,8 @@ EnemySwitch_TrainerHud: ; 2c012 ShowPlayerMonsRemaining: ; 2c01c call DrawPlayerPartyIconHUDBorder - ld hl, PartyMon1HP - ld de, PartyCount + ld hl, wPartyMon1HP + ld de, wPartyCount call StageBallTilesData ; ldpixel wPlaceBallsX, 12, 12 ld a, 12 * 8 @@ -28,14 +28,14 @@ ShowPlayerMonsRemaining: ; 2c01c ld [hl], a ld a, 8 ld [wPlaceBallsDirection], a - ld hl, Sprite01 + ld hl, wVirtualOAMSprite00 jp LoadTrainerHudOAM ; 2c03a ShowOTTrainerMonsRemaining: ; 2c03a call DrawEnemyHUDBorder - ld hl, OTPartyMon1HP - ld de, OTPartyCount + ld hl, wOTPartyMon1HP + ld de, wOTPartyCount call StageBallTilesData ; ldpixel wPlaceBallsX, 9, 4 ld hl, wPlaceBallsX @@ -44,14 +44,14 @@ ShowOTTrainerMonsRemaining: ; 2c03a ld [hl], 4 * 8 ld a, -8 ld [wPlaceBallsDirection], a - ld hl, Sprite01 + PARTY_LENGTH * SPRITEOAMSTRUCT_LENGTH + ld hl, wVirtualOAMSprite00 + PARTY_LENGTH * SPRITEOAMSTRUCT_LENGTH jp LoadTrainerHudOAM ; 2c059 StageBallTilesData: ; 2c059 ld a, [de] push af - ld de, Buffer1 + ld de, wBuffer1 ld c, PARTY_LENGTH ld a, $34 ; empty slot .loop1 @@ -60,7 +60,7 @@ StageBallTilesData: ; 2c059 dec c jr nz, .loop1 pop af - ld de, Buffer1 + ld de, wBuffer1 .loop2 push af call .GetHUDTile @@ -147,7 +147,7 @@ DrawEnemyHUDBorder: ; 2c0c5 ld a, [wBattleMode] dec a ret nz - ld a, [TempEnemyMonSpecies] + ld a, [wTempEnemyMonSpecies] dec a call CheckCaughtMon ret z @@ -167,25 +167,25 @@ PlaceHUDBorderTiles: ; 2c0f1 ld [hl], a ld bc, SCREEN_WIDTH add hl, bc - ld a, [StartFlypoint] + ld a, [wStartFlypoint] ld [hl], a ld b, $8 .loop add hl, de - ld a, [MovementBuffer] + ld a, [wMovementBuffer] ld [hl], a dec b jr nz, .loop add hl, de - ld a, [EndFlypoint] + ld a, [wEndFlypoint] ld [hl], a ret ; 2c10d LinkBattle_TrainerHuds: ; 2c10d call LoadBallIconGFX - ld hl, PartyMon1HP - ld de, PartyCount + ld hl, wPartyMon1HP + ld de, wPartyCount call StageBallTilesData ld hl, wPlaceBallsX ld a, 10 * 8 @@ -193,22 +193,22 @@ LinkBattle_TrainerHuds: ; 2c10d ld [hl], 8 * 8 ld a, $8 ld [wPlaceBallsDirection], a - ld hl, Sprite01 + ld hl, wVirtualOAMSprite00 call LoadTrainerHudOAM - ld hl, OTPartyMon1HP - ld de, OTPartyCount + ld hl, wOTPartyMon1HP + ld de, wOTPartyCount call StageBallTilesData ld hl, wPlaceBallsX ld a, 10 * 8 ld [hli], a ld [hl], 13 * 8 - ld hl, Sprite01 + PARTY_LENGTH * SPRITEOAMSTRUCT_LENGTH + ld hl, wVirtualOAMSprite00 + PARTY_LENGTH * SPRITEOAMSTRUCT_LENGTH jp LoadTrainerHudOAM ; 2c143 LoadTrainerHudOAM: ; 2c143 - ld de, Buffer1 + ld de, wBuffer1 ld c, PARTY_LENGTH .loop ld a, [wPlaceBallsY] @@ -250,10 +250,10 @@ _ShowLinkBattleParticipants: ; 2c1b2 ld c, 14 call TextBox hlcoord 4, 5 - ld de, PlayerName + ld de, wPlayerName call PlaceString hlcoord 4, 10 - ld de, OTPlayerName + ld de, wOTPlayerName call PlaceString hlcoord 9, 8 ld a, "<BOLD_V>" diff --git a/engine/battle/updatebattlehuds.asm b/engine/battle/updatebattlehuds.asm index ec7f662e8..0c31f1c36 100644 --- a/engine/battle/updatebattlehuds.asm +++ b/engine/battle/updatebattlehuds.asm @@ -1,9 +1,9 @@ _UpdateBattleHUDs: farcall DrawPlayerHUD - ld hl, PlayerHPPal + ld hl, wPlayerHPPal call SetHPPal farcall DrawEnemyHUD - ld hl, EnemyHPPal + ld hl, wEnemyHPPal call SetHPPal farcall FinishBattleAnim ret diff --git a/engine/battle/used_move_text.asm b/engine/battle/used_move_text.asm index 1b5aa564c..bab0ea834 100755 --- a/engine/battle/used_move_text.asm +++ b/engine/battle/used_move_text.asm @@ -46,7 +46,7 @@ UsedMoveText: ; 105db9 ; everything except 'instead' made redundant in localization ; check obedience - ld a, [AlreadyDisobeyed] + ld a, [wAlreadyDisobeyed] and a ld hl, UsedMove2Text ret nz @@ -71,7 +71,7 @@ UsedMove2Text: ; 105e0b start_asm UsedMoveText_CheckObedience: ; 105e10 ; check obedience - ld a, [AlreadyDisobeyed] + ld a, [wAlreadyDisobeyed] and a jr z, .GetMoveNameText ; print "instead," @@ -183,11 +183,11 @@ INCLUDE "data/moves/grammar.asm" UpdateUsedMoves: ; 105ed0 -; append move a to PlayerUsedMoves unless it has already been used +; append move a to wPlayerUsedMoves unless it has already been used push bc ; start of list - ld hl, PlayerUsedMoves + ld hl, wPlayerUsedMoves ; get move id ld b, a ; next count @@ -209,7 +209,7 @@ UpdateUsedMoves: ; 105ed0 ; if the list is full and the move hasn't already been used ; shift the list back one byte, deleting the first move used ; this can occur with struggle or a new learned move - ld hl, PlayerUsedMoves + 1 + ld hl, wPlayerUsedMoves + 1 ; 1 = 2 ld a, [hld] ld [hli], a @@ -223,7 +223,7 @@ UpdateUsedMoves: ; 105ed0 ld [hl], a ; 4 = new move ld a, b - ld [PlayerUsedMoves + 3], a + ld [wPlayerUsedMoves + 3], a jr .quit .add |