summaryrefslogtreecommitdiff
path: root/docs
diff options
context:
space:
mode:
authorRangi <remy.oukaour+rangi42@gmail.com>2020-04-18 17:31:51 -0400
committerRangi <remy.oukaour+rangi42@gmail.com>2020-04-18 17:31:51 -0400
commit576cbf5b3e4ae7cd377dfeb0d75dca54b44518bc (patch)
tree3ba8cb1bc06c9cb26b35f7ddde9ac1b2c51a7f6c /docs
parentceb747c622cd90e9796515e917f2a0e00ebd7764 (diff)
Miscellaneous fixes, including one for the Pokédex design flaw by ax6
Diffstat (limited to 'docs')
-rw-r--r--docs/bugs_and_glitches.md38
-rw-r--r--docs/design_flaws.md119
2 files changed, 154 insertions, 3 deletions
diff --git a/docs/bugs_and_glitches.md b/docs/bugs_and_glitches.md
index f306cc84d..6220ff343 100644
--- a/docs/bugs_and_glitches.md
+++ b/docs/bugs_and_glitches.md
@@ -78,6 +78,7 @@ Some fixes are mentioned as breaking compatibility with link battles. This can b
- [`LoadSpriteGFX` does not limit the capacity of `UsedSprites`](#loadspritegfx-does-not-limit-the-capacity-of-usedsprites)
- [`ChooseWildEncounter` doesn't really validate the wild Pokémon species](#choosewildencounter-doesnt-really-validate-the-wild-pokémon-species)
- [`TryObjectEvent` arbitrary code execution](#tryobjectevent-arbitrary-code-execution)
+- [`ReadObjectEvents` overflows into `wObjectMasks`](#readobjectevents-overflows-into-wobjectmasks)
- [`ClearWRAM` only clears WRAM bank 1](#clearwram-only-clears-wram-bank-1)
- [`BattleAnimCmd_ClearObjs` only clears the first 6⅔ objects](#battleanimcmd_clearobjs-only-clears-the-first-6-objects)
@@ -341,7 +342,7 @@ As Pryce's dialog ("That BADGE will raise the SPECIAL stats of POKéMON.") impli
call GetBattleVarAddr
push af
set SUBSTATUS_CONFUSED, [hl]
-+ ld a, [hBattleTurn]
++ ldh a, [hBattleTurn]
+ and a
+ ld hl, wEnemyConfuseCount
+ jr z, .set_confuse_count
@@ -349,7 +350,7 @@ As Pryce's dialog ("That BADGE will raise the SPECIAL stats of POKéMON.") impli
+.set_confuse_count
+ call BattleRandom
+ and %11
-+ add a, 2
++ add 2
+ ld [hl], a
ld a, BATTLE_VARS_MOVE_ANIM
call GetBattleVarAddr
@@ -2145,6 +2146,39 @@ This supports up to six entries.
```
+## `ReadObjectEvents` overflows into `wObjectMasks`
+
+**Fix:** Edit `ReadObjectEvents` in [home/map.asm](https://github.com/pret/pokecrystal/blob/master/home/map.asm):
+
+```diff
+-; get NUM_OBJECTS - [wCurMapObjectEventCount]
++; get NUM_OBJECTS - [wCurMapObjectEventCount] - 1
+ ld a, [wCurMapObjectEventCount]
+ ld c, a
+- ld a, NUM_OBJECTS ; - 1
++ ld a, NUM_OBJECTS - 1
+ sub c
+ jr z, .skip
+- ; jr c, .skip
++ jr c, .skip
+
+ ; could have done "inc hl" instead
+ ld bc, 1
+ add hl, bc
+-; Fill the remaining sprite IDs and y coords with 0 and -1, respectively.
+-; Bleeds into wObjectMasks due to a bug. Uncomment the above code to fix.
+ ld bc, MAPOBJECT_LENGTH
+ .loop
+ ld [hl], 0
+ inc hl
+ ld [hl], -1
+ dec hl
+ add hl, bc
+ dec a
+ jr nz, .loop
+```
+
+
## `ClearWRAM` only clears WRAM bank 1
**Fix:** Edit `ClearWRAM` in [home/init.asm](https://github.com/pret/pokecrystal/blob/master/home/init.asm):
diff --git a/docs/design_flaws.md b/docs/design_flaws.md
index 26560b58f..945c2ff75 100644
--- a/docs/design_flaws.md
+++ b/docs/design_flaws.md
@@ -513,7 +513,124 @@ PokedexShow_GetDexEntryBank:
db BANK("Pokedex Entries 193-251")
```
-**Fix:** Use `dba` instead of `dw` in `PokedexDataPointerTable`. Then edit [home.asm](https://github.com/pret/pokecrystal/blob/master/home.asm) to contain a single copy of the `PokedexDataPointerTable` lookup code, updated to work with 3-byte `dba` entries and get the bank from the first entry byte. Delete the three separate lookup routines and use the new one (placed in [home.asm](https://github.com/pret/pokecrystal/blob/master/home.asm) so it can be called from any bank.)
+**Fix:**
+
+Use `dba` instead of `dw` in `PokedexDataPointerTable`.
+
+Delete `GetPokedexEntryBank` and `PokedexShow_GetDexEntryBank`. You can also delete `NUM_DEX_ENTRY_BANKS` from [constants/pokemon_data_constants.asm](https://github.com/pret/pokecrystal/blob/master/constants/pokemon_data_constants.asm).
+
+Edit [engine/pokedex/pokedex_2.asm](https://github.com/pret/pokecrystal/blob/master/engine/pokedex/pokedex_2.asm):
+
+```diff
+ GetDexEntryPointer:
+ ; return dex entry pointer b:de
+ push hl
+ ld hl, PokedexDataPointerTable
+ ld a, b
+ dec a
+ ld d, 0
+ ld e, a
+ add hl, de
+ add hl, de
+- ld e, [hl]
+- inc hl
+- ld d, [hl]
+- push de
+- rlca
+- rlca
+- maskbits NUM_DEX_ENTRY_BANKS
+- ld hl, .PokedexEntryBanks
+- ld d, 0
+- ld e, a
+- add hl, de
+- ld b, [hl]
+- pop de
++ add hl, de
++ ; b = bank
++ ld a, [hli]
++ ld b, a
++ ; de = address
++ ld a, [hli]
++ ld e, a
++ ld d, [hl]
+ pop hl
+ ret
+-
+-.PokedexEntryBanks:
+- db BANK("Pokedex Entries 001-064")
+- db BANK("Pokedex Entries 065-128")
+- db BANK("Pokedex Entries 129-192")
+- db BANK("Pokedex Entries 193-251")
+```
+
+Edit [engine/items/item_effects.asm](https://github.com/pret/pokecrystal/blob/master/engine/items/item_effects.asm):
+
+```diff
+ HeavyBallMultiplier:
+ ; subtract 20 from catch rate if weight < 102.4 kg
+ ; else add 0 to catch rate if weight < 204.8 kg
+ ; else add 20 to catch rate if weight < 307.2 kg
+ ; else add 30 to catch rate if weight < 409.6 kg
+ ; else add 40 to catch rate (never happens)
+ ld a, [wEnemyMonSpecies]
+ ld hl, PokedexDataPointerTable
+ dec a
+ ld e, a
+ ld d, 0
+ add hl, de
+ add hl, de
++ add hl, de
++ ; d = bank, hl = address
++ ld a, BANK(PokedexDataPointerTable)
++ call GetFarByte
++ push af
++ inc hl
+ ld a, BANK(PokedexDataPointerTable)
+ call GetFarHalfword
++ pop de
+
+ .SkipText:
+- call GetPokedexEntryBank
++ ld a, d
+ call GetFarByte
+ inc hl
+ cp "@"
+ jr nz, .SkipText
+
+- call GetPokedexEntryBank
++ ld a, d
+ push bc
+ inc hl
+ inc hl
+ call GetFarHalfword
+```
+
+And edit [engine/pokegear/radio.asm](https://github.com/pret/pokecrystal/blob/master/engine/pokegear/radio.asm):
+
+```diff
+ PokedexShow2:
+ ld a, [wCurPartySpecies]
+ dec a
+ ld hl, PokedexDataPointerTable
+ ld c, a
+ ld b, 0
+ add hl, bc
+ add hl, bc
++ add hl, bc
++ b = bank
++ ld a, BANK(PokedexDataPointerTable)
++ call GetFarByte
++ ld b, a
++ inc hl
++ ; hl = address
+ ld a, BANK(PokedexDataPointerTable)
+ call GetFarHalfword
+- call PokedexShow_GetDexEntryBank
++ ld a, b
+ push af
+ push hl
+ call CopyDexEntryPart1
+```
## Identical sine wave code and data is repeated five times