Units of computing data

From Glitch City Wiki
Jump to navigation Jump to search
Wikipedia also has an article about Units of computing data.

Computing data is referred to in a variety of different units, most derived from the byte unit.

Bits

A bit is a state of either "on" or "off". It is the smallest possible unit of data on any computer.

Bytes

Wikipedia also has an article about Units of computing data.

The term byte represents an ordered collection of bits, with each bit representing a binary value of either 0 or 1. In most modern hardware, the defined size of a byte is eight bits, hence usually there are 2^8 (or 256) distinct values in one byte.

In the Pokémon games, the smallest groups of identifiers can only be read by the console in single 8-bit bytes. This explains, for example, the reason why there are 105 glitch Pokémon in Generation I: 2^8 is 256, and 256 - 151 = 105.

Bytes are also sometimes read as arrays of bits, in other words an ordered list of eight "ons" and "offs", used for instance when storing the badges the player has obtained in Pokémon Red, Blue, and Yellow, or Pokédex flags.

Words

The size of a word depends on the type of hardware. On 32-bit processors, such as that of the Game Boy Advance, the size of a word is four bytes (or 32 bits). A unit of two bytes in this architecture is referred to as a halfword, and a unit of eight a double word or dword.

In all main-series Pokémon games after Generation II, Pokémon species identifiers are stored as words. Hence, there are 65150, 65043 and 64887 invalid identifiers representing 'glitch Pokémon' in Generation III (which has 386 valid Pokémon), Generation IV (which has 493 valid Pokémon) and Generation V (which has 649 valid Pokémon) main series Pokémon games respectively.

In Generation III, the personality value (or PID) of a Pokémon is stored as a dword in the Pokémon data substructure, and the individual values of a Pokémon are stored in the last 15 bits of a word in the Pokémon data substructure.

For this reason, knowing the above units is relevant for two Generation III glitches:

  • The roaming Pokémon IV glitch, where data is only written to the first byte of a roaming Pokémon's individual values when it is captured (in Generation III games other than Pokémon Emerald).
  • The Generation III bit set glitch, where bit 0 and 2 (+hex:05) or bit 6 (+hex:40) may be written to a Pokémon in the storage box when one of the aforementioned bits are not set.