Reformat some bugfix diffs

This commit is contained in:
Rangi 2018-07-29 00:27:13 -04:00
parent 9dec80b07e
commit 20ffc8bd8b
1 changed files with 90 additions and 89 deletions

View File

@ -306,7 +306,7 @@ This bug affects Attract, Curse, Foresight, Mean Look, Mimic, Nightmare, Spider
**Fix:** Edit `CheckHiddenOpponent` in [engine/battle/effect_commands.asm](/engine/battle/effect_commands.asm): **Fix:** Edit `CheckHiddenOpponent` in [engine/battle/effect_commands.asm](/engine/battle/effect_commands.asm):
```diff ```diff
-CheckHiddenOpponent: CheckHiddenOpponent:
-; BUG: This routine is completely redundant and introduces a bug, since BattleCommand_CheckHit does these checks properly. -; BUG: This routine is completely redundant and introduces a bug, since BattleCommand_CheckHit does these checks properly.
- ld a, BATTLE_VARS_SUBSTATUS3_OPP - ld a, BATTLE_VARS_SUBSTATUS3_OPP
- call GetBattleVar - call GetBattleVar
@ -887,20 +887,20 @@ CopyPokemonName_Buffer1_Buffer3:
([Video](https://www.youtube.com/watch?v=eij_1060SMc)) ([Video](https://www.youtube.com/watch?v=eij_1060SMc))
There are three things wrong here:
- `wEnemyMonLevel` isn't initialized yet
- `wBattleMonLevel` gets overwritten after it's initialized by `FindFirstAliveMonAndStartBattle`
- `wBattleMonLevel` isn't initialized until much later when the battle is with a trainer
**Fix:** **Fix:**
There's three things wrong here. First, edit [engine/battle/battle_transition.asm](/engine/battle/battle_transition.asm):
* `wEnemyMonLevel` doesn't have the value its name implies yet; it'll be populated later from `wCurPartyLevel`.
* `wBattleMonLevel` gets overwritten between when the value is written in `FindFirstAliveMonAndStartBattle` and when it's read.
* `wBattleMonLevel` isn't set until much later when the battle is with a trainer; extra code is needed to read a trainer's party and get the level of their lead Pokémon.
First, in [engine/battle/battle_transition.asm](/engine/battle/battle_transition.asm):
```diff ```diff
StartTrainerBattle_DetermineWhichAnimation: StartTrainerBattle_DetermineWhichAnimation:
; The screen flashes a different number of times depending on the level of ; The screen flashes a different number of times depending on the level of
; your lead Pokemon relative to the opponent's. ; your lead Pokemon relative to the opponent's.
-; BUG: wBattleMonLevel and wEnemyMonLevel 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. -; values happen to be there will determine the animation.
+ ld a, [wOtherTrainerClass] + ld a, [wOtherTrainerClass]
@ -927,43 +927,43 @@ StartTrainerBattle_DetermineWhichAnimation:
ld de, 0 ld de, 0
- ld a, [wBattleMonLevel] - ld a, [wBattleMonLevel]
+ ld a, [hl] + ld a, [hl]
add 3 add 3
- ld hl, wEnemyMonLevel - ld hl, wEnemyMonLevel
+ ld hl, wCurPartyLevel + ld hl, wCurPartyLevel
cp [hl] cp [hl]
jr nc, .not_stronger jr nc, .not_stronger
set TRANS_STRONGER_F, e set TRANS_STRONGER_F, e
.not_stronger .not_stronger
ld a, [wEnvironment] ld a, [wEnvironment]
cp CAVE cp CAVE
jr z, .cave jr z, .cave
cp ENVIRONMENT_5 cp ENVIRONMENT_5
jr z, .cave jr z, .cave
cp DUNGEON cp DUNGEON
jr z, .cave jr z, .cave
set TRANS_NO_CAVE_F, e set TRANS_NO_CAVE_F, e
.cave .cave
ld hl, .StartingPoints ld hl, .StartingPoints
add hl, de add hl, de
ld a, [hl] ld a, [hl]
ld [wJumptableIndex], a ld [wJumptableIndex], a
ret ret
.StartingPoints: .StartingPoints:
; entries correspond to TRANS_* constants ; entries correspond to TRANS_* constants
db BATTLETRANSITION_CAVE db BATTLETRANSITION_CAVE
db BATTLETRANSITION_CAVE_STRONGER db BATTLETRANSITION_CAVE_STRONGER
db BATTLETRANSITION_NO_CAVE db BATTLETRANSITION_NO_CAVE
db BATTLETRANSITION_NO_CAVE_STRONGER db BATTLETRANSITION_NO_CAVE_STRONGER
``` ```
In [engine/battle/start_battle.asm](/engine/battle/start_battle.asm): Then edit [engine/battle/start_battle.asm](/engine/battle/start_battle.asm):
```diff ```diff
FindFirstAliveMonAndStartBattle: FindFirstAliveMonAndStartBattle:
xor a xor a
ld [hMapAnims], a ld [hMapAnims], a
call DelayFrame call DelayFrame
- ld b, 6 - ld b, 6
- ld hl, wPartyMon1HP - ld hl, wPartyMon1HP
- ld de, PARTYMON_STRUCT_LENGTH - 1 - ld de, PARTYMON_STRUCT_LENGTH - 1
@ -981,57 +981,58 @@ FindFirstAliveMonAndStartBattle:
- add hl, de - add hl, de
- ld a, [hl] - ld a, [hl]
- ld [wBattleMonLevel], a - ld [wBattleMonLevel], a
predef DoBattleTransition predef DoBattleTransition
``` ```
Finally, add this code to the end of [engine/battle/read_trainer_party.asm](/engine/battle/read_trainer_party.asm): Finally, edit [engine/battle/read_trainer_party.asm](/engine/battle/read_trainer_party.asm):
```asm ```asm
SetTrainerBattleLevel: INCLUDE "data/trainers/parties.asm"
ld a, 255 +
ld [wCurPartyLevel], a +SetTrainerBattleLevel:
+ ld a, 255
ld a, [wInBattleTowerBattle] + ld [wCurPartyLevel], a
bit 0, a +
ret nz + ld a, [wInBattleTowerBattle]
+ bit 0, a
ld a, [wLinkMode] + ret nz
and a +
ret nz + ld a, [wLinkMode]
+ and a
ld a, [wOtherTrainerClass] + ret nz
dec a +
ld c, a + ld a, [wOtherTrainerClass]
ld b, 0 + dec a
ld hl, TrainerGroups + ld c, a
rept 2 + ld b, 0
add hl, bc + ld hl, TrainerGroups
endr + add hl, bc
ld a, [hli] + add hl, bc
ld h, [hl] + ld a, [hli]
ld l, a + ld h, [hl]
+ ld l, a
ld a, [wOtherTrainerID] +
ld b, a + ld a, [wOtherTrainerID]
.skip_trainer + ld b, a
dec b +.skip_trainer
jr z, .got_trainer + dec b
.loop1 + jr z, .got_trainer
ld a, [hli] +.loop1
cp $ff + ld a, [hli]
jr nz, .loop1 + cp $ff
jr .skip_trainer + jr nz, .loop1
.got_trainer + jr .skip_trainer
+.got_trainer
.skip_name +
ld a, [hli] +.skip_name
cp "@" + ld a, [hli]
jr nz, .skip_name + cp "@"
+ jr nz, .skip_name
inc hl +
ld a, [hl] + inc hl
ld [wCurPartyLevel], a + ld a, [hl]
ret + ld [wCurPartyLevel], a
+ ret
``` ```
@ -1138,7 +1139,7 @@ The exact cause of this bug is unknown.
```diff ```diff
.Cry: .Cry:
- call Pokedex_GetSelectedMon - call Pokedex_GetSelectedMon
- ld a, [wd265] - ld a, [wTempSpecies]
- call GetCryIndex - call GetCryIndex
- ld e, c - ld e, c
- ld d, b - ld d, b