Fix brightness tables: identity mapping for palette columns D/E/F#337
Fix brightness tables: identity mapping for palette columns D/E/F#337jonathanpeppers wants to merge 2 commits intomainfrom
Conversation
The old clbr/neslib brightness tables mapped NES color columns D, E, F to 'safe' values (e.g. 0x0D->0x0F, 0x1D->0x00, 0x3D->0x20). The reference crypto ROM uses full identity mapping for these columns at each brightness level, which is what modern neslib versions use. This caused palette colors like 0x0D (dark blue) and 0x3D (light blue) to display as wrong colors at runtime. Verified by dumping brightness tables from the reference ROM via Mesen2 and comparing byte-for-byte. Fixes #315 Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
There was a problem hiding this comment.
Pull request overview
This PR fixes incorrect palette rendering for NES palette columns D/E/F by updating the built-in palette brightness lookup tables to use identity mappings, aligning runtime behavior with the reference ROM.
Changes:
- Updated
palBrightTable4–palBrightTable7to map colors$xD/$xE/$xFto themselves rather than “safe” substitutes. - Updated transpiler snapshot outputs (
*.verified.bin) to reflect the new ROM bytes for the brightness tables.
Reviewed changes
Copilot reviewed 1 out of 39 changed files in this pull request and generated no comments.
Show a summary per file
| File | Description |
|---|---|
| src/neslib/NESLib.cs | Adjusts palette brightness tables 4–7 to use identity mappings for columns D/E/F. |
| src/dotnes.tests/TranspilerTests.Write.transtable.verified.bin | Snapshot updated to match new ROM bytes (brightness table data). |
| src/dotnes.tests/TranspilerTests.Write.tileset1.verified.bin | Snapshot updated to match new ROM bytes (brightness table data). |
| src/dotnes.tests/TranspilerTests.Write.shoot2.verified.bin | Snapshot updated to match new ROM bytes (brightness table data). |
| src/dotnes.tests/TranspilerTests.Write.monobitmap.verified.bin | Snapshot updated to match new ROM bytes (brightness table data). |
| src/dotnes.tests/TranspilerTests.Write.hello.verified.bin | Snapshot updated to match new ROM bytes (brightness table data). |
Closing -- the current values are correctThe brightness tables on \\�sm The remapping of columns D/E/F is intentional -- Shiru's neslib avoids these colors because The reference crypto ROM compared against uses modified brightness tables that diverge from the standard neslib. dotnes should match the original upstream, not a modified fork. Closing issue #315 as well -- see comment there for full rationale. |
Problem
Palette colors in NES columns D/E/F (e.g. $0D dark blue, $3D light blue) display as wrong colors at runtime. The universal background color shows $0F (black) instead of the intended $0D.
Root Cause
The brightness lookup tables (palBrightTable4-7) used the old clbr/neslib values that map columns D/E/F to "safe" alternatives:
The reference crypto ROM uses full identity mapping for these columns. Verified by dumping brightness table bytes at runtime via Mesen2 headless test runner.
Fix
Updated palBrightTable4-7 in NESLib.cs to use identity mapping for columns D/E/F, matching the reference ROM. Updated 38 verified.bin snapshots (only the 8 brightness table bytes change in each ROM).
All 586 tests pass.