Function GetRandomSeed

From Uzebox Wiki
Revision as of 01:36, 12 September 2014 by Uze (talk | contribs)
Jump to navigation Jump to search
Prototype

unsigned int GetRandomSeed(void);

Description

Obtain a truly random integer generated upon startup. This value is generated only once and should serve to seed a pseudo-random number generator function. The functionn uses the inherent entropy caused by the jitter of the ATmega644 internal watchdog timer RC timer vs the system's crystal. To be able to use this function, you must add "-DTRUE_RANDOM_GEN=1" compile switch to you makefile's KERNEL_OPTIONS variable. The generation of the random seed re

Parameters

None

Returns

Random seed generated only once at system's startup.

Video Modes

N/A

Since

V3.3

Example:

int main(){
  srand(GetRandomSeed());
  ...
  //a truly random value will now be generated!
  int r=rand();
  ...
  return 0;
}