Generate a random value as: 1) random_next() or 2) fixed16_16(value) * fract(random_next())
| 43 | // 1) random_next() or |
| 44 | // 2) fixed16_16(value) * fract(random_next()) |
| 45 | s32 random(s32 value) |
| 46 | { |
| 47 | s32 newValue = random_next(); |
| 48 | if (newValue > value || newValue < 0) |
| 49 | { |
| 50 | // Note the value is cast to fixed16_16 but is not actually converted. |
| 51 | // This means that if the incoming value is not fixed point, the result will also not be fixed point. |
| 52 | newValue = mul16(fixed16_16(value), fract16(newValue)); |
| 53 | } |
| 54 | return newValue; |
| 55 | } |
| 56 | |
| 57 | void random_seed(u32 seed) |
| 58 | { |
no test coverage detected