Commit 35193272 authored by Scott Duensing's avatar Scott Duensing

Added jlUtilRandom() and friends.

parent d588561b
......@@ -70,6 +70,7 @@ char _jlTempString[1024]; // Used internally for pathname ope
static jlColorT _jlDefaultPalette[16];
static jlStackT *_jlFillStackTop = NULL;
static byte _jlDrawFillColor = 0;
static juint32 _jlSeed = 0;
void _jlDrawCircleClipped(jint16 x0, jint16 y0, jint16 radius);
......@@ -610,6 +611,22 @@ char *jlUtilMakePathname(char *filename, char *extension) {
}
juint16 jlUtilRandom(void) {
_jlSeed = _jlSeed * 1103515245 + 12345;
return _jlSeed / 65536;
}
juint32 jlUtilRandomSeedGet(void) {
return _jlSeed;
}
void jlUtilRandomSeedSet(juint32 seed) {
_jlSeed = seed;
}
void *_jlUtilStackPop(jlStackT **stack) {
void *d = NULL;
jlStackT *s;
......
......@@ -29,6 +29,12 @@
#include <limits.h>
#define JINT16_MIN -32768
#define JINT16_MAX 32767
#define JUINT16_MIN 0
#define JUINT16_MAX 65535
// Determine platform and settings
#ifdef __linux__
......@@ -272,6 +278,9 @@ void jlUtilIdle(void);
char *jlUtilMakePathname(char *filename, char *extension);
bool jlUtilMustExit(void);
void jlUtilNibbleSwap(byte *mem, jint16 count, byte old, byte new);
juint16 jlUtilRandom(void);
juint32 jlUtilRandomSeedGet(void);
void jlUtilRandomSeedSet(juint32 seed);
void jlUtilShutdown(void) __attribute__((noreturn));
#define jlUtilStackPop(stack) _jlUtilStackPop((jlStackT **)&(stack)) // Syntatic Sugar
void *_jlUtilStackPop(jlStackT **stack);
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment