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.