Commit fbf1c846 authored by NY00123's avatar NY00123 Committed by Richard Gobeille
Browse files

Engine: Add wrand, intended to mimic the behaviors of Watcom C 10.0's rand.

Also add WRANDOM_MAX. This will be used in SW, preventing possible freezes.
parent e2bab6e4
......@@ -13,10 +13,14 @@
#include "compat.h"
#define WRAND_MAX 32767u
#ifdef engine_c_
int32_t randomseed;
uint32_t wrandomseed = 1;
#else
extern int32_t randomseed;
extern uint32_t wrandomseed;
#endif
#if !KRANDDEBUG
......@@ -35,4 +39,11 @@ static FORCE_INLINE int32_t seed_krand(int32_t* seed)
return ((uint32_t)*seed) >> 16;
}
// This aims to mimic Watcom C's implementation of rand
static FORCE_INLINE int32_t wrand(void)
{
wrandomseed = 1103515245 * wrandomseed + 12345;
return (wrandomseed >> 16) & 0x7FFF;
}
#endif
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