Glitch City Laboratories Archives

Glitch City Laboratories closed on 1 September 2020 (announcement). This is an archived copy of a thread from Glitch City Laboratories Forums.

You can join Glitch City Research Institute to ask questions or discuss current developments.

You may also download the archive of this forum in .tar.gz, .sql.gz, or .sqlite.gz formats.

Generation II Glitch Discussion

Hunting a "Gift Pokemon" Script in Pokémon Crystal - Page 1

Hunting a "Gift Pokemon" Script in Pokémon Crystal

Posted by: Arkazra
Date: 2018-03-12 23:33:35
After tinkering with Pokémon Yellow ACE, I was able to build a Pokémon Dispenser, that used the gift pokémon script at $3E59 to give me whichever Pokémon I was after at whatever level I was after. (https://pastebin.com/i3tW2705 for anyone interested)

Now I've moved on to Pokémon Crystal, and I've been analyzing the ROM/RAM contents in and around the Eevee and Dratini gifts, looking for a similar gift script. I've tracked down where in memory the species and level of the gifts are loaded from, but I'm struggling to find where the code actually gives you the Pokémon.

At the end of the conversations that give you the gift, (Eevee and Dratini at least, the Shuckle seem's to do things differently), the code somehow manoeuvers its way to $7932 (in Bank 25)
$7932 contains "call 26D4". $26D4 has a series of instructions I haven't entirely deduced the purpose of, apart from a few, which notably include:

After returning from the call 26D4, the code continues at $7935, by putting species value currently stored in register a into RAM at $D108.
This is followed by another call 26D4, but this time the value returned in register a is the gift Pokémon's level, which is put into RAM at $D143.
A third call 26D4 retrieves the held item of the gift pokemon, putting it into RAM at $D106.

After all this, the pc is at 7944, the Pokémon's species, level and held item are all in RAM at D108, D143 and D106 respectively, but I lose track of things from there, and can't follow the thread to actually getting the Pokémon. I've almost given up hope of finding a simple script as there was in gen 1, but does anyone have any ideas about how to progress forward? (Or in this case, backward?) It's easy enough work forward through the code (I'm using the debugger on BGB to step through it line by line), but I'm struggling to find how the code reaches $7932 in the first place.

My next step is probably going to be manually setting D108, D143 and D106 and jumping to $7944, just to see what happens, but I thought I'd bring it up here and see if anyone else has been tinkering in this area of the code :)