Skip to main content

Module palette

Module palette 

Source
Expand description

Palettes: what the two bits of a pixel turn into.

A tile pixel is two bits, so it names a colour index rather than a colour. What that index becomes is the palette’s business, which is why the same tile can be drawn light in one place and dark in another.

On the original Game Boy the four shades are fixed in hardware and a palette only chooses which index gets which of them. On the Game Boy Color a palette holds four real colours. See https://gbdev.io/pandocs/Palettes.html.

Index 0 is transparent for objects, which leaves the lowest two bits of an object palette unused.

An original Game Boy ignores the colour registers and keeps drawing with the shades set_background chose, so a cartridge that runs on both machines can set colours without asking which it is on.

Structs§

Colorcgb
One colour, five bits per channel.

Enums§

ObjSlot
Which of the two object palettes, as OamAttr::dmg_palette picks between.

Constants§

COLORScgb
Colours in one palette.
PALETTEScgb
Palettes of each kind: this many for the background, and as many again for objects.

Functions§

background
The palette the background and window are drawn with.
object
One of the two object palettes.
set_background
Set the palette the background and window are drawn with.
set_background_colorscgb
Set one background palette.
set_object
Set one of the two object palettes.
set_object_colorscgb
Set one object palette.