2018-08-04 11:44:00 +00:00
|
|
|
#pragma once
|
|
|
|
|
2019-01-16 00:46:42 +00:00
|
|
|
namespace nall::Encode {
|
2018-08-04 11:44:00 +00:00
|
|
|
|
2018-08-21 03:17:12 +00:00
|
|
|
template<uint S = 1, uint M = 4 / S> //S = word size; M = match length
|
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 RLE(array_view<uint8_t> input) -> vector<uint8_t> {
|
2018-08-21 03:17:12 +00:00
|
|
|
vector<uint8_t> output;
|
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 byte : range(8)) output.append(input.size() >> byte * 8);
|
2018-08-04 11:44:00 +00:00
|
|
|
|
|
|
|
uint base = 0;
|
|
|
|
uint skip = 0;
|
|
|
|
|
2018-08-21 03:17:12 +00:00
|
|
|
auto load = [&](uint offset) -> uint8_t {
|
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
|
|
|
return input(offset);
|
2018-08-21 03:17:12 +00:00
|
|
|
};
|
2018-08-04 11:44:00 +00:00
|
|
|
|
2018-08-21 03:17:12 +00:00
|
|
|
auto read = [&](uint offset) -> uint64_t {
|
|
|
|
uint64_t value = 0;
|
|
|
|
for(uint byte : range(S)) value |= load(offset + byte) << byte * 8;
|
|
|
|
return value;
|
2018-08-04 11:44:00 +00:00
|
|
|
};
|
|
|
|
|
2018-08-21 03:17:12 +00:00
|
|
|
auto write = [&](uint64_t value) -> void {
|
|
|
|
for(uint byte : range(S)) output.append(value >> byte * 8);
|
2018-08-04 11:44:00 +00:00
|
|
|
};
|
|
|
|
|
2018-08-21 03:17:12 +00:00
|
|
|
auto flush = [&] {
|
|
|
|
output.append(skip - 1);
|
|
|
|
do {
|
|
|
|
write(read(base));
|
|
|
|
base += S;
|
|
|
|
} while(--skip);
|
2018-08-04 11:44:00 +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
|
|
|
while(base + S * skip < input.size()) {
|
2018-08-04 11:44:00 +00:00
|
|
|
uint same = 1;
|
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 = base + S * (skip + 1); offset < input.size(); offset += S) {
|
2018-08-21 03:17:12 +00:00
|
|
|
if(read(offset) != read(base + S * skip)) break;
|
|
|
|
if(++same == 127 + M) break;
|
2018-08-04 11:44:00 +00:00
|
|
|
}
|
|
|
|
|
2018-08-21 03:17:12 +00:00
|
|
|
if(same < M) {
|
2018-08-04 11:44:00 +00:00
|
|
|
if(++skip == 128) flush();
|
|
|
|
} else {
|
|
|
|
if(skip) flush();
|
2018-08-21 03:17:12 +00:00
|
|
|
output.append(128 | same - M);
|
2018-08-04 11:44:00 +00:00
|
|
|
write(read(base));
|
2018-08-21 03:17:12 +00:00
|
|
|
base += S * same;
|
2018-08-04 11:44:00 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
if(skip) flush();
|
|
|
|
|
2018-08-21 03:17:12 +00:00
|
|
|
return output;
|
|
|
|
}
|
|
|
|
|
2019-01-16 00:46:42 +00:00
|
|
|
}
|