diff options
-rwxr-xr-x | constants/status_constants.asm | 30 | ||||
-rwxr-xr-x | engine/battle/1.asm | 10 | ||||
-rwxr-xr-x | engine/battle/14.asm | 10 | ||||
-rwxr-xr-x | engine/battle/1a.asm | 27 | ||||
-rwxr-xr-x | engine/battle/4_2.asm | 64 | ||||
-rwxr-xr-x | engine/battle/5.asm | 12 | ||||
-rwxr-xr-x | engine/battle/9.asm | 4 | ||||
-rwxr-xr-x | engine/battle/a.asm | 4 | ||||
-rwxr-xr-x | engine/battle/b_2.asm | 22 | ||||
-rwxr-xr-x | engine/battle/c.asm | 10 | ||||
-rwxr-xr-x | engine/battle/core.asm | 414 | ||||
-rwxr-xr-x | engine/battle/e_2.asm | 14 | ||||
-rwxr-xr-x | engine/items/items.asm | 14 | ||||
-rwxr-xr-x | wram.asm | 8 |
14 files changed, 341 insertions, 302 deletions
diff --git a/constants/status_constants.asm b/constants/status_constants.asm index 866ea03c..3b5aee06 100755 --- a/constants/status_constants.asm +++ b/constants/status_constants.asm @@ -1,6 +1,32 @@ -; status ailments
-SLP EQU %111 ; mask
+; non-volatile statuses
+SLP EQU %111 ; sleep counter
PSN EQU 3
BRN EQU 4
FRZ EQU 5
PAR EQU 6
+
+; volatile statuses 1
+StoringEnergy EQU 0 ; Bide
+ThrashingAbout EQU 1 ; e.g. Thrash
+AttackingMultipleTimes EQU 2 ; e.g. Double Kick, Fury Attack
+Flinched EQU 3
+ChargingUp EQU 4 ; e.g. Solar Beam, Fly
+UsingTrappingMove EQU 5 ; e.g. Wrap
+Invulnerable EQU 6 ; charging up Fly/Dig
+Confused EQU 7
+
+; volatile statuses 2
+UsingXAccuracy EQU 0
+ProtectedByMist EQU 1
+GettingPumped EQU 2 ; Focus Energy
+; EQU 3 ; unused?
+HasSubstituteUp EQU 4
+NeedsToRecharge EQU 5 ; Hyper Beam
+UsingRage EQU 6
+Seeded EQU 7
+
+; volatile statuses 3
+BadlyPoisoned EQU 0
+HasLightScreenUp EQU 1
+HasReflectUp EQU 2
+Transformed EQU 3
diff --git a/engine/battle/1.asm b/engine/battle/1.asm index fdf2841d..e28cd056 100755 --- a/engine/battle/1.asm +++ b/engine/battle/1.asm @@ -1,5 +1,5 @@ DrainHPEffect_: ; 783f (1:783f) - ld hl, W_DAMAGE ; W_DAMAGE + ld hl, W_DAMAGE ld a, [hl] srl a ; divide damage by 2 ld [hli], a @@ -16,8 +16,8 @@ DrainHPEffect_: ; 783f (1:783f) ld a, [H_WHOSETURN] ; $fff3 and a jp z, Func_7861 - ld hl, wEnemyMonHP ; wEnemyMonHP - ld de, wEnemyMonMaxHP ; wEnemyMonMaxHP + ld hl, wEnemyMonHP + ld de, wEnemyMonMaxHP Func_7861: ; 7861 (1:7861) ld bc, wHPBarOldHP+1 @@ -38,7 +38,7 @@ Func_7861: ; 7861 (1:7861) add b ld [hld], a ld [wHPBarNewHP], a - ld a, [W_DAMAGE] ; W_DAMAGE + ld a, [W_DAMAGE] ld b, [hl] adc b ld [hli], a @@ -83,7 +83,7 @@ Func_7861: ; 7861 (1:7861) and a ld a, [W_PLAYERMOVEEFFECT] ; wcfd3 jr z, .asm_78d2 - ld a, [W_ENEMYMOVEEFFECT] ; W_ENEMYMOVEEFFECT + ld a, [W_ENEMYMOVEEFFECT] .asm_78d2 cp DREAM_EATER_EFFECT jr nz, .asm_78d9 diff --git a/engine/battle/14.asm b/engine/battle/14.asm index 18aaa5e1..cabaae07 100755 --- a/engine/battle/14.asm +++ b/engine/battle/14.asm @@ -13,7 +13,7 @@ Func_525af: ; 525af (14:65af) ld [wCriticalHitOrOHKO], a ld [wBattleMonSpecies], a ld [wPartyGainExpFlags], a - ld [wPlayerMonNumber], a ; wPlayerMonNumber + ld [wPlayerMonNumber], a ld [wEscapedFromBattle], a ld [wMapPalOffset], a ld hl, wcf1d @@ -27,7 +27,7 @@ Func_525af: ; 525af (14:65af) jr nz, .asm_525e1 inc a ld [wccd9], a - ld a, [W_CURMAP] ; W_CURMAP + ld a, [W_CURMAP] cp SAFARI_ZONE_EAST jr c, .asm_525f9 cp SAFARI_ZONE_REST_HOUSE_1 @@ -45,7 +45,7 @@ ParalyzeEffect_: ; 52601 (14:6601) ld a, [H_WHOSETURN] ; $fff3 and a jp z, .asm_52613 - ld hl, wBattleMonStatus ; wBattleMonStatus + ld hl, wBattleMonStatus ld de, W_ENEMYMOVETYPE ; wcfcf .asm_52613 @@ -69,10 +69,10 @@ ParalyzeEffect_: ; 52601 (14:6601) push hl callab MoveHitTest pop hl - ld a, [W_MOVEMISSED] ; W_MOVEMISSED + ld a, [W_MOVEMISSED] and a jr nz, .asm_52659 - set 6, [hl] + set PAR, [hl] callab QuarterSpeedDueToParalysis ld c, $1e call DelayFrames diff --git a/engine/battle/1a.asm b/engine/battle/1a.asm index 6b502a31..ecf5040b 100755 --- a/engine/battle/1a.asm +++ b/engine/battle/1a.asm @@ -7,16 +7,19 @@ DecrementPP: ; 68000 (1a:4000) ld hl, W_PLAYERBATTSTATUS1 ld a, [hli] ; load the W_PLAYERBATTSTATUS1 pokemon status flags and increment hl to load the ; W_PLAYERBATTSTATUS2 status flags later - and a, 7 ; check to see if bits 0, 1, or 2 are set + and a, (1 << StoringEnergy) | (1 << ThrashingAbout) | (1 << AttackingMultipleTimes) ret nz ; if any of these statuses are true, don't decrement PP - bit 6, [hl] ; check 6th bit status flag on W_PLAYERBATTSTATUS2 - ret nz ; and return if it is set + bit UsingRage, [hl] + ret nz ; don't decrement PP either if Pokemon is using Rage ld hl, wBattleMonPP ; PP of first move (in battle) - call .DecrementPP - - ld a, [W_PLAYERBATTSTATUS3] ; load pokemon status bits? - bit 3, a ; XXX transform status? - ret nz ; If it is, return. Pokemon Red stores the "current pokemon's" PP + +; decrement PP in the battle struct + call .DecrementPP + +; decrement PP in the party struct + ld a, [W_PLAYERBATTSTATUS3] + bit Transformed, a + ret nz ; Return if transformed. Pokemon Red stores the "current pokemon's" PP ; separately from the "Pokemon in your party's" PP. This is ; duplication -- in all cases *other* than Pokemon with Transform. ; Normally, this means we have to go on and make the same @@ -26,12 +29,12 @@ DecrementPP: ; 68000 (1a:4000) ; its opponent, which is *not* the same as its real PP as part of your ; party. So we return, and don't do that part. - ld hl, wPartyMon1PP ; PP of first move (in party) - ld a, [wPlayerMonNumber] ; which mon in party is active - ld bc, $2C ; XXX probably size of party pokemon's data structure + ld hl, wPartyMon1PP ; PP of first move (in party) + ld a, [wPlayerMonNumber] ; which mon in party is active + ld bc, wPartyMon2 - wPartyMon1 call AddNTimes ; calculate address of the mon to modify .DecrementPP - ld a, [wPlayerMoveListIndex] ; which move (0, 1, 2, 3) did we use? + ld a, [wPlayerMoveListIndex] ; which move (0, 1, 2, 3) did we use? ld c, a ld b, 0 add hl ,bc ; calculate the address in memory of the PP we need to decrement diff --git a/engine/battle/4_2.asm b/engine/battle/4_2.asm index ef4798bd..6ab5c004 100755 --- a/engine/battle/4_2.asm +++ b/engine/battle/4_2.asm @@ -103,15 +103,15 @@ Func_13870: ; 13870 (4:7870) .asm_13888 callab Func_128d8 jr z, .asm_13884 - ld a, [wd0db] + ld a, [wRepelRemainingSteps] and a jr z, .asm_1389e dec a - jr z, .asm_13905 - ld [wd0db], a + jr z, .lastRepelStep + ld [wRepelRemainingSteps], a .asm_1389e -; determine if wild pokémon can appear where we’re standing. -; are we standing in grass/water? +; determine if wild pokémon can appear in the half-block we’re standing +; is the bottom right tile (9,9) of the half-block are we standing a grass/water tile? hlCoord 9, 9 ld c, [hl] ld a, [W_GRASSTILE] @@ -133,6 +133,7 @@ Func_13870: ; 13870 (4:7870) jr z, .CantEncounter ld a, [W_GRASSRATE] .CanEncounter +; weigh encounter chance to a random number to determine if there will be an encounter ld b, a ld a, [hRandomAdd] cp b @@ -140,20 +141,23 @@ Func_13870: ; 13870 (4:7870) ld a, [hRandomSub] ld b, a ld hl, WildMonEncounterSlotChances -.asm_138d0 +.determineEncounterSlot ld a, [hli] cp b - jr nc, .asm_138d7 + jr nc, .gotEncounterSlot inc hl - jr .asm_138d0 -.asm_138d7 + jr .determineEncounterSlot +.gotEncounterSlot +; determine which wild pokémon (grass or water) can appear in the half-block we’re standing ld c, [hl] ld hl, W_GRASSMONS - aCoord 8, 9 - cp $14 - jr nz, .asm_138e5 + aCoord 8, 9 + cp $14 ; is the bottom left tile (8,9) of the half-block are we standing a water tile? + jr nz, .gotWildEncounterType ; else, it's treated as a grass tile by default ld hl, W_WATERMONS -.asm_138e5 +; since the bottom right tile of a "left shore" half-block is $14 but the bottom left tile is not, +; "left shore" half-blocks (such as the one in the east coast of Cinnabar), load grass encounters. +.gotWildEncounterType ld b, $0 add hl, bc ld a, [hli] @@ -161,17 +165,17 @@ Func_13870: ; 13870 (4:7870) ld a, [hl] ld [wcf91], a ld [wEnemyMonSpecies2], a - ld a, [wd0db] + ld a, [wRepelRemainingSteps] and a - jr z, .asm_13916 + jr z, .willEncounter ld a, [wPartyMon1Level] ld b, a ld a, [W_CURENEMYLVL] cp b jr c, .CantEncounter - jr .asm_13916 -.asm_13905 - ld [wd0db], a + jr .willEncounter +.lastRepelStep + ld [wRepelRemainingSteps], a ld a, $d2 ld [H_DOWNARROWBLINKCNT2], a ; $ff8c call EnableAutoTextBoxDrawing @@ -180,7 +184,7 @@ Func_13870: ; 13870 (4:7870) ld a, $1 and a ret -.asm_13916 +.willEncounter xor a ret @@ -282,7 +286,7 @@ ConversionEffect_: ; 139a3 (4:79a3) pop de ld a, [W_PLAYERBATTSTATUS1] .asm_139b8 - bit 6, a ; is mon immune to typical attacks (dig/fly) + bit Invulnerable, a ; is mon immune to typical attacks (dig/fly) jr nz, PrintButItFailedText ld a, [hli] ld [de], a @@ -340,22 +344,22 @@ HazeEffect_: ; 139da (4:79da) ld [hli], a ld [hl], a ld hl, W_PLAYERBATTSTATUS1 - call Func_13a37 + call CureStatuses ld hl, W_ENEMYBATTSTATUS1 - call Func_13a37 + call CureStatuses ld hl, Func_3fba8 call Func_139d5 ld hl, StatusChangesEliminatedText jp PrintText -Func_13a37: ; 13a37 (4:7a37) - res 7, [hl] - inc hl +CureStatuses: ; 13a37 (4:7a37) + res Confused, [hl] + inc hl ; BATTSTATUS2 ld a, [hl] - and $78 - ld [hli], a + and (1 << UsingRage) | (1 << NeedsToRecharge) | (1 << HasSubstituteUp) | (1 << 3) ; clear all but these from BATTSTATUS2 + ld [hli], a ; BATTSTATUS3 ld a, [hl] - and $f8 + and %11110000 | (1 << Transformed) ; clear Bad Poison, Reflect and Light Screen statuses ld [hl], a ret @@ -382,8 +386,8 @@ StatusChangesEliminatedText: ; 13a53 (4:7a53) db "@" GetTrainerName_: ; 13a58 (4:7a58) - ld hl, W_GRASSRATE ; W_GRASSRATE - ld a, [W_ISLINKBATTLE] ; W_ISLINKBATTLE + ld hl, W_GRASSRATE + ld a, [W_ISLINKBATTLE] and a jr nz, .rival ld hl, W_RIVALNAME ; wd34a diff --git a/engine/battle/5.asm b/engine/battle/5.asm index 82518052..e534470d 100755 --- a/engine/battle/5.asm +++ b/engine/battle/5.asm @@ -12,7 +12,7 @@ SubstituteEffectHandler: ; 17dad (5:7dad) ld bc, W_ENEMYBATTSTATUS2 .notEnemy ld a, [bc] ;load flags - bit 4, a ;user already has substitute? + bit HasSubstituteUp, a ;user already has substitute? jr nz, .alreadyHasSubstitute ;skip this code if so ;user doesn't have a substitute [yet] push bc @@ -41,13 +41,13 @@ SubstituteEffectHandler: ; 17dad (5:7dad) ld [hl], d ;store low byte HP ld h, b ld l, c - set 4, [hl] ;set bit 4 of flags, user now has substitute - ld a, [W_OPTIONS] ;load options - bit 7, a ;battle animation is enabled? - ld hl, Func_3fba8 ; $7ba8 ;animation enabled: 0F:7BA8 + set HasSubstituteUp, [hl] ;set bit 4 of flags, user now has substitute + ld a, [W_OPTIONS] ;load options + bit 7, a ;battle animation is enabled? + ld hl, Func_3fba8 ;animation enabled: 0F:7BA8 ld b, BANK(Func_3fba8) jr z, .animationEnabled - ld hl, AnimationSubstitute ;animation disabled: 1E:56E0 + ld hl, AnimationSubstitute ;animation disabled: 1E:56E0 ld b, BANK(AnimationSubstitute) .animationEnabled call Bankswitch ;jump to routine depending on animation setting diff --git a/engine/battle/9.asm b/engine/battle/9.asm index 26f65317..eb86cce0 100755 --- a/engine/battle/9.asm +++ b/engine/battle/9.asm @@ -163,9 +163,9 @@ FocusEnergyEffect_: ; 27f86 (9:7f86) jr z, .asm_27f91 ld hl, W_ENEMYBATTSTATUS2 ; W_ENEMYBATTSTATUS2 .asm_27f91 - bit 2, [hl] ; is mon already using focus energy? + bit GettingPumped, [hl] ; is mon already using focus energy? jr nz, .asm_27fa5 - set 2, [hl] ; mon is now using focus energy + set GettingPumped, [hl] ; mon is now using focus energy callab Func_3fba8 ld hl, GettingPumpedText ; $7fb2 jp PrintText diff --git a/engine/battle/a.asm b/engine/battle/a.asm index fd3ef40b..917a462b 100755 --- a/engine/battle/a.asm +++ b/engine/battle/a.asm @@ -18,9 +18,9 @@ LeechSeedEffect_: ; 2bea9 (a:7ea9) ld a, [de] cp GRASS jr z, .asm_2bee7 - bit 7, [hl] + bit Seeded, [hl] jr nz, .asm_2bee7 - set 7, [hl] + set Seeded, [hl] callab Func_3fba8 ld hl, WasSeededText ; $7ef2 jp PrintText diff --git a/engine/battle/b_2.asm b/engine/battle/b_2.asm index 4ff8b66b..4a49bb10 100755 --- a/engine/battle/b_2.asm +++ b/engine/battle/b_2.asm @@ -95,27 +95,27 @@ PayDayEffect_ ; 2feb8 (b:7eb8) ld a, [wEnemyMonLevel] .asm_2fec8 add a - ld [$ff98], a + ld [H_DIVIDEND + 3], a xor a - ld [$ff95], a - ld [$ff96], a - ld [$ff97], a + ld [H_DIVIDEND], a + ld [H_DIVIDEND + 1], a + ld [H_DIVIDEND + 2], a ld a, $64 - ld [$ff99], a + ld [H_DIVISOR], a ld b, $4 call Divide - ld a, [$ff98] + ld a, [H_QUOTIENT + 3] ld [hli], a - ld a, [$ff99] - ld [$ff98], a + ld a, [H_REMAINDER] + ld [H_DIVIDEND + 3], a ld a, $a - ld [$ff99], a + ld [H_DIVISOR], a ld b, $4 call Divide - ld a, [$ff98] + ld a, [H_QUOTIENT + 3] swap a ld b, a - ld a, [$ff99] + ld a, [H_REMAINDER] add b ld [hl], a ld de, wTotalPayDayMoney + 2 diff --git a/engine/battle/c.asm b/engine/battle/c.asm index e31b1fce..07369375 100755 --- a/engine/battle/c.asm +++ b/engine/battle/c.asm @@ -5,9 +5,9 @@ MistEffect_: ; 33f2b (c:7f2b) jr z, .asm_33f36 ld hl, W_ENEMYBATTSTATUS2 .asm_33f36 - bit 1, [hl] ; is mon protected by mist? + bit ProtectedByMist, [hl] ; is mon protected by mist? jr nz, .asm_33f4a - set 1, [hl] ; mon is now protected by mist + set ProtectedByMist, [hl] ; mon is now protected by mist callab Func_3fba8 ld hl, ShroudedInMistText jp PrintText @@ -21,7 +21,7 @@ ShroudedInMistText: ; 33f52 (c:7f52) db "@" OneHitKOEffect_: ; 33f57 (c:7f57) - ld hl, W_DAMAGE ; W_DAMAGE + ld hl, W_DAMAGE xor a ld [hli], a ld [hl], a ; set the damage output to zero @@ -45,7 +45,7 @@ OneHitKOEffect_: ; 33f57 (c:7f57) ld a, [hl] sbc b jr c, .asm_33f8a - ld hl, W_DAMAGE ; W_DAMAGE + ld hl, W_DAMAGE ld a, $ff ld [hli], a ld [hl], a @@ -54,5 +54,5 @@ OneHitKOEffect_: ; 33f57 (c:7f57) ret .asm_33f8a ld a, $1 - ld [W_MOVEMISSED], a ; W_MOVEMISSED + ld [W_MOVEMISSED], a ret diff --git a/engine/battle/core.asm b/engine/battle/core.asm index 90c296e4..381c82b1 100755 --- a/engine/battle/core.asm +++ b/engine/battle/core.asm @@ -385,15 +385,15 @@ MainInBattleLoop: ; 3c233 (f:4233) xor a ld [wd11d], a ld a, [W_PLAYERBATTSTATUS2] - and %01100000 ; check if the player is using Rage or needs to recharge + and (1 << NeedsToRecharge) | (1 << UsingRage) ; check if the player is using Rage or needs to recharge jr nz, .selectEnemyMove ; the player is not using Rage and doesn't need to recharge ld hl, W_ENEMYBATTSTATUS1 - res 3, [hl] ; reset flinch bit + res Flinched, [hl] ; reset flinch bit ld hl, W_PLAYERBATTSTATUS1 - res 3, [hl] ; reset flinch bit + res Flinched, [hl] ; reset flinch bit ld a, [hl] - and %00010010 ; check if the player is thrashing about or charging for an attack + and (1 << ThrashingAbout) | (1 << ChargingUp) ; check if the player is thrashing about or charging for an attack jr nz, .selectEnemyMove ; if so, jump ; the player is neither thrashing about nor charging for an attack call DisplayBattleMenu ; show battle menu @@ -405,10 +405,10 @@ MainInBattleLoop: ; 3c233 (f:4233) and (1 << FRZ) | SLP ; is mon frozen or asleep? jr nz, .selectEnemyMove ; if so, jump ld a, [W_PLAYERBATTSTATUS1] - and %00100001 ; check player is using Bide or using a multi-turn attack like wrap + and (1 << StoringEnergy) | (1 << UsingTrappingMove) ; check player is using Bide or using a multi-turn attack like wrap jr nz, .selectEnemyMove ; if so, jump ld a, [W_ENEMYBATTSTATUS1] - bit 5, a ; check if enemy is using a multi-turn attack like wrap + bit UsingTrappingMove, a ; check if enemy is using a multi-turn attack like wrap jr z, .selectPlayerMove ; if not, jump ; enemy is using a mult-turn attack like wrap, so player is trapped and cannot execute a move ld a, $ff @@ -446,7 +446,7 @@ MainInBattleLoop: ; 3c233 (f:4233) jr c, .noLinkBattle ; the link battle enemy has switched mons ld a, [W_PLAYERBATTSTATUS1] - bit 5, a ; check if using multi-turn move like Wrap + bit UsingTrappingMove, a ; check if using multi-turn move like Wrap jr z, .asm_3c2dd ld a, [wPlayerMoveListIndex] ld hl, wBattleMonMoves @@ -670,7 +670,7 @@ HandlePoisonBurnLeechSeed_DecreaseOwnHP: ; 3c43d (f:443d) ld hl, W_ENEMYBATTSTATUS3 ld de, W_ENEMYTOXICCOUNTER .playersTurn - bit 0, [hl] + bit BadlyPoisoned, [hl] jr z, .noToxic ld a, [de] ; increment toxic counter inc a @@ -779,14 +779,14 @@ CheckNumAttacksLeft: ; 3c50f (f:450f) jr nz, .checkEnemy ; player has 0 attacks left ld hl, W_PLAYERBATTSTATUS1 - res 5, [hl] ; player not using multi-turn attack like wrap any more + res UsingTrappingMove, [hl] ; player not using multi-turn attack like wrap any more .checkEnemy ld a, [wEnemyNumAttacksLeft] and a ret nz ; enemy has 0 attacks left ld hl, W_ENEMYBATTSTATUS1 - res 5, [hl] ; enemy not using multi-turn attack like wrap any more + res UsingTrappingMove, [hl] ; enemy not using multi-turn attack like wrap any more ret HandleEnemyMonFainted: ; 3c525 (f:4525) @@ -836,7 +836,7 @@ FaintEnemyPokemon ; 0x3c567 ld [hl], a .wild ld hl, W_PLAYERBATTSTATUS1 - res 2, [hl] + res AttackingMultipleTimes, [hl] xor a ld [W_NUMHITS], a ld hl, wd065 ; clear enemy statuses @@ -958,15 +958,15 @@ AnyEnemyPokemonAliveCheck: ; 3c64f (f:464f) ld b, a xor a ld hl, wEnemyMon1HP - ld de, $2c -.asm_3c65a + ld de, wEnemyMon2 - wEnemyMon1 +.nextPokemon or [hl] inc hl or [hl] dec hl add hl, de dec b - jr nz, .asm_3c65a + jr nz, .nextPokemon and a ret @@ -978,14 +978,14 @@ ReplaceFaintedEnemyMon: ; 3c664 (f:4664) callab DrawEnemyPokeballs ld a, [W_ISLINKBATTLE] cp $4 - jr nz, .asm_3c687 + jr nz, .notLinkBattle ; link battle call LinkBattleExchangeData ld a, [wcc3e] cp $f ret z call LoadScreenTilesFromBuffer1 -.asm_3c687 +.notLinkBattle call EnemySendOut xor a ld [W_ENEMYMOVENUM], a @@ -1171,11 +1171,11 @@ ChooseNextMon: ; 3c7d8 (f:47d8) jr z, .goBackToPartyMenu ; if mon fainted, you have to choose another ld a, [W_ISLINKBATTLE] cp $4 - jr nz, .asm_3c7fa + jr nz, .notLinkBattle inc a ld [wcd6a], a call LinkBattleExchangeData -.asm_3c7fa +.notLinkBattle xor a ld [wcd6a], a call ClearSprites @@ -1825,7 +1825,7 @@ SendOutMon: ; 3cc91 (f:4c91) ld b, $1 call GoPAL_SET ld hl, W_ENEMYBATTSTATUS1 - res 5, [hl] + res UsingTrappingMove, [hl] ld a, $1 ld [H_WHOSETURN], a ld a, POOF_ANIM @@ -2093,14 +2093,14 @@ DisplayBattleMenu: ; 3ceb3 (f:4eb3) ld bc, $b call CopyData ; temporarily save the player name in unused space, ; which is supposed to get overwritten when entering a - ; map with wild pokémon. due to an oversight, the data + ; map with wild Pokémon. Due to an oversight, the data ; may not get overwritten (cinnabar) and the infamous - ; missingno. glitch can show up. + ; Missingno. glitch can show up. ld hl, .oldManName ld de, wPlayerName ld bc, $b call CopyData - ; the following simulates the keystrokes by drawing menus on screen +; the following simulates the keystrokes by drawing menus on screen hlCoord 9, 14 ld [hl], "▶" ld c, $50 @@ -2323,13 +2323,13 @@ UseBagItem: jp z, BagWasSelected ; if not, go back to the bag menu ld a, [W_PLAYERBATTSTATUS1] - bit 5, a ; is the player using a multi-turn move like wrap? + bit UsingTrappingMove, a ; is the player using a multi-turn move like wrap? jr z, .checkIfMonCaptured ld hl, wPlayerNumAttacksLeft dec [hl] jr nz, .checkIfMonCaptured ld hl, W_PLAYERBATTSTATUS1 - res 5, [hl] ; not using multi-turn move any more + res UsingTrappingMove, [hl] ; not using multi-turn move any more .checkIfMonCaptured ld a, [wd11c] @@ -2436,7 +2436,7 @@ PartyMenuOrRockOrRun: predef StatusScreen2 ; now we need to reload the enemy mon pic ld a, [W_ENEMYBATTSTATUS2] - bit 4, a ; does the enemy mon have a substitute? + bit HasSubstituteUp, a ; does the enemy mon have a substitute? ld hl, AnimationSubstitute jr nz, .doEnemyMonAnimation ; enemy mon doesn't have substitute @@ -2771,7 +2771,6 @@ CursorDown: ; 3d3dd (f:53dd) AnyMoveToSelect: ; 3d3f5 (f:53f5) ; return z and Struggle as the selected move if all moves have 0 PP and/or are disabled - ld a, STRUGGLE ld [wPlayerSelectedMove], a ld a, [W_PLAYERDISABLEDMOVE] @@ -2986,7 +2985,7 @@ SelectEnemyMove: ; 3d564 (f:5564) cp $e jp z, .asm_3d601 cp $d - jr z, .unableToMove + jr z, .unableToSelectMove cp $4 ret nc ld [wEnemyMoveListIndex], a @@ -2998,25 +2997,25 @@ SelectEnemyMove: ; 3d564 (f:5564) jr .done .noLinkBattle ld a, [W_ENEMYBATTSTATUS2] - and $60 ; need to recharge or using rage + and (1 << NeedsToRecharge) | (1 << UsingRage) ; need to recharge or using rage ret nz ld hl, W_ENEMYBATTSTATUS1 ld a, [hl] - and $12 ; using multi-turn move or bide + and (1 << ChargingUp) | (1 << ThrashingAbout) ; using a charging move or thrash/petal dance ret nz ld a, [wEnemyMonStatus] and SLP | 1 << FRZ ; sleeping or frozen ret nz ld a, [W_ENEMYBATTSTATUS1] - and $21 ; using fly/dig or thrash/petal dance + and (1 << UsingTrappingMove) | (1 << StoringEnergy) ; using a trapping move like wrap or bide ret nz ld a, [W_PLAYERBATTSTATUS1] - bit 5, a ; caught in player's multi-turn move (e.g. wrap) - jr z, .notCaughtInWrap -.unableToMove + bit UsingTrappingMove, a ; caught in player's trapping move (e.g. wrap) + jr z, .canSelectMove +.unableToSelectMove ld a, $ff jr .done -.notCaughtInWrap +.canSelectMove ld hl, wEnemyMonMoves+1 ; 2nd enemy move ld a, [hld] and a @@ -3137,12 +3136,12 @@ ExecutePlayerMove: ; 3d65e (f:565e) .playerHasNoSpecialCondition call GetCurrentMove ld hl, W_PLAYERBATTSTATUS1 - bit 4, [hl] ; charging up for attack + bit ChargingUp, [hl] ; charging up for attack jr nz, PlayerCanExecuteChargingMove call CheckForDisobedience jp z, ExecutePlayerMoveDone -Func_3d69a: ; 3d69a (f:569a) +CheckIfPlayerNeedsToChargeUp: ; 3d69a (f:569a) ld a, [W_PLAYERMOVEEFFECT] cp CHARGE_EFFECT jp z, JumpMoveEffect @@ -3153,10 +3152,10 @@ Func_3d69a: ; 3d69a (f:569a) ; in-battle stuff PlayerCanExecuteChargingMove: ; 3d6a9 (f:56a9) ld hl,W_PLAYERBATTSTATUS1 - res 4,[hl] ; reset charging up and invulnerability statuses if mon was charging up for an attack + res ChargingUp,[hl] ; reset charging up and invulnerability statuses if mon was charging up for an attack ; being fully paralyzed or hurting oneself in confusion removes charging up status ; resulting in the Pokemon being invulnerable for the whole battle - res 6,[hl] + res Invulnerable,[hl] PlayerCanExecuteMove: ; 3d6b0 (f:56b0) call PrintMonName1Text ld hl,DecrementPP @@ -3246,12 +3245,12 @@ MirrorMoveCheck jp z,ExecutePlayerMoveDone xor a ld [wcced],a - jp Func_3d69a ; if Mirror Move was successful go back to damage calculation for copied move + jp CheckIfPlayerNeedsToChargeUp ; if Mirror Move was successful go back to damage calculation for copied move .metronomeCheck cp a,METRONOME_EFFECT jr nz,.next call MetronomePickMove - jp Func_3d69a ; Go back to damage calculation for the move picked by Metronome + jp CheckIfPlayerNeedsToChargeUp ; Go back to damage calculation for the move picked by Metronome .next ld a,[W_PLAYERMOVEEFFECT] ld hl,ResidualEffects2 @@ -3286,14 +3285,14 @@ MirrorMoveCheck call HandleBuildingRage ld hl,W_PLAYERBATTSTATUS1 - bit 2,[hl] + bit AttackingMultipleTimes,[hl] jr z,.executeOtherEffects ld a,[wPlayerNumAttacksLeft] dec a ld [wPlayerNumAttacksLeft],a jp nz,asm_3d714 ; for multi-hit moves, apply attack until PlayerNumAttacksLeft hits 0 or the enemy faints. ; damage calculation and accuracy tests only happen for the first hit - res 2,[hl] + res AttackingMultipleTimes,[hl] ; clear attacking multiple times status when all attacks are over ld hl,MultiHitText call PrintText xor a @@ -3373,7 +3372,6 @@ CheckPlayerStatusConditions: ; 3d854 (f:5854) ld a,[hl] and a,SLP ; sleep mask jr z,.FrozenCheck - ; sleeping dec a ld [wBattleMonStatus],a ; decrement number of turns left @@ -3408,7 +3406,7 @@ CheckPlayerStatusConditions: ; 3d854 (f:5854) .HeldInPlaceCheck ld a,[W_ENEMYBATTSTATUS1] - bit 5,a ; is enemy using a mult-turn move like wrap? + bit UsingTrappingMove,a ; is enemy using a mult-turn move like wrap? jp z,.FlinchedCheck ld hl,CantMoveText call PrintText @@ -3417,9 +3415,9 @@ CheckPlayerStatusConditions: ; 3d854 (f:5854) .FlinchedCheck ld hl,W_PLAYERBATTSTATUS1 - bit 3,[hl] + bit Flinched,[hl] jp z,.HyperBeamCheck - res 3,[hl] ; reset player's flinch status + res Flinched,[hl] ; reset player's flinch status ld hl,FlinchedText call PrintText ld hl,ExecutePlayerMoveDone ; player can't move this turn @@ -3427,9 +3425,9 @@ CheckPlayerStatusConditions: ; 3d854 (f:5854) .HyperBeamCheck ld hl,W_PLAYERBATTSTATUS2 - bit 5,[hl] + bit NeedsToRecharge,[hl] jr z,.AnyMoveDisabledCheck - res 5,[hl] ; reset player's recharge status + res NeedsToRecharge,[hl] ; reset player's recharge status ld hl,MustRechargeText call PrintText ld hl,ExecutePlayerMoveDone ; player can't move this turn @@ -3457,7 +3455,7 @@ CheckPlayerStatusConditions: ; 3d854 (f:5854) dec [hl] jr nz,.IsConfused ld hl,W_PLAYERBATTSTATUS1 - res 7,[hl] ; if confused counter hit 0, reset confusion status + res Confused,[hl] ; if confused counter hit 0, reset confusion status ld hl,ConfusedNoMoreText call PrintText jr .TriedToUseDisabledMoveCheck @@ -3473,7 +3471,7 @@ CheckPlayerStatusConditions: ; 3d854 (f:5854) jr c,.TriedToUseDisabledMoveCheck ld hl,W_PLAYERBATTSTATUS1 ld a,[hl] - and a,$80 ; if mon hurts itself, clear every other status from W_PLAYERBATTSTATUS1 + and a, 1 << Confused ; if mon hurts itself, clear every other status from W_PLAYERBATTSTATUS1 ld [hl],a call HandleSelfConfusionDamage jr .MonHurtItselfOrFullyParalysed @@ -3502,7 +3500,8 @@ CheckPlayerStatusConditions: ; 3d854 (f:5854) .MonHurtItselfOrFullyParalysed ld hl,W_PLAYERBATTSTATUS1 ld a,[hl] - and a, %11001100 ; clear bide, thrashing, charging up, and multi-turn moves such as warp (redundant, already cleared) + ; clear bide, thrashing, charging up, and trapping moves such as warp (already cleared for confusion damage) + and a, (1 << AttackingMultipleTimes) | (1 << Flinched) | (1 << Invulnerable) | (1 << Confused) ld [hl],a ld a,[W_PLAYERMOVEEFFECT] cp a,FLY_EFFECT @@ -3522,7 +3521,7 @@ CheckPlayerStatusConditions: ; 3d854 (f:5854) .BideCheck ld hl,W_PLAYERBATTSTATUS1 - bit 0,[hl] ; is mon using bide? + bit StoringEnergy,[hl] ; is mon using bide? jr z,.ThrashingAboutCheck xor a ld [W_PLAYERMOVENUM],a @@ -3544,7 +3543,7 @@ CheckPlayerStatusConditions: ; 3d854 (f:5854) jp .returnToHL ; unless mon unleashes energy, can't move this turn .UnleashEnergy ld hl,W_PLAYERBATTSTATUS1 - res 0,[hl] ; not using bide any more + res StoringEnergy,[hl] ; not using bide any more ld hl,UnleashedEnergyText call PrintText ld a,1 @@ -3571,7 +3570,7 @@ CheckPlayerStatusConditions: ; 3d854 (f:5854) jp .returnToHL .ThrashingAboutCheck - bit 1,[hl] ; is mon using thrash or petal dance? + bit ThrashingAbout,[hl] ; is mon using thrash or petal dance? jr z,.MultiturnMoveCheck ld a,THRASH ld [W_PLAYERMOVENUM],a @@ -3583,8 +3582,8 @@ CheckPlayerStatusConditions: ; 3d854 (f:5854) jp nz,.returnToHL push hl ld hl,W_PLAYERBATTSTATUS1 - res 1,[hl] ; no longer trashing about - set 7,[hl] ; confused + res ThrashingAbout,[hl] ; no longer trashing about + set Confused,[hl] ; confused call BattleRandom and a,3 inc a @@ -3594,7 +3593,7 @@ CheckPlayerStatusConditions: ; 3d854 (f:5854) jp .returnToHL .MultiturnMoveCheck - bit 5,[hl] ; is mon using multi-turn move? + bit UsingTrappingMove,[hl] ; is mon using multi-turn move? jp z,.RageCheck ld hl,AttackContinuesText call PrintText @@ -3607,7 +3606,7 @@ CheckPlayerStatusConditions: ; 3d854 (f:5854) .RageCheck ld a, [W_PLAYERBATTSTATUS2] - bit 6, a ; is mon using rage? + bit UsingRage, a ; is mon using rage? jp z, .checkPlayerStatusConditionsDone ; if we made it this far, mon can move normally this turn ld a, RAGE ld [wd11e], a @@ -3692,12 +3691,12 @@ PrintMoveIsDisabledText: ; 3da88 (f:5a88) ld de, W_PLAYERBATTSTATUS1 ld a, [H_WHOSETURN] and a - jr z, .asm_3da97 + jr z, .removeChargingUp inc hl ld de, W_ENEMYBATTSTATUS1 -.asm_3da97 +.removeChargingUp ld a, [de] - res 4, a + res ChargingUp, a ; end the pokemon's ld [de], a ld a, [hl] ld [wd11e], a @@ -3728,7 +3727,7 @@ HandleSelfConfusionDamage: ; 3daad (f:5aad) xor a ld [hli], a ld [wCriticalHitOrOHKO], a ; self-inflicted confusion damage can't be a Critical Hit - ld a, $28 ; 40 base power + ld a, 40 ; 40 base power ld [hli], a xor a ld [hl], a @@ -3895,13 +3894,13 @@ PrintMoveFailureText: ; 3dbe2 (f:5be2) ld hl, DoesntAffectMonText ld a, [wd05b] and $7f - jr z, .asm_3dc04 + jr z, .gotTextToPrint ld hl, AttackMissedText ld a, [wCriticalHitOrOHKO] cp $ff - jr nz, .asm_3dc04 + jr nz, .gotTextToPrint ld hl, UnaffectedText -.asm_3dc04 +.gotTextToPrint push de call PrintText xor a @@ -4215,7 +4214,7 @@ GetDamageVarsForPlayerAttack: ; 3ddcf (f:5dcf) ld b, a ld c, [hl] ; bc = enemy defense ld a, [W_ENEMYBATTSTATUS3] - bit 2, a ; check for Reflect + bit HasReflectUp, a ; check for Reflect jr z, .physicalAttackCritCheck ; if the enemy has used Reflect, double the enemy's defense sla c @@ -4228,9 +4227,9 @@ GetDamageVarsForPlayerAttack: ; 3ddcf (f:5dcf) ; in the case of a critical hit, reset the player's attack and the enemy's defense to their base values ld c, 3 ; defense stat call GetEnemyMonStat - ld a, [$ff97] + ld a, [H_PRODUCT + 2] ld b, a - ld a, [$ff98] + ld a, [H_PRODUCT + 3] ld c, a push bc ld hl, wPartyMon1Attack @@ -4245,7 +4244,7 @@ GetDamageVarsForPlayerAttack: ; 3ddcf (f:5dcf) ld b, a ld c, [hl] ; bc = enemy special ld a, [W_ENEMYBATTSTATUS3] - bit 1, a ; check for Light Screen + bit HasLightScreenUp, a ; check for Light Screen jr z, .specialAttackCritCheck ; if the enemy has used Light Screen, double the enemy's special sla c @@ -4260,9 +4259,9 @@ GetDamageVarsForPlayerAttack: ; 3ddcf (f:5dcf) ; in the case of a critical hit, reset the player's and enemy's specials to their base values ld c, 5 ; special stat call GetEnemyMonStat - ld a, [$ff97] + ld a, [H_PRODUCT + 2] ld b, a - ld a, [$ff98] + ld a, [H_PRODUCT + 3] ld c, a push bc ld hl, wPartyMon1Special @@ -4327,7 +4326,7 @@ GetDamageVarsForEnemyAttack: ; 3de75 (f:5e75) ld b, a ld c, [hl] ; bc = player defense ld a, [W_PLAYERBATTSTATUS3] - bit 2, a ; check for Reflect + bit HasReflectUp, a ; check for Reflect jr z, .physicalAttackCritCheck ; if the player has used Reflect, double the player's defense sla c @@ -4348,7 +4347,7 @@ GetDamageVarsForEnemyAttack: ; 3de75 (f:5e75) push bc ld c, 2 ; attack stat call GetEnemyMonStat - ld hl, $ff97 + ld hl, H_PRODUCT + 2 pop bc jr .scaleStats .specialAttack @@ -4357,7 +4356,7 @@ GetDamageVarsForEnemyAttack: ; 3de75 (f:5e75) ld b, a ld c, [hl] ld a, [W_PLAYERBATTSTATUS3] - bit 1, a ; check for Light Screen + bit HasLightScreenUp, a ; check for Light Screen jr z, .specialAttackCritCheck ; if the player has used Light Screen, double the player's special sla c @@ -4380,7 +4379,7 @@ GetDamageVarsForEnemyAttack: ; 3de75 (f:5e75) push bc ld c, 5 ; special stat call GetEnemyMonStat - ld hl, $ff97 + ld hl, H_PRODUCT + 2 pop bc ; if either the offensive or defensive stat is too large to store in a byte, scale both stats by dividing them by 4 ; this allows values with up to 10 bits (values up to 1023) to be handled @@ -4437,9 +4436,9 @@ GetEnemyMonStat: ; 3df1c (f:5f1c) ld bc, wEnemyMon2 - wEnemyMon1 call AddNTimes ld a, [hli] - ld [$ff97], a + ld [H_MULTIPLICAND + 1], a ld a, [hl] - ld [$ff98], a + ld [H_MULTIPLICAND + 2], a pop bc pop de ret @@ -4671,7 +4670,7 @@ CriticalHitTest: ; 3e023 (f:6023) dec hl ld c, [hl] ; read move id ld a, [de] - bit 2, a ; test for focus energy + bit GettingPumped, a ; test for focus energy jr nz, .focusEnergyUsed ; bug: using focus energy causes a shift to the right instead of left, ; resulting in 1/4 the usual crit chance sla b ; (effective (base speed/2)*2) @@ -4858,7 +4857,7 @@ ApplyDamageToEnemyPokemon: ; 3e142 (f:6142) or b jr z,ApplyAttackToEnemyPokemonDone ; we're done if damage is 0 ld a,[W_ENEMYBATTSTATUS2] - bit 4,a ; does the enemy have a substitute? + bit HasSubstituteUp,a ; does the enemy have a substitute? jp nz,AttackSubstitute ; subtract the damage from the pokemon's current HP ; also, save the current HP at wHPBarOldHP @@ -4977,7 +4976,7 @@ ApplyDamageToPlayerPokemon: ; 3e200 (f:6200) or b jr z,ApplyAttackToPlayerPokemonDone ; we're done if damage is 0 ld a,[W_PLAYERBATTSTATUS2] - bit 4,a ; does the player have a substitute? + bit HasSubstituteUp,a ; does the player have a substitute? jp nz,AttackSubstitute ; subtract the damage from the pokemon's current HP ; also, save the current HP at wHPBarOldHP and the new HP at wHPBarNewHP @@ -5095,7 +5094,7 @@ HandleBuildingRage: ; 3e2b6 (f:62b6) ld de,wPlayerMonStatMods ld bc,W_PLAYERMOVENUM .next - bit 6,[hl] ; is the pokemon being attacked under the effect of Rage? + bit UsingRage,[hl] ; is the pokemon being attacked under the effect of Rage? ret z ; return if not ld a,[de] cp a,$0d ; maximum stat modifier value @@ -5103,7 +5102,7 @@ HandleBuildingRage: ; 3e2b6 (f:62b6) ld a,[H_WHOSETURN] xor a,$01 ; flip turn for the stat modifier raising function ld [H_WHOSETURN],a -; change the target pokemon's move to $00 and the effect to the one +; temporarily change the target pokemon's move to $00 and the effect to the one ; that causes the attack modifier to go up one stage ld h,b ld l,c @@ -5414,7 +5413,7 @@ MoveHitTest: ; 3e56b (f:656b) cp a,DREAM_EATER_EFFECT jr nz,.swiftCheck ld a,[bc] - and a,$07 ; is the target pokemon sleeping? + and a,SLP ; is the target pokemon sleeping? jp z,.moveMissed .swiftCheck ld a,[de] @@ -5429,7 +5428,7 @@ MoveHitTest: ; 3e56b (f:656b) cp a,DREAM_EATER_EFFECT jp z,.moveMissed .checkForDigOrFlyStatus - bit 6,[hl] + bit Invulnerable,[hl] jp nz,.moveMissed ld a,[H_WHOSETURN] and a @@ -5439,48 +5438,47 @@ MoveHitTest: ; 3e56b (f:656b) ld a,[W_PLAYERMOVEEFFECT] cp a,ATTACK_DOWN1_EFFECT jr c,.skipEnemyMistCheck - cp a,BIDE_EFFECT + cp a,HAZE_EFFECT + 1 jr c,.enemyMistCheck - cp a,$3a + cp a,ATTACK_DOWN2_EFFECT jr c,.skipEnemyMistCheck - cp a,POISON_EFFECT + cp a,REFLECT_EFFECT + 1 jr c,.enemyMistCheck jr .skipEnemyMistCheck .enemyMistCheck ; if move effect is from $12 to $19 inclusive or $3a to $41 inclusive ; i.e. the following moves ; GROWL, TAIL WHIP, LEER, STRING SHOT, SAND-ATTACK, SMOKESCREEN, KINESIS, -; FLASH, CONVERSION, HAZE*, SCREECH, LIGHT SCREEN*, REFLECT* +; FLASH, CONVERSION*, HAZE*, SCREECH, LIGHT SCREEN*, REFLECT* ; the moves that are marked with an asterisk are not affected since this ; function is not called when those moves are used -; XXX are there are any others like those three? ld a,[W_ENEMYBATTSTATUS2] - bit 1,a ; is mon protected by mist? + bit ProtectedByMist,a ; is mon protected by mist? jp nz,.moveMissed .skipEnemyMistCheck ld a,[W_PLAYERBATTSTATUS2] - bit 0,a ; is the player using X Accuracy? + bit UsingXAccuracy,a ; is the player using X Accuracy? ret nz ; if so, always hit regardless of accuracy/evasion jr .calcHitChance .enemyTurn ld a,[W_ENEMYMOVEEFFECT] cp a,ATTACK_DOWN1_EFFECT jr c,.skipPlayerMistCheck - cp a,BIDE_EFFECT + cp a,HAZE_EFFECT + 1 jr c,.playerMistCheck - cp a,$3a + cp a,ATTACK_DOWN2_EFFECT jr c,.skipPlayerMistCheck - cp a,POISON_EFFECT + cp a,REFLECT_EFFECT + 1 jr c,.playerMistCheck jr .skipPlayerMistCheck .playerMistCheck ; similar to enemy mist check ld a,[W_PLAYERBATTSTATUS2] - bit 1,a ; is mon protected by mist? + bit ProtectedByMist,a ; is mon protected by mist? jp nz,.moveMissed .skipPlayerMistCheck ld a,[W_ENEMYBATTSTATUS2] - bit 0,a ; is the enemy using X Accuracy? + bit UsingXAccuracy,a ; is the enemy using X Accuracy? ret nz ; if so, always hit regardless of accuracy/evasion .calcHitChance call CalcHitChance ; scale the move accuracy according to attacker's accuracy and target's evasion @@ -5510,11 +5508,11 @@ MoveHitTest: ; 3e56b (f:656b) jr z,.playerTurn2 .enemyTurn2 ld hl,W_ENEMYBATTSTATUS1 - res 5,[hl] ; end multi-turn attack e.g. wrap + res UsingTrappingMove,[hl] ; end multi-turn attack e.g. wrap ret .playerTurn2 ld hl,W_PLAYERBATTSTATUS1 - res 5,[hl] ; end multi-turn attack e.g. wrap + res UsingTrappingMove,[hl] ; end multi-turn attack e.g. wrap ret ; values for player turn @@ -5631,14 +5629,14 @@ ExecuteEnemyMove: ; 3e6bc (f:66bc) jp z, ExecuteEnemyMoveDone ld a, [W_ISLINKBATTLE] cp $4 - jr nz, .asm_3e6dc + jr nz, .executeEnemyMove ld b, $1 ld a, [wcc3e] cp $e - jr z, .asm_3e6dc + jr z, .executeEnemyMove cp $4 ret nc -.asm_3e6dc +.executeEnemyMove ld hl, wccd5 inc [hl] xor a @@ -5651,21 +5649,21 @@ ExecuteEnemyMove: ; 3e6bc (f:66bc) jp [hl] .enemyHasNoSpecialConditions ld hl, W_ENEMYBATTSTATUS1 - bit 4, [hl] ; is the enemy charging up for attack? - jr nz, enemyCanExecuteChargingMove ; if so, jump + bit ChargingUp, [hl] ; is the enemy charging up for attack? + jr nz, EnemyCanExecuteChargingMove ; if so, jump call GetCurrentMove -Func_3e6fc: ; 3e6fc (f:66fc) +CheckIfEnemyNeedsToChargeUp: ; 3e6fc (f:66fc) ld a, [W_ENEMYMOVEEFFECT] cp CHARGE_EFFECT jp z, JumpMoveEffect cp FLY_EFFECT jp z, JumpMoveEffect - jr enemyCanExecuteMove -enemyCanExecuteChargingMove: ; 3e70b (f:670b) + jr EnemyCanExecuteMove +EnemyCanExecuteChargingMove: ; 3e70b (f:670b) ld hl, W_ENEMYBATTSTATUS1 - res 4, [hl] ; no longer charging up for attack - res 6, [hl] ; no longer invulnerable to typical attacks + res ChargingUp, [hl] ; no longer charging up for attack + res Invulnerable, [hl] ; no longer invulnerable to typical attacks ld a, [W_ENEMYMOVENUM] ld [wd0b5], a ld a, BANK(MoveNames) @@ -5675,7 +5673,7 @@ enemyCanExecuteChargingMove: ; 3e70b (f:670b) call GetName ld de, wcd6d call CopyStringToCF4B -enemyCanExecuteMove: ; 3e72b (f:672b) +EnemyCanExecuteMove: ; 3e72b (f:672b) xor a ld [wcced], a call PrintMonName1Text @@ -5733,7 +5731,7 @@ asm_3e7a0: ; 3e7a0 (f:67a0) asm_3e7a4: ; 3e7a4 (f:67a4) push af ld a, [W_ENEMYBATTSTATUS2] - bit 4, a ; does mon have a substitute? + bit HasSubstituteUp, a ; does mon have a substitute? ld hl, Func_79747 ld b, BANK(Func_79747) call nz, Bankswitch @@ -5744,7 +5742,7 @@ asm_3e7a4: ; 3e7a4 (f:67a4) call HandleExplodingAnimation call DrawEnemyHUDAndHPBar ld a, [W_ENEMYBATTSTATUS2] - bit 4, a ; does mon have a substitute? + bit HasSubstituteUp, a ; does mon have a substitute? ld hl, Func_79771 ld b, BANK(Func_79771) call nz, Bankswitch ; slide the substitute's sprite out @@ -5771,12 +5769,12 @@ asm_3e7ef: ; 3e7ef (f:67ef) jr nz, .notMirrorMoveEffect call MirrorMoveCopyMove jp z, ExecuteEnemyMoveDone - jp Func_3e6fc + jp CheckIfEnemyNeedsToChargeUp .notMirrorMoveEffect cp METRONOME_EFFECT jr nz, .notMetronomeEffect call MetronomePickMove - jp Func_3e6fc + jp CheckIfEnemyNeedsToChargeUp .notMetronomeEffect ld a, [W_ENEMYMOVEEFFECT] ld hl, ResidualEffects2 @@ -5810,14 +5808,14 @@ asm_3e7ef: ; 3e7ef (f:67ef) ret z call HandleBuildingRage ld hl, W_ENEMYBATTSTATUS1 - bit 2, [hl] ; is mon hitting multiple times? (example: double kick) + bit AttackingMultipleTimes, [hl] ; is mon hitting multiple times? (example: double kick) jr z, .asm_3e873 push hl ld hl, wEnemyNumAttacksLeft dec [hl] pop hl jp nz, Func_3e794 - res 2, [hl] ; mon is no longer hitting multiple times + res AttackingMultipleTimes, [hl] ; mon is no longer hitting multiple times ld hl, HitXTimesText call PrintText xor a @@ -5877,7 +5875,7 @@ CheckEnemyStatusConditions: ; 3e88f (f:688f) jp .enemyReturnToHL .checkIfTrapped ld a, [W_PLAYERBATTSTATUS1] - bit 5, a ; is the player using a multi-turn attack like warp + bit UsingTrappingMove, a ; is the player using a multi-turn attack like warp jp z, .checkIfFlinched ld hl, CantMoveText call PrintText @@ -5885,18 +5883,18 @@ CheckEnemyStatusConditions: ; 3e88f (f:688f) jp .enemyReturnToHL .checkIfFlinched ld hl, W_ENEMYBATTSTATUS1 - bit 3, [hl] ; check if enemy mon flinched + bit Flinched, [hl] ; check if enemy mon flinched jp z, .checkIfMustRecharge - res 3, [hl] + res Flinched, [hl] ld hl, FlinchedText call PrintText ld hl, ExecuteEnemyMoveDone jp .enemyReturnToHL .checkIfMustRecharge ld hl, W_ENEMYBATTSTATUS2 - bit 5, [hl] ; check if enemy mon has to recharge after using a move + bit NeedsToRecharge, [hl] ; check if enemy mon has to recharge after using a move jr z, .checkIfAnyMoveDisabled - res 5, [hl] + res NeedsToRecharge, [hl] ld hl, MustRechargeText call PrintText ld hl, ExecuteEnemyMoveDone @@ -5922,7 +5920,7 @@ CheckEnemyStatusConditions: ; 3e88f (f:688f) dec [hl] jr nz, .isConfused ld hl, W_ENEMYBATTSTATUS1 - res 7, [hl] + res Confused, [hl] ld hl, ConfusedNoMoreText call PrintText jp .checkIfTriedToUseDisabledMove @@ -5938,7 +5936,7 @@ CheckEnemyStatusConditions: ; 3e88f (f:688f) jr c, .checkIfTriedToUseDisabledMove ld hl, W_ENEMYBATTSTATUS1 ld a, [hl] - and $80 + and 1 << Confused ld [hl], a ld hl, HurtItselfText call PrintText @@ -5958,7 +5956,7 @@ CheckEnemyStatusConditions: ; 3e88f (f:688f) xor a ld [hli], a ld [wCriticalHitOrOHKO], a - ld a, $28 + ld a, 40 ld [hli], a xor a ld [hl], a @@ -6003,7 +6001,8 @@ CheckEnemyStatusConditions: ; 3e88f (f:688f) .monHurtItselfOrFullyParalysed ld hl, W_ENEMYBATTSTATUS1 ld a, [hl] - and $cc ; clear bide, thrashing, charging up, and multi-turn moves such as warp + ; clear bide, thrashing about, charging up, and multi-turn moves such as warp + and (1 << AttackingMultipleTimes) | (1 << Flinched) | (1 << Invulnerable) | (1 << Confused) ld [hl], a ld a, [W_ENEMYMOVEEFFECT] cp FLY_EFFECT @@ -6021,7 +6020,7 @@ CheckEnemyStatusConditions: ; 3e88f (f:688f) jp .enemyReturnToHL .checkIfUsingBide ld hl, W_ENEMYBATTSTATUS1 - bit 0, [hl] ; is mon using bide? + bit StoringEnergy, [hl] ; is mon using bide? jr z, .checkIfThrashingAbout xor a ld [W_ENEMYMOVENUM], a @@ -6043,7 +6042,7 @@ CheckEnemyStatusConditions: ; 3e88f (f:688f) jp .enemyReturnToHL .unleashEnergy ld hl, W_ENEMYBATTSTATUS1 - res 0, [hl] ; not using bide any more + res StoringEnergy, [hl] ; not using bide any more ld hl, UnleashedEnergyText call PrintText ld a, $1 @@ -6070,7 +6069,7 @@ CheckEnemyStatusConditions: ; 3e88f (f:688f) ld hl, asm_3e782 jp .enemyReturnToHL .checkIfThrashingAbout - bit 1, [hl] ; is mon using thrash or petal dance? + bit ThrashingAbout, [hl] ; is mon using thrash or petal dance? jr z, .checkIfUsingMultiturnMove ld a, THRASH ld [W_ENEMYMOVENUM], a @@ -6082,8 +6081,8 @@ CheckEnemyStatusConditions: ; 3e88f (f:688f) jp nz, .enemyReturnToHL push hl ld hl, W_ENEMYBATTSTATUS1 - res 1, [hl] ; mon is no longer using thrash or petal dance - set 7, [hl] ; mon is now confused + res ThrashingAbout, [hl] ; mon is no longer using thrash or petal dance + set Confused, [hl] ; mon is now confused call BattleRandom and $3 inc a @@ -6092,7 +6091,7 @@ CheckEnemyStatusConditions: ; 3e88f (f:688f) pop hl jp .enemyReturnToHL .checkIfUsingMultiturnMove - bit 5, [hl] ; is mon using multi-turn move? + bit UsingTrappingMove, [hl] ; is mon using multi-turn move? jp z, .checkIfUsingRage ld hl, AttackContinuesText call PrintText @@ -6103,7 +6102,7 @@ CheckEnemyStatusConditions: ; 3e88f (f:688f) jp .enemyReturnToHL .checkIfUsingRage ld a, [W_ENEMYBATTSTATUS2] - bit 6, a ; is mon using rage? + bit UsingRage, a ; is mon using rage? jp z, .checkEnemyStatusConditionsDone ld a, RAGE ld [wd11e], a @@ -6111,7 +6110,7 @@ CheckEnemyStatusConditions: ; 3e88f (f:688f) call CopyStringToCF4B xor a ld [W_ENEMYMOVEEFFECT], a - ld hl, enemyCanExecuteMove + ld hl, EnemyCanExecuteMove jp .enemyReturnToHL .enemyReturnToHL xor a ; set Z flag @@ -6161,7 +6160,7 @@ LoadEnemyMonData: ; 3eb01 (f:6b01) ld [wd0b5], a call GetMonHeader ld a, [W_ENEMYBATTSTATUS3] - bit 3, a ; is enemy mon transformed? + bit Transformed, a ; is enemy mon transformed? ld hl, wcceb ; copied DVs from when it used Transform ld a, [hli] ld b, [hl] @@ -6193,7 +6192,7 @@ LoadEnemyMonData: ; 3eb01 (f:6b01) cp $2 ; is it a trainer battle? jr z, .copyHPAndStatusFromPartyData ld a, [W_ENEMYBATTSTATUS3] - bit 3, a ; is enemy mon transformed? + bit Transformed, a ; is enemy mon transformed? jr nz, .copyTypes ; if transformed, jump ; if it's a wild mon and not transformed, init the current HP to max HP and the status to 0 ld a, [wEnemyMonMaxHP] @@ -6713,34 +6712,37 @@ BattleRandom: push hl push bc - ld a, [wccde] + ld a, [wLinkBattleRNCount] ld c, a ld b, 0 ld hl, wd148 add hl, bc inc a - ld [wccde], a + ld [wLinkBattleRNCount], a cp 9 ld a, [hl] pop bc pop hl ret c +; if we picked the last seed, we need to recalculate the nine seeds push hl push bc push af - + +; point to seed 0 so we pick the first number the next time xor a - ld [wccde], a - + ld [wLinkBattleRNCount], a ld hl, wd148 ld b, 9 .loop ld a, [hl] ld c, a +; multiply by 5 add a add a add c +; add 1 inc a ld [hli], a dec b @@ -6769,7 +6771,7 @@ HandleExplodingAnimation: ; 3eed3 (f:6ed3) ret nz .asm_3eef1 ld a, [de] - bit 6, a ; fly/dig + bit Invulnerable, a ; fly/dig ret nz ld a, [hli] cp GHOST @@ -7190,8 +7192,8 @@ SleepEffect: ; 3f1fc (f:71fc) .sleepEffect ld a, [bc] - bit 5, a ; does the target need to recharge? (hyper beam) - res 5, a ; target no longer needs to recharge + bit NeedsToRecharge, a ; does the target need to recharge? (hyper beam) + res NeedsToRecharge, a ; target no longer needs to recharge ld [bc], a jr nz, .setSleepCounter ; if the target had to recharge, all hit tests will be skipped ; including the event where the target already has another status @@ -7290,7 +7292,7 @@ PoisonEffect: ; 3f24f (f:724f) .ok cp TOXIC jr nz, .normalPoison ; done if move is not Toxic - set 0, [hl] ; else set Toxic battstatus + set BadlyPoisoned, [hl] ; else set Toxic battstatus xor a ld [de], a ld hl, BadlyPoisonedText @@ -7345,7 +7347,7 @@ ExplodeEffect: ; 3f2f1 (f:72f1) inc hl ld [hl], a ; set mon's status to 0 ld a, [de] - res 7, a ; clear mon's leech seed status + res Seeded, a ; clear mon's leech seed status ld [de], a ret @@ -7421,7 +7423,7 @@ opponentAttacker: ; 3f382 (f:7382) cp b ret z ld a, [W_ENEMYMOVEEFFECT] - cp a, 7 + cp a, PARALYZE_SIDE_EFFECT1 + 1 ld b, $1a jr c, .next1 ld b, $4d @@ -7512,7 +7514,7 @@ StatModifierUpEffect: ; 3f428 (f:7428) .statModifierUpEffect ld a, [de] sub ATTACK_UP1_EFFECT - cp $8 + cp EVASION_UP1_EFFECT + $3 - ATTACK_UP1_EFFECT ; covers all +1 effects jr c, .incrementStatMod sub ATTACK_UP2_EFFECT - ATTACK_UP1_EFFECT ; map +2 effects to equivalent +1 effect .incrementStatMod @@ -7523,7 +7525,7 @@ StatModifierUpEffect: ; 3f428 (f:7428) inc b ; increment corresponding stat mod ld a, $d cp b ; can't raise stat past +6 ($d or 13) - jp c, Func_3f522 + jp c, PrintNothingHappenedText ld a, [de] cp ATTACK_UP1_EFFECT + $8 ; is it a +2 effect? jr c, .ok @@ -7539,7 +7541,7 @@ StatModifierUpEffect: ; 3f428 (f:7428) jr nc, UpdateStatDone ; jump if mod affected is evasion/accuracy push hl ld hl, wBattleMonAttack + 1 - ld de, wcd12 + ld de, wPlayerMonUnmodifiedAttack ld a, [H_WHOSETURN] and a jr z, .pointToStats @@ -7558,10 +7560,10 @@ StatModifierUpEffect: ; 3f428 (f:7428) .checkIf999 pop bc ld a, [hld] - sub $e7 ; check if stat is already 999 + sub 999 % $100 ; check if stat is already 999 jr nz, .recalculateStat ld a, [hl] - sbc $3 + sbc 999 / $100 jp z, Func_3f520 .recalculateStat ; recalculate affected stat ; paralysis and burn penalties, as well as badge boosts are ignored @@ -7575,35 +7577,35 @@ StatModifierUpEffect: ; 3f428 (f:7428) add hl, bc pop bc xor a - ld [H_NUMTOPRINT], a ; $ff96 (aliases: H_MULTIPLICAND) + ld [H_MULTIPLICAND], a ld a, [de] - ld [$ff97], a + ld [H_MULTIPLICAND + 1], a inc de ld a, [de] - ld [$ff98], a + ld [H_MULTIPLICAND + 2], a ld a, [hli] - ld [H_REMAINDER], a ; $ff99 (aliases: H_DIVISOR, H_MULTIPLIER, H_POWEROFTEN) + ld [H_MULTIPLIER], a call Multiply ld a, [hl] - ld [H_REMAINDER], a ; $ff99 (aliases: H_DIVISOR, H_MULTIPLIER, H_POWEROFTEN) + ld [H_DIVISOR], a ld b, $4 call Divide pop hl ; cap at 999 - ld a, [$ff98] - sub $e7 - ld a, [$ff97] - sbc $3 + ld a, [H_PRODUCT + 3] + sub 999 % $100 + ld a, [H_PRODUCT + 2] + sbc 999 / $100 jp c, UpdateStat ld a, 999 / $100 - ld [$ff97], a + ld [H_MULTIPLICAND + 1], a ld a, 999 % $100 - ld [$ff98], a + ld [H_MULTIPLICAND + 2], a UpdateStat: ; 3f4c3 (f:74c3) - ld a, [$ff97] + ld a, [H_PRODUCT + 2] ld [hli], a - ld a, [$ff98] + ld a, [H_PRODUCT + 3] ld [hl], a pop hl UpdateStatDone: ; 3f4ca (f:74ca) @@ -7623,7 +7625,7 @@ UpdateStatDone: ; 3f4ca (f:74ca) ld a, [de] cp MINIMIZE jr nz, .asm_3f4f9 - bit 4, [hl] ; substitute + bit HasSubstituteUp, [hl] ; substitute push af push bc ld hl, Func_79747 @@ -7659,7 +7661,7 @@ Func_3f520: ; 3f520 (f:7520) pop hl dec [hl] -Func_3f522: ; 3f522 (f:7522) +PrintNothingHappenedText: ; 3f522 (f:7522) ld hl, NothingHappenedText jp PrintText @@ -7700,7 +7702,7 @@ StatModifierDownEffect: ; 3f54c (f:754c) cp $4 jr z, .statModifierDownEffect call BattleRandom - cp $40 ; 1/4 chance to miss by wildmon + cp $40 ; 1/4 chance to miss by in regular battle jp c, MoveMissed .statModifierDownEffect call CheckTargetSubstitute ; can't hit through substitute @@ -7726,13 +7728,13 @@ StatModifierDownEffect: ; 3f54c (f:754c) and a jp nz, MoveMissed ld a, [bc] - bit 6, a ; fly/dig + bit Invulnerable, a ; fly/dig jp nz, MoveMissed ld a, [de] sub ATTACK_DOWN1_EFFECT - cp $8 + cp EVASION_DOWN1_EFFECT + $3 - ATTACK_DOWN1_EFFECT ; covers al -1 effects jr c, .decrementStatMod - sub ATTACK_DOWN2_EFFECT - ATTACK_DOWN1_EFFECT ; map +2 effects to corresponding +1 effect + sub ATTACK_DOWN2_EFFECT - ATTACK_DOWN1_EFFECT ; map -2 effects to corresponding -1 effect .decrementStatMod ld c, a ld b, $0 @@ -7741,9 +7743,9 @@ StatModifierDownEffect: ; 3f54c (f:754c) dec b ; dec corresponding stat mod jp z, CantLowerAnymore ; if stat mod is 1 (-6), can't lower anymore ld a, [de] - cp $24 + cp ATTACK_DOWN2_EFFECT - $16 ; $24 jr c, .ok - cp $44 + cp EVASION_DOWN2_EFFECT + $5 ; $44 jr nc, .ok dec b ; stat down 2 effects only (dec mod again) jr nz, .ok @@ -7752,7 +7754,7 @@ StatModifierDownEffect: ; 3f54c (f:754c) ld [hl], b ; save modified mod ld a, c cp $4 - jr nc, UpdateStat2Done ; jump for evasion/accuracy + jr nc, UpdateLoweredStatDone ; jump for evasion/accuracy push hl push de ld hl, wEnemyMonAttack + 1 @@ -7761,7 +7763,7 @@ StatModifierDownEffect: ; 3f54c (f:754c) and a jr z, .pointToStat ld hl, wBattleMonAttack + 1 - ld de, wcd12 + ld de, wPlayerMonUnmodifiedAttack .pointToStat push bc sla c @@ -7793,37 +7795,37 @@ StatModifierDownEffect: ; 3f54c (f:754c) add hl, bc pop bc xor a - ld [H_NUMTOPRINT], a ; $ff96 (aliases: H_MULTIPLICAND) + ld [H_MULTIPLICAND], a ld a, [de] - ld [$ff97], a + ld [H_MULTIPLICAND + 1], a inc de ld a, [de] - ld [$ff98], a + ld [H_MULTIPLICAND + 2], a ld a, [hli] - ld [H_REMAINDER], a ; $ff99 (aliases: H_DIVISOR, H_MULTIPLIER, H_POWEROFTEN) + ld [H_MULTIPLIER], a call Multiply ld a, [hl] - ld [H_REMAINDER], a ; $ff99 (aliases: H_DIVISOR, H_MULTIPLIER, H_POWEROFTEN) + ld [H_DIVISOR], a ld b, $4 call Divide pop hl - ld a, [$ff98] + ld a, [H_PRODUCT + 3] ld b, a - ld a, [$ff97] + ld a, [H_PRODUCT + 2] or b - jp nz, UpdateStat2 - ld [$ff97], a + jp nz, UpdateLoweredStat + ld [H_MULTIPLICAND + 1], a ld a, $1 - ld [$ff98], a + ld [H_MULTIPLICAND + 2], a -UpdateStat2: ; 3f624 (f:7624) - ld a, [$ff97] +UpdateLoweredStat: ; 3f624 (f:7624) + ld a, [H_PRODUCT + 2] ld [hli], a - ld a, [$ff98] + ld a, [H_PRODUCT + 3] ld [hl], a pop de pop hl -UpdateStat2Done: ; 3f62c (f:762c) +UpdateLoweredStatDone: ; 3f62c (f:762c) ld b, c inc b push de @@ -7941,7 +7943,7 @@ BideEffect: ; 3f6e5 (f:76e5) ld de, wcd05 ld bc, wEnemyNumAttacksLeft .bideEffect - set 0, [hl] ; mon is now using bide + set StoringEnergy, [hl] ; mon is now using bide xor a ld [de], a inc de @@ -7966,7 +7968,7 @@ ThrashPetalDanceEffect: ; 3f717 (f:7717) ld hl, W_ENEMYBATTSTATUS1 ld de, wEnemyNumAttacksLeft .thrashPetalDanceEffect - set 1, [hl] ; mon is now using thrash/petal dance + set ThrashingAbout, [hl] ; mon is now using thrash/petal dance call BattleRandom and $1 inc a @@ -8102,9 +8104,9 @@ TwoToFiveAttacksEffect: ; 3f811 (f:7811) ld de, wEnemyNumAttacksLeft ld bc, wcd05 .twoToFiveAttacksEffect - bit 2, [hl] ; is mon attacking multiple times? + bit AttackingMultipleTimes, [hl] ; is mon attacking multiple times? ret nz - set 2, [hl] ; mon is now attacking multiple times + set AttackingMultipleTimes, [hl] ; mon is now attacking multiple times ld hl, W_PLAYERMOVEEFFECT ld a, [H_WHOSETURN] and a @@ -8156,7 +8158,7 @@ FlinchSideEffect: ; 3f85b (f:785b) call BattleRandom cp b ret nc - set 3, [hl] ; set mon's status to flinching + set Flinched, [hl] ; set mon's status to flinching call ClearHyperBeam ret @@ -8176,18 +8178,18 @@ ChargeEffect: ; 3f88c (f:788c) ld de, W_ENEMYMOVEEFFECT ld b, ANIM_AF .chargeEffect - set 4, [hl] + set ChargingUp, [hl] ld a, [de] dec de ; de contains enemy or player MOVENUM cp FLY_EFFECT jr nz, .notFly - set 6, [hl] ; mon is now invulnerable to typical attacks (fly/dig) + set Invulnerable, [hl] ; mon is now invulnerable to typical attacks (fly/dig) ld b, TELEPORT ; load Teleport's animation .notFly ld a, [de] cp DIG jr nz, .notDigOrFly - set 6, [hl] ; mon is now invulnerable to typical attacks (fly/dig) + set Invulnerable, [hl] ; mon is now invulnerable to typical attacks (fly/dig) ld b, ANIM_C0 .notDigOrFly xor a @@ -8256,11 +8258,11 @@ TrappingEffect: ; 3f917 (f:7917) ld hl, W_ENEMYBATTSTATUS1 ld de, wEnemyNumAttacksLeft .trappingEffect - bit 5, [hl] + bit UsingTrappingMove, [hl] ret nz call ClearHyperBeam ; since this effect is called before testing whether the move will hit, ; the target won't need to recharge even if the trapping move missed - set 5, [hl] ; mon is now using a trapping move + set UsingTrappingMove, [hl] ; mon is now using a trapping move call BattleRandom ; 3/8 chance for 2 and 3 attacks, and 1/8 chance for 4 and 5 attacks and $3 cp $2 @@ -8312,9 +8314,9 @@ ConfusionSideEffectSuccess: ; 3f96f (f:796f) ld bc, W_PLAYERCONFUSEDCOUNTER ld a, [W_ENEMYMOVEEFFECT] .confuseTarget - bit 7, [hl] ; is mon confused? + bit Confused, [hl] ; is mon confused? jr nz, ConfusionEffectFailed - set 7, [hl] ; mon is now confused + set Confused, [hl] ; mon is now confused push af call BattleRandom and $3 @@ -8355,7 +8357,7 @@ HyperBeamEffect: ; 3f9c1 (f:79c1) jr z, .hyperBeamEffect ld hl, W_ENEMYBATTSTATUS2 .hyperBeamEffect - set 5, [hl] ; mon now needs to recharge + set NeedsToRecharge, [hl] ; mon now needs to recharge ret ClearHyperBeam: ; 3f9cf (f:79cf) @@ -8366,7 +8368,7 @@ ClearHyperBeam: ; 3f9cf (f:79cf) jr z, .asm_3f9db ld hl, W_PLAYERBATTSTATUS2 .asm_3f9db - res 5, [hl] ; mon no longer needs to recharge + res NeedsToRecharge, [hl] ; mon no longer needs to recharge pop hl ret @@ -8377,7 +8379,7 @@ RageEffect: ; 3f9df (f:79df) jr z, .player ld hl, W_ENEMYBATTSTATUS2 .player - set 6, [hl] ; mon is now in "rage" mode + set UsingRage, [hl] ; mon is now in "rage" mode ret MimicEffect: ; 3f9ed (f:79ed) @@ -8398,7 +8400,7 @@ MimicEffect: ; 3f9ed (f:79ed) ld hl, wEnemyMonMoves ld a, [W_ENEMYBATTSTATUS1] .asm_3fa13 - bit 6, a + bit Invulnerable, a jr nz, .asm_3fa74 .asm_3fa17 push hl @@ -8422,7 +8424,7 @@ MimicEffect: ; 3f9ed (f:79ed) jr .asm_3fa5f .asm_3fa3a ld a, [W_ENEMYBATTSTATUS1] - bit 6, a + bit Invulnerable, a jr nz, .asm_3fa74 ld a, [wCurrentMenuItem] push af @@ -8627,12 +8629,12 @@ ParalyzedMayNotAttackText: ; 3fb74 (f:7b74) CheckTargetSubstitute: ; 3fb79 (f:7b79) push hl ld hl, W_ENEMYBATTSTATUS2 - ld a, [$fff3] ;whose turn? + ld a, [$fff3] and a jr z, .next1 ld hl, W_PLAYERBATTSTATUS2 .next1 - bit 4, [hl] ;test bit 4 in d063/d068 flags + bit HasSubstituteUp, [hl] pop hl ret diff --git a/engine/battle/e_2.asm b/engine/battle/e_2.asm index b0e08982..6c159c56 100755 --- a/engine/battle/e_2.asm +++ b/engine/battle/e_2.asm @@ -130,7 +130,7 @@ TransformEffect_: ; 3bab1 (e:7ab1) ld [wPlayerMoveListIndex], a ; wPlayerMoveListIndex ld a, [W_PLAYERBATTSTATUS1] ; W_PLAYERBATTSTATUS1 .asm_3bad1 - bit 6, a ; is mon invulnerable to typical attacks? (fly/dig) + bit Invulnerable, a ; is mon invulnerable to typical attacks? (fly/dig) jp nz, Func_3bb8c push hl push de @@ -141,7 +141,7 @@ TransformEffect_: ; 3bab1 (e:7ab1) jr z, .asm_3bae4 ld hl, W_ENEMYBATTSTATUS2 ; W_ENEMYBATTSTATUS2 .asm_3bae4 - bit 4, [hl] + bit HasSubstituteUp, [hl] push af ld hl, Func_79747 ld b, BANK(Func_79747) @@ -161,7 +161,7 @@ TransformEffect_: ; 3bab1 (e:7ab1) call nz, Bankswitch pop bc ld a, [bc] - set 3, a + set Transformed, a ld [bc], a pop de pop hl @@ -267,15 +267,15 @@ ReflectLightScreenEffect_: ; 3bb97 (e:7b97) ld a, [de] cp LIGHT_SCREEN_EFFECT jr nz, .reflect - bit 1, [hl] ; is mon already protected by light screen? + bit HasLightScreenUp, [hl] ; is mon already protected by light screen? jr nz, .moveFailed - set 1, [hl] ; mon is now protected by light screen + set HasLightScreenUp, [hl] ; mon is now protected by light screen ld hl, LightScreenProtectedText ; $7bd7 jr .asm_3bbc1 .reflect - bit 2, [hl] ; is mon already protected by reflect? + bit HasReflectUp, [hl] ; is mon already protected by reflect? jr nz, .moveFailed - set 2, [hl] ; mon is now protected by reflect + set HasReflectUp, [hl] ; mon is now protected by reflect ld hl, ReflectGainedArmorText ; $7bdc .asm_3bbc1 push hl diff --git a/engine/items/items.asm b/engine/items/items.asm index af6c9552..029c659b 100755 --- a/engine/items/items.asm +++ b/engine/items/items.asm @@ -357,13 +357,13 @@ ItemUseBall: ; d687 (3:5687) push af ;...and status ailments push hl ld hl,W_ENEMYBATTSTATUS3 - bit 3,[hl] + bit Transformed,[hl] jr z,.next15 ld a,$4c ld [wEnemyMonSpecies2],a jr .next16 .next15 ;$5871 - set 3,[hl] + set Transformed,[hl] ld hl,wcceb ld a,[wEnemyMonDVs] ld [hli],a @@ -770,7 +770,7 @@ ItemUseMedicine: ; dabb (3:5abb) ld [wBattleMonStatus],a ; remove the status ailment in the in-battle pokemon data push hl ld hl,W_PLAYERBATTSTATUS3 - res 0,[hl] ; heal Toxic status + res BadlyPoisoned,[hl] ; heal Toxic status pop hl ld bc,30 add hl,bc ; hl now points to party stats @@ -1407,7 +1407,7 @@ ItemUseRepelCommon: ; e005 (3:6005) and a jp nz,ItemUseNotTime ld a,b - ld [wd0db],a + ld [wRepelRemainingSteps],a jp PrintItemUseTextAndRemoveItem ; handles X Accuracy item @@ -1416,7 +1416,7 @@ ItemUseXAccuracy: ; e013 (3:6013) and a jp z,ItemUseNotTime ld hl,W_PLAYERBATTSTATUS2 - set 0,[hl] ; X Accuracy bit + set UsingXAccuracy,[hl] ; X Accuracy bit jp PrintItemUseTextAndRemoveItem ; This function is bugged and never works. It always jumps to ItemUseNotTime. @@ -1525,7 +1525,7 @@ ItemUseGuardSpec: ; e0dc (3:60dc) and a jp z,ItemUseNotTime ld hl,W_PLAYERBATTSTATUS2 - set 1,[hl] ; Mist bit + set ProtectedByMist,[hl] ; Mist bit jp PrintItemUseTextAndRemoveItem ItemUseSuperRepel: ; e0eb (3:60eb) @@ -1541,7 +1541,7 @@ ItemUseDireHit: ; e0f5 (3:60f5) and a jp z,ItemUseNotTime ld hl,W_PLAYERBATTSTATUS2 - set 2,[hl] ; Focus Energy bit + set GettingPumped,[hl] ; Focus Energy bit jp PrintItemUseTextAndRemoveItem ItemUseXStat: ; e104 (3:6104) @@ -348,7 +348,8 @@ wPlayerSelectedMove:: ; ccdc wEnemySelectedMove:: ; ccdd ds 1 -wccde:: ds 1 +wLinkBattleRNCount:: ; ccde + ds 1 wAICount:: ; ccdf ; number of times remaining that AI action can occur @@ -1178,7 +1179,10 @@ W_DAMAGE:: ; d0d7 ds 1 wd0d8:: ds 3 -wd0db:: ds 1 + +wRepelRemainingSteps:: ; wd0db + ds 1 + wd0dc:: ds 4 wd0e0:: ds 1 wd0e1:: ds 56 |