| 85 | } |
| 86 | |
| 87 | int RandomTable::SeedRef(int x, int z) const |
| 88 | { |
| 89 | // slow reference implementation |
| 90 | // make x, z out of order |
| 91 | enum |
| 92 | { |
| 93 | mask = Size - 1 |
| 94 | }; |
| 95 | // bitwise interleave x and z |
| 96 | int xz = 0; |
| 97 | // only 12 bits is significant |
| 98 | x = _table[x & mask]; |
| 99 | z = _table[z & mask]; |
| 100 | |
| 101 | for (int i = 0; i < 6; i++) |
| 102 | { |
| 103 | xz <<= 1, xz |= x & 1, x >>= 1; |
| 104 | xz <<= 1, xz |= z & 1, z >>= 1; |
| 105 | } |
| 106 | |
| 107 | return xz; |
| 108 | } |
| 109 | |
| 110 | const int A = 48271; |
| 111 | const int M = 0x7fffffff; |
no outgoing calls
no test coverage detected