Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

(DAT/CSPACK): support version 1. #477

Open
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

trigger-segfault
Copy link

Add support for early CatSystem archive version CsPack1 in ArcDAT.cs.

Changes

  • Version check now only compares against ASCII "CsPack". Version is then calculated/validated from the byte at offset 6: '1' or '2' (Signature property remains unchanged).
  • Entry size is now calculated based on version: 12 or 24 bytes.
  • Entry count of 0 is now explicitly allowed (as it's supported and has been observed in CatSystem releases).
  • CsNameDecryptor requires an additional argument: extension_pos. This replaces usage of 0x10 for extension check (which is specific to the CsPack2 version).

About CsPack1 and version differences

Research is based off early CatSystem trial games: Purupuru Magic and Remel

  • CsPack1 archives never use .dat extensions, and instead use extensions that reflect the contents of the archive. It's safer to say its extension is a wildcard: * (while CsPack2 still always uses .dat extension).
  • CsPack archives may contain 0 entries, as observed with Cradle Song trial/cs_vl.dat.
  • CsPack1 and CsPack2 archive versions are identical with exception to entry size and name decoding constants.
    • Offset encryption remains identical regardless of entry size (first 8 bytes XOR'ed against last 4 bytes)
  • Both filename codings are based on FAT12 / 8.3 filenames with RADIX 40.
    • CsPack1 uses an 8.3 filename.
    • CsPack2 uses a (very broken) 16.3(/26.0) filename.
    • Additionally, CsPack1 filename decoding is broken in newer engines supporting CsPack2 (so it cannot be reliably confirmed from them)

* Version check now only compares against ASCII `"CsPack"`. Version is then calculated/validated from the byte at offset 6: `'1'` or `'2'` (`Signature` property remains unchanged).
* Entry size is now calculated based on version: `12` or `24` bytes.
* Entry count of `0` is now explicitly allowed (as it's supported *and* has been observed in CatSystem releases).
* `CsNameDecryptor` requires an additional argument: `extension_pos`. This replaces usage of `0x10` for extension check (which is specific to the `CsPack2` version).
@trigger-segfault trigger-segfault changed the title (CsPack): support version 1. (DAT/CSPACK): support version 1. May 19, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant