2 Commits

5 changed files with 19 additions and 7 deletions

2
Cargo.lock generated
View File

@@ -308,7 +308,7 @@ checksum = "dcc811dc4066ac62f84f11307873c4850cb653bfa9b1719cee2bd2204a4bc5dd"
[[package]] [[package]]
name = "upkr" name = "upkr"
version = "0.2.1" version = "0.2.2"
dependencies = [ dependencies = [
"anyhow", "anyhow",
"cdivsufsort", "cdivsufsort",

View File

@@ -1,6 +1,6 @@
[package] [package]
name = "upkr" name = "upkr"
version = "0.2.1" version = "0.2.2"
edition = "2021" edition = "2021"
[profile.release] [profile.release]

View File

@@ -22,6 +22,12 @@ c_unpacker and asm_unpackers unpack the default upkr compressed format. The z80_
is based on some variations to the compressed format. (Use `upkr --z80` to select those variations.) is based on some variations to the compressed format. (Use `upkr --z80` to select those variations.)
The 16 bit dos unpacker also uses some variations. (`upkr --x86`) The 16 bit dos unpacker also uses some variations. (`upkr --x86`)
### More unpackers outside this repository
* [Atari Lynx](https://github.com/42Bastian/new_bll/blob/master/demos/depacker/unupkr.asm)
* [Atari Jaguar](https://github.com/42Bastian/new_bjl/blob/main/exp/depacker/unupkr.js)
* [8080, R800](https://github.com/ivagorRetrocomp/DeUpkr)
## Usage ## Usage
``` ```
@@ -32,10 +38,13 @@ The 16 bit dos unpacker also uses some variations. (`upkr --x86`)
-l, --level N compression level 0-9 -l, --level N compression level 0-9
-0, ..., -9 short form for setting compression level -0, ..., -9 short form for setting compression level
-u, --unpack unpack infile -d, --decompress decompress infile
--heatmap calculate heatmap from compressed file --heatmap calculate heatmap from compressed file
--margin calculate margin for overlapped unpacking of a packed file --margin calculate margin for overlapped unpacking of a packed file
When no infile is given, or the infile is '-', read from stdin.
When no outfile is given and reading from stdin, or when outfile is '-', write to stdout.
Config presets for specific unpackers: Config presets for specific unpackers:
--z80 --big-endian-bitstream --invert-bit-encoding --simplified-prob-update -9 --z80 --big-endian-bitstream --invert-bit-encoding --simplified-prob-update -9
--x86 --bitstream --invert-is-match-bit --invert-continue-value-bit --invert-new-offset-bit --x86 --bitstream --invert-is-match-bit --invert-continue-value-bit --invert-new-offset-bit

View File

@@ -26,10 +26,12 @@ upkr-linux/upkr:
cargo build --target x86_64-unknown-linux-musl --release -F terminal cargo build --target x86_64-unknown-linux-musl --release -F terminal
mkdir -p upkr-linux mkdir -p upkr-linux
cp ../target/x86_64-unknown-linux-musl/release/upkr upkr-linux/ cp ../target/x86_64-unknown-linux-musl/release/upkr upkr-linux/
strip upkr-linux/upkr
upkr-windows/upkr.exe: upkr-windows/upkr.exe:
cargo build --target x86_64-pc-windows-gnu --release -F terminal cargo build --target x86_64-pc-windows-gnu --release -F terminal
mkdir -p upkr-windows mkdir -p upkr-windows
cp ../target/x86_64-pc-windows-gnu/release/upkr.exe upkr-windows/ cp ../target/x86_64-pc-windows-gnu/release/upkr.exe upkr-windows/
x86_64-w64-mingw32-strip upkr-windows/upkr.exe
PHONY: PHONY:

View File

@@ -59,7 +59,7 @@ fn main() -> Result<()> {
level = 9; level = 9;
} }
Short('u') | Long("unpack") => unpack = true, Short('u') | Long("unpack") | Short('d') | Long("decompress") => unpack = true,
Long("margin") => calculate_margin = true, Long("margin") => calculate_margin = true,
Long("heatmap") => create_heatmap = true, Long("heatmap") => create_heatmap = true,
#[cfg(feature = "crossterm")] #[cfg(feature = "crossterm")]
@@ -68,7 +68,7 @@ fn main() -> Result<()> {
Short(n) if n.is_ascii_digit() => level = n as u8 - b'0', Short(n) if n.is_ascii_digit() => level = n as u8 - b'0',
Short('h') | Long("help") => print_help(0), Short('h') | Long("help") => print_help(0),
Long("version") => { Long("version") => {
eprintln!("{}", env!("CARGO_PKG_VERSION")); println!("{}", env!("CARGO_PKG_VERSION"));
process::exit(0); process::exit(0);
} }
Long("max-unpacked-size") => max_unpacked_size = parser.value()?.parse()?, Long("max-unpacked-size") => max_unpacked_size = parser.value()?.parse()?,
@@ -94,7 +94,7 @@ fn main() -> Result<()> {
#[cfg(feature = "terminal")] #[cfg(feature = "terminal")]
let mut packed_data = { let mut packed_data = {
let mut pb = pbr::ProgressBar::new(data.len() as u64); let mut pb = pbr::ProgressBar::on(std::io::stderr(), data.len() as u64);
pb.set_units(pbr::Units::Bytes); pb.set_units(pbr::Units::Bytes);
let packed_data = upkr::pack( let packed_data = upkr::pack(
&data, &data,
@@ -105,6 +105,7 @@ fn main() -> Result<()> {
}), }),
); );
pb.finish(); pb.finish();
eprintln!();
packed_data packed_data
}; };
#[cfg(not(feature = "terminal"))] #[cfg(not(feature = "terminal"))]
@@ -246,7 +247,7 @@ fn print_help(exit_code: i32) -> ! {
eprintln!(); eprintln!();
eprintln!(" -l, --level N compression level 0-9"); eprintln!(" -l, --level N compression level 0-9");
eprintln!(" -0, ..., -9 short form for setting compression level"); eprintln!(" -0, ..., -9 short form for setting compression level");
eprintln!(" -u, --unpack unpack infile"); eprintln!(" -d, --decompress decompress infile");
eprintln!(" --heatmap calculate heatmap from compressed file"); eprintln!(" --heatmap calculate heatmap from compressed file");
eprintln!(" --margin calculate margin for overlapped unpacking of a packed file"); eprintln!(" --margin calculate margin for overlapped unpacking of a packed file");
eprintln!(); eprintln!();