Jo Engine
2026.11.6
Jo Sega Saturn Engine
Toggle main menu visibility
Loading...
Searching...
No Matches
jo_engine
jo
sun.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
*/
50
51
#ifndef __JO_SUN_H__
52
# define __JO_SUN_H__
53
54
#ifdef JO_COMPILE_WITH_3D_SUPPORT
55
57
# define JO_SUN_MAX_HALO_STRIPS (8)
59
# define JO_SUN_FLARE_PIECES (3)
61
# define JO_SUN_FLARE_FULL (16)
62
64
typedef
struct
65
{
66
short
place
;
// On the line from the middle of the screen (0) to the sun (256); < 0: beyond the middle
67
short
size
;
// Its scale at the full level of the flare (1/8 of the sprite)
68
short
piece
;
// Its sprite (0 to JO_SUN_FLARE_PIECES - 1: jo_sun.flare[])
69
}
jo_sun_flare
;
70
72
typedef
struct
73
{
74
jo_angle
azimuth
;
// Its direction: the heading toward it (as the heading of the camera)
75
jo_angle
elevation
;
// Above the horizon
76
int
halo
[
JO_SUN_MAX_HALO_STRIPS
];
// Sprites of the halo, from the top
77
int
halo_strips
;
// Strips of the halo (0: no halo)
78
int
halo_half
;
// Half the size of the halo (pixels: 64)
79
int
strip_height
;
// Rows of a strip (pixels: 32)
80
int
core
;
// Sprite of the core (-1: none)
81
int
core_half
;
// Half the size of the core (pixels: 16)
82
int
flare
[
JO_SUN_FLARE_PIECES
];
// Sprites of the lens flare (-1: none)
83
int
flare_rgb
[
JO_SUN_FLARE_PIECES
];
// Under the horizon: drawn half transparent (-1: flare[])
84
const
jo_sun_flare
*
flares
;
// The pieces drawn (default: 7 pieces)
85
int
flare_count
;
86
int
z
;
// Depth of the sun (sprites) and its depth bias (behind everything)
87
int
bias
;
88
int
flare_z
;
// Depth of the lens flare and its depth bias (in front of everything)
89
int
flare_bias
;
90
/* Computed by jo_sun_update() */
91
bool
seen
;
// On the screen
92
int
x
;
// Its middle on the screen (pixels)
93
int
y
;
94
int
horizon_y
;
// The horizon on the screen (pixels)
95
int
flare_level
;
// The lens flare: 0 to JO_SUN_FLARE_FULL
96
}
jo_sun
;
97
103
void
jo_sun_init
(
jo_sun
*
const
sun,
const
jo_angle
azimuth,
const
jo_angle
elevation);
104
112
void
jo_sun_update
(
jo_sun
*
const
sun,
const
jo_angle
heading,
const
jo_fixed
look_down,
113
bool
(*hidden)(
void
));
114
116
void
jo_sun_draw
(
const
jo_sun
*
const
sun);
117
119
void
jo_sun_draw_flare
(
const
jo_sun
*
const
sun);
120
121
#endif
/* JO_COMPILE_WITH_3D_SUPPORT */
122
123
#endif
/* !__JO_SUN_H__ */
124
125
/*
126
** END OF FILE
127
*/
jo_sun_flare::size
short size
Definition
sun.h:67
jo_sun::flares
const jo_sun_flare * flares
Definition
sun.h:84
jo_sun::elevation
jo_angle elevation
Definition
sun.h:75
jo_sun::y
int y
Definition
sun.h:93
jo_sun::core
int core
Definition
sun.h:80
jo_sun_flare::piece
short piece
Definition
sun.h:68
jo_sun::x
int x
Definition
sun.h:92
jo_sun::flare_count
int flare_count
Definition
sun.h:85
JO_SUN_FLARE_PIECES
#define JO_SUN_FLARE_PIECES
Pieces of the lens flare (sprites): a ring, a disc, a hexagon (see jo_level/sun.py: FLARE_PIECES).
Definition
sun.h:59
jo_sun::strip_height
int strip_height
Definition
sun.h:79
jo_sun_flare::place
short place
Definition
sun.h:66
jo_sun::halo_strips
int halo_strips
Definition
sun.h:77
jo_sun::flare_bias
int flare_bias
Definition
sun.h:89
jo_sun::flare_level
int flare_level
Definition
sun.h:95
jo_sun::azimuth
jo_angle azimuth
Definition
sun.h:74
jo_sun::flare_rgb
int flare_rgb[(3)]
Definition
sun.h:83
jo_sun::seen
bool seen
Definition
sun.h:91
jo_sun_draw_flare
void jo_sun_draw_flare(const jo_sun *const sun)
Draw the lens flare (in front of the rest: before the HUD).
jo_sun::halo_half
int halo_half
Definition
sun.h:78
jo_sun_update
void jo_sun_update(jo_sun *const sun, const jo_angle heading, const jo_fixed look_down, bool(*hidden)(void))
Place the sun on the screen, fade the lens flare (once a frame).
jo_sun::horizon_y
int horizon_y
Definition
sun.h:94
jo_sun_draw
void jo_sun_draw(const jo_sun *const sun)
Draw the sun (in the frame of the 3D: behind everything).
jo_sun_init
void jo_sun_init(jo_sun *const sun, const jo_angle azimuth, const jo_angle elevation)
The default values of a sun: no sprite, the default lens flare.
jo_sun::flare
int flare[(3)]
Definition
sun.h:82
jo_sun::core_half
int core_half
Definition
sun.h:81
JO_SUN_MAX_HALO_STRIPS
#define JO_SUN_MAX_HALO_STRIPS
Strips of the halo at most.
Definition
sun.h:57
jo_sun::z
int z
Definition
sun.h:86
jo_sun::bias
int bias
Definition
sun.h:87
jo_sun::halo
int halo[(8)]
Definition
sun.h:76
jo_sun::flare_z
int flare_z
Definition
sun.h:88
jo_sun
The sun (see jo_sun_init(): the default values).
Definition
sun.h:73
jo_sun_flare
A piece of the lens flare drawn.
Definition
sun.h:65
jo_angle
short jo_angle
Angle.
Definition
types.h:65
jo_fixed
int jo_fixed
Fixed point Q16.16 number.
Definition
types.h:59
Generated by
1.18.0