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

Jo Engine Background definition and tools. More...

Go to the source code of this file.

Macros

#define JO_SCROLL_TABLE_SIZE
 512 entries. One offset for each line because the background size is a 512x512 pixels by default. More...
 

Functions

static __jo_force_inline void jo_set_background_8bits_sprite (jo_img_8bits *img, int palette_id, bool vertical_flip)
 Add 8 bits background sprite. More...
 
static __jo_force_inline void jo_set_background_sprite (const jo_img *const img, const unsigned short left, const unsigned short top)
 Add background sprite. More...
 
static __jo_force_inline void jo_clear_background (const jo_color color)
 Clear the background. More...
 
static __jo_force_inline void jo_move_background (const int x, const int y)
 Move background (scrolling) More...
 
static __jo_force_inline void jo_zoom_background2 (const float width_factor, const float height_factor)
 Zoom background width and height independently. More...
 
static __jo_force_inline void jo_zoom_background (const float factor)
 Zoom background. More...
 
static __jo_force_inline void jo_draw_background_line (int x0, int y0, int x1, int y1, const jo_color color)
 Draw a line using Bresenham's line algorithm. More...
 
static __jo_force_inline void jo_draw_background_square (const int x, const int y, const short width, const short height, const jo_color color)
 Draw a square on the background. More...
 
static __jo_force_inline void jo_put_pixel_in_background (const int x, const int y, const jo_color color)
 Put pixel in background using color. More...
 
static __jo_force_inline void jo_put_pixel_in_background_rgb (const int x, const int y, unsigned char r, unsigned char g, unsigned char b)
 Put pixel in background using composite color. More...
 
static __jo_force_inline void jo_enable_background_3d_plane (jo_color background_color)
 Enable 3D planes. More...
 
static __jo_force_inline void jo_disable_background_3d_plane (jo_color background_color)
 Disable 3D planes. More...
 
static __jo_force_inline void jo_background_3d_plane_a_img (jo_img_8bits *img, int palette_id, bool repeat, bool vertical_flip)
 Setup plane A. More...
 
static __jo_force_inline void jo_background_3d_plane_b_img (jo_img_8bits *img, int palette_id, bool repeat, bool vertical_flip)
 Setup plane B. More...
 
static __jo_force_inline void jo_background_3d_plane_a_draw (const bool use_scroll_format_matrix)
 Draw plane A. More...
 
static __jo_force_inline void jo_background_3d_plane_b_draw (const bool use_scroll_format_matrix)
 Draw plane A. More...
 
static __jo_force_inline int * jo_enable_background_horizontal_line_scroll (void)
 Enable horizontal line scroll effect. More...
 
static __jo_force_inline void jo_disable_background_horizontal_line_scroll (void)
 Disable horizontal line scroll effect. More...
 
static __jo_force_inline void jo_compute_background_horizontal_line_scroll (unsigned short offset)
 Compute horizontal line scroll effect using specific offset. More...
 

Detailed Description

Jo Engine Background definition and tools.

Author
Johannes Fetz
Warning
▲ IF YOUR ARE FAMILIAR WITH SEGA SATURN HARDWARE, USE vdp2.h FUNCTIONS INSTEAD ▲
IT'S JUST A WRAPPER FOR THOSE WHO DON'T CARE ABOUT SCREEN SCROLL AND VDP2 USAGE
Bug:
No known bugs.

Macro Definition Documentation

◆ JO_SCROLL_TABLE_SIZE

#define JO_SCROLL_TABLE_SIZE

512 entries. One offset for each line because the background size is a 512x512 pixels by default.

Function Documentation

◆ jo_background_3d_plane_a_draw()

static __jo_force_inline void jo_background_3d_plane_a_draw ( const bool  use_scroll_format_matrix)
static

Draw plane A.

Parameters
use_scroll_format_matrixConvert current matrix to scroll format matrix

◆ jo_background_3d_plane_a_img()

static __jo_force_inline void jo_background_3d_plane_a_img ( jo_img_8bits img,
int  palette_id,
bool  repeat,
bool  vertical_flip 
)
static

Setup plane A.

Parameters
img8 bits 255 colors max image. (Width AND height must be a multiple of 8)
palette_idpalette id from TGA (see also jo_palette)
repeatRepeat the plane infinitely.
vertical_flipFlip image vertically
Warning
Image need to be clockwised rotated (right) because of an optimisation

◆ jo_background_3d_plane_b_draw()

static __jo_force_inline void jo_background_3d_plane_b_draw ( const bool  use_scroll_format_matrix)
static

Draw plane A.

Parameters
use_scroll_format_matrixConvert current matrix to scroll format matrix

◆ jo_background_3d_plane_b_img()

static __jo_force_inline void jo_background_3d_plane_b_img ( jo_img_8bits img,
int  palette_id,
bool  repeat,
bool  vertical_flip 
)
static

Setup plane B.

Parameters
img8 bits 255 colors max image. (Width AND height must be a multiple of 8)
palette_idpalette id from TGA (see also jo_palette)
repeatRepeat the plane infinitely.
vertical_flipFlip image vertically
Warning
Image need to be clockwised rotated (right) because of an optimisation

◆ jo_clear_background()

static __jo_force_inline void jo_clear_background ( const jo_color  color)
static

Clear the background.

Parameters
colorClear color

◆ jo_compute_background_horizontal_line_scroll()

static __jo_force_inline void jo_compute_background_horizontal_line_scroll ( unsigned short  offset)
static

Compute horizontal line scroll effect using specific offset.

Parameters
offsetOffset in scroll table returned by jo_enable_background_horizontal_line_scroll()

◆ jo_disable_background_3d_plane()

static __jo_force_inline void jo_disable_background_3d_plane ( jo_color  background_color)
static

Disable 3D planes.

Parameters
background_colorColor (ex: JO_COLOR_Red)

◆ jo_disable_background_horizontal_line_scroll()

static __jo_force_inline void jo_disable_background_horizontal_line_scroll ( void  )
static

Disable horizontal line scroll effect.

◆ jo_draw_background_line()

static __jo_force_inline void jo_draw_background_line ( int  x0,
int  y0,
int  x1,
int  y1,
const jo_color  color 
)
static

Draw a line using Bresenham's line algorithm.

Parameters
x0horizontal location of the beginning of the line
y0vertical location of the beginning of the line
x1horizontal location of the end of the line
y1vertical location of the end of the line
colorColor (ex: JO_COLOR_Red)

◆ jo_draw_background_square()

static __jo_force_inline void jo_draw_background_square ( const int  x,
const int  y,
const short  width,
const short  height,
const jo_color  color 
)
static

Draw a square on the background.

Parameters
xSquare horizontal location
ySquare vertical location
widthSquare width
heightSquare height
colorColor (ex: JO_COLOR_Red)

◆ jo_enable_background_3d_plane()

static __jo_force_inline void jo_enable_background_3d_plane ( jo_color  background_color)
static

Enable 3D planes.

Parameters
background_colorColor (ex: JO_COLOR_Red)

◆ jo_enable_background_horizontal_line_scroll()

static __jo_force_inline int* jo_enable_background_horizontal_line_scroll ( void  )
static

Enable horizontal line scroll effect.

Returns
An array of 512 entries. One offset for each line because the background size is a 512x512 pixels by default.
Warning
Only works with 8 bits background image

◆ jo_move_background()

static __jo_force_inline void jo_move_background ( const int  x,
const int  y 
)
static

Move background (scrolling)

Parameters
xhorizontal location
yvertical location

◆ jo_put_pixel_in_background()

static __jo_force_inline void jo_put_pixel_in_background ( const int  x,
const int  y,
const jo_color  color 
)
static

Put pixel in background using color.

Parameters
xhorizontal location
yvertical location
colorColor (ex: JO_COLOR_Red)

◆ jo_put_pixel_in_background_rgb()

static __jo_force_inline void jo_put_pixel_in_background_rgb ( const int  x,
const int  y,
unsigned char  r,
unsigned char  g,
unsigned char  b 
)
static

Put pixel in background using composite color.

Parameters
xhorizontal location
yvertical location
rRed color component
gGreen color component
bBlue color component

◆ jo_set_background_8bits_sprite()

static __jo_force_inline void jo_set_background_8bits_sprite ( jo_img_8bits img,
int  palette_id,
bool  vertical_flip 
)
static

Add 8 bits background sprite.

Parameters
img8 bits 255 colors max image. (Width AND height must be a multiple of 8)
palette_idpalette id from TGA (see also jo_palette)
vertical_flipFlip image vertically
Warning
Image need to be clockwised rotated (right) because of an optimisation

◆ jo_set_background_sprite()

static __jo_force_inline void jo_set_background_sprite ( const jo_img *const  img,
const unsigned short  left,
const unsigned short  top 
)
static

Add background sprite.

Parameters
imgPointer to an image struct
leftLeft location
topTop location

◆ jo_zoom_background()

static __jo_force_inline void jo_zoom_background ( const float  factor)
static

Zoom background.

Parameters
factorZoom factor

◆ jo_zoom_background2()

static __jo_force_inline void jo_zoom_background2 ( const float  width_factor,
const float  height_factor 
)
static

Zoom background width and height independently.

Parameters
width_factorWidth zoom factor
height_factorHeight zoom factor