diff --git a/audio/engine.asm b/audio/engine.asm index d01d74c7d..c8e976cc4 100644 --- a/audio/engine.asm +++ b/audio/engine.asm @@ -233,7 +233,7 @@ UpdateChannels: ; e8125 jp [hl] -.ChannelFnPtrs +.ChannelFnPtrs: dw .Channel1 dw .Channel2 dw .Channel3 @@ -245,11 +245,11 @@ UpdateChannels: ; e8125 dw .Channel7 dw .Channel8 -.Channel1 +.Channel1: ld a, [Danger] bit 7, a ret nz -.Channel5 +.Channel5: ld hl, Channel1NoteFlags - Channel1 add hl, bc bit NOTE_UNKN_3, [hl] @@ -317,8 +317,8 @@ UpdateChannels: ; e8125 ld [rNR14], a ret -.Channel2 -.Channel6 +.Channel2: +.Channel6: ld hl, Channel1NoteFlags - Channel1 add hl, bc bit NOTE_REST, [hl] ; rest @@ -377,8 +377,8 @@ UpdateChannels: ; e8125 ld [rNR24], a ret -.Channel3 -.Channel7 +.Channel3: +.Channel7: ld hl, Channel1NoteFlags - Channel1 add hl, bc bit NOTE_REST, [hl] ; rest @@ -478,8 +478,8 @@ endr ld [rNR32], a ret -.Channel4 -.Channel8 +.Channel4: +.Channel8: ld hl, Channel1NoteFlags - Channel1 add hl, bc bit NOTE_REST, [hl] ; rest @@ -2483,62 +2483,62 @@ _PlayCryHeader:: ; e8b79 ; Play cry de using parameters: ; CryPitch ; CryLength - + call MusicOff - + ; Overload the music id with the cry id ld hl, MusicID ld [hl], e inc hl ld [hl], d - + ; 3-byte pointers (bank, address) ld hl, Cries rept 3 add hl, de endr - + ld a, [hli] ld [MusicBank], a - + ld e, [hl] inc hl ld d, [hl] - + ; Read the cry's sound header call LoadMusicByte ; Top 2 bits contain the number of channels rlca rlca and 3 - + ; For each channel: inc a .loop push af call LoadChannel - + ld hl, Channel1Flags - Channel1 add hl, bc set SOUND_REST, [hl] - + ld hl, Channel1Flags2 - Channel1 add hl, bc set SOUND_CRY_PITCH, [hl] - + ld hl, Channel1CryPitch - Channel1 add hl, bc ld a, [CryPitch] ld [hli], a ld a, [CryPitch + 1] ld [hl], a - + ; No tempo for channel 4 ld a, [CurChannel] and 3 cp 3 jr nc, .start - + ; Tempo is effectively length ld hl, Channel1Tempo - Channel1 add hl, bc @@ -2551,14 +2551,14 @@ endr ld a, [wStereoPanningMask] and a jr z, .next - + ; Stereo only: Play cry from the monster's side. ; This only applies in-battle. - + ld a, [Options] bit 5, a ; stereo jr z, .next - + ; [Tracks] &= [CryTracks] ld hl, Channel1Tracks - Channel1 add hl, bc @@ -2568,23 +2568,23 @@ endr ld hl, Channel1Tracks - Channel1 add hl, bc ld [hl], a - + .next pop af dec a jr nz, .loop - - + + ; Cries play at max volume, so we save the current volume for later. ld a, [LastVolume] and a jr nz, .end - + ld a, [Volume] ld [LastVolume], a ld a, $77 ld [Volume], a - + .end ld a, 1 ; stop playing music ld [SFXPriority], a @@ -2699,24 +2699,24 @@ PlayStereoSFX:: ; e8ca6 ; play sfx de call MusicOff - + ; standard procedure if stereo's off ld a, [Options] bit 5, a jp z, _PlaySFX - + ; else, let's go ahead with this ld hl, MusicID ld [hl], e inc hl ld [hl], d - + ; get sfx ptr ld hl, SFX rept 3 add hl, de endr - + ; bank ld a, [hli] ld [MusicBank], a @@ -2724,22 +2724,22 @@ endr ld e, [hl] inc hl ld d, [hl] - + ; bit 2-3 call LoadMusicByte rlca rlca and 3 ; ch1-4 inc a - + .loop push af call LoadChannel - + ld hl, Channel1Flags - Channel1 add hl, bc set SOUND_SFX, [hl] - + push de ; get tracks for this channel ld a, [CurChannel] @@ -2751,47 +2751,47 @@ endr ld a, [hl] ld hl, wStereoPanningMask and [hl] - + ld hl, Channel1Tracks - Channel1 add hl, bc ld [hl], a - + ld hl, Channel1Field0x30 - Channel1 ; $c131 - Channel1 add hl, bc ld [hl], a - + ld a, [CryTracks] cp 2 ; ch 1-2 jr c, .skip - + ; ch3-4 ld a, [wSFXDuration] - + ld hl, Channel1Field0x2e - Channel1 ; $c12f - Channel1 add hl, bc ld [hl], a - + ld hl, Channel1Field0x2f - Channel1 ; $c130 - Channel1 add hl, bc ld [hl], a - + ld hl, Channel1Flags2 - Channel1 add hl, bc set SOUND_UNKN_0F, [hl] - + .skip pop de - + ; turn channel on ld hl, Channel1Flags - Channel1 add hl, bc set SOUND_CHANNEL_ON, [hl] ; on - + ; done? pop af dec a jr nz, .loop - + ; we're done call MusicOn ret diff --git a/audio/music_pointers.asm b/audio/music_pointers.asm index 11d55fe2c..7e0ca0c69 100644 --- a/audio/music_pointers.asm +++ b/audio/music_pointers.asm @@ -102,9 +102,9 @@ dba Music_LakeOfRageRocketRadio ; 0xef5b1 dba Music_Printer ; 0xf07fd dba Music_PostCredits ; 0xcfd9e - + ; Crystal adds the following songs: - + dba Music_Clair ; 0x1fa8d dba Music_MobileAdapterMenu ; 0x17801f dba Music_MobileAdapter ; 0x1fc87 diff --git a/battle/ai/items.asm b/battle/ai/items.asm index c7c8f8201..90bfb840d 100644 --- a/battle/ai/items.asm +++ b/battle/ai/items.asm @@ -318,7 +318,7 @@ AI_Items: ; 39196 jp c, .Use jp .DontUse -.StatusCheckContext +.StatusCheckContext: ld a, [EnemySubStatus5] bit SUBSTATUS_TOXIC, a jr z, .FailToxicCheck @@ -328,7 +328,7 @@ AI_Items: ; 39196 call Random cp 1 + 50 percent jp c, .Use -.FailToxicCheck +.FailToxicCheck: ld a, [EnemyMonStatus] and 1 << FRZ | SLP jp z, .DontUse @@ -344,7 +344,7 @@ AI_Items: ; 39196 call .Status jp c, .DontUse -.UseFullRestore +.UseFullRestore: call EnemyUsedFullRestore jp .Use ; 38220 @@ -676,7 +676,7 @@ AI_TrySwitch: ; 3844b ld c, a ld hl, OTPartyMon1HP ld d, 0 -.SwitchLoop +.SwitchLoop: ld a, [hli] ld b, a ld a, [hld] diff --git a/battle/ai/move.asm b/battle/ai/move.asm index eb6a0536d..0d1c6c968 100755 --- a/battle/ai/move.asm +++ b/battle/ai/move.asm @@ -31,24 +31,24 @@ endr ld hl, EnemyMonMoves ld c, 0 -.CheckDisabledMove +.CheckDisabledMove: cp [hl] jr z, .ScoreDisabledMove inc c inc hl jr .CheckDisabledMove -.ScoreDisabledMove +.ScoreDisabledMove: ld hl, Buffer1 ld b, 0 add hl, bc ld [hl], 80 ; Don't pick moves with 0 PP. -.CheckPP +.CheckPP: ld hl, Buffer1 - 1 ld de, EnemyMonPP ld b, 0 -.CheckMovePP +.CheckMovePP: inc b ld a, b cp EnemyMonMovesEnd - EnemyMonMoves + 1 @@ -63,7 +63,7 @@ endr ; Apply AI scoring layers depending on the trainer class. -.ApplyLayers +.ApplyLayers: ld hl, TrainerClassAttributes + TRNATTR_AI_MOVE_WEIGHTS ; If we have a battle in BattleTower just load the Attributes of the first TrainerClass (Falkner) @@ -82,7 +82,7 @@ endr push bc push hl -.CheckLayer +.CheckLayer: pop hl pop bc @@ -119,12 +119,12 @@ endr jr .CheckLayer ; Decrement the scores of all moves one by one until one reaches 0. -.DecrementScores +.DecrementScores: ld hl, Buffer1 ld de, EnemyMonMoves ld c, EnemyMonMovesEnd - EnemyMonMoves -.DecrementNextScore +.DecrementNextScore: ; If the enemy has no moves, this will infinite. ld a, [de] inc de @@ -145,7 +145,7 @@ endr ; In order to avoid bias towards the moves located first in memory, increment the scores ; that were decremented one more time than the rest (in case there was a tie). ; This means that the minimum score will be 1. -.PickLowestScoreMoves +.PickLowestScoreMoves: ld a, c .move_loop @@ -159,14 +159,14 @@ endr ld de, EnemyMonMoves ld c, NUM_MOVES -; Give a score of 0 to a blank move +; Give a score of 0 to a blank move .loop2 ld a, [de] and a jr nz, .skip_load ld [hl], a -; Disregard the move if its score is not 1 +; Disregard the move if its score is not 1 .skip_load ld a, [hl] dec a @@ -183,8 +183,8 @@ endr dec c jr nz, .loop2 -; Randomly choose one of the moves with a score of 1 -.ChooseMove +; Randomly choose one of the moves with a score of 1 +.ChooseMove: ld hl, Buffer1 call Random and 3 diff --git a/battle/ai/scoring.asm b/battle/ai/scoring.asm index e9df9c62a..9b8dd6e42 100644 --- a/battle/ai/scoring.asm +++ b/battle/ai/scoring.asm @@ -23,7 +23,7 @@ AI_Basic: ; 38591 ; Dismiss moves with special effects if they are ; useless or not a good choice right now. -; For example, healing moves, weather moves, Dream Eater... +; For example, healing moves, weather moves, Dream Eater... push hl push de push bc @@ -33,7 +33,7 @@ AI_Basic: ; 38591 pop hl jr nz, .discourage -; Dismiss status-only moves if the player can't be statused. +; Dismiss status-only moves if the player can't be statused. ld a, [wEnemyMoveStruct + MOVE_EFFECT] push hl push de @@ -680,7 +680,7 @@ rept 2 inc [hl] endr -; 30% chance to end up here if enemy's HP is full and player is not badly poisoned. +; 30% chance to end up here if enemy's HP is full and player is not badly poisoned. ; 77% chance to end up here if enemy's HP is above 50% but not full. ; 96% chance to end up here if enemy's HP is between 25% and 50%. ; 100% chance to end up here if enemy's HP is below 25%. @@ -771,7 +771,7 @@ AI_Smart_MirrorMove: ; 3895b jr nz, .asm_38968 ; ...do nothing if enemy is slower than player - call AICompareSpeed + call AICompareSpeed ret nc ; ...or dismiss this move if enemy is faster than player. @@ -784,7 +784,7 @@ AI_Smart_MirrorMove: ; 3895b ld de, 1 call IsInArray pop hl - + ; ...do nothing if he didn't use a useful move. ret nc @@ -813,11 +813,11 @@ AI_Smart_AccuracyDown: ; 38985 call AICheckPlayerMaxHP jr nc, .asm_389a0 -; ...and enemy's HP is above 50%... +; ...and enemy's HP is above 50%... call AICheckEnemyHalfHP jr nc, .asm_389a0 -; ...greatly encourage this move if player is badly poisoned. +; ...greatly encourage this move if player is badly poisoned. ld a, [PlayerSubStatus5] bit SUBSTATUS_TOXIC, a jr nz, .asm_3899d @@ -839,21 +839,21 @@ endr call AICheckPlayerQuarterHP jr nc, .asm_389bd -; If player's HP is above 25% but not full, 4% chance to greatly encourage this move. +; If player's HP is above 25% but not full, 4% chance to greatly encourage this move. call Random cp $a jr c, .asm_3899d -; If player's HP is between 25% and 50%,... +; If player's HP is between 25% and 50%,... call AICheckPlayerHalfHP jr nc, .asm_389b8 -; If player's HP is above 50% but not full, 20% chance to greatly encourage this move. +; If player's HP is above 50% but not full, 20% chance to greatly encourage this move. call AI_80_20 jr c, .asm_3899d jr .asm_389bf -; ...50% chance to greatly discourage this move. +; ...50% chance to greatly discourage this move. .asm_389b8 call AI_50_50 jr c, .asm_389bf @@ -863,7 +863,7 @@ rept 2 inc [hl] endr -; We only end up here if the move has not been already encouraged. +; We only end up here if the move has not been already encouraged. .asm_389bf ld a, [PlayerSubStatus5] bit SUBSTATUS_TOXIC, a @@ -873,14 +873,14 @@ endr bit SUBSTATUS_LEECH_SEED, a jr nz, .asm_389ef -; Discourage this move if enemy's evasion level is higher than player's accuracy level. +; Discourage this move if enemy's evasion level is higher than player's accuracy level. ld a, [EnemyEvaLevel] ld b, a ld a, [PlayerAccLevel] cp b jr c, .asm_389e4 -; Greatly encourage this move if the player is in the middle of Fury Cutter or Rollout. +; Greatly encourage this move if the player is in the middle of Fury Cutter or Rollout. ld a, [PlayerFuryCutterCount] and a jr nz, .asm_3899d @@ -895,7 +895,7 @@ endr ; Player is badly poisoned. ; 80% chance to greatly encourage this move. -; This would counter any previous discouragement. +; This would counter any previous discouragement. .asm_389e6 call Random cp $50 @@ -907,7 +907,7 @@ endr ; Player is seeded. ; 50% chance to encourage this move. -; This would partly counter any previous discouragement. +; This would partly counter any previous discouragement. .asm_389ef call AI_50_50 ret c @@ -931,7 +931,7 @@ AI_Smart_Haze: ; 389f5 jr c, .asm_38a12 jr .asm_389fb -; 85% chance to encourage this move if any of player's stat levels is higher than +2. +; 85% chance to encourage this move if any of player's stat levels is higher than +2. .asm_38a05 ld hl, PlayerAtkLevel ld c, $8 @@ -1164,7 +1164,7 @@ AI_Smart_Confuse: ; 38adb cp $19 jr c, .asm_38ae7 inc [hl] - + .asm_38ae7 ; Discourage again if player's HP is below 25%. call AICheckPlayerQuarterHP @@ -1220,10 +1220,10 @@ AI_Smart_Fly: ; 38b12 ld a, [PlayerSubStatus3] and 1 << SUBSTATUS_FLYING | 1 << SUBSTATUS_UNDERGROUND ret z - + call AICompareSpeed ret nc - + rept 3 dec [hl] endr @@ -1246,9 +1246,9 @@ AI_Smart_Paralyze: ; 38b26 ; 50% chance to discourage this move if player's HP is below 25%. call AICheckPlayerQuarterHP jr nc, .asm_38b3a - + ; 80% chance to greatly encourage this move -; if enemy is slower than player and its HP is above 25%. +; if enemy is slower than player and its HP is above 25%. call AICompareSpeed ret c call AICheckEnemyQuarterHP @@ -1308,8 +1308,8 @@ AI_Smart_Substitute: ; 38b5c AI_Smart_HyperBeam: ; 38b63 call AICheckEnemyHalfHP jr c, .asm_38b72 - -; 50% chance to encourage this move if enemy's HP is below 25%. + +; 50% chance to encourage this move if enemy's HP is below 25%. call AICheckEnemyQuarterHP ret c call AI_50_50 @@ -1335,13 +1335,13 @@ AI_Smart_Rage: ; 38b7f bit SUBSTATUS_RAGE, a jr z, .asm_38b9b -; If enemy's Rage is building, 50% chance to encourage this move. +; If enemy's Rage is building, 50% chance to encourage this move. call AI_50_50 jr c, .asm_38b8c dec [hl] -; Encourage this move based on Rage's counter. +; Encourage this move based on Rage's counter. .asm_38b8c ld a, [wEnemyRageCounter] cp $2 @@ -1773,12 +1773,12 @@ AI_Smart_PriorityHit: ; 38d5a call AICompareSpeed ret c -; Dismiss this move if the player is flying or underground. +; Dismiss this move if the player is flying or underground. ld a, [PlayerSubStatus3] and 1 << SUBSTATUS_FLYING | 1 << SUBSTATUS_UNDERGROUND jp nz, AIDiscourageMove -; Greatly encourage this move if it will KO the player. +; Greatly encourage this move if it will KO the player. ld a, $1 ld [hBattleTurn], a push hl @@ -1895,18 +1895,18 @@ AI_Smart_MeanLook: ; 38dfb pop hl jp z, AIDiscourageMove -; 80% chance to greatly encourage this move if the enemy is badly poisoned (weird). +; 80% chance to greatly encourage this move if the enemy is badly poisoned (weird). ld a, [EnemySubStatus5] 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. +; in love, identified, stuck in Rollout, or has a Nightmare. ld a, [PlayerSubStatus1] and 1<