mirror of
https://github.com/bsnes-emu/bsnes.git
synced 2025-03-27 05:52:36 +01:00
byuu says: Changelog: - added \~130 new PAL games to icarus (courtesy of Smarthuman and aquaman) - added all three Korean-localized games to icarus - sfc: removed SuperDisc emulation (it was going nowhere) - sfc: fixed MSU1 regression where the play/repeat flags were not being cleared on track select - nall: cryptography support added; will be used to sign future databases (validation will always be optional) - minor shims to fix compilation issues due to nall changes The real magic is that we now have 25-30% of the PAL SNES library in icarus! Signing will be tricky. Obviously if I put the public key inside the higan archive, then all anyone has to do is change that public key for their own releases. And if you download from my site (which is now over HTTPS), then you don't need the signing to verify integrity. I may just put the public key on my site on my site and leave it at that, we'll see.
51 lines
971 B
C++
51 lines
971 B
C++
#pragma once
|
|
|
|
#include <nall/hash/hash.hpp>
|
|
|
|
namespace nall { namespace Hash {
|
|
|
|
struct CRC16 : Hash {
|
|
nallHash(CRC16)
|
|
|
|
auto reset() -> void override {
|
|
checksum = ~0;
|
|
}
|
|
|
|
auto input(uint8_t value) -> void override {
|
|
checksum = (checksum >> 8) ^ table(checksum ^ value);
|
|
}
|
|
|
|
auto output() const -> vector<uint8_t> override {
|
|
vector<uint8_t> result;
|
|
for(auto n : rrange(2)) result.append(~checksum >> n * 8);
|
|
return result;
|
|
}
|
|
|
|
auto value() const -> uint16_t {
|
|
return ~checksum;
|
|
}
|
|
|
|
private:
|
|
static auto table(uint8_t index) -> uint16_t {
|
|
static uint16_t table[256] = {0};
|
|
static bool initialized = false;
|
|
|
|
if(!initialized) {
|
|
initialized = true;
|
|
for(auto index : range(256)) {
|
|
uint16_t crc = index;
|
|
for(auto bit : range(8)) {
|
|
crc = (crc >> 1) ^ (crc & 1 ? 0x8408 : 0);
|
|
}
|
|
table[index] = crc;
|
|
}
|
|
}
|
|
|
|
return table[index];
|
|
}
|
|
|
|
uint16_t checksum = 0;
|
|
};
|
|
|
|
}}
|