HTML hexadecimal colors are written with 6 digits (3 bytes, a so called, A hex triplet). The Amiga's color registers takes a word (2 bytes, 16-bits) which defines a color.
Example:
There must be some kind of algorithm (or/and) some tools for converting between HTML-colors and Amiga colorregisters in an easy way? Or?... Please help:)
http://en.wikipedia.org/wiki/List_of_monochrome_and_RGB_palettes#12-bit_RGB says that there are just 4 bits used for each of R, G, and B.
In other words - I suspect that if you take the top half of each 16 bit hex pair, and string them together, you get the Amiga color.
In your example:
R = 0xFF
G = 0xFF
B = 0xF0
Take the top half (bold above):
AmigaRGB = ((R & 0xF0) << 4) + (G & 0xF0) + ( B >> 4 )
This does indeed result in 0x0FF0
Going in the other direction:
R = AmigaRGB & (0x0F00) >> 4
G = AmigaRGB & (0x00F0)
B = AmigaRGB & (0x000F) << 4
If you wanted to be fancy you could add some rounding, dithering etc.
Of course the final value used in HTML is
HTML_RGB = R<<16 + G<<8 + B
I hope this helps.
It depends on where you want to use the value, direct hardware access or graphics.library.
For direct hardware access or graphics.library -> setRGB4/loadRGB4 you need to convert to 16 bit-word where bits 15-12 are don't cares: xRGB (each nibble 4 bits). Just throw away each second digit of the HTML hex value.
For graphics.library (version >=39) -> setRGB32/loadRGB32 you need 3x32 bits with the MSB adjusted to the left (bit 31). That means you take the HTML value and split it into R, G and B (2 digts each) and pad it with six zeros to the right.
HTML: #123456 setRGB32: #$12000000, #$34000000, #$56000000
For direct hardware access to the AA-color registers, just google it. Its goddamn complicated, because there are only 32 12-bit color registers and bank-switching via a control register to select bank and lower/upper half.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With