Jo Engine 2026.11.6
Jo Sega Saturn Engine
Loading...
Searching...
No Matches
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).
#define jo_nbg3_printf(X, Y, ...)
 NBG3 printf implementation (jo_set_nbg3_8bits_font must be called before).
#define JO_NBG1_SCROLL_TABLE_SIZE
 512 entries. One offset for each line because the background size is a 512x512 pixels by default.
#define JO_NBG1_SCROLL_XY_TABLE_LINES
 Lines of the table of jo_vdp2_enable_nbg1_line_scroll_xy().
#define JO_NBG1_VERTICAL_CELL_SCROLL_TABLE_SIZE
 Entries of the NBG1 vertical cell scroll table: one for each column of 8 pixels on the screen (and one more when the screen is scrolled by a fraction of a column).
#define JO_NBG0_SCROLL_TABLE_SIZE
 512 entries. One offset for each line because the background size is a 512x512 pixels by default.
#define JO_VDP2_ADDITIVE_SPRITE_BANK
 Color bank bits of an additive sprite (see jo_enable_additive_sprites(), jo_sprite_set_additive_palette()): the priority register 3 of the sprites (sprite type 3: bits 14 and 13 of a palette pixel).
#define JO_VDP2_WINDOW_0
 Window 0 (see jo_vdp2_set_window()).
#define JO_VDP2_WINDOW_1
 Window 1 (see jo_vdp2_set_window()).
#define JO_VDP2_BLEND_RATIO_MAX
 Maximum ratio of jo_vdp2_enable_blend().
#define JO_VDP2_LINE_COLOR_LINES
 Lines of a line color table (the most lines of a screen, see jo_vdp2_set_line_colors()).
#define JO_VDP2_LINE_COLOR(PALETTE_ID, INDEX)
 Color code of a line color: the color INDEX of the palette PALETTE_ID (jo_create_palette(): its color palette.data[k] is the index k + 1).
#define JO_VDP2_SPECIAL_COLOR(INDEX)
 The special color code of the palette colors whose index ends with c (index & 15 = c): c and c ^ 1 share a code (see jo_vdp2_set_special_colors()).
#define JO_VDP2_SHADOW_COLOR
 The color of a shadow: a polygon or the pixels of a palette sprite drawn with it darken the screens under them by half (see jo_vdp2_enable_shadow()). The sprite itself is not shown.

Enumerations

enum  jo_vdp2_window_area { JO_VDP2_WINDOW_SHOW_INSIDE , JO_VDP2_WINDOW_SHOW_OUTSIDE }
 Where the screens of a window are shown (see jo_vdp2_enable_window()). More...
enum  jo_vdp2_blend_mode { JO_VDP2_BLEND_RATIO , JO_VDP2_BLEND_ADD , JO_VDP2_BLEND_EXTENDED }
 How the screens are mixed with the image under them (see jo_vdp2_set_blend_mode()). More...
enum  jo_vdp2_hires_sprite_mode { JO_VDP2_HIRES_SPRITES_BLEND , JO_VDP2_HIRES_SPRITES_PRIORITY , JO_VDP2_HIRES_SPRITES_PRIORITY_BLEND }
 What the 2 highest bits of the color index of a sprite choose in the 640 and 704 pixels modes. More...

Functions

int sprintf (char *str, const char *format,...)
 sprintf prototypes
void jo_set_displayed_screens (const jo_scroll_screen scroll_screen_flags)
 Set displayed screens.
void jo_set_default_background_color (const jo_color background_color)
 Set default background color.
void jo_set_background_line_colors (const jo_color *const colors)
 Set a color for each line of the back screen (visible where no scroll screen is displayed).
void jo_nbg2_print (int x, int y, char *str)
 NBG2 Print implementation.
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.
void jo_nbg2_clear (void)
 Clear NBG2.
void jo_nbg3_print (int x, int y, char *str)
 NBG3 Print implementation.
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.
void jo_nbg3_clear (void)
 Clear NBG3.
void jo_vdp2_set_nbg1_8bits_image (jo_img_8bits *img, int palette_id, bool vertical_flip)
 Add 8 bits NBG1 image.
void jo_vdp2_set_nbg1_8bits_image_repeat (jo_img_8bits *img, int palette_id, bool vertical_flip, bool repeat)
 Add 8 bits NBG1 image, repeated or not.
void jo_vdp2_set_nbg0_8bits_image (jo_img_8bits *img, int palette_id, bool vertical_flip, bool enabled)
 Set 8 bits NBG0 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.
void jo_vdp2_set_nbg3_8bits_image (jo_img_8bits *img, int palette_id, bool vertical_flip, bool enabled)
 Set 8 bits NBG3 image.
bool jo_vdp2_set_nbg1_8bits_bitmap (const int palette_id)
 The NBG1 bitmap in 256 colors at the resolution of the screen (one pixel of the bitmap = one pixel of the screen, not zoomed): 1024 x 256 pixels, 512 x 512 pixels in the 448 to 512 lines modes (in 640 x 480 and 704 x 480: one pixel of the bitmap = 2 pixels of the screen horizontally).
void jo_vdp2_set_nbg1_16bits_bitmap (void)
 The NBG1 bitmap in 32768 colors again (see jo_vdp2_set_nbg1_8bits_bitmap()): draw it again.
int jo_vdp2_get_nbg1_8bits_bitmap_width (void)
 Width of the 256 colors NBG1 bitmap (see jo_vdp2_set_nbg1_8bits_bitmap()).
int jo_vdp2_get_nbg1_8bits_bitmap_height (void)
 Height of the 256 colors NBG1 bitmap (see jo_vdp2_set_nbg1_8bits_bitmap()).
void jo_vdp2_clear_bitmap_nbg1_8bits (const unsigned char index)
 Fill the 256 colors NBG1 bitmap (see jo_vdp2_set_nbg1_8bits_bitmap()).
void jo_vdp2_put_pixel_bitmap_nbg1_8bits (const int x, const int y, const unsigned char index)
 Put a pixel in the 256 colors NBG1 bitmap (see jo_vdp2_set_nbg1_8bits_bitmap()).
void jo_vdp2_draw_bitmap_nbg1_8bits_image (const jo_img_8bits *const img, const int x, const int y)
 Copy an image in the 256 colors NBG1 bitmap (see jo_vdp2_set_nbg1_8bits_bitmap()).
void jo_vdp2_set_nbg1_image (const jo_img *const img, short left, short top)
 Set NBG1 bitmap image.
bool __jo_vdp2_reserve_nbg1_bitmap (void)
 Allocate and display the NBG1 bitmap at its first use (Internal usage).
void jo_vdp2_clear_bitmap_nbg1 (const jo_color color)
 Clear NBG1 bitmap.
void jo_vdp2_move_nbg1 (const int x, const int y)
 Move NBG1 (scrolling).
void jo_vdp2_move_nbg1_fixed (const jo_fixed x, const jo_fixed y)
 Scroll NBG1 with a fraction of pixel (fixed point: 8 bits of fraction are used).
void jo_vdp2_zoom_nbg1f (const float width_factor, const float height_factor)
 Zoom NBG1 width and height independently.
void jo_vdp2_zoom_nbg1_fixed (const jo_fixed width_factor, const jo_fixed height_factor)
 Zoom NBG1 (fixed point: without the float functions of libgcc).
static __jo_force_inline void jo_vdp2_zoom_nbg1 (const float factor)
 Zoom NBG1.
void jo_vdp2_move_nbg0 (const int x, const int y)
 Move NBG0 (scrolling).
void jo_vdp2_zoom_nbg0f (const float width_factor, const float height_factor)
 Zoom NBG0 width and height independently.
void jo_vdp2_zoom_nbg0_fixed (const jo_fixed width_factor, const jo_fixed height_factor)
 Zoom NBG0 (fixed point: without the float functions of libgcc).
void jo_vdp2_move_nbg0_fixed (const jo_fixed x, const jo_fixed y)
 Scroll NBG0 with a fraction of pixel (fixed point: 8 bits of fraction are used).
static __jo_force_inline void jo_vdp2_zoom_nbg0 (const float factor)
 Zoom NBG0.
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.
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.
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.
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.
void jo_vdp2_enable_rbg0 (void)
 Enable 3D planes.
void jo_vdp2_set_rbg0_far_limit (const int max_zoom_out)
 Hide the farthest part of the 3D planes (the back screen is visible instead).
void jo_vdp2_disable_rbg0 (void)
 Disable 3D planes.
void jo_vdp2_set_rbg0_plane_a_8bits_image (jo_img_8bits *img, int palette_id, bool repeat, bool vertical_flip)
 Setup plane A.
void jo_vdp2_set_rbg0_plane_a_8bits_island (jo_img_8bits *img, int palette_id, bool vertical_flip)
 Setup plane A as an island: the image once, its top left cell (8 x 8 pixels) repeated around it to the infinite (a ring in the sea, a field in a desert).
void jo_vdp2_set_rbg0_plane_b_8bits_image (jo_img_8bits *img, int palette_id, bool repeat, bool vertical_flip)
 Setup plane B.
void jo_vdp2_replace_rbg0_plane_a_8bits_image (jo_img_8bits *img, bool vertical_flip)
 Replace plane A image.
void jo_vdp2_replace_rbg0_plane_b_8bits_image (jo_img_8bits *img, bool vertical_flip)
 Replace plane B image.
void jo_vdp2_draw_rbg0_plane_a (const bool use_scroll_format_matrix)
 Draw plane A.
void jo_vdp2_draw_rbg0_plane_b (const bool use_scroll_format_matrix)
 Draw plane B.
void jo_vdp2_draw_rbg0_plane_b_flat (const int x, const int y)
 Draw plane B as a flat image, without perspective: a sky behind the plane A (sea, ground).
void jo_enable_screen_mozaic (const jo_scroll_screen screens, short x, short y)
 Enable mozaic effect for scroll screen.
void jo_disable_all_screen_mozaic (void)
 Disable mozaic effect for all scroll screen.
int * jo_vdp2_enable_nbg1_line_scroll (void)
 Enable NBG1 horizontal line scroll effect.
void jo_vdp2_disable_nbg1_line_scroll (void)
 Disable NBG1 horizontal line scroll effect.
int * jo_vdp2_enable_nbg1_line_scroll_xy (void)
 Enable the NBG1 horizontal and vertical line scroll: each line of the screen shows its own part of the image (a split screen: each view its own sky).
void jo_vdp2_compute_nbg1_line_scroll (unsigned short offset)
 Compute NBG1 horizontal line scroll effect using specific offset.
int * jo_vdp2_enable_nbg1_vertical_cell_scroll (void)
 Enable the NBG1 vertical cell scroll: each column of 8 pixels of the screen is moved vertically by its own offset (added to the vertical scroll of the screen).
void jo_vdp2_disable_nbg1_vertical_cell_scroll (void)
 Disable the NBG1 vertical cell scroll and free its table.
int * jo_vdp2_enable_nbg0_line_scroll (void)
 Enable NBG0 horizontal line scroll effect.
void jo_vdp2_disable_nbg0_line_scroll (void)
 Disable NBG0 horizontal line scroll effect.
void jo_vdp2_compute_nbg0_line_scroll (unsigned short offset)
 Compute NBG0 horizontal line scroll effect using specific offset.
void jo_disable_all_screens_transparency (void)
 Disable all screens transparency.
void jo_enable_screen_transparency (const jo_scroll_screen screen, const unsigned short transparency_level)
 Enable screen transparency.
void jo_enable_additive_sprites (void)
 The light of the additive sprites is added to the image under them (the VDP2 color calculation "add", like the glows, see jo/glow.h): a halo without edge (the sun, a flare) drawn by the VDP1. An additive sprite is a palette sprite (8 bits) drawn with jo_sprite_set_additive_palette(): its pixels have the priority register 3 of the sprites, the only one with the color calculation. Black adds nothing, the colors saturate to white.
void jo_disable_additive_sprites (void)
 The additive sprites are opaque again (see jo_enable_additive_sprites()).
void jo_vdp2_set_window (const int window, int x, int y, int width, int height)
 Set a rectangle window.
bool jo_vdp2_set_window_lines (const int window, const int top, const int count, const short *const left, const short *const right)
 Set a window of any shape: its left and right pixels on each line.
bool jo_vdp2_set_window_circle (const int window, const int x, const int y, const int radius)
 Set a round window (a spotlight, a transition).
void jo_vdp2_enable_window (const jo_scroll_screen screens, const int window, const jo_vdp2_window_area area)
 Show screens only inside a window, or hide them there.
void jo_vdp2_disable_window (const jo_scroll_screen screens)
 The screens are shown on all the screen again (see jo_vdp2_enable_window()).
void jo_vdp2_set_blend_mode (const jo_vdp2_blend_mode mode)
 Set how the screens are mixed (jo_vdp2_enable_blend()): the same for all the screens.
void jo_vdp2_enable_blend (const jo_scroll_screen screens, unsigned char ratio)
 Mix screens with the image under them.
void jo_vdp2_blend_rgb_sprites_only (const bool rgb_only)
 Mix only the RGB pixels of the sprites (jo_vdp2_enable_blend(JO_SPRITE_SCREEN, ratio)): the palette pixels stay opaque (example: see-through RGB water with opaque objects in palette colors over it).
void jo_vdp2_disable_blend (const jo_scroll_screen screens)
 The screens are opaque again (see jo_vdp2_enable_blend()).
bool jo_vdp2_set_line_colors (const unsigned short *const colors, const int count)
 Set one color for each line of the line color screen.
bool jo_vdp2_set_line_color (const unsigned short color)
 Set one color for the whole line color screen.
void jo_vdp2_enable_line_color (const jo_scroll_screen screens)
 Mix screens with the line color screen instead of the image under them (as slLineColDisp() of the SGL).
void jo_vdp2_disable_line_color (const jo_scroll_screen screens)
 The screens are no longer mixed with the line color screen (see jo_vdp2_enable_line_color()).
bool jo_vdp2_enable_blur (const jo_scroll_screen screen)
 Blur a screen horizontally where it is mixed: under a transparent screen (jo_vdp2_enable_blend()), or where it is transparent itself (water, glass, heat).
void jo_vdp2_disable_blur (void)
 No blur (see jo_vdp2_enable_blur()): the color RAM has 2048 colors again.
void jo_vdp2_set_hires_sprite_mode (const jo_vdp2_hires_sprite_mode mode)
 Choose what the color index of the sprites gives in the 640 and 704 pixels modes (sprite types F, E and D).
void jo_vdp2_set_sprite_priorities (const unsigned char p0, const unsigned char p1, const unsigned char p2, const unsigned char p3)
 The priorities of the sprites (by default all the sprites have the priority of jo_core_set_screens_order()): chosen by the color of a sprite (its bits 14-13 in palette mode, its 2 highest bits in the 640 and 704 pixels modes).
void jo_vdp2_set_sprite_blend_ratios (const unsigned char r0, const unsigned char r1, const unsigned char r2, const unsigned char r3)
 The 4 blend ratios of the sprites (jo_vdp2_enable_blend() gives the same ratio to all of them), chosen by the color of a sprite (its bits 12-11 in palette mode, its 2 highest bits in the 640 and 704 pixels modes).
void jo_vdp2_set_special_colors (const unsigned char codes)
 Choose the special colors of the screens (see jo_vdp2_enable_special_priority() and jo_vdp2_enable_special_blend()).
void jo_vdp2_enable_special_priority (const jo_scroll_screen screens)
 The special colors of the screens are drawn one priority above the others pixels of the screen (a window or lights of a background over the screen just above it, the sprites behind a part of the background).
void jo_vdp2_disable_special_priority (const jo_scroll_screen screens)
 The screens have one priority again (see jo_vdp2_enable_special_priority()).
void jo_vdp2_enable_special_blend (const jo_scroll_screen screens)
 Only the special colors of the screens are mixed (jo_vdp2_enable_blend()): the other pixels are opaque (the windows of a building, the water of a map).
void jo_vdp2_disable_special_blend (const jo_scroll_screen screens)
 All the pixels of the screens are mixed again (see jo_vdp2_enable_special_blend()).
void jo_vdp2_enable_shadow (const jo_scroll_screen screens)
 The shadows darken these screens.
void jo_vdp2_disable_shadow (void)
 No screen is darkened by the shadows (see jo_vdp2_enable_shadow()).
void jo_vdp2_enable_mosaic (const jo_scroll_screen screens, const int width, const int height)
 Enable the mosaic effect (big pixels).
void jo_vdp2_disable_mosaic (void)
 Disable the mosaic effect (see jo_vdp2_enable_mosaic()).
const unsigned short * jo_vdp2_get_registers (void)
 The values the engine gave to the VDP2 registers (most of them can't be read from the VDP2): the next VBLANK copies the new values to the VDP2.
void jo_vdp2_restore (void)
 Give the VDP2 back to the engine after the game wrote its registers and its VRAM by itself (a video in full screen): the registers again as the engine set them (at the next VBLANK), the VRAM cleared, the font of jo_printf() and the back screen color drawn again.

Variables

char __jo_sprintf_buf [JO_PRINTF_BUF_SIZE]
 Internal sprintf buffer.
bool __jo_vdp2_nbg1_bitmap_reserved
 The NBG1 bitmap is in the VRAM (Internal usage, see __jo_vdp2_reserve_nbg1_bitmap()).

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_NBG1_SCROLL_XY_TABLE_LINES

#define JO_NBG1_SCROLL_XY_TABLE_LINES

Lines of the table of jo_vdp2_enable_nbg1_line_scroll_xy().

◆ JO_NBG1_VERTICAL_CELL_SCROLL_TABLE_SIZE

#define JO_NBG1_VERTICAL_CELL_SCROLL_TABLE_SIZE

Entries of the NBG1 vertical cell scroll table: one for each column of 8 pixels on the screen (and one more when the screen is scrolled by a fraction of a column).

◆ 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

◆ JO_VDP2_ADDITIVE_SPRITE_BANK

#define JO_VDP2_ADDITIVE_SPRITE_BANK

Color bank bits of an additive sprite (see jo_enable_additive_sprites(), jo_sprite_set_additive_palette()): the priority register 3 of the sprites (sprite type 3: bits 14 and 13 of a palette pixel).

◆ JO_VDP2_BLEND_RATIO_MAX

#define JO_VDP2_BLEND_RATIO_MAX

Maximum ratio of jo_vdp2_enable_blend().

◆ JO_VDP2_LINE_COLOR

#define JO_VDP2_LINE_COLOR ( PALETTE_ID,
INDEX )

Color code of a line color: the color INDEX of the palette PALETTE_ID (jo_create_palette(): its color palette.data[k] is the index k + 1).

Remarks
The line colors are colors of the color RAM, not RGB colors: write them in a palette first

◆ JO_VDP2_LINE_COLOR_LINES

#define JO_VDP2_LINE_COLOR_LINES

Lines of a line color table (the most lines of a screen, see jo_vdp2_set_line_colors()).

◆ JO_VDP2_SHADOW_COLOR

#define JO_VDP2_SHADOW_COLOR

The color of a shadow: a polygon or the pixels of a palette sprite drawn with it darken the screens under them by half (see jo_vdp2_enable_shadow()). The sprite itself is not shown.

◆ JO_VDP2_SPECIAL_COLOR

#define JO_VDP2_SPECIAL_COLOR ( INDEX)

The special color code of the palette colors whose index ends with c (index & 15 = c): c and c ^ 1 share a code (see jo_vdp2_set_special_colors()).

◆ JO_VDP2_WINDOW_0

#define JO_VDP2_WINDOW_0

Window 0 (see jo_vdp2_set_window()).

◆ JO_VDP2_WINDOW_1

#define JO_VDP2_WINDOW_1

Window 1 (see jo_vdp2_set_window()).

Enumeration Type Documentation

◆ jo_vdp2_blend_mode

How the screens are mixed with the image under them (see jo_vdp2_set_blend_mode()).

Enumerator
JO_VDP2_BLEND_RATIO 

A part of the color of the screen and a part of the image under it (transparency).

JO_VDP2_BLEND_ADD 

The color of the screen is added to the image under it (light, fire, glow).

JO_VDP2_BLEND_EXTENDED 

Option of JO_VDP2_BLEND_RATIO and JO_VDP2_BLEND_ADD (example: JO_VDP2_BLEND_RATIO | JO_VDP2_BLEND_EXTENDED): when the screen under is also mixed, the 2 screens under the top screen are mixed together (3 screens are seen through each other). Not in the 640 and 704 pixels modes.

◆ jo_vdp2_hires_sprite_mode

What the 2 highest bits of the color index of a sprite choose in the 640 and 704 pixels modes.

Enumerator
JO_VDP2_HIRES_SPRITES_BLEND 

The blend ratio (jo_vdp2_set_sprite_blend_ratios()): 256 colors, one priority (default).

JO_VDP2_HIRES_SPRITES_PRIORITY 

The priority (jo_vdp2_set_sprite_priorities()): the colors 0 to 63 at the priority 0, 64 to 127 at the priority 1... (the 256 colors displayed).

JO_VDP2_HIRES_SPRITES_PRIORITY_BLEND 

The bit 7 the priority (0 or 1), the bit 6 the blend ratio (0 or 1).

◆ jo_vdp2_window_area

Where the screens of a window are shown (see jo_vdp2_enable_window()).

Enumerator
JO_VDP2_WINDOW_SHOW_INSIDE 

The screens are shown only inside the window.

JO_VDP2_WINDOW_SHOW_OUTSIDE 

The screens are hidden inside the window.

Function Documentation

◆ __jo_vdp2_reserve_nbg1_bitmap()

bool __jo_vdp2_reserve_nbg1_bitmap ( void )

Allocate and display the NBG1 bitmap at its first use (Internal usage).

Returns
false if it can't be at the start of the bank A0 (the bank is used by other screens: line scroll tables, cells of NBG1 or RBG0). The drawing functions of the bitmap call it
Remarks
The bitmap takes 256 KB of the VDP2 VRAM (the banks A0 and A1): a program that never draws in it doesn't allocate it. JO_COMPATIBILITY_NBG1_BITMAP_AT_INIT = 1 in the makefile: allocated and displayed by jo_core_init() (the old behavior)

◆ jo_disable_additive_sprites()

void jo_disable_additive_sprites ( void )

The additive sprites are opaque again (see jo_enable_additive_sprites()).

◆ jo_disable_all_screen_mozaic()

void jo_disable_all_screen_mozaic ( void )

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

void jo_enable_additive_sprites ( void )

The light of the additive sprites is added to the image under them (the VDP2 color calculation "add", like the glows, see jo/glow.h): a halo without edge (the sun, a flare) drawn by the VDP1. An additive sprite is a palette sprite (8 bits) drawn with jo_sprite_set_additive_palette(): its pixels have the priority register 3 of the sprites, the only one with the color calculation. Black adds nothing, the colors saturate to white.

Remarks
The color calculation mode is the same for all the screens: no transparency of a screen (see jo_enable_screen_transparency()) at the same time

◆ jo_enable_screen_mozaic()

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

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

void jo_set_background_line_colors ( const jo_color *const colors)

Set a color for each line of the back screen (visible where no scroll screen is displayed).

Parameters
colorsJO_TV_HEIGHT colors (the first one is the top of the screen)
Remarks
Useful for a sky gradient. The colors are copied: the function can be called every frame.
jo_set_default_background_color() goes back to a single color

◆ 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_blend_rgb_sprites_only()

void jo_vdp2_blend_rgb_sprites_only ( const bool rgb_only)

Mix only the RGB pixels of the sprites (jo_vdp2_enable_blend(JO_SPRITE_SCREEN, ratio)): the palette pixels stay opaque (example: see-through RGB water with opaque objects in palette colors over it).

Parameters
rgb_onlytrue: the RGB pixels only (RGB textures and colors, gouraud), false: all the pixels (default)
Remarks
The condition of the color calculation of the sprites is the MSB of their color: 1 for the RGB pixels; for a palette pixel, the MSB of its color in the color RAM (the jo colors have it: clear it in the palette, color & 0x7FFF)

◆ jo_vdp2_clear_bitmap_nbg1()

void jo_vdp2_clear_bitmap_nbg1 ( const jo_color color)

Clear NBG1 bitmap.

Parameters
colorClear color

◆ jo_vdp2_clear_bitmap_nbg1_8bits()

void jo_vdp2_clear_bitmap_nbg1_8bits ( const unsigned char index)

Fill the 256 colors NBG1 bitmap (see jo_vdp2_set_nbg1_8bits_bitmap()).

Parameters
indexColor index (0 = transparent)

◆ 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_blend()

void jo_vdp2_disable_blend ( const jo_scroll_screen screens)

The screens are opaque again (see jo_vdp2_enable_blend()).

Parameters
screensScreens

◆ jo_vdp2_disable_blur()

void jo_vdp2_disable_blur ( void )

No blur (see jo_vdp2_enable_blur()): the color RAM has 2048 colors again.

◆ jo_vdp2_disable_line_color()

void jo_vdp2_disable_line_color ( const jo_scroll_screen screens)

The screens are no longer mixed with the line color screen (see jo_vdp2_enable_line_color()).

Parameters
screensScreens

◆ jo_vdp2_disable_mosaic()

void jo_vdp2_disable_mosaic ( void )

Disable the mosaic effect (see jo_vdp2_enable_mosaic()).

◆ 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_nbg1_vertical_cell_scroll()

void jo_vdp2_disable_nbg1_vertical_cell_scroll ( void )

Disable the NBG1 vertical cell scroll and free its table.

◆ jo_vdp2_disable_rbg0()

void jo_vdp2_disable_rbg0 ( void )

Disable 3D planes.

◆ jo_vdp2_disable_shadow()

void jo_vdp2_disable_shadow ( void )

No screen is darkened by the shadows (see jo_vdp2_enable_shadow()).

◆ jo_vdp2_disable_special_blend()

void jo_vdp2_disable_special_blend ( const jo_scroll_screen screens)

All the pixels of the screens are mixed again (see jo_vdp2_enable_special_blend()).

Parameters
screensScreens

◆ jo_vdp2_disable_special_priority()

void jo_vdp2_disable_special_priority ( const jo_scroll_screen screens)

The screens have one priority again (see jo_vdp2_enable_special_priority()).

Parameters
screensScreens

◆ jo_vdp2_disable_window()

void jo_vdp2_disable_window ( const jo_scroll_screen screens)

The screens are shown on all the screen again (see jo_vdp2_enable_window()).

Parameters
screensScreens

◆ jo_vdp2_draw_bitmap_nbg1_8bits_image()

void jo_vdp2_draw_bitmap_nbg1_8bits_image ( const jo_img_8bits *const img,
const int x,
const int y )

Copy an image in the 256 colors NBG1 bitmap (see jo_vdp2_set_nbg1_8bits_bitmap()).

Parameters
img8 bits image (cut at the borders of the bitmap)
xHorizontal position
yVertical position

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

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

void jo_vdp2_draw_rbg0_plane_a ( const bool use_scroll_format_matrix)

Draw plane A.

Parameters
use_scroll_format_matrixConvert current matrix to scroll format matrix
Remarks
Called by a callback of jo_core_run(): applied when the VDP1 displays the image of the frame (in step with the sprites and the 3D of the frame); before jo_core_run() or in a VBLANK callback: at the next VBLANK

◆ jo_vdp2_draw_rbg0_plane_b()

void jo_vdp2_draw_rbg0_plane_b ( const bool use_scroll_format_matrix)

Draw plane B.

Parameters
use_scroll_format_matrixConvert current matrix to scroll format matrix
Remarks
Called by a callback of jo_core_run(): applied when the VDP1 displays the image of the frame (in step with the sprites and the 3D of the frame); before jo_core_run() or in a VBLANK callback: at the next VBLANK

◆ jo_vdp2_draw_rbg0_plane_b_flat()

void jo_vdp2_draw_rbg0_plane_b_flat ( const int x,
const int y )

Draw plane B as a flat image, without perspective: a sky behind the plane A (sea, ground).

Parameters
xHorizontal position in the image of the left of the screen (pixels, the image is repeated horizontally)
yVertical position in the image of the top of the screen (pixels)
Remarks
The plane B is displayed where the plane A is transparent: above its horizon and after its far limit (see jo_vdp2_set_rbg0_far_limit()). Above the image (y < 0), the top left cell (8 x 8 pixels) of the image is repeated: the top of the image must be one color (the top of the sky). Below the image, the image is repeated (hidden by the plane A)
The image (jo_vdp2_set_rbg0_plane_b_8bits_image()) must be as wide as the plane (512 pixels) or a divisor of it
Warning
Image need to be clockwised rotated (right) because of an optimisation
Remarks
Called by a callback of jo_core_run(): applied when the VDP1 displays the image of the frame (in step with the sprites and the 3D of the frame); before jo_core_run() or in a VBLANK callback: at the next VBLANK

◆ jo_vdp2_enable_blend()

void jo_vdp2_enable_blend ( const jo_scroll_screen screens,
unsigned char ratio )

Mix screens with the image under them.

Parameters
screensScreens (example: JO_NBG1_SCREEN | JO_SPRITE_SCREEN)
ratioJO_VDP2_BLEND_RATIO mode: 0 (the screen is opaque) to 31 (almost invisible), 16 = half and half. Not used by the JO_VDP2_BLEND_ADD mode

◆ jo_vdp2_enable_blur()

bool jo_vdp2_enable_blur ( const jo_scroll_screen screen)

Blur a screen horizontally where it is mixed: under a transparent screen (jo_vdp2_enable_blend()), or where it is transparent itself (water, glass, heat).

Parameters
screenOne screen: JO_NBG0_SCREEN to JO_NBG3_SCREEN, JO_RBG0_SCREEN or JO_SPRITE_SCREEN
Returns
false if the screen is not supported, or in the 640 and 704 pixels modes (no blur in these modes)
Remarks
Ratio mode only (JO_VDP2_BLEND_RATIO without JO_VDP2_BLEND_EXTENDED)
Warning
The color RAM has 1024 colors while the blur is enabled: the palettes 0 to 3 are displayed, the palettes after them (the 4th jo_create_palette() and the next ones) are not, and their colors must not be changed (they overwrite the first ones)

◆ jo_vdp2_enable_line_color()

void jo_vdp2_enable_line_color ( const jo_scroll_screen screens)

Mix screens with the line color screen instead of the image under them (as slLineColDisp() of the SGL).

Parameters
screensScreens (example: JO_RBG0_SCREEN): NBG0 to NBG3, RBG0 and the sprites
Remarks
Where one of these screens is on top and mixed (jo_vdp2_enable_blend(), with its ratio: 0 = the screen only, 31 = almost only the line color), its pixels are mixed with the color of their line. Example, a fog on RBG0: jo_vdp2_set_line_colors(fog, JO_TV_HEIGHT); jo_vdp2_enable_line_color(JO_RBG0_SCREEN); jo_vdp2_enable_blend(JO_RBG0_SCREEN, 12)
The ratio is the same on all the lines. A fog that thickens toward the horizon: the JO_VDP2_BLEND_ADD mode (jo_vdp2_set_blend_mode(), for all the screens) with line colors from black (near, no fog) to the fog color (far)

◆ jo_vdp2_enable_mosaic()

void jo_vdp2_enable_mosaic ( const jo_scroll_screen screens,
const int width,
const int height )

Enable the mosaic effect (big pixels).

Parameters
screensScreens: NBG0 to NBG3 and RBG0
widthWidth of the big pixels (1 to 16)
heightHeight of the big pixels (1 to 16)

◆ 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_nbg1_line_scroll_xy()

int * jo_vdp2_enable_nbg1_line_scroll_xy ( void )

Enable the NBG1 horizontal and vertical line scroll: each line of the screen shows its own part of the image (a split screen: each view its own sky).

Returns
A table of JO_NBG1_SCROLL_XY_TABLE_LINES x 2 entries in VRAM (16.16, the fraction on 8 bits): for each line of the screen from the top, the horizontal scroll, then the vertical one: the line of the image shown on this line of the screen (not an offset: 0 on every line shows the first line of the image everywhere; measured in Mednafen); JO_NULL when there is no memory
Remarks
Replaces the table of jo_vdp2_enable_nbg1_line_scroll(); jo_vdp2_disable_nbg1_line_scroll() stops it. Not with the vertical cell scroll of NBG1

◆ jo_vdp2_enable_nbg1_vertical_cell_scroll()

int * jo_vdp2_enable_nbg1_vertical_cell_scroll ( void )

Enable the NBG1 vertical cell scroll: each column of 8 pixels of the screen is moved vertically by its own offset (added to the vertical scroll of the screen).

Returns
An array of JO_NBG1_VERTICAL_CELL_SCROLL_TABLE_SIZE jo_fixed offsets in VRAM (from the left of the screen, all 0 at first), JO_NULL when there is no memory
Remarks
Needs a free VRAM access slot (T0 to T2) in the bank of the table: without it, the offsets are ignored
Works with a bitmap or a cell screen, without the line scroll of NBG1

◆ jo_vdp2_enable_rbg0()

void jo_vdp2_enable_rbg0 ( void )

Enable 3D planes.

◆ jo_vdp2_enable_shadow()

void jo_vdp2_enable_shadow ( const jo_scroll_screen screens)

The shadows darken these screens.

Parameters
screensScreens (example: JO_NBG1_SCREEN | JO_BACK_SCREEN): NBG0 to NBG3, RBG0 and the back screen

◆ jo_vdp2_enable_special_blend()

void jo_vdp2_enable_special_blend ( const jo_scroll_screen screens)

Only the special colors of the screens are mixed (jo_vdp2_enable_blend()): the other pixels are opaque (the windows of a building, the water of a map).

Parameters
screensPalette screens (16 or 256 colors): NBG0 to NBG3 and RBG0

◆ jo_vdp2_enable_special_priority()

void jo_vdp2_enable_special_priority ( const jo_scroll_screen screens)

The special colors of the screens are drawn one priority above the others pixels of the screen (a window or lights of a background over the screen just above it, the sprites behind a part of the background).

Parameters
screensPalette screens (16 or 256 colors): NBG0 to NBG3 and RBG0
Remarks
The priority of the screen (jo_core_set_screens_order()) loses its lowest bit: the other pixels have the even priority below it (a screen at the priority 5: 4 and 5 for the special colors)

◆ jo_vdp2_enable_window()

void jo_vdp2_enable_window ( const jo_scroll_screen screens,
const int window,
const jo_vdp2_window_area area )

Show screens only inside a window, or hide them there.

Parameters
screensScreens (example: JO_NBG1_SCREEN | JO_SPRITE_SCREEN): NBG0 to NBG3, RBG0 and the sprites
windowJO_VDP2_WINDOW_0 or JO_VDP2_WINDOW_1
areaJO_VDP2_WINDOW_SHOW_INSIDE or JO_VDP2_WINDOW_SHOW_OUTSIDE
Remarks
A screen with the 2 windows is hidden where one of the 2 windows hides it

◆ jo_vdp2_get_nbg1_8bits_bitmap_height()

int jo_vdp2_get_nbg1_8bits_bitmap_height ( void )

Height of the 256 colors NBG1 bitmap (see jo_vdp2_set_nbg1_8bits_bitmap()).

Returns
256 or 512 pixels

◆ jo_vdp2_get_nbg1_8bits_bitmap_width()

int jo_vdp2_get_nbg1_8bits_bitmap_width ( void )

Width of the 256 colors NBG1 bitmap (see jo_vdp2_set_nbg1_8bits_bitmap()).

Returns
1024 or 512 pixels

◆ jo_vdp2_get_registers()

const unsigned short * jo_vdp2_get_registers ( void )

The values the engine gave to the VDP2 registers (most of them can't be read from the VDP2): the next VBLANK copies the new values to the VDP2.

Returns
The registers from 0x25F80000 (TVMD) to 0x25F8011E: index = (address - 0x25F80000) / 2
Remarks
jo_vdp2_get_registers()[(0x25F800E2 - 0x25F80000) / 2]: SDCTL (shadow control)

◆ jo_vdp2_move_nbg0()

void jo_vdp2_move_nbg0 ( const int x,
const int y )

Move NBG0 (scrolling).

Parameters
xhorizontal location
yvertical location
Remarks
Called by a callback of jo_core_run(): applied when the VDP1 displays the image of the frame (in step with the sprites and the 3D of the frame); before jo_core_run() or in a VBLANK callback: at the next VBLANK

◆ jo_vdp2_move_nbg0_fixed()

void jo_vdp2_move_nbg0_fixed ( const jo_fixed x,
const jo_fixed y )

Scroll NBG0 with a fraction of pixel (fixed point: 8 bits of fraction are used).

Parameters
xHorizontal scroll (pixels of NBG0)
yVertical scroll

◆ jo_vdp2_move_nbg1()

void jo_vdp2_move_nbg1 ( const int x,
const int y )

Move NBG1 (scrolling).

Parameters
xhorizontal location
yvertical location
Remarks
Called by a callback of jo_core_run(): applied when the VDP1 displays the image of the frame (in step with the sprites and the 3D of the frame); before jo_core_run() or in a VBLANK callback: at the next VBLANK

◆ jo_vdp2_move_nbg1_fixed()

void jo_vdp2_move_nbg1_fixed ( const jo_fixed x,
const jo_fixed y )

Scroll NBG1 with a fraction of pixel (fixed point: 8 bits of fraction are used).

Parameters
xHorizontal scroll (pixels of NBG1)
yVertical scroll

◆ jo_vdp2_put_pixel_bitmap_nbg1()

__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_8bits()

void jo_vdp2_put_pixel_bitmap_nbg1_8bits ( const int x,
const int y,
const unsigned char index )

Put a pixel in the 256 colors NBG1 bitmap (see jo_vdp2_set_nbg1_8bits_bitmap()).

Parameters
xHorizontal position
yVertical position
indexColor index (0 = transparent)

◆ jo_vdp2_put_pixel_bitmap_nbg1_rgb()

__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_replace_rbg0_plane_a_8bits_image()

void jo_vdp2_replace_rbg0_plane_a_8bits_image ( jo_img_8bits * img,
bool vertical_flip )

Replace plane A image.

Parameters
img8 bits 255 colors max image. (Width AND height must be a multiple of 8)
vertical_flipFlip image vertically
Warning
jo_vdp2_set_rbg0_plane_a_8bits_image() MUST be called before
Image need to be clockwised rotated (right) because of an optimisation and the previous palette is preserved

◆ jo_vdp2_replace_rbg0_plane_b_8bits_image()

void jo_vdp2_replace_rbg0_plane_b_8bits_image ( jo_img_8bits * img,
bool vertical_flip )

Replace plane B image.

Parameters
img8 bits 255 colors max image. (Width AND height must be a multiple of 8)
vertical_flipFlip image vertically
Warning
jo_vdp2_set_rbg0_plane_b_8bits_image() MUST be called before
Image need to be clockwised rotated (right) because of an optimisation and the previous palette is preserved

◆ jo_vdp2_restore()

void jo_vdp2_restore ( void )

Give the VDP2 back to the engine after the game wrote its registers and its VRAM by itself (a video in full screen): the registers again as the engine set them (at the next VBLANK), the VRAM cleared, the font of jo_printf() and the back screen color drawn again.

Remarks
The backgrounds of the game are lost (their places in the VRAM stay reserved): the game sets them again. The color RAM is not changed

◆ jo_vdp2_set_blend_mode()

void jo_vdp2_set_blend_mode ( const jo_vdp2_blend_mode mode)

Set how the screens are mixed (jo_vdp2_enable_blend()): the same for all the screens.

Parameters
modeJO_VDP2_BLEND_RATIO (default) or JO_VDP2_BLEND_ADD, with or without JO_VDP2_BLEND_EXTENDED

◆ jo_vdp2_set_hires_sprite_mode()

void jo_vdp2_set_hires_sprite_mode ( const jo_vdp2_hires_sprite_mode mode)

Choose what the color index of the sprites gives in the 640 and 704 pixels modes (sprite types F, E and D).

Parameters
modeJO_VDP2_HIRES_SPRITES_BLEND (default), JO_VDP2_HIRES_SPRITES_PRIORITY or JO_VDP2_HIRES_SPRITES_PRIORITY_BLEND

◆ jo_vdp2_set_line_color()

bool jo_vdp2_set_line_color ( const unsigned short color)

Set one color for the whole line color screen.

Parameters
colorColor code (JO_VDP2_LINE_COLOR())
Returns
true if succeed, false if the VDP2 memory is full

◆ jo_vdp2_set_line_colors()

bool jo_vdp2_set_line_colors ( const unsigned short *const colors,
const int count )

Set one color for each line of the line color screen.

Parameters
colorsColor codes (JO_VDP2_LINE_COLOR()) of the lines, from the top of the screen
countColors count (up to JO_VDP2_LINE_COLOR_LINES; the lines after them take the last color). In the interlaced modes: 2 colors per line of a field (the lines of the frame)
Returns
true if succeed, false if the VDP2 memory is full (1 KB per table, 2 tables)
Remarks
The colors are copied: the function can be called every frame (as slLineColTable() of the SGL)

◆ 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_16bits_bitmap()

void jo_vdp2_set_nbg1_16bits_bitmap ( void )

The NBG1 bitmap in 32768 colors again (see jo_vdp2_set_nbg1_8bits_bitmap()): draw it again.

◆ jo_vdp2_set_nbg1_8bits_bitmap()

bool jo_vdp2_set_nbg1_8bits_bitmap ( const int palette_id)

The NBG1 bitmap in 256 colors at the resolution of the screen (one pixel of the bitmap = one pixel of the screen, not zoomed): 1024 x 256 pixels, 512 x 512 pixels in the 448 to 512 lines modes (in 640 x 480 and 704 x 480: one pixel of the bitmap = 2 pixels of the screen horizontally).

Parameters
palette_idPalette (jo_create_palette(): from 0 to 7)
Returns
false if the bitmap can't be allocated (the bank A0 is used)
Remarks
Its memory is the memory of the 32768 colors bitmap: jo_vdp2_set_nbg1_16bits_bitmap() (and the images drawn in 32768 colors: jo_vdp2_set_nbg1_image()...) set the 32768 colors bitmap again. A change of the screen mode changes its size: draw it again
Warning
The last 2 pixels of the bitmap hold the color of the back screen

◆ 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_8bits_image_repeat()

void jo_vdp2_set_nbg1_8bits_image_repeat ( jo_img_8bits * img,
int palette_id,
bool vertical_flip,
bool repeat )

Add 8 bits NBG1 image, repeated or not.

Parameters
img8 bits 255 colors max image. (Width AND height must be a multiple of 8, 512 x 512 at most)
palette_idpalette id from TGA (see also jo_palette)
vertical_flipFlip image vertically
repeattrue: the image is repeated in the 512 x 512 pixels of the screen; false: transparent out of the image (shows an empty cell of the image there: repeated when the image has no 8 x 8 transparent cell)
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,
short left,
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_far_limit()

void jo_vdp2_set_rbg0_far_limit ( const int max_zoom_out)

Hide the farthest part of the 3D planes (the back screen is visible instead).

Parameters
max_zoom_outBiggest reduction of the texture (0: no limit, 16: the plane stops where 16 texels are in 1 pixel)
Remarks
Far away, a plane is very reduced and looks noisy: with a back screen color like the horizon, it fades in the distance

◆ 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_a_8bits_island()

void jo_vdp2_set_rbg0_plane_a_8bits_island ( jo_img_8bits * img,
int palette_id,
bool vertical_flip )

Setup plane A as an island: the image once, its top left cell (8 x 8 pixels) repeated around it to the infinite (a ring in the sea, a field in a desert).

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
Remarks
The image is at the origin of the plane (its top left corner): translate the plane to center it
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_set_special_colors()

void jo_vdp2_set_special_colors ( const unsigned char codes)

Choose the special colors of the screens (see jo_vdp2_enable_special_priority() and jo_vdp2_enable_special_blend()).

Parameters
codesSpecial color codes (example: JO_VDP2_SPECIAL_COLOR(4) | JO_VDP2_SPECIAL_COLOR(10): the colors 4, 5, 10, 11, 20, 21, 26, 27... of the palette)

◆ jo_vdp2_set_sprite_blend_ratios()

void jo_vdp2_set_sprite_blend_ratios ( const unsigned char r0,
const unsigned char r1,
const unsigned char r2,
const unsigned char r3 )

The 4 blend ratios of the sprites (jo_vdp2_enable_blend() gives the same ratio to all of them), chosen by the color of a sprite (its bits 12-11 in palette mode, its 2 highest bits in the 640 and 704 pixels modes).

Parameters
r0Ratio 0 (0 to JO_VDP2_BLEND_RATIO_MAX)
r1Ratio 1
r2Ratio 2
r3Ratio 3
Remarks
Call it after jo_vdp2_enable_blend(JO_SPRITE_SCREEN, ...)

◆ jo_vdp2_set_sprite_priorities()

void jo_vdp2_set_sprite_priorities ( const unsigned char p0,
const unsigned char p1,
const unsigned char p2,
const unsigned char p3 )

The priorities of the sprites (by default all the sprites have the priority of jo_core_set_screens_order()): chosen by the color of a sprite (its bits 14-13 in palette mode, its 2 highest bits in the 640 and 704 pixels modes).

Parameters
p0Priority 0 (1 to 7; 0 = hidden)
p1Priority 1
p2Priority 2
p3Priority 3
Remarks
jo_core_set_screens_order() gives the same priority to all of them again

◆ jo_vdp2_set_window()

void jo_vdp2_set_window ( const int window,
int x,
int y,
int width,
int height )

Set a rectangle window.

Parameters
windowJO_VDP2_WINDOW_0 or JO_VDP2_WINDOW_1
xLeft (pixels, 0 is the left of the screen)
yTop (lines, 0 is the top of the screen)
widthWidth (pixels)
heightHeight (lines)
Remarks
Then choose its screens with jo_vdp2_enable_window(). The glows (jo/glow.h) use the 2 windows

◆ jo_vdp2_set_window_circle()

bool jo_vdp2_set_window_circle ( const int window,
const int x,
const int y,
const int radius )

Set a round window (a spotlight, a transition).

Parameters
windowJO_VDP2_WINDOW_0 or JO_VDP2_WINDOW_1
xHorizontal position of the center (pixels)
yVertical position of the center (lines)
radiusRadius (pixels)
Returns
true if succeed, false if the VDP2 memory is full

◆ jo_vdp2_set_window_lines()

bool jo_vdp2_set_window_lines ( const int window,
const int top,
const int count,
const short *const left,
const short *const right )

Set a window of any shape: its left and right pixels on each line.

Parameters
windowJO_VDP2_WINDOW_0 or JO_VDP2_WINDOW_1
topFirst line of the window
countLine count (up to 512)
leftLeft pixel of each line (count values)
rightRight pixel of each line, included (count values; smaller than left: nothing on the line)
Returns
true if succeed, false if the VDP2 memory is full (2 KB per window)

◆ jo_vdp2_zoom_nbg0()

__jo_force_inline void jo_vdp2_zoom_nbg0 ( const float factor)
static

Zoom NBG0.

Parameters
factorZoom factor

◆ jo_vdp2_zoom_nbg0_fixed()

void jo_vdp2_zoom_nbg0_fixed ( const jo_fixed width_factor,
const jo_fixed height_factor )

Zoom NBG0 (fixed point: without the float functions of libgcc).

Parameters
width_factorCoordinate increment (horizontal): JO_FIXED_1 normal, JO_FIXED_1 / 2 twice bigger (8 bits of fraction are used)
height_factorCoordinate increment (vertical)

◆ jo_vdp2_zoom_nbg0f()

void jo_vdp2_zoom_nbg0f ( const float width_factor,
const float height_factor )

Zoom NBG0 width and height independently.

Parameters
width_factorWidth zoom factor
height_factorHeight zoom factor

◆ jo_vdp2_zoom_nbg1()

__jo_force_inline void jo_vdp2_zoom_nbg1 ( const float factor)
static

Zoom NBG1.

Parameters
factorZoom factor

◆ jo_vdp2_zoom_nbg1_fixed()

void jo_vdp2_zoom_nbg1_fixed ( const jo_fixed width_factor,
const jo_fixed height_factor )

Zoom NBG1 (fixed point: without the float functions of libgcc).

Parameters
width_factorCoordinate increment (horizontal): JO_FIXED_1 normal, JO_FIXED_1 / 2 twice bigger (8 bits of fraction are used)
height_factorCoordinate increment (vertical)

◆ jo_vdp2_zoom_nbg1f()

void jo_vdp2_zoom_nbg1f ( const float width_factor,
const float height_factor )

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]
extern

Internal sprintf buffer.

Warning
MC Hammer: don't touch this

◆ __jo_vdp2_nbg1_bitmap_reserved

bool __jo_vdp2_nbg1_bitmap_reserved
extern

The NBG1 bitmap is in the VRAM (Internal usage, see __jo_vdp2_reserve_nbg1_bitmap()).