Jo Engine  2020.06.22
Jo Sega Saturn Engine
Macros | Functions | Variables
vdp2.h File Reference

Jo Engine VDP2 definition and tools. More...

Go to the source code of this file.

Macros

#define jo_nbg2_printf(X, Y, ...)
 NBG2 printf implementation (jo_set_nbg2_8bits_font must be called before) More...
 
#define jo_nbg3_printf(X, Y, ...)
 NBG3 printf implementation (jo_set_nbg3_8bits_font must be called before) More...
 
#define JO_NBG1_SCROLL_TABLE_SIZE
 512 entries. One offset for each line because the background size is a 512x512 pixels by default. More...
 
#define JO_NBG0_SCROLL_TABLE_SIZE
 512 entries. One offset for each line because the background size is a 512x512 pixels by default. More...
 

Functions

int sprintf (char *str, const char *format,...)
 sprintf prototypes More...
 
void jo_set_displayed_screens (const jo_scroll_screen scroll_screen_flags)
 Set displayed screens. More...
 
void jo_set_default_background_color (const jo_color background_color)
 Set default background color. More...
 
void jo_nbg2_print (int x, int y, char *str)
 NBG2 Print implementation. More...
 
void jo_vdp2_set_nbg2_8bits_font (jo_img_8bits *img, char *mapping, int palette_id, bool vertical_flip, bool enabled)
 Set 8 bits NBG2 font image. More...
 
void jo_nbg2_clear (void)
 Clear NBG2. More...
 
void jo_nbg3_print (int x, int y, char *str)
 NBG3 Print implementation. More...
 
void jo_vdp2_set_nbg3_8bits_font (jo_img_8bits *img, char *mapping, int palette_id, bool vertical_flip, bool enabled)
 Set 8 bits NBG3 font image. More...
 
void jo_nbg3_clear (void)
 Clear NBG3. More...
 
void jo_vdp2_set_nbg1_8bits_image (jo_img_8bits *img, int palette_id, bool vertical_flip)
 Add 8 bits NBG1 image. More...
 
void jo_vdp2_set_nbg0_8bits_image (jo_img_8bits *img, int palette_id, bool vertical_flip, bool enabled)
 Set 8 bits NBG0 image. More...
 
void jo_vdp2_set_nbg2_8bits_image (jo_img_8bits *img, int palette_id, bool vertical_flip, bool enabled)
 Set 8 bits NBG2 image. More...
 
void jo_vdp2_set_nbg3_8bits_image (jo_img_8bits *img, int palette_id, bool vertical_flip, bool enabled)
 Set 8 bits NBG3 image. More...
 
void jo_vdp2_set_nbg1_image (const jo_img *const img, const unsigned short left, const unsigned short top)
 Set NBG1 bitmap image. More...
 
void jo_vdp2_clear_bitmap_nbg1 (const jo_color color)
 Clear NBG1 bitmap. More...
 
static __jo_force_inline void jo_vdp2_move_nbg1 (const int x, const int y)
 Move NBG1 (scrolling) More...
 
static __jo_force_inline void jo_vdp2_zoom_nbg1f (const float width_factor, const float height_factor)
 Zoom NBG1 width and height independently. More...
 
static __jo_force_inline void jo_vdp2_zoom_nbg1 (const float factor)
 Zoom NBG1. More...
 
static __jo_force_inline void jo_vdp2_move_nbg0 (const int x, const int y)
 Move NBG0 (scrolling) More...
 
static __jo_force_inline void jo_vdp2_zoom_nbg0f (const float width_factor, const float height_factor)
 Zoom NBG0 width and height independently. More...
 
static __jo_force_inline void jo_vdp2_zoom_nbg0 (const float factor)
 Zoom NBG0. More...
 
void jo_vdp2_draw_bitmap_nbg1_line (int x0, int y0, int x1, int y1, const jo_color color)
 Draw a NBG1 line using Bresenham's line algorithm. More...
 
static __jo_force_inline void jo_vdp2_draw_bitmap_nbg1_square (const int x, const int y, const short width, const short height, const jo_color color)
 Draw a square on NBG1. More...
 
static __jo_force_inline void jo_vdp2_put_pixel_bitmap_nbg1 (const int x, const int y, const jo_color color)
 Put pixel in NBG1 using color. More...
 
static __jo_force_inline void jo_vdp2_put_pixel_bitmap_nbg1_rgb (const int x, const int y, unsigned char r, unsigned char g, unsigned char b)
 Put pixel in NBG1 using composite color. More...
 
void jo_vdp2_enable_rbg0 (void)
 Enable 3D planes. More...
 
void jo_vdp2_disable_rbg0 (void)
 Disable 3D planes. More...
 
void jo_vdp2_set_rbg0_plane_a_8bits_image (jo_img_8bits *img, int palette_id, bool repeat, bool vertical_flip)
 Setup plane A. More...
 
void jo_vdp2_set_rbg0_plane_b_8bits_image (jo_img_8bits *img, int palette_id, bool repeat, bool vertical_flip)
 Setup plane B. More...
 
static __jo_force_inline void jo_vdp2_draw_rbg0_plane_a (const bool use_scroll_format_matrix)
 Draw plane A. More...
 
static __jo_force_inline void jo_vdp2_draw_rbg0_plane_b (const bool use_scroll_format_matrix)
 Draw plane A. More...
 
static __jo_force_inline void jo_enable_screen_mozaic (const jo_scroll_screen screens, const short x, const short y)
 Enable mozaic effect for scroll screen. More...
 
static __jo_force_inline void jo_disable_all_screen_mozaic (void)
 Disable mozaic effect for all scroll screen. More...
 
int * jo_vdp2_enable_nbg1_line_scroll (void)
 Enable NBG1 horizontal line scroll effect. More...
 
void jo_vdp2_disable_nbg1_line_scroll (void)
 Disable NBG1 horizontal line scroll effect. More...
 
void jo_vdp2_compute_nbg1_line_scroll (unsigned short offset)
 Compute NBG1 horizontal line scroll effect using specific offset. More...
 
int * jo_vdp2_enable_nbg0_line_scroll (void)
 Enable NBG0 horizontal line scroll effect. More...
 
void jo_vdp2_disable_nbg0_line_scroll (void)
 Disable NBG0 horizontal line scroll effect. More...
 
void jo_vdp2_compute_nbg0_line_scroll (unsigned short offset)
 Compute NBG0 horizontal line scroll effect using specific offset. More...
 
void jo_disable_all_screens_transparency (void)
 Disable all screens transparency. More...
 
void jo_enable_screen_transparency (const jo_scroll_screen screen, const unsigned short transparency_level)
 Enable screen transparency. More...
 

Variables

char __jo_sprintf_buf [JO_PRINTF_BUF_SIZE]
 Internal sprintf buffer. More...
 

Detailed Description

Jo Engine VDP2 definition and tools.

Author
Johannes Fetz
Bug:
No known bugs.

Macro Definition Documentation

◆ JO_NBG0_SCROLL_TABLE_SIZE

#define JO_NBG0_SCROLL_TABLE_SIZE

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

◆ JO_NBG1_SCROLL_TABLE_SIZE

#define JO_NBG1_SCROLL_TABLE_SIZE

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

◆ jo_nbg2_printf

#define jo_nbg2_printf (   X,
  Y,
  ... 
)

NBG2 printf implementation (jo_set_nbg2_8bits_font must be called before)

Parameters
XHorizontal position from top left screen corner
YVertical position from top left screen corner
...Arguments

◆ jo_nbg3_printf

#define jo_nbg3_printf (   X,
  Y,
  ... 
)

NBG3 printf implementation (jo_set_nbg3_8bits_font must be called before)

Parameters
XHorizontal position from top left screen corner
YVertical position from top left screen corner
...Arguments

Function Documentation

◆ jo_disable_all_screen_mozaic()

static __jo_force_inline void jo_disable_all_screen_mozaic ( void  )
static

Disable mozaic effect for all scroll screen.

◆ jo_disable_all_screens_transparency()

void jo_disable_all_screens_transparency ( void  )

Disable all screens transparency.

◆ jo_enable_screen_mozaic()

static __jo_force_inline void jo_enable_screen_mozaic ( const jo_scroll_screen  screens,
const short  x,
const short  y 
)
static

Enable mozaic effect for scroll screen.

Parameters
screensScroll screens (You can pass multiple value using pipe(|). Example: JO_NBG1_SCREEN|JO_NBG2_SCREEN)
xHorizontal mozaic size [1-16]
yVertical mozaic size [1-16]
Warning
Only JO_NBG0_SCREEN, JO_NBG1_SCREEN, JO_NBG2_SCREEN, JO_NBG3_SCREEN and JO_RBG0_SCREEN supports this feature

◆ jo_enable_screen_transparency()

void jo_enable_screen_transparency ( const jo_scroll_screen  screen,
const unsigned short  transparency_level 
)

Enable screen transparency.

Parameters
screenScroll screen
transparency_levelTransparency Level 0 (fully visible) to 31 (almost invisible)

◆ jo_nbg2_clear()

void jo_nbg2_clear ( void  )

Clear NBG2.

◆ jo_nbg2_print()

void jo_nbg2_print ( int  x,
int  y,
char *  str 
)

NBG2 Print implementation.

Parameters
xHorizontal position from top left screen corner
yVertical position from top left screen corner
strString

◆ jo_nbg3_clear()

void jo_nbg3_clear ( void  )

Clear NBG3.

◆ jo_nbg3_print()

void jo_nbg3_print ( int  x,
int  y,
char *  str 
)

NBG3 Print implementation.

Parameters
xHorizontal position from top left screen corner
yVertical position from top left screen corner
strString

◆ jo_set_default_background_color()

void jo_set_default_background_color ( const jo_color  background_color)

Set default background color.

Parameters
background_colorColor

◆ jo_set_displayed_screens()

void jo_set_displayed_screens ( const jo_scroll_screen  scroll_screen_flags)

Set displayed screens.

Parameters
scroll_screen_flagsScroll screens (You can pass multiple value using pipe(|). Example: JO_NBG1_SCREEN|JO_NBG2_SCREEN)

◆ jo_vdp2_clear_bitmap_nbg1()

void jo_vdp2_clear_bitmap_nbg1 ( const jo_color  color)

Clear NBG1 bitmap.

Parameters
colorClear color

◆ jo_vdp2_compute_nbg0_line_scroll()

void jo_vdp2_compute_nbg0_line_scroll ( unsigned short  offset)

Compute NBG0 horizontal line scroll effect using specific offset.

Parameters
offsetOffset in scroll table returned by jo_vdp2_enable_nbg1_line_scroll()

◆ jo_vdp2_compute_nbg1_line_scroll()

void jo_vdp2_compute_nbg1_line_scroll ( unsigned short  offset)

Compute NBG1 horizontal line scroll effect using specific offset.

Parameters
offsetOffset in scroll table returned by jo_vdp2_enable_nbg1_line_scroll()

◆ jo_vdp2_disable_nbg0_line_scroll()

void jo_vdp2_disable_nbg0_line_scroll ( void  )

Disable NBG0 horizontal line scroll effect.

◆ jo_vdp2_disable_nbg1_line_scroll()

void jo_vdp2_disable_nbg1_line_scroll ( void  )

Disable NBG1 horizontal line scroll effect.

◆ jo_vdp2_disable_rbg0()

void jo_vdp2_disable_rbg0 ( void  )

Disable 3D planes.

◆ jo_vdp2_draw_bitmap_nbg1_line()

void jo_vdp2_draw_bitmap_nbg1_line ( int  x0,
int  y0,
int  x1,
int  y1,
const jo_color  color 
)

Draw a NBG1 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_vdp2_draw_bitmap_nbg1_square()

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

Draw a square on NBG1.

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

◆ jo_vdp2_draw_rbg0_plane_a()

static __jo_force_inline void jo_vdp2_draw_rbg0_plane_a ( const bool  use_scroll_format_matrix)
static

Draw plane A.

Parameters
use_scroll_format_matrixConvert current matrix to scroll format matrix

◆ jo_vdp2_draw_rbg0_plane_b()

static __jo_force_inline void jo_vdp2_draw_rbg0_plane_b ( const bool  use_scroll_format_matrix)
static

Draw plane A.

Parameters
use_scroll_format_matrixConvert current matrix to scroll format matrix

◆ jo_vdp2_enable_nbg0_line_scroll()

int* jo_vdp2_enable_nbg0_line_scroll ( void  )

Enable NBG0 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_vdp2_enable_nbg1_line_scroll()

int* jo_vdp2_enable_nbg1_line_scroll ( void  )

Enable NBG1 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_vdp2_enable_rbg0()

void jo_vdp2_enable_rbg0 ( void  )

Enable 3D planes.

◆ jo_vdp2_move_nbg0()

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

Move NBG0 (scrolling)

Parameters
xhorizontal location
yvertical location

◆ jo_vdp2_move_nbg1()

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

Move NBG1 (scrolling)

Parameters
xhorizontal location
yvertical location

◆ jo_vdp2_put_pixel_bitmap_nbg1()

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

Put pixel in NBG1 using color.

Parameters
xhorizontal location
yvertical location
colorColor (ex: JO_COLOR_Red)

◆ jo_vdp2_put_pixel_bitmap_nbg1_rgb()

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

Put pixel in NBG1 using composite color.

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

◆ jo_vdp2_set_nbg0_8bits_image()

void jo_vdp2_set_nbg0_8bits_image ( jo_img_8bits img,
int  palette_id,
bool  vertical_flip,
bool  enabled 
)

Set 8 bits NBG0 image.

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
enabledDisplay NBG0 now
Warning
Image need to be clockwised rotated (right) because of an optimisation

◆ jo_vdp2_set_nbg1_8bits_image()

void jo_vdp2_set_nbg1_8bits_image ( jo_img_8bits img,
int  palette_id,
bool  vertical_flip 
)

Add 8 bits NBG1 image.

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_vdp2_set_nbg1_image()

void jo_vdp2_set_nbg1_image ( const jo_img *const  img,
const unsigned short  left,
const unsigned short  top 
)

Set NBG1 bitmap image.

Parameters
imgPointer to an image struct
leftLeft location
topTop location

◆ jo_vdp2_set_nbg2_8bits_font()

void jo_vdp2_set_nbg2_8bits_font ( jo_img_8bits img,
char *  mapping,
int  palette_id,
bool  vertical_flip,
bool  enabled 
)

Set 8 bits NBG2 font image.

Parameters
img8 bits 255 colors max image. (height must be a multiple of 8). Width must be 8.
mappingImage pattern : " 0123456789ABCDEFGH...". The first character must be an empty space.
palette_idpalette id from TGA (see also jo_palette)
vertical_flipFlip image vertically
enabledDisplay NBG2 now
Warning
Image need to be clockwised rotated (right) because of an optimisation

◆ jo_vdp2_set_nbg2_8bits_image()

void jo_vdp2_set_nbg2_8bits_image ( jo_img_8bits img,
int  palette_id,
bool  vertical_flip,
bool  enabled 
)

Set 8 bits NBG2 image.

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
enabledDisplay NBG2 now
Warning
Image need to be clockwised rotated (right) because of an optimisation

◆ jo_vdp2_set_nbg3_8bits_font()

void jo_vdp2_set_nbg3_8bits_font ( jo_img_8bits img,
char *  mapping,
int  palette_id,
bool  vertical_flip,
bool  enabled 
)

Set 8 bits NBG3 font image.

Parameters
img8 bits 255 colors max image. (height must be a multiple of 8). Width must be 8
mappingImage pattern : "0123456789ABCDEFGH...". The first character must be an empty space.
palette_idpalette id from TGA (see also jo_palette)
vertical_flipFlip image vertically
enabledDisplay NBG2 now
Warning
Image need to be clockwised rotated (right) because of an optimisation

◆ jo_vdp2_set_nbg3_8bits_image()

void jo_vdp2_set_nbg3_8bits_image ( jo_img_8bits img,
int  palette_id,
bool  vertical_flip,
bool  enabled 
)

Set 8 bits NBG3 image.

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
enabledDisplay NBG3 now
Warning
Image need to be clockwised rotated (right) because of an optimisation

◆ jo_vdp2_set_rbg0_plane_a_8bits_image()

void jo_vdp2_set_rbg0_plane_a_8bits_image ( jo_img_8bits img,
int  palette_id,
bool  repeat,
bool  vertical_flip 
)

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_vdp2_set_rbg0_plane_b_8bits_image()

void jo_vdp2_set_rbg0_plane_b_8bits_image ( jo_img_8bits img,
int  palette_id,
bool  repeat,
bool  vertical_flip 
)

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_vdp2_zoom_nbg0()

static __jo_force_inline void jo_vdp2_zoom_nbg0 ( const float  factor)
static

Zoom NBG0.

Parameters
factorZoom factor

◆ jo_vdp2_zoom_nbg0f()

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

Zoom NBG0 width and height independently.

Parameters
width_factorWidth zoom factor
height_factorHeight zoom factor

◆ jo_vdp2_zoom_nbg1()

static __jo_force_inline void jo_vdp2_zoom_nbg1 ( const float  factor)
static

Zoom NBG1.

Parameters
factorZoom factor

◆ jo_vdp2_zoom_nbg1f()

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

Zoom NBG1 width and height independently.

Parameters
width_factorWidth zoom factor
height_factorHeight zoom factor

◆ sprintf()

int sprintf ( char *  str,
const char *  format,
  ... 
)

sprintf prototypes

Parameters
strString
formatFormat string
...Arguments
Returns
If successful, the total number of characters written is returned excluding the null-character appended at the end of the string, otherwise a negative number is returned in case of failure.

Variable Documentation

◆ __jo_sprintf_buf

char __jo_sprintf_buf[JO_PRINTF_BUF_SIZE]

Internal sprintf buffer.

Warning
MC Hammer: don't touch this