2018-08-21 03:17:12 +00:00
|
|
|
#pragma once
|
|
|
|
|
|
|
|
//burrows-wheeler transform
|
|
|
|
|
|
|
|
#include <nall/suffix-array.hpp>
|
|
|
|
|
2019-01-16 00:46:42 +00:00
|
|
|
namespace nall::Decode {
|
2018-08-21 03:17:12 +00:00
|
|
|
|
Update to v106r59 release.
byuu says:
Changelog:
- fixed bug in Emulator::Game::Memory::operator bool()
- nall: renamed view<string> back to `string_view`
- nall:: implemented `array_view`
- Game Boy: split cartridge-specific input mappings (rumble,
accelerometer) to their own separate ports
- Game Boy: fixed MBC7 accelerometer x-axis
- icarus: Game Boy, Super Famicom, Mega Drive cores output internal
header game titles to heuristics manifests
- higan, icarus, hiro/gtk: improve viewport geometry configuration;
fixed higan crashing bug with XShm driver
- higan: connect Video::poll(),update() functionality
- hiro, ruby: several compilation / bugfixes, should get the macOS
port compiling again, hopefully [Sintendo]
- ruby/video/xshm: fix crashing bug on window resize
- a bit hacky; it's throwing BadAccess Xlib warnings, but they're
not fatal, so I am catching and ignoring them
- bsnes: removed Application::Windows::onModalChange hook that's no
longer needed [Screwtape]
2018-08-26 06:49:54 +00:00
|
|
|
inline auto BWT(array_view<uint8_t> input) -> vector<uint8_t> {
|
2018-08-21 03:17:12 +00:00
|
|
|
vector<uint8_t> output;
|
|
|
|
|
|
|
|
uint size = 0;
|
|
|
|
for(uint byte : range(8)) size |= *input++ << byte * 8;
|
|
|
|
output.resize(size);
|
|
|
|
|
|
|
|
uint I = 0;
|
|
|
|
for(uint byte : range(8)) I |= *input++ << byte * 8;
|
|
|
|
|
Update to v106r59 release.
byuu says:
Changelog:
- fixed bug in Emulator::Game::Memory::operator bool()
- nall: renamed view<string> back to `string_view`
- nall:: implemented `array_view`
- Game Boy: split cartridge-specific input mappings (rumble,
accelerometer) to their own separate ports
- Game Boy: fixed MBC7 accelerometer x-axis
- icarus: Game Boy, Super Famicom, Mega Drive cores output internal
header game titles to heuristics manifests
- higan, icarus, hiro/gtk: improve viewport geometry configuration;
fixed higan crashing bug with XShm driver
- higan: connect Video::poll(),update() functionality
- hiro, ruby: several compilation / bugfixes, should get the macOS
port compiling again, hopefully [Sintendo]
- ruby/video/xshm: fix crashing bug on window resize
- a bit hacky; it's throwing BadAccess Xlib warnings, but they're
not fatal, so I am catching and ignoring them
- bsnes: removed Application::Windows::onModalChange hook that's no
longer needed [Screwtape]
2018-08-26 06:49:54 +00:00
|
|
|
auto suffixes = SuffixArray(input);
|
2018-08-21 03:17:12 +00:00
|
|
|
|
|
|
|
auto L = input;
|
|
|
|
auto F = new uint8_t[size];
|
Update to v106r59 release.
byuu says:
Changelog:
- fixed bug in Emulator::Game::Memory::operator bool()
- nall: renamed view<string> back to `string_view`
- nall:: implemented `array_view`
- Game Boy: split cartridge-specific input mappings (rumble,
accelerometer) to their own separate ports
- Game Boy: fixed MBC7 accelerometer x-axis
- icarus: Game Boy, Super Famicom, Mega Drive cores output internal
header game titles to heuristics manifests
- higan, icarus, hiro/gtk: improve viewport geometry configuration;
fixed higan crashing bug with XShm driver
- higan: connect Video::poll(),update() functionality
- hiro, ruby: several compilation / bugfixes, should get the macOS
port compiling again, hopefully [Sintendo]
- ruby/video/xshm: fix crashing bug on window resize
- a bit hacky; it's throwing BadAccess Xlib warnings, but they're
not fatal, so I am catching and ignoring them
- bsnes: removed Application::Windows::onModalChange hook that's no
longer needed [Screwtape]
2018-08-26 06:49:54 +00:00
|
|
|
for(uint offset : range(size)) F[offset] = L[suffixes[offset + 1]];
|
2018-08-21 03:17:12 +00:00
|
|
|
|
|
|
|
uint64_t K[256] = {};
|
|
|
|
auto C = new int[size];
|
|
|
|
for(uint i : range(size)) {
|
|
|
|
C[i] = K[L[i]];
|
|
|
|
K[L[i]]++;
|
|
|
|
}
|
|
|
|
|
|
|
|
int M[256];
|
|
|
|
memory::fill<int>(M, 256, -1);
|
|
|
|
for(uint i : range(size)) {
|
|
|
|
if(M[F[i]] == -1) M[F[i]] = i;
|
|
|
|
}
|
|
|
|
|
|
|
|
uint i = I;
|
|
|
|
for(uint j : reverse(range(size))) {
|
|
|
|
output[j] = L[i];
|
|
|
|
i = C[i] + M[L[i]];
|
|
|
|
}
|
|
|
|
|
|
|
|
return output;
|
|
|
|
}
|
|
|
|
|
2019-01-16 00:46:42 +00:00
|
|
|
}
|