Pokémon data structure (Generation IV): Difference between revisions

From Bulbapedia, the community-driven Pokémon encyclopedia.
Jump to navigationJump to search
Line 16: Line 16:
The 128 bytes of Pokémon data are split into four 32-byte blocks for shuffling.  The blocks are shuffled according to a shift value derived from the [[personality value]].  Given the personality value ''pv'', the expression yielding the shift value is:
The 128 bytes of Pokémon data are split into four 32-byte blocks for shuffling.  The blocks are shuffled according to a shift value derived from the [[personality value]].  Given the personality value ''pv'', the expression yielding the shift value is:
: ''((pv >> 0xD) & 0x1F) % 24''
: ''((pv >> 0xD) & 0x1F) % 24''
The right shifting (pv >> 0xD) is equivalent to a division for 8192.
The right shifting (pv >> 0xD) is equivalent to a division by 8192.


To shuffle the blocks, take the four blocks of unencrypted data to be ''A'', ''B'', ''C'', and ''D''.  The blocks shall be rearranged in the encrypted data according to this table:
To shuffle the blocks, take the four blocks of unencrypted data to be ''A'', ''B'', ''C'', and ''D''.  The blocks shall be rearranged in the encrypted data according to this table: