6 Commits
Author SHA1 Message Date
Mike Grimes b2b201bc16 dat: generate native readers for typed HSD archive loading (#3658) 2026-10-11 19:01:44 +00:00
e865ef5df4 dat: infer byte-command CPU scripts (#3651)
* dat: walk byte command scripts, size CPU scripts

DAT_BYTE_SCRIPT(length) sizes scripts of byte commands by an expression
in the command's first byte; cpuCommandLength gives a CPU command's
length as ftCo_800B4880 reads it. DAT_SCRIPT and DAT_BYTE_SCRIPT also
apply on pointer typedefs, for arrays of scripts.

Co-Authored-By: Claude Opus 5.5 <[email protected]>

* dat: note PlSb's unreferenced subroutines

Co-Authored-By: Claude Opus 5.5 <[email protected]>

* dat: reference the CPU interpreter for command lengths

* dat: tidy CPU script declarations and traversal

* docs: clarify CPU script annotations and walker comments

---------

Co-authored-by: Robin Avery <[email protected]>
Co-authored-by: Claude Opus 5.5 <[email protected]>
Co-authored-by: itsgrimetime <[email protected]>
2026-10-08 09:20:49 -07:00
355e23c02f dat: extend fighter and stage item inference (#3650)
* dat: add Leadead's last attribute byte, refresh TODO

Leadead's attributes have a byte at 0x1F that the sample dropped. TODO.md
drops findings that no longer occur and adds the walk's current ones.

Co-Authored-By: Claude Opus 5.5 <[email protected]>

* dat: count debug and sound-test tables

* dat: select fighter, Kirby copy and stage item attributes

Bind Article::kind for fighters' own items and Kirby's copies, and select
the remaining character, stage and head-only item layouts. Ambiguous
item-attribute unions go from 106 to 33 and walk gaps from 57 to 19.

Tooling:
- Expressions take C's ?:, in melee-dat and the native evaluator, so a
  macro can hold a table: ftData_ItemKind and ftKbCopy_ItemKind map
  fighter and slot to the kind each *_Init_OnLoad registers.
- A chosen union member's DAT_BIND applies to it (walk and native).
- Untyped roots keep their loader bindings, for the types dat_symbols.txt
  gives them (Kirby's copies get fighter_kind).

Types:
- itSpecialAttrsHead, Redead's x0 completed, is the record monsters' and
  stage items' attributes start with: Tingle, Whispy's apples, the ZG
  shell, the Arwing laser and Like-Like now use it.
- Crazy Hand's laser and bullet share Master Hand's layouts.
- gr_itkind is the whole kind.
- Five unused AnimJoint aliases that misread their trees are dropped.

Co-Authored-By: Claude Opus 5.5 <[email protected]>

* dat: type stages' item script tables and quake model lists

ALDYakuAll is a table of GroundItemScript, a scripted pointer, as far as
the data runs, so its scripts are reached and their aliases go. Each
stage's unreferenced list after quake_model_set is typed by address.
Trailing relocations go from 613 to 463.

Co-Authored-By: Claude Opus 5.5 <[email protected]>

* dat: type ItCo's copied attributes and joint lists, count CPU scripts

ItCo's copy of the common items' data types each item's attributes as
its original's kind; Food's and Unown's copied joint lists after their
model descs are typed by address. Unown's swarm shares Unown's
attributes. Fighter_804D64FC.cmdscripts holds 0x3E CPU scripts.
Trailing relocations go from 463 to 283.

Co-Authored-By: Claude Opus 5.5 <[email protected]>

* dat: preserve handoff fixes and test binding and count semantics

* dat: remove a redundant header and format union bindings

* dat: create the samples' object directory before compiling

Co-Authored-By: Claude Opus 5.5 <[email protected]>

* dat: express item lookups as tuple matches

* dat: wrap tuple bindings in annotation macros

* dat: name match wrappers after their annotation

* dat: use C-like syntax for match cases

* dat: simplify match cases to variadic expressions

---------

Co-authored-by: Robin Avery <[email protected]>
Co-authored-by: Claude Opus 5.5 <[email protected]>
Co-authored-by: itsgrimetime <[email protected]>
2026-10-07 20:40:19 -07:00
Mike Grimesanditsgrimetime ea2995d5cb dat: honor DAT_COUNT on inline arrays (#3635)
Co-authored-by: itsgrimetime <[email protected]>
2026-10-05 12:19:27 -07:00
Robin Avery 71929abafe dat: type orphan scenes and scripts, count more tables (#3634)
Sample coverage: 99.90% to 99.98% of archive bytes (about 196 KB more
explained); every sample matches.

Annotations and dat_symbols.txt:
- DAT_TERMINATED(value, n): terminators n elements long (LbAd's sound
  load lists end in two)
- DAT_COUNT on pointer typedefs, for lists of counted lists, and nested
  member names in expressions (x0.dynamicsNum)
- DAT_SCRIPT length expressions can end a script with a 0-word command;
  colAnimCommandLength for color animation scripts
- dat_symbols.txt: terminated:V for null-terminated list roots, and
  script:S for scripts nothing points to
- the native archive interface supports all of the above

Types:
- counted: spline control points and segments, hurtbox inits, stage
  parameter rows, stage joint position lists, fighter sound id lists,
  absorb descs, ftLoadCommonData's tables, dynamic bone sets
- typed: color animation scripts, target test touch lines, Mewtwo's and
  Jigglypuff's target stage params, damage shift lists
  (ftDamageShifts), fog animations (SceneFogAnim, two words)
- toy background animations loaded with their own types

Unreferenced data, typed by address:
- stage camera, fog and light wrappers, and whole orphan scenes
- orphan model descs and their lists
- more unreferenced animation and model trees; Link's and Young Link's
  rooted at their joints rather than inside them
- 131 fighter and item scripts nothing points to
- ItCo's byte-for-byte copy of the common item data
2026-10-05 13:51:35 -04:00
Robin AveryandClaude Opus 5.5 d52f449432 dat: implement C deserialization codegen, improve coverage (#3632)
A C library, tools/dat-cli/native, that reads the archives into the game's own types on any platform, from tables `melee-dat native codegen` writes from the DWARF. It's a port of the walk that converts as it goes, so `melee-dat native expect` and the library's trace must agree: they do for all 7048 archives on 64-bit and 32-bit little-endian and 32-bit big-endian (under qemu), and every converted object reads back against its data. The dat preset builds it with the host's compiler and runs its tests in ctest.

- the walk lays queued objects out as they were reached, so typedef tags
  apply (the CPU attack lists' DAT_TERMINATED was ignored)
- CPU attack tables typed (ftCo_AttackList); stage param types moved into
  their headers; stage param fields typed as their data
- 47 dat_symbols.txt aliases that read stage data as material animations
  removed
- generated C casts only between different types; untyped data typed from
  the fields that point to it
- `samples report --incomplete`, why units aren't complete
- a `native` dev shell with the DWARF/dat tools, qemu and a ppc32 cross
  compiler; the default shell is what CI needs
- clang-tidy's checks stay on src/: tools/ and the generated tables opt out

Co-Authored-By: Claude Opus 5.5 <[email protected]>

* dat: native schema as descriptors per type, a file per header, enum type indices

`melee-dat native codegen` writes a directory instead of one tables.c:
each type is a named `dat_type_*` descriptor with its members, in
types/<header>.c for the header that declares it, along with what refers
to it (pointers, arrays); roots are in roots/<module>.c; DAT_TYPE_* and
DAT_NAME_* are enums. Descriptors use designated initializers, refer to
types by name and keep expressions next to their members, with the
annotation as written in a comment where it isn't plain.

- dat/schema.h: the schema's types and the macros descriptors are written
  in; DAT_NONE is 0, so every field defaults to zero
- members, expressions, scripts, binds and roots are pointers, not ranges
  of shared tables; macros expand to a depth when evaluated
- the schema is generated when configuring, again when its inputs change
- codegen split into generator.rs (the rows) and emit.rs (the C)

Co-Authored-By: Claude Opus 5.5 <[email protected]>
2026-10-05 13:13:55 -04:00