SNES Palette info needed

Dejap's website appears to be defunct. This forum is now in archive mode.

Moderator: Dejap Staff

Locked
sage

SNES Palette info needed

Post by sage »

Hi, I'm just starting to learn how to edit ROMS and I need to know somethings about the palettes for SNES games. I found the "SNES palette Format by Jay" article and the "Tile Layer Pro " Program so the editing I think I can handle. This is the first time i've tried anything like this and am willing to experiment to findout how exactly my changes effect the game but having these starting points would be a great help.

Where is the palette info located?
Is there more than one palette for a single game?
Do games like Super Mario All Stars have any special characteristics that make the handling of palletes differnt from other simpler games?

Thanks for any help I may get.
grinvader
ZSNES Shake Shake Prinny
Posts: 5632
Joined: Wed Jul 28, 2004 4:15 pm
Location: PAL50, dood !

Post by grinvader »

The SNES can use any colour in 555 RGB in up to 8 different 16-colour palettes.
Palette data location starts at CGRAM+128. First colour of each palette is always transparent. You can write CGRAM (stored in BGR order) anytime during force-, H- or V-blank.
Also, palettes 4-7 allow tiles to participate in colour math.

Which palette is used for a sprite tile is stored in the OAM low table.

For backgrounds, it depends which mode you're in and if you're using direct colour mode or not... it's quite lengthy.
皆黙って俺について来い!!

Code: Select all

<jmr> bsnes has the most accurate wiki page but it takes forever to load (or something)
Pantheon: Gideon Zhi | CaitSith2 | Nach | kode54
anomie
Lurker
Posts: 151
Joined: Tue Dec 07, 2004 1:40 am

Post by anomie »

Palette data is stored in CGRAM, which is accessed via PPU2 Registers $2121, $2122, and $213B. CGRAM is 256 15-bit words. All colors are stored in BGR555 format. Thus, there is no place in ROM to find palettes, you have to look for writes to $2122 (note DMA and HDMA may be used for this prupose).

OBJ and BGs usually use a smaller "sub-palette" from this 256-color master palette, which are typically called palettes as well. The palettes are all stored contiguously, so for example sprites' palette 0 is at 128-143, palette 1 is at 144-159, ... and palette 7 is at 240-255. In any case, color #0 in any sub-palette is always considered transparent.

As grinvader states, sprites have eight 16-color palettes starting at CGRAM index 128. Only OBJ with palettes 4-7 participate in color math.

BGs depend on the BG mode. All BGs have access to 8 palettes, and except for Mode 0 the palettes are stored beginning at CGRAM index 0.

Mode 0 has 4 BGs, each with access to 8 4-color palettes chosen per tile. BG1's palettes start at CGRAM index 0, BG2's at 32, BG3's at 64, and BG4's at 96. All other modes begin all palettes at CGRAM index 0.

Mode 1 has 3 BGs. BG1 and BG2 have 16-color palettes, while BG3 has 4-color palettes. So yes, the palettes here overlap: changing BG3's palette 1 color #2 would also change BG1/2's palette 0 color #6.

Mode 2 has 2 BGs, both 16-color.

Mode 3 has one 256-color BG (with effectively only one palette) and one 16-color BG. Yes, the 256-color palette overlaps the OBJ palettes beginning at CGRAM index 128, as well as the eight 16-color palettes for BG2.

Mode 4 has one 256-color BG (with effectively only one palette) and one 4-color BG.

Mode 5 has one 16-color BG and one 4-color BG.

Mode 6 has only 1 BG, at 16 colors.

Mode 7 has 2 BGs, but they cannot be scrolled independantly so many existing docs only recognize one with some special semantics. The first BG is 258-color, while the second is 128-color. Both have only one palette available, and in fact Mode 7 uses a different tilemap format that lacks palette selection bits.

Also, it is possible to use the 256-color BGs of Modes 3 and 4, combined with the otherwise useless palette selection bits, as a direct color BGR344 background. Similarly, the 256-color Mode 7 BG may be used as a direct color BGR233 background.

Also note, the SNES uses the otherwise-useless CGRAM color #0 as the backdrop color, for pixels that are not covered by any BG or OBJ. There is also the Fixed Color set by PPU register $2132, used in certain modes of color math.

Note that the SNES can display more than just 256 colors on the screen at any one time. First, CGRAM may be written during the horizontal blanking period, to change colors per scanline. Second, the SNES supports several modes of Color Math: Addition, Half-Addition (averaging), Subtraction, and Half-Subtraction. Color Math can be independantly enabled per-BG, for all OBJ (with palettes 4-7), and for the color-0 backdrop. Color math can be performed using the Fixed Color or using the Subscreen data.
Locked