0% found this document useful (0 votes)
205 views2 pages

RGB555 Format

The document discusses the 15-bit BGR color format used by SNES, including how to convert colors between the 15-bit BGR format and standard 24-bit RGB format. It also introduces a tool called Palconv.exe that can convert between different palette formats including the SNES 15-bit BGR format.

Uploaded by

Andres Ruiz
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
205 views2 pages

RGB555 Format

The document discusses the 15-bit BGR color format used by SNES, including how to convert colors between the 15-bit BGR format and standard 24-bit RGB format. It also introduces a tool called Palconv.exe that can convert between different palette formats including the SNES 15-bit BGR format.

Uploaded by

Andres Ruiz
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 2

SNES Palette Format

By Jay

1) 15-Bit BGR format


2) Converting a 24-Bit RGB colour to a 15-Bit BGR colour
3) Converting a 15-Bit BGR colour to a 24-Bit colour
4) Palconv.exe

1) 15-Bit BGR format


If you can find one, SNES stores it's palette in 512 bytes in a 15-bit BGR format. Each BGR word is
2 bytes, thus it is 512 bytes for 256 colours (256 x 2). The format for each BGR word looks like this:

0BBBBBGG GGGRRRRR

Bit 15 is unused and should be set to 0. Each colour value can range from 0 - 31… So a R, G, B
value of 31, 31, 31 represents white. As you can see this is quite different from the usual 24-bit
RGB where the colours range from 0 - 255.

2) Converting a 24-Bit RGB colour to a 15-Bit BGR colour


In order to convert a 24-bit RGB value into the 15-Bit BGR format, the 8-bit colour value of the
24-Bit RGB colour must be scaled down to 5-bits. Then the 3 colour values must be packed into 2
bytes. This can be achieved by the following formula:

R = R DIV 8 (DIV means integer division: Same as division but any decimals are truncated)
G = G DIV 8
B = B DIV 8

colour = B x 1024 + G x 32 + R

The following example show how to convert white (255,255,255) to the 15-bit format:

R = 255 DIV 8 = 31
G = 255 DIV 8 = 31
B = 255 DIV 8 = 31

colour = B x 1024 + G x 32 + R
colour = 31 x 1024 + 31 x 32 + 31 = 32767

So white as a 15-bit BGR colour is 32767 or 0x7FFF in hex. And to clear up any confusion, YES,
this value will be stored in LSB order (otherwise known as 'bits reversed'). So you will see this as FF
7F in the hex editor.
3) Converting a 15-Bit BGR colour to a 24-Bit colour
To convert a 15-BGR value into 24-RGB values, is simply the reverse operation. The formula is:

R = (colour MOD 32) x 8 (MOD mean modulus: Means divide the number and take the
remainder)
G = ((colour DIV 31) MOD 32) x 8
B = ((colour DIV 1024) MOD 32) x 8

The following example shows how to convert white (32767) to it's respective RGB values:
colour = 32767

R = (colour MOD 32) x 8


R = (32767 MOD 32) x 8 = 31 x 8 = 248
G = ((colour DIV 31) MOD 32) x 8
G = ((32767 DIV 31) MOD 32) x 8 = (1023 MOD 32) x 8 = 31 x 8 = 248
B = ((colour DIV 1024) MOD 32) x 8
B = ((32767 DIV 1024) MOD 32) x 8 = (31 MOD 32) x 8 = 31 x 8 = 248

So the final output is (248, 248, 248). Uh-oh, 24-bit RGB white is (255, 255, 255) not (248, 248,
248). Apparently, what happened is there was a precision loss during the conversion. Think about
it… if you convert a 24-bit value into a 15-bit you would have loss some precision. Thus, when you
reverse the procedure from 15-bit to 24-bit, the precision is still lost and is unrecoverable. There is
nothing you can do about this precision loss; however, the loss is so minimal you probably won't
notice the difference between (248, 248, 248) and (255, 255, 255) anyways.

4) Palconv.exe

Disclaimer:
I'm not responsible for anything that happens to your computer when using this program. Use at
your own risk.

Palconv.exe is a tool bundled in with this tutorial that converts a palette from one format to another.
The formats supported are RAW 24-bit RGB format, 15-Bit BGR CG format, ZST save states,
MS-RIFF format, and JASC (Paint Shop Pro) palette format. To use, in DOS prompt type:

palconv <input format> <input file> <output format> <output file>

Where the input and output formats can be:


rgb 24-bit RGB Raw format
cg 15-bit BGR SNES format
zst *ZSNES Save State file
rif MS-Riff palette format
jsc JASC (Paint Shop Pro) Palette

For example, if you wanted to convert a zsnes savestate call "game.zst" into a JASC palette
"output.pal", then you'd type this:

palconv zst game.zst jsc output.pal

And voila, palette converted.

You might also like