KallistiOS git master
Independent SDK for the Sega Dreamcast
Loading...
Searching...
No Matches
pvr_pal.h
Go to the documentation of this file.
1/* KallistiOS ##version##
2
3 dc/pvr/pvr_pal.h
4 Copyright (C) 2002 Megan Potter
5 Copyright (C) 2014 Lawrence Sebald
6 Copyright (C) 2023 Ruslan Rostovtsev
7 Copyright (C) 2024 Falco Girgis
8*/
9
10/** \file dc/pvr/pvr_pal.h
11 \brief Palette API for the PowerVR
12 \ingroup pvr_pal_mgmt
13
14 \author Megan Potter
15 \author Roger Cattermole
16 \author Paul Boese
17 \author Brian Paul
18 \author Lawrence Sebald
19 \author Benoit Miller
20 \author Ruslan Rostovtsev
21 \author Falco Girgis
22*/
23
24#ifndef __DC_PVR_PVR_PALETTE_H
25#define __DC_PVR_PVR_PALETTE_H
26
27#include <stdint.h>
28
29#include <sys/cdefs.h>
30__BEGIN_DECLS
31
32/** \defgroup pvr_pal_mgmt Palettes
33 \brief Color palette management API of the PowerVR
34 \ingroup pvr_global
35
36 In addition to its 16-bit truecolor modes, the PVR also supports some
37 nice paletted modes.
38
39 \remark
40 These aren't useful for super high quality images most of the time,
41 but they can be useful for doing some interesting special effects,
42 like the old cheap "worm hole".
43*/
44
45/** \brief Color palette formats of the PowerVR
46 \ingroup pvr_pal_mgmt
47
48 Entries in the PVR's palettes can be of any of these formats. Note that you
49 can only have one format active at a time.
50*/
51typedef enum pvr_palfmt {
52 PVR_PAL_ARGB1555, /**< 16-bit ARGB1555 palette format */
53 PVR_PAL_RGB565, /**< 16-bit RGB565 palette format */
54 PVR_PAL_ARGB4444, /**< 16-bit ARGB4444 palette format */
55 PVR_PAL_ARGB8888 /**< 32-bit ARGB8888 palette format */
57
58/** \brief Set the palette format.
59 \ingroup pvr_pal_mgmt
60
61 This function sets the currently active palette format on the PVR. Each
62 entry in the palette table is 32-bits in length, regardless of what color
63 format is in use.
64
65 \warning
66 Be sure to use care when using the PVR_PAL_ARGB8888 format. Rendering speed
67 is greatly affected (cut about in half) if you use any filtering with
68 paletted textures with ARGB8888 entries in the palette.
69
70 \param fmt The format to use
71*/
73
74/** \brief Set a palette value.
75 \ingroup pvr_pal_mgmt
76
77 Note that while the color format is variable, each entry is still 32-bits in
78 length regardless (and you only get a total of 1024 of them). If using one
79 of the 16-bit palette formats, only the low-order 16-bits of the entry are
80 valid, and the high bits should be filled in with 0.
81
82 \param idx The index to set to (0-1023)
83 \param value The color value to set in that palette entry
84*/
85static inline void pvr_set_pal_entry(uint32_t idx, uint32_t value) {
86 PVR_SET(PVR_PALETTE_TABLE_BASE + 4 * idx, value);
87}
88
89__END_DECLS
90
91#endif /* __DC_PVR_PVR_PALETTE_H */
static void pvr_set_pal_entry(uint32_t idx, uint32_t value)
Set a palette value.
Definition pvr_pal.h:85
pvr_palfmt_t
Color palette formats of the PowerVR.
Definition pvr_pal.h:51
void pvr_set_pal_format(pvr_palfmt_t fmt)
Set the palette format.
@ PVR_PAL_ARGB1555
16-bit ARGB1555 palette format
Definition pvr_pal.h:52
@ PVR_PAL_ARGB4444
16-bit ARGB4444 palette format
Definition pvr_pal.h:54
@ PVR_PAL_RGB565
16-bit RGB565 palette format
Definition pvr_pal.h:53
@ PVR_PAL_ARGB8888
32-bit ARGB8888 palette format
Definition pvr_pal.h:55
#define PVR_SET(REG, VALUE)
Set a PVR register value.
Definition pvr_regs.h:57
#define PVR_PALETTE_TABLE_BASE
Base of the palette table.
Definition pvr_regs.h:156