mirror of
https://github.com/bsnes-emu/bsnes.git
synced 2025-09-01 03:01:59 +02:00
Update to bsnes v107r4 beta release.
byuu says: - bsnes: added video filters from bsnes v082 - bsnes: added ZSNES snow effect option when games paused or unloaded (no, I'm not joking) - bsnes: added 7-zip support (LZMA 19.00 SDK) [Recent higan WIPs have also mentioned bsnes changes, although the higan code no longer includes the bsnes code. These changes include: - higan, bsnes: added EXLOROM, EXLOROM-RAM, EXHIROM mappings - higan, bsnes: focus the viewport after leaving fullscreen exclusive mode - bsnes: re-added mightymo's cheat code database - bsnes: improved make install rules for the game and cheat code databases - bsnes: delayed construction of hiro::Window objects to properly show bsnes window icons - Ed.]
This commit is contained in:
35
nall/cd/scrambler.hpp
Normal file
35
nall/cd/scrambler.hpp
Normal file
@@ -0,0 +1,35 @@
|
||||
#pragma once
|
||||
|
||||
namespace nall::CD::Scrambler {
|
||||
|
||||
//polynomial(x) = x^15 + x + 1
|
||||
inline auto polynomial(uint x) -> uint8_t {
|
||||
static uint8_t lookup[2340]{};
|
||||
static bool once = false;
|
||||
if(!once) { once = true;
|
||||
uint16_t shift = 0x0001;
|
||||
for(uint n : range(2340)) {
|
||||
lookup[n] = shift;
|
||||
for(uint b : range(8)) {
|
||||
bool carry = shift & 1 ^ shift >> 1 & 1;
|
||||
shift = (carry << 15 | shift) >> 1;
|
||||
}
|
||||
}
|
||||
}
|
||||
return lookup[x];
|
||||
}
|
||||
|
||||
//
|
||||
|
||||
inline auto transform(array_span<uint8_t> sector) -> bool {
|
||||
if(sector.size() == 2352) sector += 12; //header is not scrambled
|
||||
if(sector.size() != 2340) return false; //F1 frames only
|
||||
|
||||
for(uint index : range(2340)) {
|
||||
sector[index] ^= polynomial(index);
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
}
|
Reference in New Issue
Block a user