Mobile System GB error traps
|This article is incomplete. Please feel free to add any missing information about the subject. It is missing: Add relevant disassembly routines (and ACE method).|
The Japanese version of Pokémon Crystal featured a number of error traps for the Mobile System GB service before its closure on December 14, 2002. These can be performed again through the use of arbitrary code execution or unofficial emulation of the service. In English Crystal, the error traps also remain in the code unused.
These are detailed below, based on posts by Wack0 in a forums thread about the subject.
Battle Tower Pokémon
This code was used to fix invalid Battle Tower Pokémon (the Japanese version supported player submitted teams), e.g. so that invalid moves are removed and invalid Pokémon are replaced with Smeargle.
If the number of Pokémon in the party is over 6, set it to 6
The party species bytes are checked. If a byte is an invalid species ($00, $FC, $FE, $FF), change that species byte and the first species byte of that Pokémon structure to Smeargle ($EB).
For all Pokémon in the party:
If the second species byte in the Pokémon structure is invalid ($FD (Egg) is also considered invalid here), change it to Smeargle.
If the Pokémon's level is below 2, set it to 2; if it is over 100, set it to 100. Recalculate the Pokémon's stats, no matter whether or not the level was modified.
If the Pokémon's nickname is unterminated after 6 bytes, terminate it by setting the 6th byte to $50; if the nickname has any invalid characters (defined here as anything that is not $00, $05 - $13, $19 - $1C, $26 - $34, $3A - $3E, $40 - $48, $60 - $FF; a function in a bank related to mobile functionality is called to do this), set it to the Pokémon species name (if the Pokémon is an Egg, then set it to "タマゴ" ("Tamago"/Egg) followed by 50 50 50 instead).
If the Pokémon's Original Trainer name is unterminated after 6 bytes, terminate it by setting the 6th byte to $50; if it has any invalid characters, set it to the player's name.
If the Pokémon has an invalid move in slot 1 ($00, $FC, $FD, $FE, $FF), replace it with Pound. If there is an invalid move in slot 2, 3, or 4, delete all moves starting from that slot.
PokéCom Center Trade Corner
This code was used to replace invalid/faulty text strings with placeholder strings after receiving a Pokémon from the PokéCom Center Trade Corner (the precursor to the Global Trade System). In the unused English version of the error trap, the default strings are not translated, resulting in mojibake. There is also a bug in the English version and not the Japanese version, where when setting the Pokémon's nickname as "?????", "?????こんにちは[END]" is printed instead (with the mojibake taken into account: "????? Ö"[END]).
Every single string (nickname, OT, mail, mail author) is checked for invalid bytes and termination (where the terminator is $4E for some reason) within the correct length, by bankswitched calls. If one of these checks fails, the offending string is replaced with a default string by a bankswitched call.
Default strings used:
OT name, mail author: "クりス" Chris followed by two terminators
Pokémon nickname: "?????" (unterminated itself but the final nickname is terminated)
Mail text: "こんにちは" ("konnichiwa", translation: "hello", followed by one terminator)
The default strings are terminated by $50 as usual.
After checking the strings, an "item" at $C60E is checked, if it's $FF it gets replaced by $00. Finally, the exact same level checks as the Battle Tower Pokémon trap are performed.
- Pokémon Crystal disassembly, Wack0 - Documentation
- Torchickens - Additional research