Fix single-file backward compatibility with original UC2 Pro

Root cause: the original UC2 Pro expects csize=0 in the cdir COMPRESS
record (it ignores the field entirely).  UC2 v3 was writing the actual
compressed size, which confused the original's archive reader.

Additional changes:
- Use default Huffman tree for all blocks (ensures tree encoding compat)
- Write method=compression_level in cdir COMPRESS (was hardcoded to 1)
- Add tests/scripts/bitdump.py for bit-level bitstream analysis

Single-file UC2 v3 archives are now fully readable by the original UC2
Pro (listing and extraction verified in DOSBox-X).  Multi-file archives
still hang — the cdir bitstream decodes correctly in our Python analyzer
but fails in the original's ASM decompressor kernel.  Investigation
continues; the bitdump.py tool enables targeted comparison.
This commit is contained in:
Eremey Valetov
2026-03-29 09:58:36 -04:00
parent be7085c4d3
commit c736b19bae
6 changed files with 423 additions and 42 deletions
+3 -3
View File
@@ -9,9 +9,9 @@ root. Key phases:
2. **Original Compression Engine** — Done. LZ77+Huffman compressor.
Cross-tool round-trip verified: original UC2 Pro archives extract
correctly in UC2 v3. Reverse direction (UC2 v3 → original) is
in progress — treegen and tree encoding now match the original's
algorithms, but a residual bitstream-level incompatibility remains.
correctly in UC2 v3. Reverse direction partial: single-file UC2
v3 archives are now readable by the original (listing + extraction).
Multi-file archives still hang; under investigation.
3. **Modernized Master-Block Deduplication** — In progress.
Content-fingerprint grouping and custom master-block generation done