int i;
for (i=0; i < 100; i++) // 100 is arbitrary rally
{
unsigned short bigaccum = S9xGetWord(0x7e1f6e,true);
bigaccum += S9xGetWord(0xc0c29f, true) * i; // I don't think this is the right address all the time
int b1 = bigaccum >> 8;
int b3 = S9xGetByte(0x001fa4,true);
int b4 = S9xGetByte(0xc0fd00 + S9xGetByte(0x001fa1,true)+i+1,true);
signed int b5 = (unsigned char)(b4+b3) - b1;
if (b5 < 0)
break;
}
if (i == 0)
strcat(data, "Uh-oh");
else
sprintf(data, "%d steps", i);
Here's the code for my "Encounter counter" plugin. It's not 100% accurate, in particular b4 should probably be zeroed every once in a while. But it does an adequare job in predicting random encoutners.
Short demo AVI (32 seconds).
S9xGetWord reads a 16 bit number, S9xGetByte reads an 8 bit number at the given address. Ignore the 'true' parameter.