I just use the classic linear congruential PRNG in one of my programs:
unsigned prngseed;
int rand()
{
prngseed = 1103515245UL*prngseed + 12345UL;
return (unsigned)prngseed % ((unsigned)INT_MAX+1);
}
void srand(unsigned s)
{
prngseed = s;
}
(This is a modification of my code so it works with 32-bit ints (assuming int is 32 bits on the Nspire). My program runs on a system with 16-bit ints)
These are actually implementations of the C standard functions rand() and srand(). It works pretty well considering its simplicity. It also doesn't rely on a timer to generate each successive value. You can set the seed using the timer though:
srand(*counter);
To use it with a maximum value you can do this:
/* RAND_MAX = 2147483647 with 32-bit int */
x = (unsigned long long)rand() * max / RAND_MAX;
Yeah, it uses 64-bit arithmetic (if long long is 64 bits, that is), but it is far more uniformly distributed than using "x/(65535/max)" as you are doing (except when max is an integer factor of 65535, in which case it's the same).