3DMMForever
3DMMForever copied to clipboard
Add C implementations of Kauai decompressors
The original code includes C implementations of these functions, however, they are broken, and they are never used anyway since x86 assembly versions are used instead.
This PR adds new C implementations of the Kauai decompressors. After attempting to repair the original code, I decided to give up and adapt the kcdc_386 and kcd2_386 so they generate pure C code. I have verified these functions work correctly, but the x86 assembly versions are still used on Win32.
Checks fail on "// clang-format on". I need advice.
strange - should work
maybe you can suppress the warning/error for this code-block: https://stackoverflow.com/questions/48426484/concise-way-to-disable-specific-warning-instances-in-clang
#if defined( __clang__)
#pragma clang diagnostic push
#pragma clang diagnostic ignored "-Wclang-format-violations"
// your code for which the warning gets suppressed
#pragma clang diagnostic pop
// not suppressed here
#endif
The clang-format issue has been solved.
I have working kauai decompressors in https://github.com/nil-vr/3dmm-dump/tree/main/src/kauai . I never figured out what was going wrong with the C++ code, but I got it working in Rust based on the C++ code and its documentation. It's pretty straightforward. It uses the bitvec crate to read the bytes as a series of bits. You just need to substitute in a different bitstream reader that yields the bits in the same order and it should be an easy port. If you can pass the tests from kcdc.rs that will prove your bitstream implementation and then kcd2 is very similar.
It might not be as fast as the custom generated version that has different implementations for each starting bit offset, but it's much easier to read and computers are a lot faster now so using Rust generics or C++ templates to achieve the same optimization seems like it'd be just for the challenge of doing it.