shithub: pokecrystal

Download patch

ref: ff1c9f36daa855d7d7253a157371b0a79244870b
parent: 62439a95a1a7efed07f7189216ce3f9011200f32
author: Thomas Winwood <[email protected]>
date: Sat Jun 9 19:35:50 EDT 2018

Convert code samples in bugs_and_glitches.md to diffs

--- 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
 ```
 
@@ -402,7 +402,7 @@
 
 **Fix:**
 
-```asm
+```diff
 BattleCommand_BeatUpFailText: ; 355b5
 ; beatupfailtext
 
@@ -409,10 +409,10 @@
 	ld a, [wBeatUpHitAtLeastOnce]
 	and a
 	ret nz
++
++	inc a
++	ld [wAttackMissed], a
 
-	inc a
-	ld [wAttackMissed], a
-
 	jp PrintButItFailed
 ```
 
@@ -613,22 +613,22 @@
 
 **Fix:**
 
-```asm
+```diff
 CalcExpAtLevel: ; 50e47
 ; (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
@@ -837,10 +837,11 @@
 
 **Fix:**
 
-```asm
+```diff
 HappinessData_DaisysGrooming: ; 746b
-	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
 ```
 
 
@@ -1037,18 +1038,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
 ```
 
 
@@ -1083,10 +1084,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
@@ -1098,6 +1101,9 @@
 	ld a, 1
 	ld [wd041], a
 	ld a, [wWalkingDirection]
+-	; This is in the wrong place.
+-	cp STANDING
+-	jr z, .not_warp
 ```
 
 
@@ -1279,15 +1285,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
@@ -1323,12 +1341,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
 ```
 
@@ -1405,12 +1425,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
 ```
@@ -1519,11 +1539,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