Uploaded September 2014 | Updated September 2026, 3 weeks ago
When we open a Pokemon box, the names of the Pokemon inside pass through the buffer at address D073. But the bad clone's name is just a bunch of 0x00 without any terminator character, so when its name is later read from that buffer, the game will keep on reading bytes as if they were characters until a random 0x50 byte is found, acting as the terminator character.
Knowing this, there is a very little routine that actually makes the whole trick possible, and that's the routine at 0:1383 in Pokemon Crystal. When a char is interpreted, it's first analyzed in case we are dealing with an identifier with an special function such as a new line, the 'POKÉ' symbol, or just a 0x00. If it's 0x00, the game is made to jump to 0:1383.
Function1383::
ld a, $e6
ld [hli], a
call PrintLetterDelay
jp NextChar
Function1383 writes 0xE6 -which is the '?' character- into the address pointed to by register hl, and then we move on the next char. Register hl happens to point to one tile in the tilemap (C4A0 - C607). The first tile that gets written is the tile that corresponds to the first letter of the bad clone's name (C599) but it will keep on corrupting the remaining tiles of the tilemap with '?', and eventually other ram addresses with 0xE6 as well. So, ironically what looks like some sort of error handling routine that converts unknown characters 0x00 into the '?' symbol, is what makes the bad clone glitch possible.
So we now where the all the '?' come from. But what about the Kingdras? The routine at 38:6DEF reads the pokedex number of the different Pokemon in the box from RAM address C800 + 3*PkmnPos. While C800 is also the start of the Overworld map it seems to store the species of the Pokemon in the box as well. Anywho, the species of FF/CANCEL necessarily has to be located between C800 and around C840 depending on the number of pokemon stored, and, for example, in one of my tests, I saw addresses up to C863 get corrupted. Thus, we have just had our Pokemon FF/CANCEL become a withdrawable E6/KINGDRA!
There is also a simple explanation to why the bad clone trick doesn't work unless you save and reset the game boy in front of the PC and perform the trick right away. There are a total of 4 string buffers, and the buffer at D073 is the first one, meaning that if any of the other 3 buffers has been used before, there will be a terminator character in it, stopping the corruption of 0xE6 bytes too early.
When we open a Pokemon box, the names of the Pokemon inside pass through the buffer at address D073. But the bad clone's name is just a bunch of 0x00 without any terminator character, so when its name is later read from that buffer, the game will keep on reading bytes as if they were characters until a random 0x50 byte is found, acting as the terminator character.
Knowing this, there is a very little routine that actually makes the whole trick possible, and that's the routine at 0:1383 in Pokemon Crystal. When a char is interpreted, it's first analyzed in case we are dealing with an identifier with an special function such as a new line, the 'POKÉ' symbol, or just a 0x00. If it's 0x00, the game is made to jump to 0:1383.
Function1383::
ld a, $e6
ld [hli], a
call PrintLetterDelay
jp NextChar
Function1383 writes 0xE6 -which is the '?' character- into the address pointed to by register hl, and then we move on the next char. Register hl happens to point to one tile in the tilemap (C4A0 - C607). The first tile that gets written is the tile that corresponds to the first letter of the bad clone's name (C599) but it will keep on corrupting the remaining tiles of the tilemap with '?', and eventually other ram addresses with 0xE6 as well. So, ironically what looks like some sort of error handling routine that converts unknown characters 0x00 into the '?' symbol, is what makes the bad clone glitch possible.
So we now where the all the '?' come from. But what about the Kingdras? The routine at 38:6DEF reads the pokedex number of the different Pokemon in the box from RAM address C800 + 3*PkmnPos. While C800 is also the start of the Overworld map it seems to store the species of the Pokemon in the box as well. Anywho, the species of FF/CANCEL necessarily has to be located between C800 and around C840 depending on the number of pokemon stored, and, for example, in one of my tests, I saw addresses up to C863 get corrupted. Thus, we have just had our Pokemon FF/CANCEL become a withdrawable E6/KINGDRA!
There is also a simple explanation to why the bad clone trick doesn't work unless you save and reset the game boy in front of the PC and perform the trick right away. There are a total of 4 string buffers, and the buffer at D073 is the first one, meaning that if any of the other 3 buffers has been used before, there will be a terminator character in it, stopping the corruption of 0xE6 bytes too early.


![The Snake game in Pokemon Silver (arbitrary code execution)
Update! You can see the snake game being programmed in an actual Pokemon Crystal cartridge (with different ACE exploits) in this video - https://www.youtube.com/watch?v=g2mCyh7Y2xM
********************************************************************************************************************************************
Arbitrary code execution with Coin Case (explained by Sanqui, who discovered the ACE exploit): http://forums.glitchcity.info/index.php?topic=6716.0
Two different coin case setups are required. The first one to write our program in multiple iterations and the second one to make the game jump to it.
Setup 1 item list / asm code: http://pastebin.com/RG5HE9Ks (there is an error in this one. It says I38 = 01, but should be I38 = Max Potion [11], although Master Ball [01] also works)
Setup 2 item list / asm code: http://pastebin.com/X2hAyN9t
Box name characters to hex conversion: http://pastebin.com/4ZDpQXGe
Program asm code: http://pastebin.com/t8Qu6Pc2
Raw bytes: http://pastebin.com/72vbixu4
Pokemon Silver save file (the program is already written and the items in the PC correspond to the second setup, so you only need to use Coin Case once): http://www.mediafire.com/download/gf29w70lh2jpoio/Pokemon_Silver.sav
Check out this video by TheZZAZZGlitch where I took the idea from: https://www.youtube.com/watch?v=D3EvpRHL_vk (nevermind, youve already seen it).
The Coin Case Glitch is a translation error that is only present in the english localizations of Pokemon Gold and Pokemon Silver. That means, it wont work in Pokemon Crystal, or in Pokemon Gold or Silver in any other language. As for emulators, it wont work on VBA (as it doesnt emulate Echo RAM correctly), but will work fine in BGB or TGB.
Everything else is explained in the video. The Snake game in Pokemon Silver (arbitrary code execution)](https://i.ytimg.com/vi/c81P5srA7vY/mqdefault.jpg)






![Pokemon Pyrite - Trainer Pokemon with EVs (sort of)
READ DESCRIPTION!
I have received comments saying that the game gets easier as it advances, that the last gyms and pokemon battles are easier that the first ones. Kinda got the same feeling myself too. Your Pokemons EVs start to make a difference, and you become able to teach better moves and all that stuff. Even if the opponents Pokemon also get better moves, good moves vs good moves favours the player over bad moves vs bad moves, for the mere reason that the player is more intelligent than the AI. So, inevitably, the game progressively becomes easier for the most part.
The solution Ive come up with is some sort of EV system that is applied to trainer Pokemon, instead of just going nuts overincreasing the levels of the opponents to keep the same level of competitivity. This EV system doesnt work exactly like EVs would so to speak, since it affects the stats directly insetad of affecting them indirectly via other variables like the EVs themselves. But regardless, these stat changes (boosts) are intended to resemble EVs. Why shouldnt the rest of the trainers be able to get bonus from EVs just like you, if they also train their Pokemon? :P
The increase in the stats depends on the level of the pokemon. The higher the level, the higher the stat boost is, obviously, since thats how EVs work. The stats affected are attack, defense, special attack, special defense and speed, and the boost is the same for the five stats.
The stat boosts applied are (for each of the following level ranges):
[1,32]: boost = 0
[33,54]: boost = level/16
[55,73]: boost = level/16 + level/16
[74,77]: boost = level/8
[78,99]: boost = level/8 + level/32
[100,100]: boost = level/4
Notice how it never comes close to the maximum possible boost provided by EVs, which is nearly level*64/100. Another thing to keep in mind is that, even when the players Pokemon reach level 100, they still dont have had their EVs maximized, and the most recently caught Pokemon would have low EVs at the beggining. So I had to make sure that the boosts arent too high. In the end, they still leave the opponents Pokemon a bit weaker than the players on average; after all, the players good training should be rewarded!
The video shows the comparison between a battle against an EVd Pokemon (right), and against the same pokemon before the boosts had been implemented (left). Obviously, its still subject to RNG, but I think the differences can be seen clearly enough.
This feature will be included in the next release of Pokemon Pyrite and is subject to minor adjustements.
For those interested, the asm implementation can be seen here: http://pastebin.com/F3B9tnCC
I do believe and hope its bug-free. Its free for anyone to use it on his/her hack if desired, but if so, crediting is always welcome :) Pokemon Pyrite - Trainer Pokemon with EVs (sort of)](https://i.ytimg.com/vi/eF_lfPgoQdY/mqdefault.jpg)
