# Creating and Loading a PLUT

Setting the 32 values in the PLUT registers of the cel engine determines the colors and VH values the PLUT puts out to the pixel decoder and the projector. To load a custom PLUT for a cel, first you must create the custom PLUT. A PLUT is simply a collection of 32 16-bit values that are read into the PLUT registers. The values are stored two to a word in a register order from register 0 to register 31.

Once the custom PLUT is created, you set the `LDPLUT` flag of the CCB's FLAGS word to 1 to load the PLUT. You place a pointer to the first word of the PLUT and the place it in the `PLUTPTR` word of the CCB. `PLUTPTR` can be either absolute or relative; you must set one or the other in the `PPABS` flag of the FLAGS word.

When the cel engine encounters a set `LDPLUT` flag, it uses the `PLUTPTR` to go to the first word of the PLUT. It then determines the number of bits used per pixel by reading the bpp value in the cel's preamble.

The hardware always loads a minimum number of PLUT words if the `CCB_LDPLUT` bit is set. A 1- or 2-bpp cel causes the minimum number of PLUT words to be read into the first colors in the PLUT table. A 4-bpp cel loads 8 PLUT words, loading over the first 16 colors in the PLUT table. A 6-, 8- or 16-bpp cel causes 16 PLUT words to be loaded, setting all 32 entries in the PLUT table. The hardware always loads the PLUT data into the first entries of the PLUT table, regardless of the setting of the `PLUTA` bit in the `CCB_FLAGS` word.

When you create a PLUT, keep in mind the bpp load limits and the registers where the new PLUT values are loaded. If you create a PLUT for a 1-, 2-, or 4-bit cel, you do not need to create a PLUT larger than four words; any extra words are ignored. You should also know exactly how many registers are loaded; a 1-bit PLUT loads eight registers, which you should keep in mind if you think that only two registers are changed. The `PLUTA` bits of the CCB can also change which registers the cel uses; for example, they can be set to 1111 for a 1-bit cel, which means that the cel uses registers 30 and 31. Loading a custom PLUT for such a cel means that the registers used will not be affected by the PLUT loading.