mirror of
https://github.com/libretro/bsnes-libretro.git
synced 2024-11-23 17:09:44 +00:00
0b923489dd
byuu says: New update. Most of the work today went into eliminating hiro::Image from all objects in all ports, replacing with nall::image. That took an eternity. Changelog: - fixed crashing bug when loading games [thanks endrift!!] - toggling "show status bar" option adjusts window geometry (not supposed to recenter the window, though) - button sizes improved; icon-only button icons no longer being cut off
41 lines
914 B
C++
41 lines
914 B
C++
#pragma once
|
|
|
|
#include <nall/serializer.hpp>
|
|
#include <nall/stdint.hpp>
|
|
|
|
namespace nall {
|
|
|
|
struct RandomNumberGenerator {
|
|
virtual auto seed(uint64_t) -> void = 0;
|
|
virtual auto operator()() -> uint64_t = 0;
|
|
virtual auto serialize(serializer&) -> void = 0;
|
|
};
|
|
|
|
//Galois LFSR using CRC64 polynomials
|
|
struct LinearFeedbackShiftRegisterGenerator : RandomNumberGenerator {
|
|
auto seed(uint64_t seed) -> void {
|
|
lfsr = seed;
|
|
for(unsigned n = 0; n < 8; n++) operator()();
|
|
}
|
|
|
|
auto operator()() -> uint64_t {
|
|
return lfsr = (lfsr >> 1) ^ (-(lfsr & 1) & crc64jones);
|
|
}
|
|
|
|
auto serialize(serializer& s) -> void {
|
|
s.integer(lfsr);
|
|
}
|
|
|
|
private:
|
|
static const uint64_t crc64ecma = 0x42f0e1eba9ea3693;
|
|
static const uint64_t crc64jones = 0xad93d23594c935a9;
|
|
uint64_t lfsr = crc64ecma;
|
|
};
|
|
|
|
inline auto random() -> uint64_t {
|
|
static LinearFeedbackShiftRegisterGenerator lfsr;
|
|
return lfsr();
|
|
}
|
|
|
|
}
|