# Color and Palette Functions

```c
set_color( unsigned int index, unsigned int value );
```

Set the specified color `index` (0-511) to the given rgb-value.

***

```c
set_color_rgb( unsigned int index, unsigned char r, unsigned char g, unsigned char b );
```

Set the specified color to the given rgb component values.

This function is easier to use than `set_color()`, but it is slower.

***

```c
get_color( unsigned int index ); 
```

Retrieve the rgb-value of the specified color.

***

{% code overflow="wrap" %}
```c
load_palette( unsigned char palette, unsigned char __far *data, unsigned int num_palettes );
```
{% endcode %}

Load one or more 16-color palette-blocks at once. `palette` is the index of the first block (0-31) to load, and `num_palettes` the number of blocks.

This function can be used to load palettes defined using `#defpal` or included with `#incpal` directives.

***

{% code overflow="wrap" %}
```c
set_sprpal( unsigned char palette, unsigned char __far *data );
set_sprpal( unsigned char palette, unsigned char __far *data, unsigned int num_palettes ); 
```
{% endcode %}

Exactly the same function as `load_palette()`, but this function offers direct access to sprite palette-blocks. Sprite palette-blocks are standard block number 16 to 31, but with this function you can simply access them with indexes 0 to 15.

This function and the `set_bgpal()` function make sprite and character palette-block manipulation easier; with them you don't have to know the real block indexes. Without the third arguments, the function loads only one block.

***

{% code overflow="wrap" %}
```c
set_bgpal( unsigned char palette, unsigned char __far *data );
set_bgpal( unsigned char palette, unsigned char __far *data, unsigned int num_palettes ); 
```
{% endcode %}

Exactly the same function has `load_palette()`, but this function offers direct access to charachter palette-blocks. Character palette-blocks are standard block number 16 to 31, but with this function you can simply access them with indexes 0 to 15.

This function and the `set_sprpal()` function make sprite and character palette-blocks manipulation easier; with them you don't have to know the real block indexes. Without the third arguments, the function loads only one block.
