dm2-graphics: console-family 4-bit images carry a trailing per-image Palette16 — dropped by the decoder, blocks colour-correct Mac JP / PC-98x1 / IBM PS/V rendering #186
Loading…
Add table
Add a link
Reference in a new issue
No description provided.
Delete branch "%!s()"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
Problem
decode_4bit_bodyonly preserves the trailing 16-byte per-image Palette16 whenpc_familyis true (crates/dm2-graphics/src/image/decoders.rs~785,trailing_palette = pc_family). The engine copies the last 16 bytes of every 4-bit dtImage record into the decoded buffer as the per-image palette, unconditionally ([SKPROJECT] v5/bgdat.cpp:1252, thevw_1c == 4branch ofDM2_EXTRACT_GDAT_IMAGE).Fixture evidence says the engine is right and the crate's console-family assumption is wrong for 4 of the 6 non-PC ports:
(cls1, cls2, cls4, cls5)tuple and dimensions, the last 16 payload bytes are byte-identical to the dos-en trailing Palette16 on Mac JP (515/623), Amiga (446/452), PC-9821 and IBM PS/V (554 each) — while zero payloads match in full. Bodies differ (different encodings/revisions), palettes match: only a genuine palette explains that.0x01of the(0, 0, 0x0b, 0)inline feature word correlates perfectly across all 9 archives — set on dos-en/dos-de/dos-fr/Mac US (0x7b), Mac JP / PC-9801 / PC-9821 / IBM PS/V (0x0b), Amiga (0x2b); clear on Sega CD / FM-Towns (0x0a), the only two ports without trailing palettes.Consequences
Archive::find_image_palette's docstring ("Mac JP … the Mac JP application binary holds the actual palette tables") and the matching sections ofdocs/formats/graphics-dat.md.SKUL.FTL.palette: Nonefor these records andfind_image_palettefalls back to wrong-colour heuristics; pixels are usually unaffected (the RLE fills the buffer before reaching the palette bytes), but any under-filling stream reads palette bytes as RLE commands.Fix direction
Gate the trailing palette on
pc_family || (inline word bit 0x01)— or simply on bit 0x01, since all four PC-family archives set it — indecode_4bit_body, and plumb the flag throughArchive::decode_image_payload/Image::parse. Then letfind_image_paletteprefer the per-image palette + 256-entry master on Mac JP / PC-9821 / IBM PS/V, and consider a--master-palettestyle override so Amiga can borrow the DOS master. Updatedocs/formats/graphics-dat.mdand thefind_image_palettecoverage table accordingly.Probes:
scratch/probe_trailing_pal.py,scratch/probe_tail_match.py(gitignored).