|
123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960 |
-
-
-
-
- extern "C" {
- #include "stdlib.h"
- }
-
- void randomSeed(unsigned int seed)
- {
- if (seed != 0) {
- srandom(seed);
- }
- }
-
- long random(long howbig)
- {
- if (howbig == 0) {
- return 0;
- }
- return random() % howbig;
- }
-
- long random(long howsmall, long howbig)
- {
- if (howsmall >= howbig) {
- return howsmall;
- }
- long diff = howbig - howsmall;
- return random(diff) + howsmall;
- }
-
- long map(long x, long in_min, long in_max, long out_min, long out_max)
- {
- return (x - in_min) * (out_max - out_min) / (in_max - in_min) + out_min;
- }
-
- unsigned int makeWord(unsigned int w) { return w; }
- unsigned int makeWord(unsigned char h, unsigned char l) { return (h << 8) | l; }
|