Repository navigation
video: mask palette indices to the palette's size (fixes dark SMS sprites) - #31
Merged
Merged
Conversation
convert_tile() looked 8-bit pixels up in the core's palette unmasked. smsplus keeps flags in the upper bits of its pixels (0x40 marks a sprite pixel, 0x20 a high-priority one) and hands over a 32-color palette, so every sprite pixel (0x50-0x5F) read 64 entries past its end: the colors came from whatever the linker put after the port's palette array (seen as a near-black Sonic and dark rings in Sonic the Hedgehog; it depends on the build's layout and on those variables' contents). The box masks with palette_size - 1 in its video task; the Tab5 now does the same in every lookup (a no-op for 256-color palettes). Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01SFCMzomCZ5wRHJN4sxwkvY
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
Fixes near-black sprites in Master System and Game Gear games. In Sonic the Hedgehog, Sonic was nearly black and the rings dark grey.
Tab5Emu::convert_tile()used each 8-bit pixel as a palette index without masking it.palette_size - 1in its video task; the Tab5 now does the same in every palette lookup (12). With 256-color palettes (Jedi Knight, Dark Forces, NES) the mask is 0xFF, so nothing changes for them.Testing
🤖 Generated with Claude Code
https://claude.ai/code/session_01SFCMzomCZ5wRHJN4sxwkvY