fix: use correct 5-bit to 8-bit color conversion formula#44
Merged
eddmann merged 2 commits intoNov 11, 2025
Conversation
Changes the CGB color conversion from simple multiplication/division to the bit-perfect formula specified in cgb-acid2 test documentation: (r << 3) | (r >> 2) This ensures accurate color reproduction that matches hardware behavior and passes color accuracy requirements for test ROMs. Before: RGB555(13,23,31) -> RGB888(106,189,255) ❌ After: RGB555(13,23,31) -> RGB888(107,189,255) ✅ Improves cgb-acid2 output accuracy from 83.36% to proper color values. Note: cgb-acid2 still shows 84.96% similarity to reference due to separate PPU rendering issues (yellow/black pixels rendering as white in mouth/nose regions). Color conversion is now correct. Affects: src/Ppu/Color.php:56-62
Documents the color conversion fix and remaining PPU rendering issues: Fixed (84.96% similarity achieved): - ✅ 5-bit to 8-bit color conversion now bit-perfect - ✅ Colors render correctly per CGB hardware spec Remaining Issues (15.04% difference from reference): - Yellow/black pixels rendering as white (3,376 pixels) - Primarily affecting mouth (1,306px) and nose (238px) regions - Root causes likely: palette selection, priority handling, or VRAM banking Analysis includes: - Detailed pixel difference breakdown - Color substitution patterns - Affected regions mapped to test features - Recommended investigation steps - Reference links and success criteria This provides a roadmap for achieving 100% cgb-acid2 compliance.
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.
Changes the CGB color conversion from simple multiplication/division
to the bit-perfect formula specified in cgb-acid2 test documentation:
(r << 3) | (r >> 2)
This ensures accurate color reproduction that matches hardware behavior
and passes color accuracy requirements for test ROMs.
Before: RGB555(13,23,31) -> RGB888(106,189,255) ❌
After: RGB555(13,23,31) -> RGB888(107,189,255) ✅
Improves cgb-acid2 output accuracy from 83.36% to proper color values.
Note: cgb-acid2 still shows 84.96% similarity to reference due to
separate PPU rendering issues (yellow/black pixels rendering as white
in mouth/nose regions). Color conversion is now correct.
Affects: src/Ppu/Color.php:56-62