mirror of
https://github.com/bsnes-emu/bsnes.git
synced 2025-08-28 21:50:43 +02:00
Update to v106r54 release.
byuu says: Changes to hiro will break all but the GTK target. Not that it matters much given that the only ruby drivers that function are all on BSD anyway. But if you are fortunate enough to be able to run this ... you'll find lots of polishing improvements to the bsnes GUI. I posted some screenshots on Twitter, if anyone were interested.
This commit is contained in:
46
nall/decode/rle.hpp
Normal file
46
nall/decode/rle.hpp
Normal file
@@ -0,0 +1,46 @@
|
||||
#pragma once
|
||||
|
||||
namespace nall { namespace Decode {
|
||||
|
||||
template<typename T> inline auto RLE(const uint8_t* data, uint remaining = ~0, uint minimum = 0) -> vector<T> {
|
||||
if(!minimum) minimum = max(1, 4 / sizeof(T));
|
||||
vector<T> result;
|
||||
|
||||
auto load = [&]() -> uint8_t {
|
||||
if(!remaining) return 0x00;
|
||||
return --remaining, *data++;
|
||||
};
|
||||
|
||||
uint base = 0;
|
||||
uint size = 0;
|
||||
for(uint byte : range(sizeof(uint))) size |= load() << byte * 8;
|
||||
size /= sizeof(T);
|
||||
result.resize(size);
|
||||
|
||||
auto read = [&]() -> T {
|
||||
T value = 0;
|
||||
for(uint byte : range(sizeof(T))) value |= load() << byte * 8;
|
||||
return value;
|
||||
};
|
||||
|
||||
auto write = [&](T value) -> void {
|
||||
if(base >= size) return;
|
||||
result[base++] = value;
|
||||
};
|
||||
|
||||
while(base < size) {
|
||||
auto byte = *data++;
|
||||
if(byte < 128) {
|
||||
byte++;
|
||||
while(byte--) write(read());
|
||||
} else {
|
||||
auto value = read();
|
||||
byte = (byte & 127) + minimum;
|
||||
while(byte--) write(value);
|
||||
}
|
||||
}
|
||||
|
||||
return result;
|
||||
}
|
||||
|
||||
}}
|
Reference in New Issue
Block a user