Jo Engine
2026.11.1
Jo Sega Saturn Engine
Toggle main menu visibility
Loading...
Searching...
No Matches
jo_engine
jo
colors.h
Go to the documentation of this file.
1
/*
2
** Jo Sega Saturn Engine
3
** Copyright (c) 2012-2026, Johannes Fetz (johannesfetz@gmail.com)
4
** All rights reserved.
5
**
6
** Redistribution and use in source and binary forms, with or without
7
** modification, are permitted provided that the following conditions are met:
8
** * Redistributions of source code must retain the above copyright
9
** notice, this list of conditions and the following disclaimer.
10
** * Redistributions in binary form must reproduce the above copyright
11
** notice, this list of conditions and the following disclaimer in the
12
** documentation and/or other materials provided with the distribution.
13
** * Neither the name of the Johannes Fetz nor the
14
** names of its contributors may be used to endorse or promote products
15
** derived from this software without specific prior written permission.
16
**
17
** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
18
** ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
19
** WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
20
** DISCLAIMED. IN NO EVENT SHALL Johannes Fetz BE LIABLE FOR ANY
21
** DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
22
** (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
23
** LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
24
** ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
25
** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
26
** SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
27
*/
34
35
#ifndef __JO_COLORS_H__
36
# define __JO_COLORS_H__
37
38
/*
39
** MACROS
40
*/
41
42
/*
43
** for jo_set_printf_color_index
44
*/
45
#define JO_COLOR_INDEX_White (0)
46
#define JO_COLOR_INDEX_Black (1)
47
#define JO_COLOR_INDEX_Red (2)
48
#define JO_COLOR_INDEX_Green (3)
49
#define JO_COLOR_INDEX_Yellow (4)
50
#define JO_COLOR_INDEX_Blue (5)
51
#define JO_COLOR_INDEX_Purple (6)
52
53
/*
54
** jo_color constants
55
*/
56
# define JO_COLOR_White (65535)
57
# define JO_COLOR_Black (32768)
58
# define JO_COLOR_Red (32799)
59
# define JO_COLOR_Green (33760)
60
# define JO_COLOR_Yellow (33791)
61
# define JO_COLOR_Blue (64512)
62
# define JO_COLOR_Purple (64543)
63
# define JO_COLOR_Cyan (65504)
64
# define JO_COLOR_Gray (58136)
65
# define JO_COLOR_DarkRed (32776)
66
# define JO_COLOR_DarkGreen (33024)
67
# define JO_COLOR_DarkYellow (33032)
68
# define JO_COLOR_DarkBlue (40960)
69
# define JO_COLOR_DarkPurple (40968)
70
# define JO_COLOR_DarkCyan (41216)
71
# define JO_COLOR_DarkGray (41224)
72
# define JO_COLOR_MediumRed (32784)
73
# define JO_COLOR_MediumGreen (33280)
74
# define JO_COLOR_MediumYellow (33296)
75
# define JO_COLOR_MediumBlue (49152)
76
# define JO_COLOR_MediumPurple (49168)
77
# define JO_COLOR_MediumCyan (49664)
78
# define JO_COLOR_MediumWhite (49680)
79
# define JO_COLOR_SemiRed (32792)
80
# define JO_COLOR_SemiGreen (33536)
81
# define JO_COLOR_SemiYellow (33560)
82
# define JO_COLOR_SemiBlue (57344)
83
# define JO_COLOR_SemiPurple (57368)
84
# define JO_COLOR_SemiCyan (58112)
85
87
# define JO_COLOR_Transparent (0)
88
90
# define JO_COLOR_SATURN(C) (JO_DIV_BY_8(C) & 0x1f)
92
# define JO_COLOR_SATURN_RGB(R,G,B) ((jo_color)(0x8000 | ((B) << 10) | ((G) << 5) | (R)))
95
# define JO_COLOR_SATURN_MSB (0x8000)
96
# define JO_COLOR_SATURN_GET_R(C) ((C) & 0x1f)
97
# define JO_COLOR_SATURN_GET_G(C) (((C) >> 5) & 0x1f)
98
# define JO_COLOR_SATURN_GET_B(C) (((C) >> 10) & 0x1f)
99
106
# define JO_COLOR_RGB(R,G,B) JO_COLOR_SATURN_RGB(JO_COLOR_SATURN(R), JO_COLOR_SATURN(G), JO_COLOR_SATURN(B))
107
114
static
__jo_force_inline
jo_color
jo_color_mix
(
const
jo_color
a,
const
jo_color
b,
const
int
t)
115
{
116
int
r;
117
int
g;
118
int
bl;
119
120
r = (a & 31) + (((b & 31) - (a & 31)) * t >> 8);
121
g = ((a >> 5) & 31) + ((((b >> 5) & 31) - ((a >> 5) & 31)) * t >> 8);
122
bl = ((a >> 10) & 31) + ((((b >> 10) & 31) - ((a >> 10) & 31)) * t >> 8);
123
return
(
JO_COLOR_SATURN_RGB
(r, g, bl));
124
}
125
126
133
void
jo_set_screen_color_filter_a
(
const
jo_scroll_screen
screens,
const
short
r,
const
short
g,
const
short
b);
134
141
void
jo_set_screen_color_filter_b
(
const
jo_scroll_screen
screens,
const
short
r,
const
short
g,
const
short
b);
142
146
void
jo_disable_screen_color_filter
(
const
jo_scroll_screen
screens);
147
155
void
jo_fade_screens
(
const
jo_scroll_screen
screens,
const
short
from,
const
short
to,
const
int
frames);
156
159
static
__jo_force_inline
void
jo_disable_all_screen_color_filter
(
void
)
160
{
161
jo_disable_screen_color_filter
(
JO_ALL_SCROLL_SCREEN
);
162
}
163
164
165
#endif
/* !__JO_COLORS_H__ */
166
167
/*
168
** END OF FILE
169
*/
jo_disable_screen_color_filter
void jo_disable_screen_color_filter(const jo_scroll_screen screens)
Disable color filter for scroll screen.
JO_COLOR_SATURN_RGB
#define JO_COLOR_SATURN_RGB(R, G, B)
Internal, you should not use this macro.
Definition
colors.h:92
jo_set_screen_color_filter_a
void jo_set_screen_color_filter_a(const jo_scroll_screen screens, const short r, const short g, const short b)
Set color filter A for scroll screen.
jo_color_mix
static __jo_force_inline jo_color jo_color_mix(const jo_color a, const jo_color b, const int t)
A color between 2 colors (each component interpolated).
Definition
colors.h:114
jo_disable_all_screen_color_filter
static __jo_force_inline void jo_disable_all_screen_color_filter(void)
Disable color filter for all scroll screen.
Definition
colors.h:159
jo_fade_screens
void jo_fade_screens(const jo_scroll_screen screens, const short from, const short to, const int frames)
Fade scroll screens: their color filter A from a level to another, a step at each VBLANK (waits for t...
jo_set_screen_color_filter_b
void jo_set_screen_color_filter_b(const jo_scroll_screen screens, const short r, const short g, const short b)
Set color filter A for scroll screen.
__jo_force_inline
#define __jo_force_inline
force inline attribute (and prevent Doxygen prototype parsing bug)
Definition
types.h:39
jo_color
unsigned short jo_color
15 bits color type
Definition
types.h:42
jo_scroll_screen
jo_scroll_screen
Sega Saturn Scroll Screen Ids.
Definition
types.h:322
JO_ALL_SCROLL_SCREEN
@ JO_ALL_SCROLL_SCREEN
Definition
types.h:335
Generated by
1.18.0