PID Generation for Wild Pokémon
For the most part, PID generation is handled in the same manner described by X-Act in his article, but the process of getting the initial PID has changed in the 4th generation. In the 3rd generation, without a synchronizer present, the next two or three numbers from the RNG were taken and used directly to form a PID. In the 4th generation games this procedure has changed and there is an initial call to the RNG to get the nature and then the RNG is advanced until an appropriate PID (that is, one that has a matching nature) is found.
Starting from s[n], which can be thought as your current seed, when entering a battle with a Pokémon (wild or Synchronizable legend), the first seed used to generate the Pokémon is s[n+1].
This number is used to determine the nature of the Pokémon as follows:
floor (s[n+1]/0xA3E)
This operation will produce a number between 0 and 24, which is the target nature.
Next is the PID generation.
PID is [s[m]][s[m+1]]
where m starts as m = n+2 and is incremented by 2 until a PID is found with the target nature.
In the end the IVs, as usual, are formed with [s[m+2]][s[m+3]]
<insert complete example with pid generation>
Effect of Synchronize:
The high bit of s[n+1] acts as a trigger.
If it's 1, Synchronize has failed. In this case the method above is used, but s[n+1] is NOT recycled to determine nature. Instead another call is made to the RNG and that number is considered to be s[n+1].
If it's 0, the the target nature will be that of the first Pokémon in your party.
Next step is the PID generation.
PID is [s[m]][s[m+1]]
where m starts as m = n+2 and is incremented by 2 until a PID is found with the target nature.
In the end the IVs, as usual, are formed with [s[m+2]][s[m+3]]