I got tired of manually converting 24 bit hex colors (like
0xRRGGBB) into 15
bit BGR555 colors (like
0b0BBBBBGGGGGRRRRR) so I slapped this together to do
it for me. Be warned that the 4 character color it outputs is in BGR format
for use on the Game Boy Color and the Game Boy Advance instead of RGB. It also
outputs a 24 bit representation of the 15 bit color (still in
use in things like your sprite software.
It outputs a rounded down and rounded up variant, it's up to you to look at it and decide which you like, because they may differ significantly.
Also, note that I do NO input checking beyond making sure that the color is provided in the first place, so use weird inputs at your own risk.
git clone https://sr.ht/~nytpu/rgb555conv cd rgb555conv gcc -Wall -pedantic -O3 -o rgb555conv main.c
send patches and reports to ~firstname.lastname@example.org