Jo Engine 2026.11.6
Jo Sega Saturn Engine
Loading...
Searching...
No Matches
palette.h File Reference

Jo Engine Palette Handling. More...

Go to the source code of this file.

Macros

#define JO_PALETTE_MAX_COLORS
 Define the maximum of color entry available on each palette.
#define JO_PALETTE_LIGHT_COLOR(PALETTE_ID, FIRST, I)
 Color code of the color i of the shades written by jo_palette_set_light_shades() (its darkest shade).

Functions

void jo_create_palette (jo_palette *const output)
 Create a new palette with 255 entries maximum.
void jo_palette_set_light_shades (jo_palette *const palette, const int first, const jo_color *const colors, const int count, const int levels)
 Write the shades of colors in a palette for the palette lighting (see jo_3d_set_palette_light()): the shade s (0 = the darkest, levels - 1 = the brightest) of the color i is the index first + s * count + i.
static __jo_force_inline jo_color jo_palette_color (const jo_palette *const palette, const int index)
 Color code of a color of a palette: a polygon of this color (jo_3d_set_mesh_polygon_color()) has the color of the palette, in all the modes.
static __jo_force_inline void jo_palette_to_cram (unsigned short *restrict data, unsigned short *restrict cram_addr, unsigned int size)
 Copies the image palette data to CRAM.
static __jo_force_inline void jo_create_palette_from (jo_palette *const output, unsigned short *data, unsigned int size)
 Create a new palette from existing data.
void jo_set_palette_register (const unsigned short palette_index, const jo_color color)
 Set palette index color.
jo_color jo_get_palette_register (const unsigned short palette_index)
 Get palette color from index.

Detailed Description

Jo Engine Palette Handling.

Author
Johannes Fetz
Bug
No known bugs.

Macro Definition Documentation

◆ JO_PALETTE_LIGHT_COLOR

#define JO_PALETTE_LIGHT_COLOR ( PALETTE_ID,
FIRST,
I )

Color code of the color i of the shades written by jo_palette_set_light_shades() (its darkest shade).

◆ JO_PALETTE_MAX_COLORS

#define JO_PALETTE_MAX_COLORS

Define the maximum of color entry available on each palette.

Warning
MC Hammer: don't touch this

Function Documentation

◆ jo_create_palette()

void jo_create_palette ( jo_palette *const output)

Create a new palette with 255 entries maximum.

Parameters
outputThe new palette: output->data[k] is the color of the pixels of index k + 1 (the index 0 is transparent; the TGA files: their index + 1)

See also jo_sprite_set_palette_id()

◆ jo_create_palette_from()

__jo_force_inline void jo_create_palette_from ( jo_palette *const output,
unsigned short * data,
unsigned int size )
static

Create a new palette from existing data.

Parameters
outputThe new palette
dataData source
sizeData size

See also jo_sprite_set_palette_id()

◆ jo_get_palette_register()

jo_color jo_get_palette_register ( const unsigned short palette_index)

Get palette color from index.

Parameters
palette_indexpalette Index
Returns
color Color

◆ jo_palette_color()

__jo_force_inline jo_color jo_palette_color ( const jo_palette *const palette,
const int index )
static

Color code of a color of a palette: a polygon of this color (jo_3d_set_mesh_polygon_color()) has the color of the palette, in all the modes.

Parameters
palettePalette (jo_create_palette())
indexIndex of the color in the palette (1 to 255: palette->data[index - 1])
Returns
jo_color

◆ jo_palette_set_light_shades()

void jo_palette_set_light_shades ( jo_palette *const palette,
const int first,
const jo_color *const colors,
const int count,
const int levels )

Write the shades of colors in a palette for the palette lighting (see jo_3d_set_palette_light()): the shade s (0 = the darkest, levels - 1 = the brightest) of the color i is the index first + s * count + i.

Parameters
palettePalette (jo_create_palette())
firstIndex of the darkest shade of the first color (1 to 255; a multiple of 16 for the textures of 16 colors)
colorsColors (the color itself at the shade levels / 2, from 35 % of it at the shade 0 to 125 % at the last one)
countColors count (16 for a texture of 16 colors: its color bank is the shade 0)
levelsShades of each color (2 to 32)
Remarks
The polygon of the color i: jo_3d_set_mesh_polygon_color(mesh, JO_PALETTE_LIGHT_COLOR(palette->id, first, i), index)

◆ jo_palette_to_cram()

__jo_force_inline void jo_palette_to_cram ( unsigned short *restrict data,
unsigned short *restrict cram_addr,
unsigned int size )
static

Copies the image palette data to CRAM.

Parameters
dataData source
cram_addrColor RAM address
sizeData size

◆ jo_set_palette_register()

void jo_set_palette_register ( const unsigned short palette_index,
const jo_color color )

Set palette index color.

Parameters
palette_indexpalette Index
colorColor