Merge pull request #606 from ISSOtm/patch-1

Correct some bugfixes, add some compatibility extensions
This commit is contained in:
Rangi 2019-03-03 17:30:58 -05:00 committed by GitHub
commit eee79d7049
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -89,6 +89,7 @@ Some fixes are mentioned as breaking compatibility with link battles. This can b
+ ld a, HIGH(MAX_STAT_VALUE) + ld a, HIGH(MAX_STAT_VALUE)
+ cp h + cp h
+ jr c, .cap + jr c, .cap
+ ret nz
+ ld a, LOW(MAX_STAT_VALUE) + ld a, LOW(MAX_STAT_VALUE)
+ cp l + cp l
+ ret nc + ret nc
@ -126,6 +127,7 @@ Some fixes are mentioned as breaking compatibility with link battles. This can b
+ ld a, HIGH(MAX_STAT_VALUE) + ld a, HIGH(MAX_STAT_VALUE)
+ cp b + cp b
+ jr c, .cap + jr c, .cap
+ ret nz
+ ld a, LOW(MAX_STAT_VALUE) + ld a, LOW(MAX_STAT_VALUE)
+ cp c + cp c
+ ret nc + ret nc
@ -166,7 +168,7 @@ This bug existed for all battles in Gold and Silver, and was only fixed for sing
## Moves with a 100% secondary effect chance will not trigger it in 1/256 uses ## Moves with a 100% secondary effect chance will not trigger it in 1/256 uses
*Fixing this bug will break compatibility with standard Pokémon Crystal for link battles.* *Fixing this bug **may** break compatibility with standard Pokémon Crystal for link battles.*
([Video](https://www.youtube.com/watch?v=mHkyO5T5wZU&t=206)) ([Video](https://www.youtube.com/watch?v=mHkyO5T5wZU&t=206))
@ -175,24 +177,38 @@ This bug existed for all battles in Gold and Silver, and was only fixed for sing
```diff ```diff
- ; BUG: 1/256 chance to fail even for a 100% effect chance, - ; BUG: 1/256 chance to fail even for a 100% effect chance,
- ; since carry is not set if BattleRandom == [hl] == 255 - ; since carry is not set if BattleRandom == [hl] == 255
- call BattleRandom
+ ld a, [hl] + ld a, [hl]
+ cp 100 percent + sub 100 percent
+ jr z, .ok + ; If chance was 100%, RNG won't be called (carry not set)
call BattleRandom + ; Thus chance will be subtracted from 0, guaranteeing a carry
+ call c, BattleRandom
cp [hl] cp [hl]
- pop hl pop hl
- ret c ret c
+ jr c, .ok
.failed .failed
ld a, 1 ld a, 1
ld [wEffectFailed], a ld [wEffectFailed], a
and a and a
+.ok
+ pop hl
ret ret
``` ```
**Compatibility preservation:** If you wish to keep compatibility with standard Pokémon Crystal, you can disable the fix during link battles by also applying the following edit in the same place:
```diff
+ ld a, [wLinkMode]
+ cp LINK_COLOSSEUM
+ scf ; Force RNG to be called
+ jr z, .nofix ; Don't apply fix in link battles, for compatibility
ld a, [hl]
sub 100 percent
; If chance was 100%, RNG won't be called (carry not set)
; Thus chance will be subtracted from 0, guaranteeing a carry
+.nofix
call c, BattleRandom
```
## Belly Drum sharply boosts Attack even with under 50% HP ## Belly Drum sharply boosts Attack even with under 50% HP
*Fixing this bug will break compatibility with standard Pokémon Crystal for link battles.* *Fixing this bug will break compatibility with standard Pokémon Crystal for link battles.*