Files
Toeesh Chaudhary 2e39817ea2 docs: measure the story-archive compressor and the mission state tables
Two new format pages, both measured over the user's own copy with no payload stored.

docs/coder.md - the 51.5 MB compressed mass in story000_script.rpf. Two interleaved
populations (105 zlib blocks, 767 unidentified). Entry framing is
u16 tag + 6 header bytes, zero pad, payload at align16(entry+8) - confirmed 10/10 on
pad length and %16 alignment, which is why earlier scans that assumed the entry start
found nothing. A 32-value tag alphabet that correlates with nothing. The payload is
deflate-shaped but proprietary (popcount correlation +0.632 against zlib-9's +0.676,
plane bias +0.0083 vs +0.0138; lzma -0.065 and bz2 -0.432 are excluded, and AES is
excluded by the ~40 sigma plane bias). Codes are variable-length and LSB-first: 7 and 8
bit lengths measured from the bit spacing of single-symbol runs. No table is stored, so
the symbol->length array is static in the executable; the Kraft constraint narrows it to
a 129-140 byte vector of 7s and 8s, most likely n7=116 + n8=24.

docs/mission_logic.md - the mission containers are state machines, not instruction
streams: 32-byte records keyed by joaat, 40,804 of them across 2,309 containers. Records
the details that cost a false start (the band field is a counter, not zero; offsets are
file-absolute for most records), the 64-byte pool element carrying world transforms, the
case-folding behaviour of joaat (340/340 folding vs 91/340 case-sensitive, so lookups must
fold), and the flow shapes. 113 identical-state-set clusters cover 82.4% of the files, so
naming one cluster names dozens of files.

docs/README.md gets both rows.
2026-11-22 13:17:34 +05:30

111 lines
6.6 KiB
Markdown
Raw Permalink Blame History

This file contains ambiguous Unicode characters
This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.
# The compressed mass in the story script archives
`story000_script.rpf` and `script.rpf` hold data in a framing the rest of the package does not use.
Most of it is ordinary zlib, but a large part of `story000_script.rpf` is compressed by an encoder that
no standard decoder reproduces. This page records what was measured about it, so the next attempt starts
from the numbers instead of from a guess. Everything below is counts, offsets, constants and
statistics over the user's own copy — no payload is stored here.
Subject: `story000_script.rpf`, region `0x2000..0x3127000` (51,531,776 bytes), 905 page-blocks.
## Two populations
| population | blocks | bytes | share | decoder |
|---|---:|---:|---:|---|
| `78 DA` zlib at block start | 105 | 893,535 | 1.79 % | standard zlib, raw deflate at +2 with a 32 KiB window |
| anything else | 767 | 49,095,163 | 98.21 % | unidentified |
The two are **interleaved**, not separated by region: 211 population switches across the first 120
blocks. The zlib blocks yield ~2 MB of plaintext that is plainly structured data (8-byte aligned records,
`0x50000000`-space pointers, `FFFFFFFF` sentinels, ascending u32 tables). The other 767 do not decode yet.
## Entry framing
Each entry is:
```
u16 tag + 6 class-biased header bytes │ zero pad │ payload at the next 16-byte FILE boundary
```
i.e. `payload_offset = align16(entry_offset + 8)`, which is `+16` for 766 of the 800 entries measured.
The rule was confirmed 10/10: the predicted pad length equals the observed zero run every time, and the
absolute payload offset is `%16 == 0` every time. This is why earlier scans that assumed payloads start at
the entry start, or that stopped at skip +12, found nothing.
Header shape (distinct byte values per position over the 800 unknown entries):
`52, 65, 191, 198, 171, 148, 176, 188, 219, 239, 243, 243, …` — i.e. bytes 0..7 are structured and byte 8
onwards is noise. There is no size field in the header (60 width/endianness combinations tested, all
`|r| < 0.10` against the block length).
The first two bytes form a **32-value tag alphabet**: 75 distinct u16 in total, but 32 codes carry nearly
all 800 entries at 15–33 each (800/32 = 25 expected). It is not a bitfield (byte 0 has 52 values, byte 1
has 65, joint 75 ≪ 3380), and it correlates with nothing measured: length (`r = -0.035`), gap to the next
entry (`-0.036`), offset (`+0.035`), or neighbours' population. Codes never cluster in file order (881 runs
over 905 entries), so it is not a file or stream id.
## What the payload is not
Every decoder below was run at the **correct** `align16(entry+8)` offset, with a positive control that
passes on data compressed by that same decoder, and against a same-geometry random baseline.
| family | result |
|---|---|
| deflate (raw, and raw with a 32 KiB zero window) | 0 of 800 entries give even 4 KiB of partial output |
| zlib, both framing and preset-dictionary (all 32 fcheck-valid CMF/FLG, FDICT set) | 0 — payloads never begin with a `78 xx` header at all |
| zstd (magicless and framed), brotli, snappy, lz4 (two decoders), LZAV, FastLZ, LZF, LZJB, bz2, xz, lzma-alone, lzma-raw | 0 |
| Oodle (oo2core 2.9.10, positive control bit-exact) | 0 over 11 offsets × 19 destination sizes × fuzzSafe 0/1 |
| 21 byte/bit transforms (bit-reverse, nibble-swap, rotates, delta, xor-prev, transposes, block reversal) × 4 decoders | 5 hits against a 2-hit random baseline, 4 degenerate |
## What the payload is
Statistical shape, measured against the same statistics computed on data compressed by each family:
| statistic | zlib level 9 | lzma | bz2 | this payload |
|---|---:|---:|---:|---:|
| popcount correlation | +0.676 | −0.065 | −0.432 | **+0.632** |
| bit-plane bias | +0.0138 | −0.0007 | −0.0110 | **+0.0083** |
So it is **deflate-shaped but proprietary**: an LZ+entropy coder in the deflate family, not LZMA and not a
BWT coder. AES-class output is excluded because all eight bit planes are biased the same way at ~40σ,
which ciphertext cannot do. Bit autocorrelation is +0.006 *inside* a byte and exactly 0 at byte boundaries,
so the stream is bit-domain with no byte framing.
The code is **variable-length and LSB-first**. That was established from runs of one repeated symbol: a run
emits the same code repeatedly, so the bit spacing of a run equals the code length. Across the region,
21 non-zero period-7 runs show a uniform **7-bit** spacing and 6 show **8 bits**, in LSB-first order
(MSB-first gives 9, 9, 9, 9, 9, 2, 7 on the same patterns — inconsistent).
The only visible structure in the 331,760-byte single-block sample at `script.rpf+0x2010` is a 496-byte
field at payload+0x14460, 16-byte aligned at both ends, made of exact period-7 repeats in two groups
(54 and 16 copies). Decomposed as 8 symbols × 7 bits, each group is **one plaintext u32 repeated**:
```
group A: 63 30 48 16 | 63 30 48 16
group B: 2 7 115 102 | 2 7 115 102
```
at 28 bits per 4 bytes = **7.00 bits/byte**. So the field is a table of ~140 identical 4-byte entries
(default records), the repeats are literals rather than matches, and the coder achieves roughly 1/8
compression on repeated data. The eight 7-bit code values read out are `2, 7, 16, 30, 48, 63, 102, 115`.
## The one missing piece
The coder stores **no table**: the longest run of identical bytes anywhere in 331 KB is the 32-byte zero
tail, and a canonical-Kraft scan over 8,192 offsets finds nothing. With variable-length codes of 7 and 8
bits and no stored table, the symbol→length mapping is a **static array in the executable**.
That array is narrow enough to search for. A Kraft-exact length vector for 7- and 8-bit codes satisfies
`2·n7 + n8 = 256`; with the largest observed code value 115 requiring `n7 ≥ 116`, the candidate families
are `n7 = 116..127`, i.e. a **129–140 byte vector of 7s and 8s**, most likely `n7 = 116, n8 = 24`
(140 symbols). Search the executable for a 129–140 byte run of values in `{7,8}` satisfying that equation.
It is not in the package: the 16 bundled DLLs and the whole 348 MB `gameos.xvd` contain no such run
(byte-exact search), and no `oo2core`/`Oodle`/codec string exists in either.
## Recovered plaintext, for calibration
Two independent extractions recovered 1,961,559 bytes and 855,961 bytes of payload (the second from
entries whose zlib part is buried behind the aligned header). The 0x88-byte record structure in it is
described in the mission notes; the useful calibration here is that a correct decode of the remaining
767 entries should produce the same record discipline: 8-byte alignment, pointers of the form
`0x50000000 | offset` with the high dword 0, and 96.7 % of pointers at even dword indices.