MiSTer-devel / NeoGeo_MiSTer

NeoGeo for MiSTer
GNU General Public License v2.0
148 stars 78 forks source link

fix incorrect expansion of colors #127

Closed Kitrinx closed 3 years ago

Kitrinx commented 3 years ago

The MSB was accidently being used twice in color expansion causing an uneven color ramp.

Kitrinx commented 3 years ago

@jotego I am unclear what these values in this chart are supposed to represent. What are the X and Y in these cases?

Typical color expansion repeats the existing color value from MSB to LSB until you reach the desired number of bits. In old implementation, the MSB of the 5 bit color was used to expand by one prior to subtracting the dark bit, and then used again when expanding the 6 bit resulting number to 8 bit. In actually it should use the top three MSB, so the bottom two of the 8 bit color should be bits 4, 3, and 2 of the 5 bit number. The way it is written makes this less obvious, but it just expands at two different times when reaching 8 bits from 5 bits.

jotego commented 3 years ago

I see. It makes sense with your explanation. The problem was that by doing the expansion in two steps, it wasn't as precise as doing it in one. I see your point now. Thanks.

Kitrinx commented 3 years ago

Probably it would be much more clear to expand to 8 bits initially and then subtract 4 for the dark bit, but I think that there isn't a logical difference to do so.

sorgelig commented 3 years ago

ok, let's use it till better option.