Adding Particle System (port from AC)
- port from AC - also adding hardware random functions
This commit is contained in:
@@ -653,3 +653,18 @@ char *cleanUpName(char *in) {
|
||||
|
||||
return(in);
|
||||
}
|
||||
|
||||
// 32 bit hardware random number generator, inlining uses more code, use hw_random16() if speed is critical (see fcn_declare.h)
|
||||
uint32_t hw_random(uint32_t upperlimit) {
|
||||
uint32_t rnd = hw_random();
|
||||
uint64_t scaled = uint64_t(rnd) * uint64_t(upperlimit);
|
||||
return scaled >> 32;
|
||||
}
|
||||
|
||||
int32_t hw_random(int32_t lowerlimit, int32_t upperlimit) {
|
||||
if(lowerlimit >= upperlimit) {
|
||||
return lowerlimit;
|
||||
}
|
||||
uint32_t diff = upperlimit - lowerlimit;
|
||||
return hw_random(diff) + lowerlimit;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user