Jo Engine  2024.04.28
Jo Sega Saturn Engine
colors.h
Go to the documentation of this file.
1 /*
2 ** Jo Sega Saturn Engine
3 ** Copyright (c) 2012-2024, 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 */
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)
91 
92 # define JO_COLOR_SATURN_RGB(R,G,B) ((jo_color)(0x8000 | ((B) << 10) | ((G) << 5) | (R)))
93 
94 # define JO_COLOR_SATURN_GET_R(C) ((C) & 0x1f)
95 # define JO_COLOR_SATURN_GET_G(C) (((C) >> 5) & 0x1f)
96 # define JO_COLOR_SATURN_GET_B(C) (((C) >> 10) & 0x1f)
97 
104 # define JO_COLOR_RGB(R,G,B) JO_COLOR_SATURN_RGB(JO_COLOR_SATURN(R), JO_COLOR_SATURN(G), JO_COLOR_SATURN(B))
105 
106 #if JO_COMPILE_USING_SGL
107 
114 static __jo_force_inline void jo_set_screen_color_filter_a(jo_scroll_screen screens, short r, short g, short b)
115 {
116  slColOffsetA(r, g, b);
117  slColOffsetAUse(screens);
118 }
119 
126 static __jo_force_inline void jo_set_screen_color_filter_b(jo_scroll_screen screens, short r, short g, short b)
127 {
128  slColOffsetB(r, g, b);
129  slColOffsetBUse(screens);
130 }
131 
136 {
137  slColOffsetOff(screens);
138 }
139 
143 {
145 }
146 
147 #endif
148 
149 #endif /* !__JO_COLORS_H__ */
150 
151 /*
152 ** END OF FILE
153 */
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:142
jo_set_screen_color_filter_a
static __jo_force_inline void jo_set_screen_color_filter_a(jo_scroll_screen screens, short r, short g, short b)
Set color filter A for scroll screen.
Definition: colors.h:114
JO_ALL_SCROLL_SCREEN
@ JO_ALL_SCROLL_SCREEN
Definition: types.h:329
__jo_force_inline
#define __jo_force_inline
force inline attribute (and prevent Doxygen prototype parsing bug)
Definition: types.h:39
jo_set_screen_color_filter_b
static __jo_force_inline void jo_set_screen_color_filter_b(jo_scroll_screen screens, short r, short g, short b)
Set color filter A for scroll screen.
Definition: colors.h:126
jo_disable_screen_color_filter
static __jo_force_inline void jo_disable_screen_color_filter(jo_scroll_screen screens)
Disable color filter for scroll screen.
Definition: colors.h:135
jo_scroll_screen
jo_scroll_screen
Sega Saturn Scroll Screen Ids.
Definition: types.h:316