Glitch Pokédex flag

From Glitch City Wiki
Revision as of 13:34, 23 September 2018 by >Torchickens
Bulbapedia also has an article about Glitch Pokédex flag.

Glitch Pokédex flags refers to the mechanism of how glitch Pokémon with Pokédex numbers 152-255 and 0 are registered in the Pokédex, in terms of whether the Pokémon is registered "seen" or "own"ed.

While every valid Pokémon in the game have their own Pokédex flags, glitch Pokémon extrapolate from the structure into inventory items, which is why MissingNo. (No. 000 or 'No. 256') can duplicate the sixth item by 128.

This includes Pokédex flags for families 153-255, 0. Glitch Pokémon with Pokédex numbers 1-151 (hybrids by definition) do not use glitch Pokédex flags per se; encountering and catching them will set the flag of the Pokémon the glitch Pokémon was a hybrid of.

Depending on the glitch Pokémon's Pokédex number, encountering it or catching it will set a bit which will affect the state of the player's inventory if the relevant flag was previously unset.

Why glitch flags?

In computer programming, and games are no exception to this, everything is numbers. Thus, each Pokémon is assigned a number, called its ID. The game identifies each Pokémon using its ID, and each ID corresponds to a specific Pokémon.

When the game wants to retrieve or edit the Pokédex flags of Pokémon X, it gets the flag with the same ID as the Pokémon (eg, the first flag of the "encountered" list is associated with Pokémon ID 1, etc.)

Since a flag is represented by a bit, and a byte is 8 bits large, the game does more or less the following :

  1. Get byte number (Pokédex ID - 1) / 8 in the corresponding table, rounding down.
  2. Tamper with its ( (Pokédex ID - 1) % 8)th flag (Note : % is the modulo operator).

Why "Pokédex ID-1"? Because in computer programming, IDs start at 0 (for mathematical and convenience reasons). So, instead of going from 1 to 151, internally, IDs go from 0 to 150. For the same reason, the bits of a byte are numbered from 0 (rightmost) to 7 (leftmost).

For example, take Generation I and its 151 (non-glitch) Pokémon. We need to store all the flags in an integer amount of bytes, hence, 19 bytes (152 bits) are used.

Now, imagine we caught a Rattata (Pokédex ID 19). The game starts at address D2F7 (wPokedexOwned), and advances (18 / 8 :) 2 bytes forward. Then it sets bit (18 % 8 :) 2, because we have captured it.

Now, this method works fine for all IDs up to 151. But what would happen with higher IDs? You guessed it, the game will go beyond the end of the Pokédex flags table. (The exception being Pokédex flag 152, which is still in-bounds, and has its own unused bit), and will affect the player's inventory.

The more complicated case is Pokémon with ID 0 (like Missingno or 'M (R/B)), because upon subtracting 1 (Pokédex ID - 1, remember?), the 0 underflows to 255.

Uses/effects

Setting a flag (whether it be "seen" or "caught") modifies one bit in memory. The most famous example is when seeing Missingno, where it sets bit 7 of the quantity of the 6th item in the player's inventory (which is why it is known as "gives 128 if has less than 128").

The other way around is that if a Pokémon is marked as "already caught", its Pokédex entry won't show up. Since some glitch Pokémon's Pokédex entries crash the game, they are required to be "already caught" to be catchable without freezing.

Corruption effects

Via encounter flags

  • Item duplication: Involves the game adding to a specific item quantity in the player's inventory. The most infamous example is the glitch Pokémon MissingNo. and 'M (00) adding 127 to the sixth item quantity upon encountering it or catching it, if the value is less than 128.
  • Item mutation: Involves the game changing an item's ID in the player's inventory. One example is glitch Pokémon 94 (0xF1).
  • Total items changing glitch Pokémon: Only caused by Pokédex numbers between 153-160
  • Pokémon No. 152: Only applies to アノ゙ (CC). Has its own viewable Pokédex entry, even from the Pokédex menu, and without any further glitches.

Via capture flags

  • Setting Pokémon as seen: The flag for a glitch Pokémon with ID beyond 151 being 'own'ed will set an unrelated Pokémon as seen. Example: MissingNo. and Cubone.
  • Pokémon No. 152 (see above)
This article or section is a stub. You can help Glitch City Wiki by expanding it.