I'm messing with FireRed because my wife and kids have dibs on the other games. :) I've been able to determine where I am in the 32-bit RNG, usually with just two Pokemon, but I'm trying to bring that down to just one. It looks like the RNG naturally moves by about 90 clicks per second, even in a place where there should be no other calls to the RNG. (Such as standing still the first floor of Cerulean Cave.)
#1. How is the RNG on FireRed seeded?
Some articles say it's seeded from something in the save file. But I've done both soft and hard resets on both a GBASP and a DSLite, and it seems that I always end up at very different parts of the walk. So it's not purely the save file. Unless something changes the save file every time?
The fact that it seeds at different places is both a blessing and a curse. It means I need to figure out the position in the RNG each start up, but if there are very rare events I'm trying to get, I can reseed myself easily.
#2. How are random pokemon encounters determined?
I go to an area and use sweet scent, and I get a pokemon to show up. From what I can tell, there are a small number of level/species combinations that I get. Besides the PID/IV calls, this determines everything else for a Pokemon: its experience points and moveset and set exactly by the level/species.
However, there must be a call to the RNG to determine this information. How much time passes between the call to the encounter picker and the PID/IV calls?
I've looked through the ROM and found the encounter table. (I don't have a debugger that can step, but I've comfortable enough searching and editing binaries to find what I need.) I don't see how the probabilities are determined, though. It just seems to be a list of levels and species.
What kind of RNG calls are used to determine the species in a random Pokemon? I know that if I mangle the RNG code I can get the game to go into an infinite loop as it keeps on trying to get a result that it never will.