3DMMForever icon indicating copy to clipboard operation
3DMMForever copied to clipboard

Add C implementations of Kauai decompressors

Open beholdnec opened this issue 2 years ago • 4 comments

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.

beholdnec avatar Jun 20 '22 00:06 beholdnec

Checks fail on "// clang-format on". I need advice.

beholdnec avatar Jun 23 '22 00:06 beholdnec

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

LowLevelMahn avatar Jun 24 '22 09:06 LowLevelMahn

The clang-format issue has been solved.

beholdnec avatar Jul 08 '22 21:07 beholdnec

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.

nil-vr avatar Apr 08 '23 21:04 nil-vr