Palette pairing session 2: validate the lighting-stripe hypothesis via emulator captures #214

Closed
opened 2026-07-07 17:23:09 +02:00 by jqueuniet · 0 comments
jqueuniet commented 2026-07-07 17:23:09 +02:00 (Migrated from codeberg.org)

Continuation of the static research merged in #213 (stripe-aware palette_oracle_match + cross-port docs). This issue carries the handoff so the next session can run on any machine with the fixtures staged — the working scratch directory from session 1 is machine-local and its artifacts are all re-derivable (commands below).

Goal

Confirm or refute, against fresh Sega CD CRAM captures:

CRAM line 1 == conv(bank[map_graphics_style(current map)][light_stripe])

where bank = the six 96-entry records at cls=(0x08, 0x00..0x05, 0x09, 0x00), map_graphics_style = dungeon.dat per-map w14 bits 7:4 (static; see docs/formats/dungeon-dat.md), and light_stripe = the engine's 6-state light level. Background and evidence: docs/formats/palette-lut.md § "The lighting-stripe hypothesis".

Protocol (Sega CD / BlastEm — harness in tooling/palette-oracle/, Phase-0 gate already passed)

  1. Build BlastEm via tooling/palette-oracle/blastem.nix; debugger commands are written up in tooling/palette-oracle/blastem-debugger.md.
  2. Capture 3–4 varied dungeon scenes with save/w <path>/cram_<scene>.bin vdp:cram 64and note per capture: the party's current map and the torch/light state. Map → environment via dm2 dump fixtures/dos-en/dungeon.dat (mapGraphicsStyle field; the console dungeons differ but carry the same field — dump the Sega CD dungeon for exact values).
  3. Run the stripe-aware matcher (landed in #213):
    cargo run -p dm2-graphics --example palette_oracle_match -- fixtures/sega-cd-us/graphics.dat <capture-dir>
    Expect line-1 hits labeled #idx stripe s with s tracking the light state and idx tracking map_graphics_style.
  4. If confirmed: console viewport colour is fully explained by static data + (map, light) — file the decoder-wiring work and skip the live-trace fallback.
  5. If refuted: fall back to the live ADDR_PALSEL trace — resolver 0x1e78e, policy sites 0x147d4 / 0xf6aa (CODE-hunk-relative; jump-table anchored), runtime entry previously seen at 0x375a0 (bias-relative, re-verify per boot). All documented in docs/formats/palette-lut.md.

Secondary target (either outcome): the per-object LUT selector

Static RE showed the cls3=0x0E LUT cls4 selector is computed per drawn object: cls4 = helper(record) via A5 jump-table slot 186 (Amiga offsets; see docs/formats/palette-lut.md § "Amiga cross-port corroboration" — the Amiga and Sega CD SKUL.FTL are the same C codebase, so either port works). Options:

  • Static: decode each module's BSS jump table (dm2-ftl parses BSS) to reconstruct the merged A5 table (merge order unconfirmed; slot 186 / the resolver at slot 337 likely land in GRF1.FTL), then read the helper's body.
  • Dynamic: breakpoint the policy site, log (object record, cls4, chosen LUT) triples; a handful of samples should pin the function.

On Amiga (single CPU — easiest correlation): breakpoint the VDEO palette loader (CODE 0x4ed6 + hunk bias) or watch the staging global -0xc3c(a5) in WinUAE/fs-uae.

FM-Towns: SKULL.EXP is a "P3" flat-386 RUN386 executable (decompilable with rz-ghidra x86); cold byte-scans hit only data tables, so start from MAME watchpoints on the Towns palette I/O and walk back.

Re-deriving the session-1 scratch artifacts

  • FTL code hunks (all ports): dm2 extract fixtures/amiga-eu/DM2/<MOD>.FTL -o <dir> (also tooling/palette-oracle/extract_code_hunk.sh for Sega CD SKUL).
  • DOS Beta joined archive: cat fixtures/dos-en-beta/DATA/GRAPHICS.DAT fixtures/dos-en-beta/DATA/GRAPHIC2.DAT > beta.dat; then dm2 extract beta.dat -o <dir> --all-bins reproduces the six banks (08_0?_09_00__*.gpl, 384 B) and the 3,357 cls3=0x0D Palette16 population analysed in docs/sources/dos-en-beta.md § "Palette architecture".
  • Amiga disassembly: rizin -N -a m68k -b 32 -e cfg.bigendian=true <hunk> — key offsets in docs/formats/palette-lut.md.

References

  • #213 — stripe-aware matcher + all findings docs (merged).
  • docs/formats/palette-lut.md — RE hub: hypothesis, offsets, capture architecture, Amiga/FM-Towns sections.
  • docs/formats/dungeon-dat.mdmap_graphics_style semantics + engine citations.
  • docs/sources/dos-en-beta.md § "Palette architecture" — the static-pairing Rosetta stone.
  • ROADMAP § Phase 7 "Sega CD / Amiga / FM-Towns colour resolution" — the tracked residue: (a) this validation, (b) the cls4 helper, (c) decoder wiring.
Continuation of the static research merged in #213 (stripe-aware `palette_oracle_match` + cross-port docs). This issue carries the handoff so the next session can run on any machine with the fixtures staged — the working scratch directory from session 1 is machine-local and its artifacts are all re-derivable (commands below). ## Goal Confirm or refute, against fresh Sega CD CRAM captures: CRAM line 1 == conv(bank[map_graphics_style(current map)][light_stripe]) where `bank` = the six 96-entry records at `cls=(0x08, 0x00..0x05, 0x09, 0x00)`, `map_graphics_style` = `dungeon.dat` per-map `w14` bits 7:4 (static; see `docs/formats/dungeon-dat.md`), and `light_stripe` = the engine's 6-state light level. Background and evidence: `docs/formats/palette-lut.md` § "The lighting-stripe hypothesis". ## Protocol (Sega CD / BlastEm — harness in `tooling/palette-oracle/`, Phase-0 gate already passed) 1. Build BlastEm via `tooling/palette-oracle/blastem.nix`; debugger commands are written up in `tooling/palette-oracle/blastem-debugger.md`. 2. Capture 3–4 varied dungeon scenes with `save/w <path>/cram_<scene>.bin vdp:cram 64` — **and note per capture: the party's current map and the torch/light state.** Map → environment via `dm2 dump fixtures/dos-en/dungeon.dat` (`mapGraphicsStyle` field; the console dungeons differ but carry the same field — dump the Sega CD dungeon for exact values). 3. Run the stripe-aware matcher (landed in #213): `cargo run -p dm2-graphics --example palette_oracle_match -- fixtures/sega-cd-us/graphics.dat <capture-dir>` Expect line-1 hits labeled `#idx stripe s` with `s` tracking the light state and `idx` tracking `map_graphics_style`. 4. **If confirmed**: console viewport colour is fully explained by static data + (map, light) — file the decoder-wiring work and skip the live-trace fallback. 5. **If refuted**: fall back to the live `ADDR_PALSEL` trace — resolver `0x1e78e`, policy sites `0x147d4` / `0xf6aa` (CODE-hunk-relative; jump-table anchored), runtime entry previously seen at `0x375a0` (bias-relative, re-verify per boot). All documented in `docs/formats/palette-lut.md`. ## Secondary target (either outcome): the per-object LUT selector Static RE showed the `cls3=0x0E` LUT `cls4` selector is computed per drawn object: `cls4 = helper(record)` via A5 jump-table slot 186 (Amiga offsets; see `docs/formats/palette-lut.md` § "Amiga cross-port corroboration" — the Amiga and Sega CD `SKUL.FTL` are the same C codebase, so either port works). Options: - Static: decode each module's BSS jump table (`dm2-ftl` parses BSS) to reconstruct the merged A5 table (merge order unconfirmed; slot 186 / the resolver at slot 337 likely land in `GRF1.FTL`), then read the helper's body. - Dynamic: breakpoint the policy site, log `(object record, cls4, chosen LUT)` triples; a handful of samples should pin the function. On Amiga (single CPU — easiest correlation): breakpoint the `VDEO` palette loader (CODE `0x4ed6` + hunk bias) or watch the staging global `-0xc3c(a5)` in WinUAE/fs-uae. FM-Towns: `SKULL.EXP` is a "P3" flat-386 RUN386 executable (decompilable with rz-ghidra x86); cold byte-scans hit only data tables, so start from MAME watchpoints on the Towns palette I/O and walk back. ## Re-deriving the session-1 scratch artifacts - FTL code hunks (all ports): `dm2 extract fixtures/amiga-eu/DM2/<MOD>.FTL -o <dir>` (also `tooling/palette-oracle/extract_code_hunk.sh` for Sega CD `SKUL`). - DOS Beta joined archive: `cat fixtures/dos-en-beta/DATA/GRAPHICS.DAT fixtures/dos-en-beta/DATA/GRAPHIC2.DAT > beta.dat`; then `dm2 extract beta.dat -o <dir> --all-bins` reproduces the six banks (`08_0?_09_00__*.gpl`, 384 B) and the 3,357 `cls3=0x0D` Palette16 population analysed in `docs/sources/dos-en-beta.md` § "Palette architecture". - Amiga disassembly: `rizin -N -a m68k -b 32 -e cfg.bigendian=true <hunk>` — key offsets in `docs/formats/palette-lut.md`. ## References - #213 — stripe-aware matcher + all findings docs (merged). - `docs/formats/palette-lut.md` — RE hub: hypothesis, offsets, capture architecture, Amiga/FM-Towns sections. - `docs/formats/dungeon-dat.md` — `map_graphics_style` semantics + engine citations. - `docs/sources/dos-en-beta.md` § "Palette architecture" — the static-pairing Rosetta stone. - ROADMAP § Phase 7 "Sega CD / Amiga / FM-Towns colour resolution" — the tracked residue: (a) this validation, (b) the cls4 helper, (c) decoder wiring.
Sign in to join this conversation.
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#214
No description provided.