comparison src/util/prng.rs @ 647:1520b559cacc

Double checked prng.
author Gauvain "GovanifY" Roussel-Tarbouriech <gauvain@govanify.com>
date Sun, 04 Aug 2019 00:07:46 +0200
parents 7d92730bf543
children ac092b70c39a
comparison
equal deleted inserted replaced
646:7d92730bf543 647:1520b559cacc
16 16
17 /// Generates a pseudo-random u16. 17 /// Generates a pseudo-random u16.
18 /// 18 ///
19 /// RE’d from 102h.exe@0x41e780 19 /// RE’d from 102h.exe@0x41e780
20 pub fn get_u16(&mut self) -> u16 { 20 pub fn get_u16(&mut self) -> u16 {
21 let x = ((self.seed ^ 0x9630) - 0x6553) & 0xffff; 21 let x = (self.seed ^ 0x9630) - 0x6553;
22 self.seed = (((x & 0xc000) >> 14) | (x << 2)) & 0xffff; 22 self.seed = (((x & 0xc000) >> 14) | (x << 2)) & 0xffff;
23 self.seed 23 self.seed
24 } 24 }
25 25
26 /// Combines two u16 into a single u32. 26 /// Combines two u16 into a single u32.