As far as I see, the R, G and B components of colors in SNES emulators like ZSNES are converted like this:
PcValue = SnesValue * 256 / 32
This has the strange behavior that white is 248,248,248 instead of 255,255,255.
Then I've read some stuff about replicating the top three bits into the bottom three bits to get to the full range. Which sounds totally random and nonsensical to me. Why should you ever do this? In how far do the upper and the lower bits have any connection to each other to ever justify this kind of behavior?
Why don't they simply use the formula:
PcValue = SnesValue * 255 / 31
In this case, white is actually 255,255,255 and black is still 0,0,0.
And the colors (well, their exact values, not the rounded integers) are still evenly distributed.
So, why this crappy calculation with 32 and 256 instead of 31 and 255? And why some strange hack about replicating bits that have nothing to do with each other?
If calculating with 31 and 255 is a speed issue: Just declare a lookup array. It takes you exactly 32 bytes of space. Then you can do:
PcValue = AllPcValues[SnesValue]
PcValue = SnesValue * 256 / 32
This has the strange behavior that white is 248,248,248 instead of 255,255,255.
Then I've read some stuff about replicating the top three bits into the bottom three bits to get to the full range. Which sounds totally random and nonsensical to me. Why should you ever do this? In how far do the upper and the lower bits have any connection to each other to ever justify this kind of behavior?
Why don't they simply use the formula:
PcValue = SnesValue * 255 / 31
In this case, white is actually 255,255,255 and black is still 0,0,0.
And the colors (well, their exact values, not the rounded integers) are still evenly distributed.
So, why this crappy calculation with 32 and 256 instead of 31 and 255? And why some strange hack about replicating bits that have nothing to do with each other?
If calculating with 31 and 255 is a speed issue: Just declare a lookup array. It takes you exactly 32 bytes of space. Then you can do:
PcValue = AllPcValues[SnesValue]