ft2-clone

Fasttracker 2 clone
Log | Files | Refs | README | LICENSE

ft2_random.c (363B)


      1 #include <SDL2/SDL.h>
      2 #include <stdint.h>
      3 #include <stdbool.h>
      4 
      5 static uint32_t randSeed;
      6 
      7 void randomize(void)
      8 {
      9 	randSeed = (uint32_t)SDL_GetTicks();
     10 }
     11 
     12 int32_t randoml(int32_t limit)
     13 {
     14 	randSeed *= 134775813;
     15 	randSeed++;
     16 	return ((int64_t)randSeed * (int32_t)limit) >> 32;
     17 }
     18 
     19 int32_t random32(void)
     20 {
     21 	randSeed *= 134775813;
     22 	randSeed++;
     23 
     24 	return randSeed;
     25 }