dm2-graphics fidelity batch: fixes for #186–#194 #208

Merged
jqueuniet merged 0 commits from refs/pull/208/head into main 2026-07-06 06:20:12 +02:00
jqueuniet commented 2026-07-05 23:30:08 +02:00 (Migrated from codeberg.org)

Implements all nine open dm2-graphics issues, one commit per issue (dependency-ordered — a shared feature-flags word underpins several fixes, and cls3=0x02 SFX keying is shared by #187/#190).

Fixes

  • #194 — typed Archive::feature_flags() foundation ((0,0,0x0b,0) word); is_pc_family delegates to it. Plus low-severity divergence notes (LZW mode 1, odd-width remainder, dropped-record superset).
  • #186 — recover the trailing per-image Palette16 on console 4-bit images (gated on feature bit 0x01, not pc_family); Mac JP / PC-9821 / IBM PS/V now render colour-correct.
  • #187 — decode console-family SFX by keying iter_sfx on cls3=0x02 dtSnd records with a 2-byte / 5500 Hz header form. Ports that reported zero SFX now surface 67/52/48/17; dm2 info/extract follow automatically.
  • #190 — champion (0x16,htype,0x02,0x82) is the voice SFX, not a palette (Champion::palettevoice: Option<Sfx>).
  • #188 — route champion portraits through compose_image_at_dbidx so FM-Towns format-4 dispatch and console overlay composition apply.
  • #191 — full three-path sprite displacement (Archive::sprite_offset); 8-bit header bytes surfaced on Image::eight_bit_offset.
  • #189 — language-aware ENT1 lookup (find_in_language) mirroring the engine's cls5 & 0xf0 ∈ {0, tag} admission rule; disambiguates the 545 duplicate tuples find resolved arbitrarily.
  • #193 — terminate dtText at the first NUL like the engine; drops the trailing U+0000 on JP even-padded payloads.
  • #192 — ENT1 type headers are (field letter, byte width) descriptors, not per-type counts (TypeHeader::countwidth) + a canonical-layout guard.

Verification

Full workspace: 103/103 test binaries pass, zero clippy warnings. Each behavioral fix adds fixture-backed regression tests (including ports the suite never exercised — FM-Towns, Mac JP, PC-9821), dm2-cli was propagated where a fix changed tool output, and docs/formats/graphics-dat.md was corrected for every refuted claim.

Closes #186, #187, #188, #189, #190, #191, #192, #193, #194.

Implements all nine open `dm2-graphics` issues, one commit per issue (dependency-ordered — a shared feature-flags word underpins several fixes, and `cls3=0x02` SFX keying is shared by #187/#190). ## Fixes - **#194** — typed `Archive::feature_flags()` foundation (`(0,0,0x0b,0)` word); `is_pc_family` delegates to it. Plus low-severity divergence notes (LZW mode 1, odd-width remainder, dropped-record superset). - **#186** — recover the trailing per-image `Palette16` on console 4-bit images (gated on feature bit `0x01`, not `pc_family`); Mac JP / PC-9821 / IBM PS/V now render colour-correct. - **#187** — decode console-family SFX by keying `iter_sfx` on `cls3=0x02` `dtSnd` records with a 2-byte / 5500 Hz header form. Ports that reported **zero** SFX now surface 67/52/48/17; `dm2 info`/`extract` follow automatically. - **#190** — champion `(0x16,htype,0x02,0x82)` is the voice SFX, not a palette (`Champion::palette` → `voice: Option<Sfx>`). - **#188** — route champion portraits through `compose_image_at_dbidx` so FM-Towns format-4 dispatch and console overlay composition apply. - **#191** — full three-path sprite displacement (`Archive::sprite_offset`); 8-bit header bytes surfaced on `Image::eight_bit_offset`. - **#189** — language-aware ENT1 lookup (`find_in_language`) mirroring the engine's `cls5 & 0xf0 ∈ {0, tag}` admission rule; disambiguates the 545 duplicate tuples `find` resolved arbitrarily. - **#193** — terminate `dtText` at the first NUL like the engine; drops the trailing `U+0000` on JP even-padded payloads. - **#192** — ENT1 type headers are `(field letter, byte width)` descriptors, not per-type counts (`TypeHeader::count` → `width`) + a canonical-layout guard. ## Verification Full workspace: **103/103 test binaries pass, zero clippy warnings**. Each behavioral fix adds fixture-backed regression tests (including ports the suite never exercised — FM-Towns, Mac JP, PC-9821), `dm2-cli` was propagated where a fix changed tool output, and `docs/formats/graphics-dat.md` was corrected for every refuted claim. Closes #186, #187, #188, #189, #190, #191, #192, #193, #194.
jqueuniet commented 2026-07-06 05:54:27 +02:00 (Migrated from codeberg.org)

Code review

Found 1 issue:

  1. Stale references to the removed Champion::palette field survive the #190 rename. The format doc's "Deferred follow-ups from category 0x16" section still says "Champion::palette returns Option<EntryRef>" and frames palette resolution as blocked on that field, and the Champion struct's doc comment still describes the record as "2 portraits + optional palette reference" — both contradict this PR's own change of the field to pub voice: Option<Sfx<'a>> and the updated "Voice samples" prose elsewhere in the same doc.

codeberg.org/jqueuniet/dm2-tools@659e3d432c/docs/formats/graphics-dat.md (L1694-L1700)

codeberg.org/jqueuniet/dm2-tools@659e3d432c/crates/dm2-graphics/src/champion.rs (L152-L156)

Checked for bugs, doc/code consistency, historical regressions, and prior review feedback; no functional issues found in the parsing or decode paths.

### Code review Found 1 issue: 1. Stale references to the removed `Champion::palette` field survive the #190 rename. The format doc's "Deferred follow-ups from category 0x16" section still says "`Champion::palette` returns `Option<EntryRef>`" and frames palette resolution as blocked on that field, and the `Champion` struct's doc comment still describes the record as "2 portraits + optional palette reference" — both contradict this PR's own change of the field to `pub voice: Option<Sfx<'a>>` and the updated "Voice samples" prose elsewhere in the same doc. https://codeberg.org/jqueuniet/dm2-tools/src/commit/659e3d432cb4a12d36b06a5a816ecdb126674333/docs/formats/graphics-dat.md#L1694-L1700 https://codeberg.org/jqueuniet/dm2-tools/src/commit/659e3d432cb4a12d36b06a5a816ecdb126674333/crates/dm2-graphics/src/champion.rs#L152-L156 Checked for bugs, doc/code consistency, historical regressions, and prior review feedback; no functional issues found in the parsing or decode paths.
Sign in to join this conversation.
No reviewers
No labels
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!208
No description provided.