Code: Select all
//call this for each color channel, obviously it won't work on a packed pixel
uint64_t normalize(uint64_t color, unsigned sourceDepth, unsigned targetDepth) {
while(sourceDepth < targetDepth) {
color = (color << sourceDepth) | color;
sourceDepth += sourceDepth;
}
if(targetDepth < sourceDepth) color >>= (sourceDepth - targetDepth);
return color;
}
ZSNES, from my testing, was using an RGB55 (or 565, I forget) surface with DirectDraw, which did not compensate for this. So a solid white screen in that emulator appears as #f8f8f8 (very slightly gray), not #ffffff. They no doubt chose to use a 16-bit surface anyway because it was marginally faster than copying a 32-bit surface. But comparing that slight inaccuracy against the flat-out completely wrong gamma is kind of silly. Images are blindingly bright if you don't correct the gamma difference between a TV and LCD monitor.
Fun side-tangent: SNES brightness register is a luminance adjust, not an RGB555 adjust. As such, it's technically possible to choose from more than 32768 color shades. But good luck computing exactly how many (certainly there's bound to be a lot of overlap between the different luma settings.)