summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--Discovering-GameShark-cheat-codes.md46
1 files changed, 45 insertions, 1 deletions
diff --git a/Discovering-GameShark-cheat-codes.md b/Discovering-GameShark-cheat-codes.md
index a4fee22..56e2480 100644
--- a/Discovering-GameShark-cheat-codes.md
+++ b/Discovering-GameShark-cheat-codes.md
@@ -8,6 +8,50 @@ A GameShark cheat code looks like this: `ttvvllhh`
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".
+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 [GCL's 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.
+
+Note that not every address has its own label. For example, [GCL](https://www.glitchcity.info/wiki/Pok%C3%A9mon_Crystal_GameShark_codes) lists these four codes as "skill modifiers":
+
+```
+Skill 1 Modifier 01??E1DC
+Skill 2 Modifier 01??E2DC
+Skill 3 Modifier 01??E3DC
+Skill 4 Modifier 01??E4DC
+```
+
+But this is all we have in [pokecrystal.sym](https://raw.githubusercontent.com/pret/pokecrystal/symbols/pokecrystal.sym):
+
+```
+01:dce1 wPartyMon1Moves
+```
+
+Nor is there any `wPartyMon1Moves` label in [wram.asm](../blob/master/wram.asm). However, there is this:
+
+```
+wPartyMon1:: party_struct wPartyMon1
+```
+
+And [macros/wram.asm](../blob/master/macros/wram.asm) defines the `party_struct` macro:
+
+```
+party_struct: MACRO
+ box_struct \1
+\1Status:: db
+...
+\1StatsEnd::
+ENDM
+```
+
+```
+box_struct: MACRO
+\1Species:: db
+\1Item:: db
+\1Moves:: ds NUM_MOVES
+...
+\1End::
+ENDM
+```
+
+That `ds NUM_MOVES` means that the label `wPartyMon1Moves` covers four bytes, not one (since `NUM_MOVES EQU 4` in [constants/battle_constants.asm](../blob/master/constants/battle_constants.asm)). Cheat codes can address any of the four move bytes, but only one label exists.