Repository navigation
feat(drawing): resolve palettes for legacy archive entries - #9
Merged
Merged
Conversation
Port the palette auto-resolution rules from the palette-resolution specification. A legacy .epf/.hpf/.mpf/tileset frame is a grid of palette indices; these rules find the palette for it. - PaletteResolver: one instance per open archive. It caches each palette source, takes sibling archives from an ArchiveProvider callback, and never throws — null sends the host to a manual picker. Reproduces the setoa field000.pal wart and the khan body/pants rules. - matchPaletteRule: the pure rule-match stage over (archive, entry) names. It emits stable ruleId strings for the planned C# port. - PaletteLookup.getResolvedPaletteForId: reports the real palette number and the luminance-blend flag; getPaletteForId now wraps it. - tests/fixtures/palette-resolution.json: the frozen cross-port conformance contract, plus gated suites that verified every rule family against a real 7.41 client install. Release chores: version 3.1.0, changelog entry, README section. Co-Authored-By: Fintan (Claude Opus) <noreply@anthropic.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Ports the palette auto-resolution rules from the palette-resolution specification (document repo,
docs/architecture/palette-resolution.md) so downstream tools get a correct default palette instead of the first.palin archive order.PaletteResolver— instance per open archive; caches every palette source (failed builds included); sibling archives (khanpal.dat,legend.dat) come from anArchiveProvidercallback so no filesystem paths are named;resolve()never throws —nullmeans fall back to the manual picker. Reproduces thesetoa.datfield000.palwart and resolves khan bodies to the lowestpalmpalette and khan pants to dye index 0.matchPaletteRule— the pure rule-match stage (legend, national, roh, setoa, misc, khan letter remaps, hpf, mpf, tilesets), exported so hosts and tests can assert on the stableruleIdstrings the planned C# port must copy.PaletteLookup.getResolvedPaletteForId— additive; reports the real palette number and the luminance-blend flag.getPaletteForIdis now a wrapper, behavior unchanged.tests/fixtures/palette-resolution.json— frozen cross-port conformance contract (~90 match cases covering every ladder row and all four ordering hazards) plus gated real-client cases.Version 3.1.0 (additive), changelog entry, README section.
Test plan
stcpal/stspal/mptpal/mpspaltable naming, the khan archive wiring, and the spec's open question §8.1 (national.dat/misc.datresolve via the siblinglegend.pal).tsc --noEmitandtsupbuild clean;PaletteResolversmoke-tested from the built bundle.🤖 Generated with Claude Code