ref: b4906ff54de06f4a1379741a2c73c4753fe18a96
parent: 9a1ae1332cd98abd65c2f26a1ae4d65c6450530a
parent: 60ffde3752d079d557dab9a8acecb0bc9e5d46aa
author: Rangi <remy.oukaour+rangi42@gmail.com>
date: Thu Jul 26 12:23:12 EDT 2018
Merge branch 'master' of https://github.com/pret/pokecrystal
--- a/docs/bugs_and_glitches.md
+++ b/docs/bugs_and_glitches.md
@@ -76,21 +76,21 @@
**Fix:**
-```asm
+```diff
; Double the stat
sla l
rl h
-
- ld a, HIGH(MAX_STAT_VALUE)
- cp h
- jr c, .cap
- ld a, LOW(MAX_STAT_VALUE)
- cp l
- ret nc
-
-.cap
- ld h, HIGH(MAX_STAT_VALUE)
- ld l, LOW(MAX_STAT_VALUE)
++
++ ld a, HIGH(MAX_STAT_VALUE)
++ cp h
++ jr c, .cap
++ ld a, LOW(MAX_STAT_VALUE)
++ cp l
++ ret nc
++
++.cap
++ ld h, HIGH(MAX_STAT_VALUE)
++ ld l, LOW(MAX_STAT_VALUE)
ret
```
@@ -123,7 +123,7 @@
**Fix:**
-```asm
+```diff
ld a, c
srl a
add c
@@ -138,17 +138,17 @@
.done
scf
rr c
-
- ld a, HIGH(MAX_STAT_VALUE)
- cp b
- jr c, .cap
- ld a, LOW(MAX_STAT_VALUE)
- cp c
- ret nc
-
-.cap
- ld b, HIGH(MAX_STAT_VALUE)
- ld c, LOW(MAX_STAT_VALUE)
++
++ ld a, HIGH(MAX_STAT_VALUE)
++ cp b
++ jr c, .cap
++ ld a, LOW(MAX_STAT_VALUE)
++ cp c
++ ret nc
++
++.cap
++ ld b, HIGH(MAX_STAT_VALUE)
++ ld c, LOW(MAX_STAT_VALUE)
ret
```
@@ -329,9 +329,15 @@
ret
```
-*To do:* Fix this bug.
+Fix:
+```asm
+CheckHiddenOpponent: ; 37daa
+ ret
+```
+The code in `CheckHiddenOpponent` is completely redundant as `CheckHit` already does what this code is doing. Another option is to remove `CheckHiddenOpponent` completely, the calls to `CheckHiddenOpponent`, and the jump afterwards.
+
## Beat Up can desynchronize link battles
*Fixing this bug will break compatibility with standard Pokémon Crystal for link battles.*
@@ -430,7 +436,7 @@
**Fix:**
-```asm
+```diff
BattleCommand_BeatUpFailText:
; beatupfailtext
@@ -437,10 +443,10 @@
ld a, [wBeatUpHitAtLeastOnce]
and a
ret nz
++
++ inc a
++ ld [wAttackMissed], a
- inc a
- ld [wAttackMissed], a
-
jp PrintButItFailed
```
@@ -640,22 +646,22 @@
**Fix:**
-```asm
+```diff
CalcExpAtLevel:
; (a/b)*n**3 + c*n**2 + d*n - e
- ld a, d
- cp 1
- jr nz, .UseExpFormula
-; Pokémon have 0 experience at level 1
- xor a
- ld hl, hProduct
- ld [hli], a
- ld [hli], a
- ld [hli], a
- ld [hl], a
- ret
-
-.UseExpFormula
++ ld a, d
++ cp 1
++ jr nz, .UseExpFormula
++; Pokémon have 0 experience at level 1
++ xor a
++ ld hl, hProduct
++ ld [hli], a
++ ld [hli], a
++ ld [hli], a
++ ld [hl], a
++ ret
++
++.UseExpFormula
ld a, [wBaseGrowthRate]
add a
add a
@@ -864,10 +870,11 @@
**Fix:**
-```asm
+```diff
HappinessData_DaisysGrooming:
- db $80, 2, HAPPINESS_GROOMING ; 50% chance
- db $ff, 2, HAPPINESS_GROOMING ; 50% chance
+- db $ff, 2, HAPPINESS_GROOMING ; 99.6% chance
++ db $80, 2, HAPPINESS_GROOMING ; 50% chance
++ db $ff, 2, HAPPINESS_GROOMING ; 50% chance
```
@@ -1061,18 +1068,18 @@
**Fix:**
-```asm
+```diff
ld de, MUSIC_ROCKET_BATTLE
cp GRUNTM
jr z, .done
cp GRUNTF
jr z, .done
- cp EXECUTIVEM
- jr z, .done
- cp EXECUTIVEF
- jr z, .done
- cp SCIENTIST
- jr z, .done
++ cp EXECUTIVEM
++ jr z, .done
++ cp EXECUTIVEF
++ jr z, .done
++ cp SCIENTIST
++ jr z, .done
```
@@ -1107,10 +1114,12 @@
**Fix:**
-```asm
+```diff
ld a, [wWalkingDirection]
- cp STANDING
- jr z, .not_warp
+- ; cp STANDING
+- ; jr z, .not_warp
++ cp STANDING
++ jr z, .not_warp
ld e, a
ld d, 0
ld hl, .EdgeWarps
@@ -1122,6 +1131,9 @@
ld a, 1
ld [wd041], a
ld a, [wWalkingDirection]
+- ; This is in the wrong place.
+- cp STANDING
+- jr z, .not_warp
```
@@ -1303,15 +1315,27 @@
**Fix:**
-```asm
+```diff
ld hl, wEnemySubStatus5
ld a, [hl]
push af
set SUBSTATUS_TRANSFORMED, [hl]
+-; This code is buggy. Any wild Pokémon that has Transformed will be
+-; caught as a Ditto, even if it was something else like Mew.
+-; To fix, do not set [wTempEnemyMonSpecies] to DITTO.
bit SUBSTATUS_TRANSFORMED, a
- jr nz, .load_data
+- jr nz, .ditto
+- jr .not_ditto
++ jr nz, .load_data
+-.ditto
+- ld a, DITTO
+- ld [wTempEnemyMonSpecies], a
+- jr .load_data
+-
+-.not_ditto
+- set SUBSTATUS_TRANSFORMED, [hl]
ld hl, wEnemyBackupDVs
ld a, [wEnemyMonDVs]
ld [hli], a
@@ -1347,12 +1371,14 @@
**Fix:**
-```asm
+```diff
.room_in_party
xor a
ld [wWildMon], a
- ld a, [wBattleType]
- cp BATTLETYPE_CONTEST
+- ld a, [wCurItem]
+- cp PARK_BALL
++ ld a, [wBattleType]
++ cp BATTLETYPE_CONTEST
call nz, ReturnToBattle_UseBall
```
@@ -1429,12 +1455,12 @@
ld a, [hli]
and a
jr z, .nope
- cp EVOLVE_STAT
- jr nz, .not_four_bytes
++ cp EVOLVE_STAT
++ jr nz, .not_four_bytes
++ inc hl
++.not_four_bytes
inc hl
-.not_four_bytes
inc hl
- inc hl
cp EVOLVE_ITEM
jr nz, .loop2
```
@@ -1542,11 +1568,12 @@
**Fix:**
-```asm
+```diff
ld a, b
ld [wCurPartyLevel], a
ld b, [hl]
- ld a, b
+- ; ld a, b
++ ld a, b
call ValidateTempWildMonSpecies
jr c, .nowildbattle
--- a/docs/design_flaws.md
+++ b/docs/design_flaws.md
@@ -152,21 +152,22 @@
Modify `GetFrontpicPointer`:
-```asm
+```diff
ld a, [wCurPartySpecies]
cp UNOWN
jr z, .unown
ld a, [wCurPartySpecies]
- ld hl, PokemonPicPointers
++ ld hl, PokemonPicPointers
ld d, BANK(PokemonPicPointers)
jr .ok
.unown
ld a, [wUnownLetter]
- ld hl, UnownPicPointers
++ ld hl, UnownPicPointers
ld d, BANK(UnownPicPointers)
.ok
+- ld hl, PokemonPicPointers ; UnownPicPointers
dec a
ld bc, 6
call AddNTimes
@@ -175,13 +176,15 @@
And `GetMonBackpic`:
```asm
+- ; These are assumed to be at the same address in their respective banks.
+- ld hl, PokemonPicPointers ; UnownPicPointers
ld a, b
- ld hl, PokemonPicPointers
++ ld hl, PokemonPicPointers
ld d, BANK(PokemonPicPointers)
cp UNOWN
jr nz, .ok
ld a, c
- ld hl, UnownPicPointers
++ ld hl, UnownPicPointers
ld d, BANK(UnownPicPointers)
.ok
dec a
@@ -268,12 +271,26 @@
Modify `Pokedex_LoadAnyFootprint`:
-```asm
+```diff
+- push hl
ld e, l
ld d, h
ld hl, vTiles2 tile $62
- lb bc, BANK(Footprints), 4
+- lb bc, BANK(Footprints), 2
++ lb bc, BANK(Footprints), 4
call Request1bpp
+- pop hl
+-
+- ; Whoever was editing footprints forgot to fix their
+- ; tile editor. Now each bottom half is 8 tiles off.
+- ld de, 8 tiles
+- add hl, de
+-
+- ld e, l
+- ld d, h
+- ld hl, vTiles2 tile $64
+- lb bc, BANK(Footprints), 2
+- call Request1bpp
```
@@ -341,10 +358,19 @@
Modify engine/items/items.asm:
-```asm
+```diff
GetTMHMNumber::
; Return the number of a TM/HM by item id c.
ld a, c
+-; Skip any dummy items.
+- cp ITEM_C3 ; TM04-05
+- jr c, .done
+- cp ITEM_DC ; TM28-29
+- jr c, .skip
+- dec a
+-.skip
+- dec a
+-.done
sub TM01
inc a
ld c, a
@@ -353,6 +379,16 @@
GetNumberedTMHM:
; Return the item id of a TM/HM by number c.
ld a, c
+-; Skip any gaps.
+- cp ITEM_C3 - (TM01 - 1)
+- jr c, .done
+- cp ITEM_DC - (TM01 - 1) - 1
+- jr c, .skip_one
+-.skip_two
+- inc a
+-.skip_one
+- inc a
+-.done
add TM01
dec a
ld c, a