Text resources: extract, pack with relocatable pointers, round-trip #27
Loading…
Reference in a new issue
No description provided.
Delete branch "res-text"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
Text resources: our own codec, extract to UTF-8 trees, pack with rebuilt pointer tables, core pack backend. Fixes #9
What
tools/textcodec.py(own code, decision D5): exact decoder and encoder for the US (DTE pairs, control codes, variables) and JP (kana, two-byte kanji, MTE words) text encodings, in the disassembly text syntax. Character tablestools/textcodec_tables.json; thedte/mtetables are built at run time from the game's owndte_tbl/mte_tblresources (ROM content, not committed).tools/extract.py text --version us_v10|jp_v10 [--out DIR]->DIR/us10|jp10/text/*.txt+meta/text/*.json(per string: original bytes, SHA-256 of the extracted text, offset, shared flag) +extract.json. Default DIRothers/extracted/(workspace, never the repo).tools/pack.py->.ff6packformat v0 (docs/pack.md, writertools/packfile.py): unedited strings keep Square's bytes, edited strings are re-encoded, strings block + pointer table + dialogue bank split (DlgBankInc, $CC:E600) rebuilt (tools/restext.py). Clear errors naming file and string (unknown char/control code, too long for a fixed field, missing{0}, beyond pointer range, changed header or string count, ambiguous encoding).re/assets.toml(31 text assets + the RNG table: ids, ROM ranges per version, pointer tables, headers, round-trip status) andre/text_labels.toml(labels only).tools/gen_res.py->core/res/res_gen.{h,c}(resource ids, ROM locations;tools.gen_res.checkkeeps them in sync).core/res/res_pack.{h,c}reader (magic, format_major, game version, TOC bounds/order, payload CRC-32),ff6_config_t.pack_data(optional, copied),FF6_ERR_BAD_PACK;res_get= pack first, then ROM;res_rom_get/res_pack_getfor comparisons. The emulated game keeps reading the ROM.docs/pack.md,docs/resources.md,docs/build.mdtools section.Numbers
Extracted text files are byte-identical to the disassembly's
assets/text/*.txt(working tree) for all 59 files (oracle check, scratch script).Edit test (
rom.text_roundtrip.*): one dialogue string grows by 561 bytes (US) / 481 bytes (JP), 3 078 later pointers move by exactly that, bank split 1574 -> 1564 (US) / 1820 -> 1809 (JP), plus one battle message and one item name; every string of every resource read back through the pack's pointer tables decodes to the extracted text with the edits, unedited strings keep their bytes; five error cases checked.Tests
tools.textcodec(18 cases: codec, text files, layout, container),unit.res_pack(synthetic pack, every error status),tools.gen_res.check.rom.text_roundtrip.{US_V10,JP_V10}(Python, fixture producing the vanilla pack) androm.res_pack.{US_V10,JP_V10}(C: pack backend == ROM backend for every text resource; a pack of the other version is refused).--fast20/20, release--fast20/20; clang and mingw build clean (0 warnings), new tests pass on debug, clang and mingw (wine).Decisions taken here
{0}included), so the decoder is lossless and the vanilla block is the concatenation of the strings; strings are laid out back to back in table order (all ROM tables are monotonic, checked at extraction).dte_tbl/mte_tblare not editable (unedited dialogue keeps its original codes); header lines and string counts are fixed by the catalogue.🤖 Generated with Claude Code