Add RLE
This commit is contained in:
1 parent
941b7a1f07
commit
893f7917ef
4 files changed
+67
-7
No files matched your search
Binary file not shown.
+21
-4
@@ -164,12 +164,29 @@ unsafe fn write_imports(
|
||||
prelude.write(&[0xc9, 0xc3]);
|
||||
}
|
||||
|
||||
unsafe fn write_starting_state(binary: *mut u8, reader: &mut Reader) {
|
||||
unsafe fn write_starting_state(mut out: *mut u8, reader: &mut Reader) {
|
||||
let length = reader.read::<u32>() as usize;
|
||||
let ptr = reader.ptr;
|
||||
println!("length: {:?}", length);
|
||||
|
||||
binary.copy_from(ptr, length);
|
||||
let end = out.byte_add(length);
|
||||
while out < end {
|
||||
let code = reader.read::<u8>();
|
||||
if code > 0 {
|
||||
// RLE: repeat
|
||||
let byte = reader.read::<u8>();
|
||||
for i in 0..code {
|
||||
*out = byte;
|
||||
out = out.byte_add(1);
|
||||
}
|
||||
} else {
|
||||
// N literal bytes
|
||||
let count = reader.read::<u8>();
|
||||
for _ in 0..count {
|
||||
let byte = reader.read::<u8>();
|
||||
*out = byte;
|
||||
out = out.byte_add(1);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
unsafe fn _main_remote() {
|
||||
|
||||
Reference in new issue
Block a user