Jo Engine 2026.11.6
Jo Sega Saturn Engine
Loading...
Searching...
No Matches
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
64typedef 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[])
70
72typedef 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)
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)
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
103void jo_sun_init(jo_sun * const sun, const jo_angle azimuth, const jo_angle elevation);
104
112void jo_sun_update(jo_sun * const sun, const jo_angle heading, const jo_fixed look_down,
113 bool (*hidden)(void));
114
116void jo_sun_draw(const jo_sun * const sun);
117
119void 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*/
short size
Definition sun.h:67
const jo_sun_flare * flares
Definition sun.h:84
jo_angle elevation
Definition sun.h:75
int y
Definition sun.h:93
int core
Definition sun.h:80
short piece
Definition sun.h:68
int x
Definition sun.h:92
int flare_count
Definition sun.h:85
#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
int strip_height
Definition sun.h:79
short place
Definition sun.h:66
int halo_strips
Definition sun.h:77
int flare_bias
Definition sun.h:89
int flare_level
Definition sun.h:95
jo_angle azimuth
Definition sun.h:74
int flare_rgb[(3)]
Definition sun.h:83
bool seen
Definition sun.h:91
void jo_sun_draw_flare(const jo_sun *const sun)
Draw the lens flare (in front of the rest: before the HUD).
int halo_half
Definition sun.h:78
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).
int horizon_y
Definition sun.h:94
void jo_sun_draw(const jo_sun *const sun)
Draw the sun (in the frame of the 3D: behind everything).
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.
int flare[(3)]
Definition sun.h:82
int core_half
Definition sun.h:81
#define JO_SUN_MAX_HALO_STRIPS
Strips of the halo at most.
Definition sun.h:57
int z
Definition sun.h:86
int bias
Definition sun.h:87
int halo[(8)]
Definition sun.h:76
int flare_z
Definition sun.h:88
The sun (see jo_sun_init(): the default values).
Definition sun.h:73
A piece of the lens flare drawn.
Definition sun.h:65
short jo_angle
Angle.
Definition types.h:65
int jo_fixed
Fixed point Q16.16 number.
Definition types.h:59