feat(bindings): graphics.dat archive handle #436

Merged
jqueuniet merged 1 commit from feat/431-archive-handle into main 2026-10-30 18:43:42 +01:00
Owner

Closes #431.

GraphicsArchive parses a graphics.dat once and carries every graphics* function as a method:

  • wasm: new GraphicsArchive(bytes), decodePng, entriesJson, …, free().
  • FFI: dm2_graphics_archive_open(ptr, len, &g) (error in the returned buffer), dm2_graphics_archive_*, dm2_graphics_archive_free; null handle → error.
  • Python: GraphicsArchive context manager.

Free functions unchanged.

Decoding all 5,676 DOS images in Node:

wasm build free functions handle speedup
debug 13.1 ms/img 1.6 ms/img 8.1×
release, no wasm-opt 1.02 ms/img 0.11 ms/img 9.2×

New dependency self_cell (no deps; Apache-2.0 OR GPL-2.0-only, passes cargo-deny) for the owned-bytes + borrowing-archive pair, instead of hand-written unsafe.

https://claude.ai/code/session_01SnENBXnZbhNNrojZT5jbJ7

Closes #431. `GraphicsArchive` parses a `graphics.dat` once and carries every `graphics*` function as a method: - wasm: `new GraphicsArchive(bytes)`, `decodePng`, `entriesJson`, …, `free()`. - FFI: `dm2_graphics_archive_open(ptr, len, &g)` (error in the returned buffer), `dm2_graphics_archive_*`, `dm2_graphics_archive_free`; null handle → error. - Python: `GraphicsArchive` context manager. Free functions unchanged. Decoding all 5,676 DOS images in Node: | wasm build | free functions | handle | speedup | |---|---|---|---| | debug | 13.1 ms/img | 1.6 ms/img | 8.1× | | release, no wasm-opt | 1.02 ms/img | 0.11 ms/img | 9.2× | New dependency `self_cell` (no deps; Apache-2.0 OR GPL-2.0-only, passes cargo-deny) for the owned-bytes + borrowing-archive pair, instead of hand-written `unsafe`. https://claude.ai/code/session_01SnENBXnZbhNNrojZT5jbJ7
feat(bindings): graphics.dat archive handle
All checks were successful
CI / msrv (1.90) (pull_request) Successful in 44s
CI / audit (pull_request) Successful in 13s
CI / stable (pull_request) Successful in 1m29s
CI / python bindings (3.11) (pull_request) Successful in 34s
CI / msrv (1.90) (push) Successful in 45s
CI / audit (push) Successful in 14s
CI / stable (push) Successful in 1m29s
CI / python bindings (3.11) (push) Successful in 33s
d3a8425b75
GraphicsArchive parses a graphics.dat once and carries the graphics_*
functions as methods: a wasm class, an opaque FFI handle, a Python
class. The free functions stay as wrappers. Decoding every DOS image
through one wasm handle runs 8-9x faster than through the free
functions, which copy the file into WASM memory per call.

Closes #431

Claude-Session: https://claude.ai/code/session_01SnENBXnZbhNNrojZT5jbJ7
jqueuniet deleted branch feat/431-archive-handle 2026-10-30 18:43:42 +01:00
Sign in to join this conversation.
No reviewers
No milestone
No project
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set.

Reference
jqueuniet/dm2-tools!436
No description provided.