summaryrefslogtreecommitdiff
path: root/Discovering-GameShark-cheat-codes.md
diff options
context:
space:
mode:
Diffstat (limited to 'Discovering-GameShark-cheat-codes.md')
-rw-r--r--Discovering-GameShark-cheat-codes.md15
1 files changed, 15 insertions, 0 deletions
diff --git a/Discovering-GameShark-cheat-codes.md b/Discovering-GameShark-cheat-codes.md
new file mode 100644
index 0000000..31e5493
--- /dev/null
+++ b/Discovering-GameShark-cheat-codes.md
@@ -0,0 +1,15 @@
+There are a lot of popular cheat codes in Pokémon games: walk through walls, get Rare Candies and Master Balls, find wild shiny Pokémon, get all the Badges... Different physical cheat devices exist, like [GameShark](https://en.wikipedia.org/wiki/GameShark), [Game Genie](https://en.wikipedia.org/wiki/Game_Genie), [Action Replay](https://en.wikipedia.org/wiki/Action_Replay), and even Pokémon-specific ones like [Monster Brain](https://bulbapedia.bulbagarden.net/wiki/Monster_Brain). Game Boy emulators tend to support GameShark-style cheat codes because they're popular and straightforward.
+
+A GameShark cheat code looks like this:
+
+ ttvvllhh
+
+- `tt` is the code type, usually `01` or sometimes `91`. It specifies the WRAM bank.
+- `vv` is the value to write into RAM.
+- `hhll` is the RAM address to write to.
+
+We can reverse-engineer the meaning of particular codes, and discover our own new codes, with the [**symbol files**](https://github.com/pret/pokecrystal/tree/symbols). When we run `make` to build the ROM, along with the .gbc file it creates a .sym file. This file lists all the labels from the source code with their corresponding banks and addresses in the ROM.
+
+For example, the code `010730D2` writes `07` to `01:D230`. We can look up this address in [pokecrystal.sym](https://raw.githubusercontent.com/pret/pokecrystal/symbols/pokecrystal.sym): it's `wBattleType`, from [wram.asm](../blob/master/wram.asm). Its appropriate values are the `BATTLETYPE_*` constants, from [constants/battle_constants.asm](../blob/master/constants/battle_constants.asm), of which #7 (remember, `const_def` counts up from 0) is `BATTLETYPE_SHINY`. So this looks like a cheat to force shiny battles like Red Gyarados. And sure enough, in this [list of Crystal codes](https://www.glitchcity.info/wiki/Pok%C3%A9mon_Crystal_GameShark_codes), that code appears as "Fight Shiny Pokémon".
+
+We can design new codes this way. If your pokecrystal-based hack project ended up shifting the location of `wBattleType`, or changed the value of `BATTLETYPE_SHINY`, then the code `010730D2` would affect something else, and might do nothing, cause glitches, or crash the game. But you can just find the new address of `wBattleType` in your own .sym file and edit the code to use that.