Board Thread:Questions and Answers/@comment-24865336-20150610214031

For those of you have read my recent contribution containing most(for now) of the format specifications of the Petit Comuter files. You will have taken notice to the strange color model of the palette. Well there is something even more confusing that I have not been able to crack and I was hoping to get some ideas on what I am doing wrong.

So first off we all know there are three colors, two 5bpp red and blue channels that increment in units of 8, and the green channel which is 6bpp and is twice as precise. However there is a strange anomaly in how these channels are calculated. The common formula for converting from 0-255(&hFF) range to 0-31(DS range) and 0-63(BPP6) is,

BPP6 = (BPP8 * 63) / 255

BPP5 = (BPP8 * 31) / 255

Where BPP6/5 and BPP8 are unsigned integers. Results would go as follows for BPP6 and PTC green channel returned from COLREAD.

Num given:

0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13

PTC:

0, 0, 0, 0, 4, 4, 4, 4, 8, 8,  8,   8, 12, 12

Standard Formula:

0, 0, 0, 0, 0, 4, 4, 4, 4, 8,  8,   8,  8, 12

As you can see the 256-to-64 formula is behind by 1, which does not happen in the 256-to-31 formula. Also there are occasional moments in the PTC results where it will jump up by 5 instead of 4.

40 -> 45, 125 -> 130, 210 -> 215

Where it will then reach 255 once the number given is >=252

Any help is appreciated on cracking this formula. 