Wire the validated console palette model into the decoders #261

Merged
jqueuniet merged 0 commits from refs/pull/261/head into main 2026-07-17 14:07:34 +02:00
jqueuniet commented 2026-07-17 13:53:13 +02:00 (Migrated from codeberg.org)

Closes #260.

Wires the validated console palette model (#214 / PR #259) into the decoders: the dungeon-viewport palette conv(bank[map_graphics_style][light_stripe]) becomes the resolution path for console-family images, with (style, light) as an explicit, defaultable rendering context.

Library (dm2-graphics)

  • LightingContext { style, light } — default {3, 1} (the most common map style; the validated in-game "good light" stripe).
  • Archive::lighting_stripe(style, light) — the 16-entry stripe slice of the 96-entry bank at cls = (0x08, style, 0x09, 0x00); None on out-of-range input, missing banks (PC retail archives), or malformed payloads.
  • find_image_palette_ctx — the existing chain extended with three evidence-backed steps: graphics-set images (cls1 = 0x08) use their own cls2 as the bank (engine-verified pairing), UI-side categories (cls1 < 0x08) fall back to the engine-verified CRAM line-0 palette at (0x01, 0x00, 0x09, 0x00), and the remaining viewport categories use the context bank. Existing signatures unchanged (delegating with the default context); PC-family resolution short-circuits at the master exactly as before, byte-identical.
  • iter_image_with_palette_ctx threads the context through the image iterator.

CLI

dm2 extract --style <0-5> --light <0-5> (defaults 3/1, range-validated; console-family only — PC archives resolve through the master and ignore them).

Effect

Sega CD US extraction goes from 2 to 4,338 correctly-paletted image PNGs (previously only the two title banners resolved any palette); Amiga similarly (4,758). A --light 5 run visibly darkens 4,022 of the Sega CD PNGs. Yield counts are pinned in three independent tests so a silent resolution regression fails loudly; a four-port smoke pins the banks on Sega CD US/JP, Amiga EU, and FM-Towns JP (surfacing that Sega CD JP's bank 0 is flat).

Remaining residues (line-2 torch-glow palette, the never-observed stripe 0, the -0x1aa4(a5) gate global, the cls4 table record) stay tracked in ROADMAP Phase 7.

Closes #260. Wires the validated console palette model (#214 / PR #259) into the decoders: the dungeon-viewport palette `conv(bank[map_graphics_style][light_stripe])` becomes the resolution path for console-family images, with `(style, light)` as an explicit, defaultable rendering context. ## Library (`dm2-graphics`) - `LightingContext { style, light }` — default `{3, 1}` (the most common map style; the validated in-game "good light" stripe). - `Archive::lighting_stripe(style, light)` — the 16-entry stripe slice of the 96-entry bank at `cls = (0x08, style, 0x09, 0x00)`; `None` on out-of-range input, missing banks (PC retail archives), or malformed payloads. - `find_image_palette_ctx` — the existing chain extended with three evidence-backed steps: graphics-set images (`cls1 = 0x08`) use their own `cls2` as the bank (engine-verified pairing), UI-side categories (`cls1 < 0x08`) fall back to the engine-verified CRAM line-0 palette at `(0x01, 0x00, 0x09, 0x00)`, and the remaining viewport categories use the context bank. Existing signatures unchanged (delegating with the default context); PC-family resolution short-circuits at the master exactly as before, byte-identical. - `iter_image_with_palette_ctx` threads the context through the image iterator. ## CLI `dm2 extract --style <0-5> --light <0-5>` (defaults 3/1, range-validated; console-family only — PC archives resolve through the master and ignore them). ## Effect Sega CD US extraction goes from **2 to 4,338** correctly-paletted image PNGs (previously only the two title banners resolved any palette); Amiga similarly (4,758). A `--light 5` run visibly darkens 4,022 of the Sega CD PNGs. Yield counts are pinned in three independent tests so a silent resolution regression fails loudly; a four-port smoke pins the banks on Sega CD US/JP, Amiga EU, and FM-Towns JP (surfacing that Sega CD JP's bank 0 is flat). Remaining residues (line-2 torch-glow palette, the never-observed stripe 0, the `-0x1aa4(a5)` gate global, the cls4 table record) stay tracked in ROADMAP Phase 7.
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!261
No description provided.