VDP color ramp

Despite what may be your first impression, the color ramp output by the Mega Drive VDP is not linear. Nor logarithmic. It's some, er, particular curve which is more flattened near the middle than the extremes. Failure to account for this can lead to dark pictures looking brighter than intended and vice versa.

Mode 5 ramp

(chart, see paragraph below)

In a scale from 0 to 255, the approximate values are: 0, 29, 52, 70, 87, 101, 116, 130, 144, 158, 172, 187, 206, 228, 255. The normal colors are every other value, the shadow colors the first eight values, and the highlight colors the last eight values.

Output level for VDP colors
CRAM valueNormalShadowHighlight
000130
25229144
48752158
611670172
814487187
A172101206
C206116228
E255130255

On hardware, these values represent voltages from 0V to 1V (where 255 = 1V).

Mode 4 ramp

Turns out that ramps can be slightly different per component, and again this differs per VDP revision, so consider this information outdated. These ramps are still much more accurate than linear ramps, so they can still be used for reference meanwhile.

The ramp for mode 4 is much closer to linear, with 1/3 being slightly brighter and 2/3 being almost perfect (on a Master System). The exact levels vary slightly between Master System revisions and the Mega Drive.

Mega Drive has the same squishing that it has in mode 5, but it's not anywhere as pronounced in this case.

Explanation

This weird ramp seems to have been unintentional: a look at the Mega Drive VDP die shows that the three DACs are resistors with multiple taps (one for each possible value), and that the taps are evenly spaced. Seems that they failed to account for analog effects that distort the values coming out of it.

Mode 4 also has two dedicated taps for its 1/3 and 2/3 output levels, this likely exacerbated the aforementioned effect.