Repository navigation
dat: generate native readers for typed HSD archive loading - #3658
Conversation
ribbanya
left a comment
There was a problem hiding this comment.
Maybe I'm missing something but why does it need any of this stuff still? The task is to read an archive (meaning understand the header) then using some kind of type dispatch expand it to its in-memory form and return it. So GetPublicAs specifies the type and then the only job of the C code here is to read a symbol back as that type.
So I don't see why, for example, a growable vector or a private arena would be necessary.
|
The intended concept is very simple: Rust generates "dumb" C code that simply reads a 32-bit BE archive and translates it at runtime to the same struct laid out appropriately for the running platform. So each generated set of C files only understands one architecture and polymorphism is abstracted through simple tables and callbacks (a dispatched reader). It doesn't perform any complex reasoning, it just takes the type and symbol name requested from the Again, maybe I am missing something that makes this unviable but I can't think of anything. There should be enough information in the dwarf for the Rust code to generate this kind of C code. |
|
So basically what we need is |
|
We can create a new |
ribbanya
left a comment
There was a problem hiding this comment.
This is much better, thank you. Will need some tweaking for a while but it's a good foundation.
ribbanya
left a comment
There was a problem hiding this comment.
As I said, needs more iteration, but this looks good for now. Thanks!
7e5c71d to
f8fecfd
Compare
…s, particle fixes 18 upstream commits (through af59f8c). web-single builds clean. Conflicts + integration resolved keeping the port paths: - archive.c: upstream gates the body under #ifndef TARGET_PC (native builds use the generated reader in tools/dat-cli). The wasm port loads archives through this file with its in-place endian swap, so kept the port include block (hsd_endian/archive_swap.h) and HSD_ArchiveParse on TARGET_PC; dropped the dangling EOF #endif. - granime.c grAnime_801C6F50: kept the port TARGET_PC wasm-signature-safe dispatch switch; took upstream grAnimeCallback typed-union code for the #else (GameCube) branch. - archive.h / lbarchive.c / lbdvd.c: upstream doldecomp#3658 moved archive loading onto a native DatArchive reader under TARGET_PC (native_data field, growing HSD_Archive to 0x48 and breaking ASSERT_SIZE 0x44; plus HSD_ArchiveReleaseNative / HSD_ArchiveGetPublicTyped, which are undefined for the port -- only in tools/dat-cli). The port uses its own endian-swap + DAT_ROOTS schema, so reverted those TARGET_PC additions: dropped native_data (restores 0x44), restored the DAT_ROOTS_ENABLED HSD_ArchiveGetPublicAs, removed the HSD_ArchiveReleaseNative calls in lbarchive.c and lbdvd.c. Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01S9oD2L2sgETDKcnJp2UdYy
Uh oh!
There was an error while loading. Please reload this page.