Jo Engine 2026.11.6
Jo Sega Saturn Engine
Loading...
Searching...
No Matches
sprites.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_SPRITES_H__
36# define __JO_SPRITES_H__
37
38/*
39██╗███╗ ██╗████████╗███████╗██████╗ ███╗ ██╗ █████╗ ██╗
40██║████╗ ██║╚══██╔══╝██╔════╝██╔══██╗████╗ ██║██╔══██╗██║
41██║██╔██╗ ██║ ██║ █████╗ ██████╔╝██╔██╗ ██║███████║██║
42██║██║╚██╗██║ ██║ ██╔══╝ ██╔══██╗██║╚██╗██║██╔══██║██║
43██║██║ ╚████║ ██║ ███████╗██║ ██║██║ ╚████║██║ ██║███████╗
44╚═╝╚═╝ ╚═══╝ ╚═╝ ╚══════╝╚═╝ ╚═╝╚═╝ ╚═══╝╚═╝ ╚═╝╚══════╝
45▲ DO NOT USE THESE FUNCTIONS ▲
46*/
47
55extern jo_texture_definition __jo_sprite_def[JO_MAX_SPRITE];
59extern jo_picture_definition __jo_sprite_pic[JO_MAX_SPRITE];
63extern unsigned short __jo_sprite_lut[JO_MAX_SPRITE];
67void jo_sprite_draw(const int sprite_id, const jo_pos3D * const pos, const bool centered_style_coordinates, const bool billboard);
71void jo_sprite_draw_rotate(const int sprite_id, const jo_pos3D * const pos, const int angle, const bool centered_style_coordinates, const bool billboard);
73static __jo_force_inline void __internal_jo_sprite_set_position3D(const int x, const int y, const int z)
74{
75 extern jo_pos3D __jo_sprite_pos;
76 __jo_sprite_pos.x = x;
77 __jo_sprite_pos.y = y;
78 __jo_sprite_pos.z = z;
79}
80
81/*
82 █████╗ ██████╗ ██████╗ ██╗██████╗ ███████╗██████╗ ██╗ █████╗ ██████╗███████╗ ██╗███████╗██████╗ ███████╗███████╗
83██╔══██╗██╔══██╗██╔══██╗ ██╔╝██╔══██╗██╔════╝██╔══██╗██║ ██╔══██╗██╔════╝██╔════╝ ██╔╝██╔════╝██╔══██╗██╔════╝██╔════╝
84███████║██║ ██║██║ ██║ ██╔╝ ██████╔╝█████╗ ██████╔╝██║ ███████║██║ █████╗ ██╔╝ █████╗ ██████╔╝█████╗ █████╗
85██╔══██║██║ ██║██║ ██║ ██╔╝ ██╔══██╗██╔══╝ ██╔═══╝ ██║ ██╔══██║██║ ██╔══╝ ██╔╝ ██╔══╝ ██╔══██╗██╔══╝ ██╔══╝
86██║ ██║██████╔╝██████╔╝██╔╝ ██║ ██║███████╗██║ ███████╗██║ ██║╚██████╗███████╗██╔╝ ██║ ██║ ██║███████╗███████╗
87╚═╝ ╚═╝╚═════╝ ╚═════╝ ╚═╝ ╚═╝ ╚═╝╚══════╝╚═╝ ╚══════╝╚═╝ ╚═╝ ╚═════╝╚══════╝╚═╝ ╚═╝ ╚═╝ ╚═╝╚══════╝╚══════╝
88*/
89
94
95#ifdef JO_DEBUG
96
102# define __JO_SPRITE_IS_MISSING(SPRITE_ID) \
103 ((int)(SPRITE_ID) > jo_get_last_sprite_id() && \
104 (jo_core_error("Sprite %d not added (last one: %d)", (int)(SPRITE_ID), jo_get_last_sprite_id()), true))
105
106#endif
107
112int jo_sprite_add(const jo_img * const img);
113
120static __jo_force_inline int jo_sprite_add_rgb(const jo_color * const pixels, const unsigned short width, const unsigned short height)
121{
122 jo_img img;
123
124 img.width = width;
125 img.height = height;
126 img.data = (jo_color *)pixels;
127 return (jo_sprite_add(&img));
128}
129
136
149int jo_sprite_add_4bits_lut(const unsigned char * const pixels, const unsigned short width, const unsigned short height,
150 const jo_color * const lut);
151
159
165int jo_sprite_replace(const jo_img * const img, const int sprite_id);
166
176bool jo_sprite_add_end_codes(const int sprite_id);
177
182void jo_sprite_free_from(const int sprite_id);
183
188{
190}
191
192# ifdef JO_COMPILE_WITH_SPRITE_HASHTABLE
198int jo_sprite_name2id(const char *const filename);
199#endif
200
201/*
202████████╗██████╗ █████╗ ███╗ ██╗███████╗██████╗ █████╗ ██████╗ ███████╗███╗ ██╗ ██████╗██╗ ██╗
203╚══██╔══╝██╔══██╗██╔══██╗████╗ ██║██╔════╝██╔══██╗██╔══██╗██╔══██╗██╔════╝████╗ ██║██╔════╝╚██╗ ██╔╝
204 ██║ ██████╔╝███████║██╔██╗ ██║███████╗██████╔╝███████║██████╔╝█████╗ ██╔██╗ ██║██║ ╚████╔╝
205 ██║ ██╔══██╗██╔══██║██║╚██╗██║╚════██║██╔═══╝ ██╔══██║██╔══██╗██╔══╝ ██║╚██╗██║██║ ╚██╔╝
206 ██║ ██║ ██║██║ ██║██║ ╚████║███████║██║ ██║ ██║██║ ██║███████╗██║ ╚████║╚██████╗ ██║
207 ╚═╝ ╚═╝ ╚═╝╚═╝ ╚═╝╚═╝ ╚═══╝╚══════╝╚═╝ ╚═╝ ╚═╝╚═╝ ╚═╝╚══════╝╚═╝ ╚═══╝ ╚═════╝ ╚═╝
208*/
209
210/*
211** Screen doors filter (old school transparency)
212*/
213
220
227
228/*
229** Half transparency
230*/
231
235{
236 // (the color calculation mode of the VDP1: 3, or 7 with the gouraud shading)
238}
239
247
248/*
249███████╗██╗ ██╗ █████╗ ██████╗ ██████╗ ██╗ ██╗
250██╔════╝██║ ██║██╔══██╗██╔══██╗██╔═══██╗██║ ██║
251███████╗███████║███████║██║ ██║██║ ██║██║ █╗ ██║
252╚════██║██╔══██║██╔══██║██║ ██║██║ ██║██║███╗██║
253███████║██║ ██║██║ ██║██████╔╝╚██████╔╝╚███╔███╔╝
254╚══════╝╚═╝ ╚═╝╚═╝ ╚═╝╚═════╝ ╚═════╝ ╚══╝╚══╝
255*/
256
260{
261 // (the mode 1 of the VDP1: no gouraud shading with it)
263}
264
272
273/*
274** Dark filter
275*/
276
280{
281 // (the mode 2 of the VDP1, half luminance: 6 with the gouraud shading)
283}
284
288{
289 if ((__jo_sprite_attributes.effect & 0x3) == 0x2)
291}
292
293/*
294 ██████╗ ██████╗ ██╗ ██╗██████╗ █████╗ ██╗ ██╗██████╗ ███████╗██╗ ██╗ █████╗ ██████╗ ██╗███╗ ██╗ ██████╗
295██╔════╝ ██╔═══██╗██║ ██║██╔══██╗██╔══██╗██║ ██║██╔══██╗ ██╔════╝██║ ██║██╔══██╗██╔══██╗██║████╗ ██║██╔════╝
296██║ ███╗██║ ██║██║ ██║██████╔╝███████║██║ ██║██║ ██║ ███████╗███████║███████║██║ ██║██║██╔██╗ ██║██║ ███╗
297██║ ██║██║ ██║██║ ██║██╔══██╗██╔══██║██║ ██║██║ ██║ ╚════██║██╔══██║██╔══██║██║ ██║██║██║╚██╗██║██║ ██║
298╚██████╔╝╚██████╔╝╚██████╔╝██║ ██║██║ ██║╚██████╔╝██████╔╝ ███████║██║ ██║██║ ██║██████╔╝██║██║ ╚████║╚██████╔╝
299 ╚═════╝ ╚═════╝ ╚═════╝ ╚═╝ ╚═╝╚═╝ ╚═╝ ╚═════╝ ╚═════╝ ╚══════╝╚═╝ ╚═╝╚═╝ ╚═╝╚═════╝ ╚═╝╚═╝ ╚═══╝ ╚═════╝
300*/
301
303# define JO_NO_GOURAUD_COLOR (0xc210)
304
313 const jo_color topright_color,
314 const jo_color bottomright_color,
315 const jo_color bottomleft_color);
316
320{
321 // (no shadow with it: 5 is prohibited)
322 if ((__jo_sprite_attributes.effect & 0x7) == 0x1)
325}
326
333
338static __jo_force_inline void jo_sprite_set_gouraud_table(const unsigned short table)
339{
341}
342
344# define JO_DEFAULT_BRIGHTNESS (16)
345
347# define JO_MAX_BRIGHTNESS (31)
348
352void jo_set_gouraud_shading_brightness(const unsigned char brightness);
353
354/*
355██╗ ██╗ ██████╗ ██████╗ ██╗███████╗ ██╗██╗ ██╗███████╗██████╗ ████████╗ ███████╗██╗ ██╗██████╗
356██║ ██║██╔═══██╗██╔══██╗██║╚══███╔╝ ██╔╝██║ ██║██╔════╝██╔══██╗╚══██╔══╝ ██╔════╝██║ ██║██╔══██╗
357███████║██║ ██║██████╔╝██║ ███╔╝ ██╔╝ ██║ ██║█████╗ ██████╔╝ ██║ █████╗ ██║ ██║██████╔╝
358██╔══██║██║ ██║██╔══██╗██║ ███╔╝ ██╔╝ ╚██╗ ██╔╝██╔══╝ ██╔══██╗ ██║ ██╔══╝ ██║ ██║██╔═══╝
359██║ ██║╚██████╔╝██║ ██║██║███████╗██╔╝ ╚████╔╝ ███████╗██║ ██║ ██║ ██║ ███████╗██║██║
360╚═╝ ╚═╝ ╚═════╝ ╚═╝ ╚═╝╚═╝╚══════╝╚═╝ ╚═══╝ ╚══════╝╚═╝ ╚═╝ ╚═╝ ╚═╝ ╚══════╝╚═╝╚═╝
361*/
362
369
376
382
389
390/*
391███████╗ ██████╗ █████╗ ██╗ ███████╗
392██╔════╝██╔════╝██╔══██╗██║ ██╔════╝
393███████╗██║ ███████║██║ █████╗
394╚════██║██║ ██╔══██║██║ ██╔══╝
395███████║╚██████╗██║ ██║███████╗███████╗
396╚══════╝ ╚═════╝╚═╝ ╚═╝╚══════╝╚══════╝
397*/
398
402# define JO_NO_ZOOM (65536)
403
412
418{
419 jo_sprite_change_sprite_scale_fixed(jo_float2fixed(scale));
420}
421
426static __jo_force_inline void jo_sprite_change_sprite_scale_xy(const float scale_x, const float scale_y)
427{
428 __jo_sprite_attributes.fixed_scale_x = jo_float2fixed(scale_x);
429 __jo_sprite_attributes.fixed_scale_y = jo_float2fixed(scale_y);
430}
431
441
449
450/*
451██████╗ ██████╗ █████╗ ██╗ ██╗
452██╔══██╗██╔══██╗██╔══██╗██║ ██║
453██║ ██║██████╔╝███████║██║ █╗ ██║
454██║ ██║██╔══██╗██╔══██║██║███╗██║
455██████╔╝██║ ██║██║ ██║╚███╔███╔╝
456╚═════╝ ╚═╝ ╚═╝╚═╝ ╚═╝ ╚══╝╚══╝
457*/
458
462static __jo_force_inline void jo_sprite_set_palette(int palette_id)
463{
464#ifdef JO_DEBUG
465 if (__JO_INDEX_IS_WRONG(palette_id, JO_PALETTE_MAX, "palette id"))
466 return;
467#endif
469}
470
476{
477#ifdef JO_DEBUG
478 if (__JO_INDEX_IS_WRONG(palette_id, JO_PALETTE_MAX, "palette id"))
479 return;
480#endif
481 // (bits 14 and 13: the priority register 3 of the sprites, see JO_VDP2_ADDITIVE_SPRITE_BANK in jo/vdp2.h)
483}
484
491void __jo_vdp1_draw_sprite3D(const int sprite_id, const int x, const int y, const int z);
492
499void __jo_vdp1_draw_sprite3D2(const int sprite_id, const int x, const int y, const int z);
500
508static __jo_force_inline void jo_sprite_draw3D_and_rotate(const int sprite_id, const int x, const int y, const int z, const int angle)
509{
510 extern jo_pos3D __jo_sprite_pos;
512 jo_sprite_draw_rotate(sprite_id, &__jo_sprite_pos, angle, true, false);
513}
514
521static __jo_force_inline void jo_sprite_draw3D(const int sprite_id, const int x, const int y, const int z)
522{
523 __jo_vdp1_draw_sprite3D(sprite_id, x, y, z);
524}
525
533static __jo_force_inline void jo_sprite_draw3D_and_rotate2(const int sprite_id, const int x, const int y, const int z, const int angle)
534{
535 extern jo_pos3D __jo_sprite_pos;
537 jo_sprite_draw_rotate(sprite_id, &__jo_sprite_pos, angle, false, false);
538}
539
546static __jo_force_inline void jo_sprite_draw3D2(const int sprite_id, const int x, const int y, const int z)
547{
548 __jo_vdp1_draw_sprite3D2(sprite_id, x, y, z);
549}
550
557void jo_sprite_draw_4p_fixed(const int sprite_id, const jo_pos2D_fixed * const four_points, const jo_fixed z, const bool centered_style_coordinates);
558
568void jo_sprite_draw_rotated_fixed(const int sprite_id, const jo_fixed x, const jo_fixed y, const jo_fixed z,
569 const jo_fixed half_width, const jo_fixed half_height, const int angle);
570
571/*
572** Colored shapes: VDP1 polygons of one color, drawn like the sprites (no texture, no sprite to add)
573*/
574
599void jo_sprite_draw_rectangle(const int x, const int y, const int width, const int height, const jo_color color, const int z);
600
617void jo_sprite_draw_color_4p_fixed(const jo_pos2D_fixed * const four_points, const jo_color color, const jo_fixed z,
618 const bool centered_style_coordinates);
619
620/*
621 ██████╗██╗ ██╗██████╗ ██████╗ ██╗███╗ ██╗ ██████╗
622██╔════╝██║ ██║██╔══██╗██╔══██╗██║████╗ ██║██╔════╝
623██║ ██║ ██║██████╔╝██████╔╝██║██╔██╗ ██║██║ ███╗
624██║ ██║ ██║██╔═══╝ ██╔═══╝ ██║██║╚██╗██║██║ ██║
625╚██████╗███████╗██║██║ ██║ ██║██║ ╚████║╚██████╔╝
626 ╚═════╝╚══════╝╚═╝╚═╝ ╚═╝ ╚═╝╚═╝ ╚═══╝ ╚═════╝
627*/
628
636
643
644
652void jo_sprite_set_clipping_area(const unsigned int x, const unsigned int y, const unsigned int width, const unsigned int height, const int depth);
653
659void jo_sprite_set_system_clipping_area(const unsigned int width, const unsigned int height);
660
661/*
662 ██████╗ ███████╗████████╗ ███████╗██████╗ ██████╗ ██╗████████╗███████╗ ██╗███╗ ██╗███████╗ ██████╗
663██╔════╝ ██╔════╝╚══██╔══╝ ██╔════╝██╔══██╗██╔══██╗██║╚══██╔══╝██╔════╝ ██║████╗ ██║██╔════╝██╔═══██╗
664██║ ███╗█████╗ ██║ ███████╗██████╔╝██████╔╝██║ ██║ █████╗ ██║██╔██╗ ██║█████╗ ██║ ██║
665██║ ██║██╔══╝ ██║ ╚════██║██╔═══╝ ██╔══██╗██║ ██║ ██╔══╝ ██║██║╚██╗██║██╔══╝ ██║ ██║
666╚██████╔╝███████╗ ██║ ███████║██║ ██║ ██║██║ ██║ ███████╗ ██║██║ ╚████║██║ ╚██████╔╝
667 ╚═════╝ ╚══════╝ ╚═╝ ╚══════╝╚═╝ ╚═╝ ╚═╝╚═╝ ╚═╝ ╚══════╝ ╚═╝╚═╝ ╚═══╝╚═╝ ╚═════╝
668*/
669
677static __jo_force_inline jo_color jo_sprite_get_pixel_color(const jo_color * const data, const unsigned int x, const unsigned int y, const unsigned int image_width)
678{
679 return (data[x + y * image_width]);
680}
681
689static __jo_force_inline unsigned char jo_sprite_get_pixel_palette_index(const unsigned char * const data, const unsigned int x, const unsigned int y, const unsigned int image_width)
690{
691 return (data[x + y * image_width]);
692}
693
702static __jo_force_inline bool jo_sprite_is_pixel_transparent(const jo_color * const data, const unsigned int x, const unsigned int y, const unsigned int image_width)
703{
704 return (jo_sprite_get_pixel_color(data, x, y, image_width) == JO_COLOR_Transparent);
705}
706
711static __jo_force_inline int jo_sprite_get_width(const int sprite_id)
712{
713#ifdef JO_DEBUG
714 if (sprite_id < 0 || __JO_SPRITE_IS_MISSING(sprite_id))
715 return (0);
716#endif
717 return (__jo_sprite_def[sprite_id].width);
718}
719
724static __jo_force_inline int jo_sprite_get_height(const int sprite_id)
725{
726#ifdef JO_DEBUG
727 if (sprite_id < 0 || __JO_SPRITE_IS_MISSING(sprite_id))
728 return (0);
729#endif
730 return (__jo_sprite_def[sprite_id].height);
731}
732
737static __jo_force_inline void *jo_sprite_get_raw_data(const int sprite_id)
738{
739#ifdef JO_DEBUG
740 if (sprite_id < 0 || __JO_SPRITE_IS_MISSING(sprite_id))
741 return ((void *)0);
742#endif
743 return (__jo_sprite_pic[sprite_id].data);
744}
745
754static __jo_force_inline jo_color *jo_sprite_get_lut(const int sprite_id)
755{
756#ifdef JO_DEBUG
757 if (sprite_id < 0 || __JO_SPRITE_IS_MISSING(sprite_id))
758 return ((jo_color *)0);
759#endif
760 // ((jo_color *)0: JO_NULL is not known by all the files that include this one)
761 return (__jo_sprite_lut[sprite_id] == 0 ? (jo_color *)0 : (jo_color *)(JO_VDP1_VRAM + JO_MULT_BY_8(__jo_sprite_lut[sprite_id])));
762}
763
764/*
765███████╗████████╗ █████╗ ████████╗██╗███████╗████████╗██╗ ██████╗███████╗
766██╔════╝╚══██╔══╝██╔══██╗╚══██╔══╝██║██╔════╝╚══██╔══╝██║██╔════╝██╔════╝
767███████╗ ██║ ███████║ ██║ ██║███████╗ ██║ ██║██║ ███████╗
768╚════██║ ██║ ██╔══██║ ██║ ██║╚════██║ ██║ ██║██║ ╚════██║
769███████║ ██║ ██║ ██║ ██║ ██║███████║ ██║ ██║╚██████╗███████║
770╚══════╝ ╚═╝ ╚═╝ ╚═╝ ╚═╝ ╚═╝╚══════╝ ╚═╝ ╚═╝ ╚═════╝╚══════╝
771*/
772
777{
778 return (jo_get_last_sprite_id() + 1);
779}
780
786
790unsigned int jo_sprite_free_memory(void);
791
792#endif /* !__JO_SPRITES_H__ */
793
794/*
795** END OF FILE
796*/
#define JO_COLOR_Transparent
Transparent color.
Definition colors.h:87
#define __JO_INDEX_IS_WRONG(INDEX, COUNT, WHAT)
Check an index given to a function of the engine (Internal usage, JO_DEBUG).
Definition core.h:55
void * data
Definition entity.h:19
int height
Definition entity.h:4
#define JO_MULT_BY_256(X)
Multiply a variable by 256.
Definition math.h:111
#define JO_MULT_BY_8(X)
Multiply a variable by 8.
Definition math.h:81
#define JO_REMOVE_FLAG(BYTEFIELD, FLAG)
Remove flag in bytefield.
Definition math.h:381
#define JO_ADD_FLAG(BYTEFIELD, FLAG)
Add flag in bytefield.
Definition math.h:375
#define JO_PALETTE_MAX
Define the maximum of palette (the 256 colors palettes of the color RAM).
Definition sega_saturn.h:157
#define JO_VDP1_VRAM
VDP1 VRAM (512 kilobytes).
Definition sega_saturn.h:90
void jo_sprite_draw(const int sprite_id, const jo_pos3D *const pos, const bool centered_style_coordinates, const bool billboard)
(internal engine usage)
void jo_set_gouraud_shading_colors(const jo_color topleft_color, const jo_color topright_color, const jo_color bottomright_color, const jo_color bottomleft_color)
Change Gouraud Shading colors (a new table for the sprites displayed after this call with jo_sprite_e...
unsigned int jo_sprite_free_memory(void)
Get the free sprite memory (VDP1 VRAM).
void jo_set_gouraud_shading_brightness(const unsigned char brightness)
Change Gouraud Shading brightness.
void __jo_vdp1_draw_sprite3D2(const int sprite_id, const int x, const int y, const int z)
Draw a sprite of the current sprite attributes without rotation (internal usage: see jo_sprite_draw3D...
void jo_sprite_free_from(const int sprite_id)
Free all sprites from the given sprite_id.
static __jo_force_inline void jo_sprite_disable_vertical_flip(void)
Disable vertical flip for every sprite displayed after this call.
Definition sprites.h:372
static __jo_force_inline void jo_sprite_draw3D_and_rotate(const int sprite_id, const int x, const int y, const int z, const int angle)
Display a sprite in 3 dimensional space.
Definition sprites.h:508
void jo_sprite_set_system_clipping_area(const unsigned int width, const unsigned int height)
Set the VDP1 drawing area (system clipping).
jo_texture_definition __jo_sprite_def[JO_MAX_SPRITE]
(internal engine usage)
static __jo_force_inline void jo_sprite_enable_horizontal_flip(void)
Activate horizontal flip for every sprite displayed after this call.
Definition sprites.h:378
int jo_sprite_name2id(const char *const filename)
Retrive the Sprite Id from filename based on the four first character in the filename.
static __jo_force_inline int jo_sprite_count(void)
Get sprite count.
Definition sprites.h:776
static __jo_force_inline unsigned char jo_sprite_get_pixel_palette_index(const unsigned char *const data, const unsigned int x, const unsigned int y, const unsigned int image_width)
Get a specific pixel palette index from image bytes.
Definition sprites.h:689
int jo_sprite_replace(const jo_img *const img, const int sprite_id)
Replace a sprite.
static __jo_force_inline bool jo_sprite_is_pixel_transparent(const jo_color *const data, const unsigned int x, const unsigned int y, const unsigned int image_width)
Get if a specific pixel is transparent (JO_COLOR_Transparent) in image bytes.
Definition sprites.h:702
void jo_sprite_draw_color_4p_fixed(const jo_pos2D_fixed *const four_points, const jo_color color, const jo_fixed z, const bool centered_style_coordinates)
Draw a quadrilateral of one color (no texture) on 4 points: jo_sprite_draw_4p_fixed() with a color in...
static __jo_force_inline void jo_sprite_draw3D(const int sprite_id, const int x, const int y, const int z)
Display a sprite in 3 dimensional space.
Definition sprites.h:521
static __jo_force_inline int jo_sprite_add_rgb(const jo_color *const pixels, const unsigned short width, const unsigned short height)
Add a sprite from its pixels (jo_sprite_add() without the image struct: a texture in an array of the ...
Definition sprites.h:120
void jo_sprite_set_clipping_area(const unsigned int x, const unsigned int y, const unsigned int width, const unsigned int height, const int depth)
Set user clipping area.
static __jo_force_inline void jo_sprite_enable_clipping(bool outside)
Activate sprite clipping for every sprite displayed after this call.
Definition sprites.h:632
static __jo_force_inline void jo_sprite_draw3D2(const int sprite_id, const int x, const int y, const int z)
Display a sprite in 3 dimensional space.
Definition sprites.h:546
static __jo_force_inline void jo_sprite_set_additive_palette(int palette_id)
Change palette for every 8 bits sprite displayed after this call: their light is added to the image u...
Definition sprites.h:475
void __jo_vdp1_draw_sprite3D(const int sprite_id, const int x, const int y, const int z)
Draw a sprite of the current sprite attributes without rotation (internal usage: see jo_sprite_draw3D...
void jo_sprite_draw_rotated_fixed(const int sprite_id, const jo_fixed x, const jo_fixed y, const jo_fixed z, const jo_fixed half_width, const jo_fixed half_height, const int angle)
Display a sprite turned on the screen (any angle: the 4 corners are computed, the sprite is distorted...
int jo_sprite_usage_percent(void)
Get sprite memory usage.
static __jo_force_inline void jo_sprite_disable_clipping(void)
Disable sprite clipping for every sprite displayed after this call.
Definition sprites.h:639
static __jo_force_inline void jo_sprite_disable_screen_doors_filter(void)
Disable screen doors filter for every sprite displayed after this call.
Definition sprites.h:223
static __jo_force_inline int jo_sprite_get_width(const int sprite_id)
Get sprite width.
Definition sprites.h:711
static __jo_force_inline void jo_sprite_change_sprite_scale_fixed(const jo_fixed scale)
Change scale for every sprite displayed after this call using fixed number.
Definition sprites.h:407
jo_picture_definition __jo_sprite_pic[JO_MAX_SPRITE]
(internal engine usage)
static __jo_force_inline void jo_sprite_disable_gouraud_shading(void)
Disable Gouraud Shading for every sprite displayed after this call.
Definition sprites.h:329
static __jo_force_inline void jo_sprite_change_sprite_scale_xy(const float scale_x, const float scale_y)
Change scale for every sprite displayed after this call.
Definition sprites.h:426
static __jo_force_inline void jo_sprite_change_sprite_scale(const float scale)
Change scale for every sprite displayed after this call.
Definition sprites.h:417
int jo_sprite_add(const jo_img *const img)
Add a sprite.
static __jo_force_inline void jo_sprite_change_sprite_scale_xy_fixed(const jo_fixed scale_x, const jo_fixed scale_y)
Change scale for every sprite displayed after this call using fixed number.
Definition sprites.h:436
static __jo_force_inline void jo_sprite_restore_sprite_scale(void)
Restore default scale for every sprite displayed after this call.
Definition sprites.h:444
static __jo_force_inline void jo_sprite_disable_horizontal_flip(void)
Disable horizontal flip for every sprite displayed after this call.
Definition sprites.h:385
static __jo_force_inline void jo_sprite_set_palette(int palette_id)
Change palette for every 8 bits sprite displayed after this call.
Definition sprites.h:462
static __jo_force_inline int jo_sprite_get_height(const int sprite_id)
Get sprite height.
Definition sprites.h:724
static __jo_force_inline void __internal_jo_sprite_set_position3D(const int x, const int y, const int z)
Internal usage don't use it.
Definition sprites.h:73
int jo_sprite_add_image_4bits_lut(const jo_img *const img)
Add an RGB image of 14 colors at most (the index 15 is the end code of the VDP1) as a 16 colors textu...
void jo_sprite_draw_rotate(const int sprite_id, const jo_pos3D *const pos, const int angle, const bool centered_style_coordinates, const bool billboard)
(internal engine usage)
static __jo_force_inline void jo_sprite_enable_vertical_flip(void)
Activate vertical flip for every sprite displayed after this call.
Definition sprites.h:365
static __jo_force_inline void jo_sprite_disable_half_transparency(void)
Disable half transparency for every sprite displayed after this call.
Definition sprites.h:242
static __jo_force_inline jo_color * jo_sprite_get_lut(const int sprite_id)
Get the color lookup table of a 16 colors texture (jo_sprite_add_4bits_lut()): its 16 entries in the ...
Definition sprites.h:754
unsigned short __jo_sprite_lut[JO_MAX_SPRITE]
(internal engine usage)
static __jo_force_inline void jo_sprite_set_gouraud_table(const unsigned short table)
Gouraud table of the sprites displayed after this call with jo_sprite_enable_gouraud_shading() (inste...
Definition sprites.h:338
void jo_sprite_draw_rectangle(const int x, const int y, const int width, const int height, const jo_color color, const int z)
Draw a rectangle of one color (no texture): a health bar, a frame, a window of text,...
jo_sprite_attributes __jo_sprite_attributes
Current displayed sprite attribute (internal engine usage).
#define __JO_SPRITE_IS_MISSING(SPRITE_ID)
Check the id of a sprite given to a function of the engine (Internal usage, JO_DEBUG).
Definition sprites.h:102
static __jo_force_inline jo_color jo_sprite_get_pixel_color(const jo_color *const data, const unsigned int x, const unsigned int y, const unsigned int image_width)
Get a specific pixel color from image bytes.
Definition sprites.h:677
bool jo_sprite_add_end_codes(const int sprite_id)
Write the VDP1 end codes after the last visible pixel of each line of a sprite (RGB sprites).
static __jo_force_inline void jo_sprite_enable_half_transparency(void)
Activate half transparency for every sprite displayed after this call.
Definition sprites.h:234
static __jo_force_inline void * jo_sprite_get_raw_data(const int sprite_id)
Get sprite raw image contents.
Definition sprites.h:737
static __jo_force_inline void jo_sprite_free_all(void)
Free all sprites.
Definition sprites.h:187
int jo_sprite_add_4bits_lut(const unsigned char *const pixels, const unsigned short width, const unsigned short height, const jo_color *const lut)
Add a 16 colors texture with its color lookup table: 4 bits per pixel (4 times less VRAM than an RGB ...
int jo_get_last_sprite_id(void)
Get last Sprite Id.
static __jo_force_inline void jo_sprite_disable_shadow_filter(void)
Disable shadow filter for every sprite displayed after this call.
Definition sprites.h:267
int jo_sprite_add_8bits_image(const jo_img_8bits *const img)
Add a 8 bits sprite.
static __jo_force_inline void jo_sprite_enable_screen_doors_filter(void)
Activate screen doors filter for every sprite displayed after this call.
Definition sprites.h:216
#define JO_NO_ZOOM
Value used to keep the original scale (1.0 in jo_fixed).
Definition sprites.h:402
static __jo_force_inline void jo_sprite_enable_gouraud_shading(void)
Activate Gouraud Shading for every sprite displayed after this call.
Definition sprites.h:319
static __jo_force_inline void jo_sprite_enable_dark_filter(void)
Activate dark filter for every sprite displayed after this call.
Definition sprites.h:279
static __jo_force_inline void jo_sprite_enable_shadow_filter(void)
Activate shadow filter for every sprite displayed after this call.
Definition sprites.h:259
static __jo_force_inline void jo_sprite_disable_dark_filter(void)
Disable dark filter for every sprite displayed after this call.
Definition sprites.h:287
static __jo_force_inline void jo_sprite_draw3D_and_rotate2(const int sprite_id, const int x, const int y, const int z, const int angle)
Display a sprite in 3 dimensional space.
Definition sprites.h:533
void jo_sprite_draw_4p_fixed(const int sprite_id, const jo_pos2D_fixed *const four_points, const jo_fixed z, const bool centered_style_coordinates)
Display a sprite on 4 points (distorted sprite).
#define __jo_force_inline
force inline attribute (and prevent Doxygen prototype parsing bug)
Definition types.h:39
int y
Definition types.h:87
unsigned int color_table_index
Definition types.h:287
unsigned short height
Definition types.h:244
unsigned short jo_color
15 bits color type
Definition types.h:53
unsigned short effect
Definition types.h:285
unsigned int clipping
Definition types.h:291
jo_color * data
Definition types.h:245
unsigned short width
Definition types.h:243
jo_fixed fixed_scale_y
Definition types.h:290
int jo_fixed
Fixed point Q16.16 number.
Definition types.h:59
int x
Definition types.h:86
int z
Definition types.h:88
unsigned int gouraud_shading_index
Definition types.h:288
unsigned short direction
Definition types.h:286
jo_fixed fixed_scale_x
Definition types.h:289
15 bits image struct
Definition types.h:242
8 bits image struct
Definition types.h:250
Picture definition.
Definition types.h:234
2D position using fixed number
Definition types.h:76
3D position
Definition types.h:85
Sprite attributes.
Definition types.h:284
Texture definition.
Definition types.h:225
#define JO_VDP1_NO_WINDOW
No clipping window.
Definition vdp1_command_pipeline.h:133
#define JO_VDP1_WINDOW_IN
Draw inside the user clipping area.
Definition vdp1_command_pipeline.h:135
#define JO_VDP1_WINDOW_OUT
Draw outside the user clipping area.
Definition vdp1_command_pipeline.h:137