Jo Engine 2026.11.1
Jo Sega Saturn Engine
Loading...
Searching...
No Matches
effects.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_EFFECTS_H__
36# define __JO_EFFECTS_H__
37
38#ifdef JO_COMPILE_WITH_EFFECTS_SUPPORT
39
40/*
41██╗ ██╗ ██████╗ ███╗ ███╗██╗███╗ ██╗ ██████╗ ██╗ █████╗ ███████╗███████╗██████╗
42██║ ██║██╔═══██╗████╗ ████║██║████╗ ██║██╔════╝ ██║ ██╔══██╗██╔════╝██╔════╝██╔══██╗
43███████║██║ ██║██╔████╔██║██║██╔██╗ ██║██║ ███╗ ██║ ███████║███████╗█████╗ ██████╔╝
44██╔══██║██║ ██║██║╚██╔╝██║██║██║╚██╗██║██║ ██║ ██║ ██╔══██║╚════██║██╔══╝ ██╔══██╗
45██║ ██║╚██████╔╝██║ ╚═╝ ██║██║██║ ╚████║╚██████╔╝ ███████╗██║ ██║███████║███████╗██║ ██║
46╚═╝ ╚═╝ ╚═════╝ ╚═╝ ╚═╝╚═╝╚═╝ ╚═══╝ ╚═════╝ ╚══════╝╚═╝ ╚═╝╚══════╝╚══════╝╚═╝ ╚═╝
47*/
48
66
75void jo_init_homing_laser(jo_homing_laser * const homing_laser, const int sprite_id, const unsigned short thickness,
76 const int z, const unsigned short nb_sections);
77
82void jo_draw_homing_laser(jo_homing_laser * const homing_laser);
83
84#ifdef JO_COMPILE_WITH_3D_SUPPORT
85
86/*
87** Effects of the 3D world: animated sprites (fire, smoke, dust, sparks...), flash of the screen, shake of the camera.
88** Cheap on the Saturn: the sprites are opaque with end codes (half transparency costs a lot of VDP1 time), the flash is
89** the color offset of the VDP2 (free), the shake is an offset of the camera given to the game.
90** The explosions of the entities use them (see entity.h)
91*/
92
94# define JO_EFFECT_MAX (32)
96# define JO_EFFECT_MAX_FRAMES (4)
97
99# define JO_EFFECT_HALF_TRANSPARENT (0x01)
101# define JO_EFFECT_STANDING (0x02)
103# define JO_EFFECT_RANDOM_FLIP (0x04)
104
106typedef struct
107{
108 short sprites[JO_EFFECT_MAX_FRAMES]; // Frames of the animation (played once during the life)
109 unsigned char frame_count;
110 unsigned char life; // Frames of the game
111 unsigned char flags; // JO_EFFECT_xxx
112 unsigned char __pad;
113 short size_start; // Half size at the start and at the end (world units)
114 short size_end;
115 short rise; // Speed up (1/16 world units per frame of the game)
116 short __pad2;
118
124void jo_effect_add(const jo_effect_def * const def, const jo_pos3D_fixed * const position, const int delay);
125
128
131
136
145void jo_effect_flash(const int r, const int g, const int b, const int frames);
146
152void jo_effect_fade(const int darkness, const int frames);
153
156
161void jo_effect_shake(const int amount, const int frames);
162
167
168#endif /* !JO_COMPILE_WITH_3D_SUPPORT */
169
170#endif /* !JO_COMPILE_WITH_EFFECTS_SUPPORT */
171
172#endif /* !__JO_EFFECTS_H__ */
173
174/*
175** END OF FILE
176*/
unsigned char frame_count
Definition effects.h:109
short rise
Definition effects.h:115
unsigned char __pad
Definition effects.h:112
unsigned char flags
Definition effects.h:111
void jo_effect_get_shake(jo_pos3D_fixed *const offset)
Offset of the camera of the shake (add it to the position of the eyes).
jo_vector_fixed intermediate_point_a
Definition effects.h:55
void jo_draw_homing_laser(jo_homing_laser *const homing_laser)
Draw homing laser effect.
void jo_effects_update(void)
Animate the effects, the flash and the shake: once per frame of the game.
jo_vector_fixed intermediate_point_b
Definition effects.h:57
jo_fixed horizontal_thickness
Definition effects.h:60
jo_fixed section_step
Definition effects.h:62
short __pad2
Definition effects.h:116
jo_vector_fixed source
Definition effects.h:53
bool use_intermediate_point_b
Definition effects.h:56
short sprites[(4)]
Definition effects.h:108
void jo_effect_flash(const int r, const int g, const int b, const int frames)
Flash of the screen: the color offset of the VDP2 is added to all the screens, it fades to 0.
void jo_effect_add(const jo_effect_def *const def, const jo_pos3D_fixed *const position, const int delay)
Add an effect.
jo_vector_fixed target
Definition effects.h:58
short size_end
Definition effects.h:114
bool center_sprites_according_to_thickness
Definition effects.h:64
jo_fixed vertical_thickness
Definition effects.h:61
#define JO_EFFECT_MAX_FRAMES
Frames of the animation of an effect at most.
Definition effects.h:96
short size_start
Definition effects.h:113
bool use_intermediate_point_a
Definition effects.h:54
void jo_effects_clear(void)
Remove all the effects, the flash and the shake.
int sprite_id
Definition effects.h:63
jo_fixed length
Definition effects.h:59
bool jo_effect_is_fading(void)
Check if the fade is not finished (see jo_effect_fade()).
int jo_effects_draw(void)
Draw the effects (in the world: the camera matrix is the current matrix, see jo_3d_set_depth_bias()).
void jo_effect_fade(const int darkness, const int frames)
Fade of the screen to black (or back): the color offset of the VDP2 (see jo_effect_flash()).
void jo_effect_shake(const int amount, const int frames)
Shake of the camera.
void jo_init_homing_laser(jo_homing_laser *const homing_laser, const int sprite_id, const unsigned short thickness, const int z, const unsigned short nb_sections)
Init jo_homing_laser struct.
unsigned char life
Definition effects.h:110
Definition of an effect (shared by the effects of the same kind).
Definition effects.h:107
Homing laser effect definition.
Definition effects.h:52
int jo_fixed
Fixed point Q16.16 number.
Definition types.h:48
3D position using fixed numbers
Definition types.h:92
Vector for 3D computation using fixed number.
Definition types.h:155