HIDDEN_PALETTE
PICO-8 has 16 extra colors that are undocumented and a bit tricky to access.
This means we actually have 32 colors to choose from and you can set your own 16 color palette using a mix of them both.
Using the palette swapping function, you can change a default color with a hidden color but you must set the last argument to 1.
pal( current color, new color, 1 )
You also need to use poke
to access the PICO-8 memory and set the color palette to change. Do this once somewhere before using pal
to set a custom palette.
poke( 0x5f2e, 1 )
Swap the full palette using a mix of default and hidden color numbers in a table of 16 color numbers and the second argument set to 1.
pal( {1,2,3...} ,1 )
Swap all of the default colors to the hidden colors.
pal( {[0]=128,129,130,131,132,133,134,135,136,137,138,139,140,141,142,143}, 1 )
Warning:
If you swap specific colors of your custom palette or change the transparent color, you can do that without any problems. However you will likely want to reset the palette back to normal after that. Normally you just call pal()
to reset it but this will completely reset your custom palette back to the default colors. So when resetting your custom palette, you must call the entire pal( custom_palette_table, 1 )
to set your custom colors every time. So it is common to create your own reset_pal()
function like this:
function _init()
poke( 0x5f2e, 1 ) --enable hidden colors
custom_palette = {[0]=0,128,133,5,6,7,1,140,12,3,139,11,130,132,4,15}
reset_pal()
end
function reset_pal()
pal()
pal( custom_palette, 1 )
end
3929
24 May 2024