You can set a custom color palette for a screen, by creating a custom VDL, which can be an involved process. A custom VDL lets you change color palettes from line to line within a screen. If you simply want to set a color palette for an entire screen that uses a simple VDL (one that doesn't change parameters from line to line), you can use the simpler Graphics folio color calls. These calls accept new color entries for a screen's CLUT set and then revise the screen VDL appropriately. You don't have to deal directly with the VDL.
When a 15-bit RGB value enters the CLUT set, it's broken into its red, green, and blue components. Each component enters the appropriate CLUT, where it selects a corresponding 8-bit red, green, or blue value. The three outputs are combined into a 24-bit RGB value that is then used for that pixel in the rest of the display generator.
The CLUT for each color has 33 registers: numbers 0-31 are for direct color indexing; number 32 is for any pixel marked as background. Although red, green, and blue are separated when they enter the CLUT set and the CLUT set is treated as three CLUTs, one for each color, the physical reality of the CLUT hardware is that each CLUT register extends across all three colors. That is, each register is 24 bits wide. The first 8 bits are for red, the second 8 bits for green, and the last 8 bits for blue. When the VDL processor writes a new register value into the CLUT set, it writes a 24-bit value that changes red, green, and blue for that register number. For example, if the VDL processor sets a new value for register 3, it writes a 24-bit value that changes red register 3, green register 3, and blue register 3.
MakeCLUTColorEntry
to specify red, green, and blue together and then return a value you can use to set red, green, and blue within a CLUT register:
VDLEntry MakeCLUTColorEntry( index, red, green, blue )
MakeCLUTColorEntry
accepts an unsigned index byte that indicates which CLUT set register you want to change. A value of 0 to 31 indicates registers 0 to 31 in the CLUT set; a value of 32 indicates the background register.
MakeCLUTColorEntry
also accepts an unsigned byte each for the red, green, and blue value you want to set in the CLUT set register. A minimum value of 0 indicates none of the color, while a maximum value of 255 indicates as much of the color as possible.
MakeCLUTColorEntry()
returns a 32-bit value that you can use with the color-setting calls to change CLUT set registers.
To specify only a red, a green, or a blue value to write into a CLUT register without touching any of the other color values in the register, use these three calls:
Each macro accepts an unsigned index byte to indicate which CLUT set register you want to change, and then accepts an unsigned byte that signifies a red, green, or blue color value you want to set. Use
VDLEntry MakeCLUTRedEntry( index, red )
VDLEntry MakeCLUTGreenEntry( index, blue )
VDLEntry MakeCLUTBlueEntry( index, blue )
MakeCLUTRedEntry()
to specify a red value, MakeCLUTGreenEntry()
to specify a green value, and MakeCLUTBlueEntry()
to specify a blue value.
Each of these macros returns a 32-bit value to use with a color-setting call.
int32 SetScreenColor( Item screenItem, uint32 colorEntry )
SetScreenColor()
accepts the item number of the screen for which you want to change the color palette. It also accepts a color entry value created by any of the four CLUT entry macros: MakeCLUTColorEntry(), MakeCLUTRedEntry()
, MakeCLUTGreenEntry(),
and MakeCLUTBlueEntry()
. The color value specifies the color register and the colors you want to change. SetScreenColor()
then changes the screen's VDL so the screen uses the custom CLUT set (if it was using the fixed CLUT set) and so the appropriate register in the CLUT set uses the new color or colors you specified.
SetScreenColor()
returns 0 if successful, or a negative number (an error code) if unsuccessful. This macro only works on VDLTYPE_Simple
screen items.
The macro accepts the item number of the screen for which you want to change the color palette. It also accepts a pointer to a list of 32-bit color entries and a 32-bit count value that gives the number of entries in the list. Each of the color entries is a value set by one of the four CLUT entry calls.
int32 SetScreenColors( Item screenItem, int32 *entries, int32 count )
When SetScreenColors()
executes, it reads each color entry, and then changes the specified screen's VDL appropriately so that it uses the custom CLUT set and writes the specified colors into the specified CLUT set registers. This macro only works on VDLTYPE_Simple
screen items.
It accepts an index number from 0 to 32 that specifies registers 0 to 31 or the background register (32) of the CLUT set. It returns a 24-bit RGB value if successful. The first byte of the RGB value is red, the second is green, and the third is blue. The macro returns a negative number (an error code) if unsuccessful. This macro only works on
RGB888 ReadCLUTColor( ulong index )
VDLTYPE_Simple
screen items.
It accepts the item number of the screen for which you want to reset the palette and, when it is executed, changes the screen's simple VDL so it specifies the fixed CLUT set for the entire screen. It returns 0 if successful, or a negative number (an error code) if unsuccessful. This macro only works on
int32 ResetScreenColors( Item screenItem )
VDLTYPE_Simple
screen items.