Skip to content

feat(drawing): PaletteResolver — shared legacy palette resolution (.epf + khan) - #21

Merged
baughj merged 1 commit into
mainfrom
feature/palette-resolver
Aug 2, 2026
Merged

feat(drawing): PaletteResolver — shared legacy palette resolution (.epf + khan)#21
baughj merged 1 commit into
mainfrom
feature/palette-resolver

Conversation

@baughj

@baughj baughj commented Jul 27, 2026

Copy link
Copy Markdown
Member

feat(drawing): PaletteResolver — shared legacy palette resolution

Implements comhaigne's palette-resolution.md (transcribed from ChaosAssetManager)
as the single source of truth all consumers (foscail, Brigid, dalib-ts, Taliesin)
can share instead of re-deriving. Selects a palette; does not decode or draw.

Scope this PR: .epf archive rules + the khan family — the immediate UI-extraction
need, and conflict-free with existing code.

  • Contract: ResolvedPalette record (palette, paletteNumber, isLuminanceBlended,
    kind, ruleId), PaletteSourceKind {Table,Indexed,Fixed,Constant}, ArchiveProvider
    delegate for sibling access (no hardcoded paths). Instance-scoped caches (the
    spec's answer to CAM's 27-field static Reset()).
  • Rules: legend.dat (9 branches), setoa.dat (25 hand-mapped gui rules, order
    hazards preserved, field000 wart), roh.dat (efct/mefc), national/misc (sibling
    legend.pal), and khan (letter remap a->b/g->c/j->c/o->m/s->p, table letters with
    male/female override, body -> lowest palm, pants -> color0.tbl dye index 0).
  • Luminance >=1000 reported via the flag; the arithmetic stays in PaletteLookup.
  • 22 tests: first-match order hazards (dlgcre01/emot00/lsbackm/setup12), the four
    kinds, khan remap+override+luminance, sibling legend.pal, the field000 wart.

Deferred (own follow-up): .hpf/.mpf/tileset rules — the tileset mpt +1 (spec) vs
+2 (DALib RenderMap) keying needs reconciling against retail first. Then wire
foscail's ConvertEpf to the resolver (supersedes PR #20) and agree the shared
conformance fixture + ruleId strings with dalib-ts.

Co-Authored-By: Imbas imbas@eris.co

Generated with Imbas imbas@eris.co

Implements comhaigne's palette-resolution.md (transcribed from ChaosAssetManager)
as the single source of truth all consumers (foscail, Brigid, dalib-ts, Taliesin)
can share instead of re-deriving. Selects a palette; does not decode or draw.

Scope this PR: .epf archive rules + the khan family — the immediate UI-extraction
need, and conflict-free with existing code.

- Contract: ResolvedPalette record (palette, paletteNumber, isLuminanceBlended,
  kind, ruleId), PaletteSourceKind {Table,Indexed,Fixed,Constant}, ArchiveProvider
  delegate for sibling access (no hardcoded paths). Instance-scoped caches (the
  spec's answer to CAM's 27-field static Reset()).
- Rules: legend.dat (9 branches), setoa.dat (25 hand-mapped gui rules, order
  hazards preserved, field000 wart), roh.dat (efct/mefc), national/misc (sibling
  legend.pal), and khan (letter remap a->b/g->c/j->c/o->m/s->p, table letters with
  male/female override, body -> lowest palm, pants -> color0.tbl dye index 0).
- Luminance >=1000 reported via the flag; the arithmetic stays in PaletteLookup.
- 22 tests: first-match order hazards (dlgcre01/emot00/lsbackm/setup12), the four
  kinds, khan remap+override+luminance, sibling legend.pal, the field000 wart.

Deferred (own follow-up): .hpf/.mpf/tileset rules — the tileset mpt +1 (spec) vs
+2 (DALib RenderMap) keying needs reconciling against retail first. Then wire
foscail's ConvertEpf to the resolver (supersedes PR #20) and agree the shared
conformance fixture + ruleId strings with dalib-ts.

Co-Authored-By: Imbas <imbas@eris.co>
@baughj
baughj merged commit 593bcea into main Aug 2, 2026
1 check passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant