Jo Engine  2024.04.28
Jo Sega Saturn Engine
Macros | Functions | Variables
sprites.h File Reference

Jo Engine Sprite definition and tools. More...

Go to the source code of this file.

Macros

#define JO_NO_GOURAUD_COLOR
 Value used to keep the original color for jo_set_gouraud_shading_colors() More...
 
#define JO_DEFAULT_BRIGHTNESS
 Default brightness for jo_set_gouraud_shading_brightness() More...
 
#define JO_MAX_BRIGHTNESS
 Maximum brightness value for jo_set_gouraud_shading_brightness() More...
 
#define JO_NO_ZOOM
 Value used to keep the original scale. More...
 

Functions

void jo_sprite_draw (const int sprite_id, const jo_pos3D *const pos, const bool centered_style_coordinates, const bool billboard)
 (internal engine usage) More...
 
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) More...
 
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. More...
 
int jo_get_last_sprite_id (void)
 Get last Sprite Id. More...
 
int jo_sprite_add (const jo_img *const img)
 Add a sprite. More...
 
int jo_sprite_add_8bits_image (const jo_img_8bits *const img)
 Add a 8 bits sprite. More...
 
int jo_sprite_replace (const jo_img *const img, const int sprite_id)
 Replace a sprite. More...
 
void jo_sprite_free_from (const int sprite_id)
 Free all sprites from the given sprite_id. More...
 
static __jo_force_inline void jo_sprite_free_all (void)
 Free all sprites. More...
 
int jo_sprite_name2id (const char *const filename)
 Retrive the Sprite Id from filename based on the four first character in the filename. More...
 
static __jo_force_inline void jo_sprite_enable_screen_doors_filter (void)
 Activate screen doors filter for every sprite displayed after this call. More...
 
static __jo_force_inline void jo_sprite_disable_screen_doors_filter (void)
 Disable screen doors filter for every sprite displayed after this call. More...
 
static __jo_force_inline void jo_sprite_enable_half_transparency (void)
 Activate half transparency for every sprite displayed after this call. More...
 
static __jo_force_inline void jo_sprite_disable_half_transparency (void)
 Disable half transparency for every sprite displayed after this call. More...
 
static __jo_force_inline void jo_sprite_enable_shadow_filter (void)
 Activate shadow filter for every sprite displayed after this call. More...
 
static __jo_force_inline void jo_sprite_disable_shadow_filter (void)
 Disable shadow filter for every sprite displayed after this call. More...
 
static __jo_force_inline void jo_sprite_enable_dark_filter (void)
 Activate dark filter for every sprite displayed after this call. More...
 
static __jo_force_inline void jo_sprite_disable_dark_filter (void)
 Disable dark filter for every sprite displayed after this call. More...
 
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. More...
 
static __jo_force_inline void jo_sprite_enable_gouraud_shading (void)
 Activate Gouraud Shading for every sprite displayed after this call. More...
 
static __jo_force_inline void jo_sprite_disable_gouraud_shading (void)
 Disable Gouraud Shading for every sprite displayed after this call. More...
 
void jo_set_gouraud_shading_brightness (const unsigned char brightness)
 Change Gouraud Shading brightness. More...
 
static __jo_force_inline void jo_sprite_enable_vertical_flip (void)
 Activate vertical flip for every sprite displayed after this call. More...
 
static __jo_force_inline void jo_sprite_disable_vertical_flip (void)
 Disable vertical flip for every sprite displayed after this call. More...
 
static __jo_force_inline void jo_sprite_enable_horizontal_flip (void)
 Activate horizontal flip for every sprite displayed after this call. More...
 
static __jo_force_inline void jo_sprite_disable_horizontal_flip (void)
 Disable horizontal flip for every sprite displayed after this call. More...
 
static __jo_force_inline void jo_sprite_change_sprite_scale (const float scale)
 Change scale for every sprite displayed after this call. More...
 
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. More...
 
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. More...
 
static __jo_force_inline void jo_sprite_restore_sprite_scale (void)
 Restore default scale for every sprite displayed after this call. More...
 
static __jo_force_inline void jo_sprite_set_palette (int palette_id)
 Change palette for every 8 bits sprite displayed after this call. More...
 
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. More...
 
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. More...
 
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. More...
 
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. More...
 
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)
 
static __jo_force_inline void jo_sprite_enable_clipping (bool outside)
 Activate sprite clipping for every sprite displayed after this call. More...
 
static __jo_force_inline void jo_sprite_disable_clipping (void)
 Disable sprite clipping for every sprite displayed after this call. More...
 
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. More...
 
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. More...
 
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. More...
 
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. More...
 
static __jo_force_inline int jo_sprite_get_width (const int sprite_id)
 Get sprite width. More...
 
static __jo_force_inline int jo_sprite_get_height (const int sprite_id)
 Get sprite height. More...
 
static __jo_force_inline void * jo_sprite_get_raw_data (const int sprite_id)
 Get sprite raw image contents. More...
 
static __jo_force_inline int jo_sprite_count (void)
 Get sprite count. More...
 
int jo_sprite_usage_percent (void)
 Get sprite memory usage. More...
 

Variables

jo_sprite_attributes __jo_sprite_attributes
 Current displayed sprite attribute (internal engine usage) More...
 
jo_texture_definition __jo_sprite_def [JO_MAX_SPRITE]
 (internal engine usage) More...
 
jo_picture_definition __jo_sprite_pic [JO_MAX_SPRITE]
 (internal engine usage) More...
 

Detailed Description

Jo Engine Sprite definition and tools.

Author
Johannes Fetz
Bug:
No known bugs.

Macro Definition Documentation

◆ JO_DEFAULT_BRIGHTNESS

#define JO_DEFAULT_BRIGHTNESS

Default brightness for jo_set_gouraud_shading_brightness()

◆ JO_MAX_BRIGHTNESS

#define JO_MAX_BRIGHTNESS

Maximum brightness value for jo_set_gouraud_shading_brightness()

◆ JO_NO_GOURAUD_COLOR

#define JO_NO_GOURAUD_COLOR

Value used to keep the original color for jo_set_gouraud_shading_colors()

◆ JO_NO_ZOOM

#define JO_NO_ZOOM

Value used to keep the original scale.

Function Documentation

◆ __internal_jo_sprite_set_position3D()

static __jo_force_inline void __internal_jo_sprite_set_position3D ( const int  x,
const int  y,
const int  z 
)
static

Internal usage don't use it.

◆ jo_get_last_sprite_id()

int jo_get_last_sprite_id ( void  )

Get last Sprite Id.

Returns
Last Sprite Id

◆ jo_set_gouraud_shading_brightness()

void jo_set_gouraud_shading_brightness ( const unsigned char  brightness)

Change Gouraud Shading brightness.

Parameters
brightnessBrightness from 0 to 31

◆ jo_set_gouraud_shading_colors()

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.

Parameters
topleft_colorTop left corner color in sprite
topright_colorTop right corner color in sprite
bottomright_colorbottom right corner color in sprite
bottomleft_colorbottom left corner color in sprite

◆ jo_sprite_add()

int jo_sprite_add ( const jo_img *const  img)

Add a sprite.

Parameters
imgPointer to a 15 bits image struct
Returns
Sprite Id or -1 if failed

◆ jo_sprite_add_8bits_image()

int jo_sprite_add_8bits_image ( const jo_img_8bits *const  img)

Add a 8 bits sprite.

Parameters
imgPointer to a 8 bits bits image struct
Returns
Sprite Id or -1 if failed
Warning
255 colors maximum not 256 !

◆ jo_sprite_change_sprite_scale()

static __jo_force_inline void jo_sprite_change_sprite_scale ( const float  scale)
static

Change scale for every sprite displayed after this call.

Parameters
scaleSprite scale

◆ jo_sprite_change_sprite_scale_xy()

static __jo_force_inline void jo_sprite_change_sprite_scale_xy ( const float  scale_x,
const float  scale_y 
)
static

Change scale for every sprite displayed after this call.

Parameters
scale_xHorizontal sprite scale
scale_yVertical sprite scale

◆ jo_sprite_change_sprite_scale_xy_fixed()

static __jo_force_inline void jo_sprite_change_sprite_scale_xy_fixed ( const jo_fixed  scale_x,
const jo_fixed  scale_y 
)
static

Change scale for every sprite displayed after this call using fixed number.

Parameters
scale_xHorizontal sprite scale
scale_yVertical sprite scale

◆ jo_sprite_count()

static __jo_force_inline int jo_sprite_count ( void  )
static

Get sprite count.

Returns
Count

◆ jo_sprite_disable_clipping()

static __jo_force_inline void jo_sprite_disable_clipping ( void  )
static

Disable sprite clipping for every sprite displayed after this call.

◆ jo_sprite_disable_dark_filter()

static __jo_force_inline void jo_sprite_disable_dark_filter ( void  )
static

Disable dark filter for every sprite displayed after this call.

◆ jo_sprite_disable_gouraud_shading()

static __jo_force_inline void jo_sprite_disable_gouraud_shading ( void  )
static

Disable Gouraud Shading for every sprite displayed after this call.

◆ jo_sprite_disable_half_transparency()

static __jo_force_inline void jo_sprite_disable_half_transparency ( void  )
static

Disable half transparency for every sprite displayed after this call.

◆ jo_sprite_disable_horizontal_flip()

static __jo_force_inline void jo_sprite_disable_horizontal_flip ( void  )
static

Disable horizontal flip for every sprite displayed after this call.

◆ jo_sprite_disable_screen_doors_filter()

static __jo_force_inline void jo_sprite_disable_screen_doors_filter ( void  )
static

Disable screen doors filter for every sprite displayed after this call.

◆ jo_sprite_disable_shadow_filter()

static __jo_force_inline void jo_sprite_disable_shadow_filter ( void  )
static

Disable shadow filter for every sprite displayed after this call.

◆ jo_sprite_disable_vertical_flip()

static __jo_force_inline void jo_sprite_disable_vertical_flip ( void  )
static

Disable vertical flip for every sprite displayed after this call.

◆ jo_sprite_draw()

void jo_sprite_draw ( const int  sprite_id,
const jo_pos3D *const  pos,
const bool  centered_style_coordinates,
const bool  billboard 
)

(internal engine usage)

Warning
MC Hammer: don't touch this

◆ jo_sprite_draw3D()

static __jo_force_inline void jo_sprite_draw3D ( const int  sprite_id,
const int  x,
const int  y,
const int  z 
)
static

Display a sprite in 3 dimensional space.

Parameters
sprite_idSprite Id
xHorizontal position from the center of the screen
yVertical position from the center of the screen
zZ index (depth))

◆ jo_sprite_draw3D2()

static __jo_force_inline void jo_sprite_draw3D2 ( const int  sprite_id,
const int  x,
const int  y,
const int  z 
)
static

Display a sprite in 3 dimensional space.

Parameters
sprite_idSprite Id returned by jo_sprite_add(), jo_sprite_add_tga() or jo_sprite_add_image_pack()
xHorizontal position from the top left corner
yVertical position from the top left corner
zZ index (depth)

◆ jo_sprite_draw3D_and_rotate()

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 
)
static

Display a sprite in 3 dimensional space.

Parameters
sprite_idSprite Id
xHorizontal position from the center of the screen
yVertical position from the center of the screen
zZ index (depth)
angleAngle (Z axe)

◆ jo_sprite_draw3D_and_rotate2()

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 
)
static

Display a sprite in 3 dimensional space.

Parameters
sprite_idSprite Id returned by jo_sprite_add(), jo_sprite_add_tga() or jo_sprite_add_image_pack()
xHorizontal position from the top left corner
yVertical position from the top left corner
zZ index (depth)
angleAngle (Z axe)

◆ jo_sprite_draw_4p_fixed()

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 
)

◆ jo_sprite_draw_rotate()

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)

Warning
MC Hammer: don't touch this

◆ jo_sprite_enable_clipping()

static __jo_force_inline void jo_sprite_enable_clipping ( bool  outside)
static

Activate sprite clipping for every sprite displayed after this call.

Parameters
outsideClip everything inside clipping area

◆ jo_sprite_enable_dark_filter()

static __jo_force_inline void jo_sprite_enable_dark_filter ( void  )
static

Activate dark filter for every sprite displayed after this call.

◆ jo_sprite_enable_gouraud_shading()

static __jo_force_inline void jo_sprite_enable_gouraud_shading ( void  )
static

Activate Gouraud Shading for every sprite displayed after this call.

◆ jo_sprite_enable_half_transparency()

static __jo_force_inline void jo_sprite_enable_half_transparency ( void  )
static

Activate half transparency for every sprite displayed after this call.

◆ jo_sprite_enable_horizontal_flip()

static __jo_force_inline void jo_sprite_enable_horizontal_flip ( void  )
static

Activate horizontal flip for every sprite displayed after this call.

◆ jo_sprite_enable_screen_doors_filter()

static __jo_force_inline void jo_sprite_enable_screen_doors_filter ( void  )
static

Activate screen doors filter for every sprite displayed after this call.

◆ jo_sprite_enable_shadow_filter()

static __jo_force_inline void jo_sprite_enable_shadow_filter ( void  )
static

Activate shadow filter for every sprite displayed after this call.

◆ jo_sprite_enable_vertical_flip()

static __jo_force_inline void jo_sprite_enable_vertical_flip ( void  )
static

Activate vertical flip for every sprite displayed after this call.

◆ jo_sprite_free_all()

static __jo_force_inline void jo_sprite_free_all ( void  )
static

Free all sprites.

Warning
Don't use any sprites after this call or the game may crash unexpectedly

◆ jo_sprite_free_from()

void jo_sprite_free_from ( const int  sprite_id)

Free all sprites from the given sprite_id.

Parameters
sprite_idSprite ID to replace
Warning
Don't use freed sprites after this call or the game may crash unexpectedly

◆ jo_sprite_get_height()

static __jo_force_inline int jo_sprite_get_height ( const int  sprite_id)
static

Get sprite height.

Parameters
sprite_idSprite Id returned by jo_sprite_add(), jo_sprite_add_tga() or jo_sprite_add_image_pack()
Returns
Sprite height

◆ jo_sprite_get_pixel_color()

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 
)
static

Get a specific pixel color from image bytes.

Parameters
dataBytes (raw image data)
xHorizontal ccord in the image
yVertical ccord in the image
image_widthImage width (in pixels)
Warning
This method doesn't work for 8 bits image

◆ jo_sprite_get_pixel_palette_index()

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 
)
static

Get a specific pixel palette index from image bytes.

Parameters
dataBytes (raw image data)
xHorizontal ccord in the image
yVertical ccord in the image
image_widthImage width (in pixels)
Warning
This method only works for 8 bits image

◆ jo_sprite_get_raw_data()

static __jo_force_inline void* jo_sprite_get_raw_data ( const int  sprite_id)
static

Get sprite raw image contents.

Parameters
sprite_idSprite Id returned by jo_sprite_add(), jo_sprite_add_tga() or jo_sprite_add_image_pack()
Returns
Raw image contents

◆ jo_sprite_get_width()

static __jo_force_inline int jo_sprite_get_width ( const int  sprite_id)
static

Get sprite width.

Parameters
sprite_idSprite Id returned by jo_sprite_add(), jo_sprite_add_tga() or jo_sprite_add_image_pack()
Returns
Sprite width

◆ jo_sprite_is_pixel_transparent()

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 
)
static

Get if a specific pixel is transparent (JO_COLOR_Transparent) in image bytes.

Parameters
dataBytes (raw image data)
xHorizontal ccord in the image
yVertical ccord in the image
Returns
true if the pixel is transparent otherwise false
Parameters
image_widthImage width (in pixels)
Warning
This method doesn't work for 8 bits image

◆ jo_sprite_name2id()

int jo_sprite_name2id ( const char *const  filename)

Retrive the Sprite Id from filename based on the four first character in the filename.

Parameters
filenameFilename (upper case and shorter as possible like "A.TEX")
Warning
Slow, use carefully
Returns
Sprite Id of the first image or -1 if not found

◆ jo_sprite_replace()

int jo_sprite_replace ( const jo_img *const  img,
const int  sprite_id 
)

Replace a sprite.

Parameters
imgPointer to a image struct
sprite_idSprite ID to replace
Returns
sprite_id

◆ jo_sprite_restore_sprite_scale()

static __jo_force_inline void jo_sprite_restore_sprite_scale ( void  )
static

Restore default scale for every sprite displayed after this call.

◆ jo_sprite_set_clipping_area()

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.

Parameters
xHorizontal coord from top left corner
yVertical coord from top left corner
widthWidth of the clipping rectangle
heightHeight of the clipping rectangle
depthSpecifies depth up to which sprites get clipped

◆ jo_sprite_set_palette()

static __jo_force_inline void jo_sprite_set_palette ( int  palette_id)
static

Change palette for every 8 bits sprite displayed after this call.

Parameters
palette_idPalette id from jo_create_palette()

◆ jo_sprite_usage_percent()

int jo_sprite_usage_percent ( void  )

Get sprite memory usage.

Returns
Sprite memory usage percent
Remarks
jo_printf(0, 0, "Sprite memory usage: %d%% ", jo_sprite_usage_percent());

Variable Documentation

◆ __jo_sprite_attributes

jo_sprite_attributes __jo_sprite_attributes

Current displayed sprite attribute (internal engine usage)

Warning
MC Hammer: don't touch this

◆ __jo_sprite_def

jo_texture_definition __jo_sprite_def[JO_MAX_SPRITE]

(internal engine usage)

Warning
MC Hammer: don't touch this

◆ __jo_sprite_pic

jo_picture_definition __jo_sprite_pic[JO_MAX_SPRITE]

(internal engine usage)

Warning
MC Hammer: don't touch this