Jo Engine 2026.11.1
Jo Sega Saturn Engine
Loading...
Searching...
No Matches
vdp1_command_pipeline.h File Reference

VDP1 command table handling. More...

Go to the source code of this file.

Data Structures

struct  jo_vdp1_command
 VDP1 command (32 bytes). More...
struct  jo_vdp1_sprite_attribute
 Sprite attribute. More...
struct  jo_vdp1_sprite_position
 Sprite position (internal usage). More...
struct  jo_vdp1_window
 3D window (internal usage) More...

Macros

#define JO_VDP1_MAX_COMMANDS
 Maximum commands per frame (sprites, polygons, the headers of the windows). Each one costs 36 bytes of RAM per command buffer (2 buffers with the second CPU) + 4 bytes for the sort; the 3D of the slave CPU can write JO_VDP1_MAX_COMMANDS - 40 commands.
#define JO_VDP1_CMD_NORMAL_SPRITE
 VDP1 command types (CMDCTRL).
#define JO_VDP1_CMD_SCALED_SPRITE
#define JO_VDP1_CMD_DISTORTED_SPRITE
#define JO_VDP1_CMD_POLYGON
#define JO_VDP1_CMD_POLYLINE
#define JO_VDP1_CMD_LINE
#define JO_VDP1_CMD_USER_CLIP
#define JO_VDP1_CMD_SYSTEM_CLIP
#define JO_VDP1_CMD_LOCAL_COORD
#define JO_VDP1_CMD_SKIP_ASSIGN
#define JO_VDP1_CMD_END
#define JO_VDP1_FUNCTION_SPRITE
 Normal sprite.
#define JO_VDP1_FUNCTION_TEXTURE
 Textured polygon (distorted sprite).
#define JO_VDP1_FUNCTION_POLYGON
 Polygon.
#define JO_VDP1_FUNCTION_POLYLINE
 Polyline.
#define JO_VDP1_FUNCTION_LINE
 Line.
#define JO_VDP1_FUNCTION_USER_CLIP
 User clipping area.
#define JO_VDP1_FUNCTION_SYSTEM_CLIP
 System clipping area.
#define JO_VDP1_FUNCTION_LOCAL_COORDINATES
 Local coordinates.
#define JO_VDP1_DIRECTION_FUNCTION_MASK
 Drawing function mask of the direction attribute.
#define JO_VDP1_DIRECTION_FLIP_MASK
 Flip mask of the direction attribute (CMDCTRL layout).
#define JO_VDP1_H_FLIP
 Horizontal flip bit of the direction attribute (CMDCTRL layout).
#define JO_VDP1_MSB_ON
 Write the MSB of the frame buffer (shadow).
#define JO_VDP1_HIGH_SPEED_SHRINK
 High speed shrink.
#define JO_VDP1_NO_WINDOW
 No clipping window.
#define JO_VDP1_WINDOW_IN
 Draw inside the user clipping area.
#define JO_VDP1_WINDOW_OUT
 Draw outside the user clipping area.
#define JO_VDP1_MESH
 Mesh (screen door).
#define JO_VDP1_NO_MESH
 No mesh.
#define JO_VDP1_END_CODE_DISABLE
 Disable end code (texture).
#define JO_VDP1_RGB_END_CODE
 End code of the RGB textures: the VDP1 stops drawing a line after 2 end codes (see jo_sprite_add_end_codes()).
#define JO_VDP1_TRANSPARENT_PIXEL_DISABLE
 Disable transparent pixel (texture).
#define JO_VDP1_COLOR_MODE_16_BANK
 Texture color mode: 16 colors (color bank).
#define JO_VDP1_COLOR_MODE_16_LOOKUP
 Texture color mode: 16 colors (lookup table).
#define JO_VDP1_COLOR_MODE_64_BANK
 Texture color mode: 64 colors (color bank).
#define JO_VDP1_COLOR_MODE_128_BANK
 Texture color mode: 128 colors (color bank).
#define JO_VDP1_COLOR_MODE_256_BANK
 Texture color mode: 256 colors (color bank).
#define JO_VDP1_COLOR_MODE_RGB
 Texture color mode: RGB (32768 colors).
#define JO_VDP1_COLOR_MODE_MASK
 Color mode mask.
#define JO_VDP1_COLOR_CALC_REPLACE
 Color calculation: replace.
#define JO_VDP1_COLOR_CALC_SHADOW
 Color calculation: shadow.
#define JO_VDP1_COLOR_CALC_HALF_LUMINANCE
 Color calculation: half luminance.
#define JO_VDP1_COLOR_CALC_HALF_TRANSPARENT
 Color calculation: half transparent.
#define JO_VDP1_COLOR_CALC_GOURAUD
 Color calculation: gouraud shading.
#define JO_VDP1_COLOR_CALC_MASK
 Color calculation mask.
#define JO_VDP1_NO_GOURAUD
 No gouraud table.
#define JO_VDP1_NO_PALETTE
 No palette (color).
#define JO_VDP1_TEXTURE_SIZE_SHIFT_16_COLORS
 Texture size shift for 16 colors textures (4 bits per pixel).
#define JO_VDP1_TEXTURE_SIZE_SHIFT_256_COLORS
 Texture size shift for 64, 128 and 256 colors textures (8 bits per pixel).
#define JO_VDP1_TEXTURE_SIZE_SHIFT_32K_COLORS
 Texture size shift for RGB textures (16 bits per pixel).
#define JO_VDP1_OPTION_USE_TEXTURE
 Option (bits 16-23 of the direction attribute): the polygon is textured.
#define JO_VDP1_SPRITE_NO_FLIP
 Textured sprite without flip.
#define JO_VDP1_SPRITE_H_FLIP
 Textured sprite with horizontal flip.
#define JO_VDP1_SPRITE_V_FLIP
 Textured sprite with vertical flip.
#define JO_VDP1_SPRITE_HV_FLIP
 Textured sprite with horizontal and vertical flip.
#define JO_VDP1_POLYGON
 Flat color polygon.
#define JO_VDP1_POLYLINE
 Flat color polyline.
#define JO_VDP1_LINE
 Flat color line.
#define JO_VDP1_DIRECTION_COMMAND(DIRECTION)
 Command bits of a direction attribute (drawing function and flip).
#define JO_VDP1_DIRECTION_OPTIONS(DIRECTION)
 Options of a direction attribute (JO_VDP1_OPTION_USE_TEXTURE).
#define JO_VDP1_DIRECTION_DRAW_MODE(DIRECTION)
 Draw mode bits of a direction attribute (JO_VDP1_END_CODE_DISABLE, JO_VDP1_TRANSPARENT_PIXEL_DISABLE).
#define JO_VDP1_SPRITE_ATTRIBUTE(TEXTURE, COLOR, GOURAUD, DRAW_MODE, DIRECTION)
 Sprite attribute initializer.
#define JO_VDP1_LIGHT_TABLE_OFFSET
 Gouraud tables used for 3D lighting (32 brightness levels, 16 is neutral).
#define JO_VDP1_CLIP_GOURAUD_TABLE_OFFSET
 Gouraud tables of the parts of the 3D polygons clipped by the near plane or subdivided near the camera (2 sets: one per frame).
#define JO_VDP1_CLIP_GOURAUD_TABLE_COUNT
 Gouraud tables of the clipped and subdivided 3D polygons (8 bytes each).
#define JO_VDP1_WINDOW_COUNT
 3D windows (internal usage)
#define JO_VDP1_MAX_KEY
 Biggest depth key.

Functions

void __jo_vdp1_init (void)
 Initialize the VDP1 (internal usage).
void __jo_vdp1_end_frame (void)
 Sort the commands of the frame and copy them into the VDP1 VRAM (internal usage).
void __jo_vdp1_vblank (void)
 Display the last complete command table (internal usage, called during VBLANK-IN).
unsigned int __jo_vdp1_frame_tag (void)
 Number of the frame being built (internal usage): the VDP2 changes that must match the image of this frame are kept with this number and applied when it is displayed (see __jo_vdp1_displayed_frame_changed()).
bool __jo_vdp1_displayed_frame_changed (unsigned int *const tag)
 Called during the VBLANK, after __jo_vdp1_vblank() (internal usage, a VBLANK callback): the image of an other frame is displayed from this field.
void jo_vdp1_redraw_last_frame (void)
 Draw the last frame again (from a VBLANK callback while the main loop doesn't run: a loading). A texture of this frame changed by the callback is seen (the sand of an hourglass).
jo_vdp1_command * __jo_vdp1_add_command (const jo_fixed z)
 Allocate a command for the current frame (internal usage).
jo_vdp1_command * __jo_vdp1_reserve_commands (const unsigned int count, unsigned short **keys, unsigned int *reserved)
 Reserve commands for the current frame (internal usage).
unsigned short * __jo_vdp1_commit_commands_without_window (const unsigned int used)
 Add the first commands reserved by __jo_vdp1_reserve_commands() to the frame, their windows written by the caller (internal usage: the slave CPU copies its commands, see jo_3d_slave_end()).
void __jo_vdp1_commit_commands (const unsigned int used)
 Add the first commands reserved by __jo_vdp1_reserve_commands() to the frame (internal usage).
static __jo_force_inline unsigned short __jo_vdp1_sort_key (const jo_fixed z)
 Depth key of a command (internal usage).
bool __jo_vdp1_set_attribute (jo_vdp1_command *cmd, const jo_vdp1_sprite_attribute *attr)
 Fill the drawing part of a command from a sprite attribute (internal usage).
static __jo_force_inline void __jo_vdp1_update_near_clip (void)
 Compute the near clipping distance (internal usage).
static __jo_force_inline jo_fixed __jo_vdp1_near_clip (void)
 Near clipping distance (internal usage).
bool __jo_vdp1_draw_sprite (const jo_vdp1_sprite_position *const pos, const jo_vdp1_sprite_attribute *const attr, const jo_angle angle)
 Draw a sprite on the screen (internal usage).
bool __jo_vdp1_draw_sprite_hv (const jo_vdp1_sprite_position *const pos, const jo_vdp1_sprite_attribute *const attr, const jo_angle angle)
 Draw a sprite on the screen with different horizontal and vertical scale (internal usage).
bool __jo_vdp1_draw_sprite_4p (const jo_pos2D_fixed *const points, const jo_fixed z, const jo_vdp1_sprite_attribute *const attr)
 Draw a sprite or a polygon using 4 points (internal usage).
bool __jo_vdp1_write_sprite_4p (jo_vdp1_command *const cmd, const jo_pos2D_fixed *const points, const jo_fixed z, const jo_vdp1_sprite_attribute *const attr, const int window)
 Write the command of a sprite using 4 points in a command table of the caller (internal usage: the slave CPU, see jo_3d_slave_draw_standing_sprite()).
void __jo_sprite_attributes_of (jo_vdp1_sprite_attribute *attr, const int sprite_id, const jo_sprite_attributes *const state)
 Attribute of a sprite with some sprite attributes (internal usage: the slave CPU uses its copy of them, see jo_3d_slave_begin()).
bool __jo_vdp1_draw_sprite_3d (const jo_vdp1_sprite_position *const pos, const jo_vdp1_sprite_attribute *const attr, const jo_angle angle)
 Draw a sprite in the 3D space using the current matrix (internal usage).
void __jo_vdp1_set_window (const short left, const short top, const short right, const short bottom, const short zlimit, const short center_x, const short center_y)
 Set the current 3D window (internal usage).
static __jo_force_inline void __jo_vdp1_select_window (const int window)
 Select the 3D window used by the next commands (internal usage).
int jo_vdp1_command_count (void)
 VDP1 commands of the last frame (the polygons, their parts, the sprites: see jo_vdp1_command_max()).
int __jo_vdp1_frame_command_count (void)
 VDP1 commands of the frame being made by the master CPU, read without the cache (internal usage: the budget of the subdivisions, see 3d.c; the commands of the slave CPU are added at jo_3d_slave_end()).
int jo_vdp1_command_max (void)
 Most VDP1 commands in a frame (the next ones are not drawn).

Variables

jo_vdp1_window __jo_vdp1_windows [(3)]
int __jo_vdp1_current_window
 Current 3D window (internal usage).
jo_fixed __jo_vdp1_projection_distance
 Projection distance in Q16.16 (internal usage, see jo_3d_perspective_angle()).
unsigned short __jo_vdp1_display_level
 Near clipping divisor (internal usage, see jo_3d_display_level()).
int __jo_vdp1_depth_bias
 Depth added to the keys of the commands (see jo_3d_set_depth_bias()).
short __jo_vdp1_system_clip_right
 Right of the system clipping area (internal usage).
short __jo_vdp1_system_clip_bottom
 Bottom of the system clipping area (internal usage).
jo_fixed __jo_vdp1_near_z
 Near clipping distance (internal usage, see __jo_vdp1_near_clip()).
bool __jo_vdp1_wireframe
 Wireframe mode (internal usage, see jo_3d_set_wireframe()).

Detailed Description

VDP1 command table handling.

Author
Johannes Fetz
Bug
No known bugs.

Data Structure Documentation

◆ jo_vdp1_command

struct jo_vdp1_command

VDP1 command (32 bytes).

Data Fields
unsigned short colr
unsigned short ctrl
unsigned short grda
unsigned short link
unsigned short pmod
unsigned short reserved
unsigned short size
unsigned short srca
short xa
short xb
short xc
short xd
short ya
short yb
short yc
short yd

◆ jo_vdp1_sprite_attribute

struct jo_vdp1_sprite_attribute

Sprite attribute.

Data Fields
unsigned short color
unsigned short direction
unsigned short draw_mode
unsigned short gouraud_table
unsigned short texture_id

◆ jo_vdp1_sprite_position

struct jo_vdp1_sprite_position

Sprite position (internal usage).

Data Fields
jo_fixed scale_x
jo_fixed scale_y
jo_fixed x
jo_fixed y
jo_fixed z

◆ jo_vdp1_window

struct jo_vdp1_window

3D window (internal usage)

Data Fields
short bottom
short center_x
short center_y
unsigned short clip_mode
short left
short right
short top
jo_fixed zlimit

Macro Definition Documentation

◆ JO_VDP1_CLIP_GOURAUD_TABLE_COUNT

#define JO_VDP1_CLIP_GOURAUD_TABLE_COUNT

Gouraud tables of the clipped and subdivided 3D polygons (8 bytes each).

◆ JO_VDP1_CLIP_GOURAUD_TABLE_OFFSET

#define JO_VDP1_CLIP_GOURAUD_TABLE_OFFSET

Gouraud tables of the parts of the 3D polygons clipped by the near plane or subdivided near the camera (2 sets: one per frame).

◆ JO_VDP1_CMD_DISTORTED_SPRITE

#define JO_VDP1_CMD_DISTORTED_SPRITE

◆ JO_VDP1_CMD_END

#define JO_VDP1_CMD_END

◆ JO_VDP1_CMD_LINE

#define JO_VDP1_CMD_LINE

◆ JO_VDP1_CMD_LOCAL_COORD

#define JO_VDP1_CMD_LOCAL_COORD

◆ JO_VDP1_CMD_NORMAL_SPRITE

#define JO_VDP1_CMD_NORMAL_SPRITE

VDP1 command types (CMDCTRL).

◆ JO_VDP1_CMD_POLYGON

#define JO_VDP1_CMD_POLYGON

◆ JO_VDP1_CMD_POLYLINE

#define JO_VDP1_CMD_POLYLINE

◆ JO_VDP1_CMD_SCALED_SPRITE

#define JO_VDP1_CMD_SCALED_SPRITE

◆ JO_VDP1_CMD_SKIP_ASSIGN

#define JO_VDP1_CMD_SKIP_ASSIGN

◆ JO_VDP1_CMD_SYSTEM_CLIP

#define JO_VDP1_CMD_SYSTEM_CLIP

◆ JO_VDP1_CMD_USER_CLIP

#define JO_VDP1_CMD_USER_CLIP

◆ JO_VDP1_COLOR_CALC_GOURAUD

#define JO_VDP1_COLOR_CALC_GOURAUD

Color calculation: gouraud shading.

◆ JO_VDP1_COLOR_CALC_HALF_LUMINANCE

#define JO_VDP1_COLOR_CALC_HALF_LUMINANCE

Color calculation: half luminance.

◆ JO_VDP1_COLOR_CALC_HALF_TRANSPARENT

#define JO_VDP1_COLOR_CALC_HALF_TRANSPARENT

Color calculation: half transparent.

◆ JO_VDP1_COLOR_CALC_MASK

#define JO_VDP1_COLOR_CALC_MASK

Color calculation mask.

◆ JO_VDP1_COLOR_CALC_REPLACE

#define JO_VDP1_COLOR_CALC_REPLACE

Color calculation: replace.

◆ JO_VDP1_COLOR_CALC_SHADOW

#define JO_VDP1_COLOR_CALC_SHADOW

Color calculation: shadow.

◆ JO_VDP1_COLOR_MODE_128_BANK

#define JO_VDP1_COLOR_MODE_128_BANK

Texture color mode: 128 colors (color bank).

◆ JO_VDP1_COLOR_MODE_16_BANK

#define JO_VDP1_COLOR_MODE_16_BANK

Texture color mode: 16 colors (color bank).

◆ JO_VDP1_COLOR_MODE_16_LOOKUP

#define JO_VDP1_COLOR_MODE_16_LOOKUP

Texture color mode: 16 colors (lookup table).

◆ JO_VDP1_COLOR_MODE_256_BANK

#define JO_VDP1_COLOR_MODE_256_BANK

Texture color mode: 256 colors (color bank).

◆ JO_VDP1_COLOR_MODE_64_BANK

#define JO_VDP1_COLOR_MODE_64_BANK

Texture color mode: 64 colors (color bank).

◆ JO_VDP1_COLOR_MODE_MASK

#define JO_VDP1_COLOR_MODE_MASK

Color mode mask.

◆ JO_VDP1_COLOR_MODE_RGB

#define JO_VDP1_COLOR_MODE_RGB

Texture color mode: RGB (32768 colors).

◆ JO_VDP1_DIRECTION_COMMAND

#define JO_VDP1_DIRECTION_COMMAND ( DIRECTION)

Command bits of a direction attribute (drawing function and flip).

Parameters
DIRECTIONJO_VDP1_SPRITE_NO_FLIP, JO_VDP1_POLYGON, etc

◆ JO_VDP1_DIRECTION_DRAW_MODE

#define JO_VDP1_DIRECTION_DRAW_MODE ( DIRECTION)

Draw mode bits of a direction attribute (JO_VDP1_END_CODE_DISABLE, JO_VDP1_TRANSPARENT_PIXEL_DISABLE).

Parameters
DIRECTIONJO_VDP1_SPRITE_NO_FLIP, JO_VDP1_POLYGON, etc

◆ JO_VDP1_DIRECTION_FLIP_MASK

#define JO_VDP1_DIRECTION_FLIP_MASK

Flip mask of the direction attribute (CMDCTRL layout).

◆ JO_VDP1_DIRECTION_FUNCTION_MASK

#define JO_VDP1_DIRECTION_FUNCTION_MASK

Drawing function mask of the direction attribute.

◆ JO_VDP1_DIRECTION_OPTIONS

#define JO_VDP1_DIRECTION_OPTIONS ( DIRECTION)

Options of a direction attribute (JO_VDP1_OPTION_USE_TEXTURE).

Parameters
DIRECTIONJO_VDP1_SPRITE_NO_FLIP, JO_VDP1_POLYGON, etc

◆ JO_VDP1_END_CODE_DISABLE

#define JO_VDP1_END_CODE_DISABLE

Disable end code (texture).

◆ JO_VDP1_FUNCTION_LINE

#define JO_VDP1_FUNCTION_LINE

Line.

◆ JO_VDP1_FUNCTION_LOCAL_COORDINATES

#define JO_VDP1_FUNCTION_LOCAL_COORDINATES

Local coordinates.

◆ JO_VDP1_FUNCTION_POLYGON

#define JO_VDP1_FUNCTION_POLYGON

Polygon.

◆ JO_VDP1_FUNCTION_POLYLINE

#define JO_VDP1_FUNCTION_POLYLINE

Polyline.

◆ JO_VDP1_FUNCTION_SPRITE

#define JO_VDP1_FUNCTION_SPRITE

Normal sprite.

◆ JO_VDP1_FUNCTION_SYSTEM_CLIP

#define JO_VDP1_FUNCTION_SYSTEM_CLIP

System clipping area.

◆ JO_VDP1_FUNCTION_TEXTURE

#define JO_VDP1_FUNCTION_TEXTURE

Textured polygon (distorted sprite).

◆ JO_VDP1_FUNCTION_USER_CLIP

#define JO_VDP1_FUNCTION_USER_CLIP

User clipping area.

◆ JO_VDP1_H_FLIP

#define JO_VDP1_H_FLIP

Horizontal flip bit of the direction attribute (CMDCTRL layout).

◆ JO_VDP1_HIGH_SPEED_SHRINK

#define JO_VDP1_HIGH_SPEED_SHRINK

High speed shrink.

◆ JO_VDP1_LIGHT_TABLE_OFFSET

#define JO_VDP1_LIGHT_TABLE_OFFSET

Gouraud tables used for 3D lighting (32 brightness levels, 16 is neutral).

◆ JO_VDP1_LINE

#define JO_VDP1_LINE

Flat color line.

◆ JO_VDP1_MAX_COMMANDS

#define JO_VDP1_MAX_COMMANDS

Maximum commands per frame (sprites, polygons, the headers of the windows). Each one costs 36 bytes of RAM per command buffer (2 buffers with the second CPU) + 4 bytes for the sort; the 3D of the slave CPU can write JO_VDP1_MAX_COMMANDS - 40 commands.

Remarks
Smaller in the makefile to save RAM (JO_VDP1_MAX_COMMANDS = 256: 30 KB less per buffer). 1000 at most (the command tables of the VRAM)

◆ JO_VDP1_MAX_KEY

#define JO_VDP1_MAX_KEY

Biggest depth key.

◆ JO_VDP1_MESH

#define JO_VDP1_MESH

Mesh (screen door).

◆ JO_VDP1_MSB_ON

#define JO_VDP1_MSB_ON

Write the MSB of the frame buffer (shadow).

◆ JO_VDP1_NO_GOURAUD

#define JO_VDP1_NO_GOURAUD

No gouraud table.

◆ JO_VDP1_NO_MESH

#define JO_VDP1_NO_MESH

No mesh.

◆ JO_VDP1_NO_PALETTE

#define JO_VDP1_NO_PALETTE

No palette (color).

◆ JO_VDP1_NO_WINDOW

#define JO_VDP1_NO_WINDOW

No clipping window.

◆ JO_VDP1_OPTION_USE_TEXTURE

#define JO_VDP1_OPTION_USE_TEXTURE

Option (bits 16-23 of the direction attribute): the polygon is textured.

◆ JO_VDP1_POLYGON

#define JO_VDP1_POLYGON

Flat color polygon.

◆ JO_VDP1_POLYLINE

#define JO_VDP1_POLYLINE

Flat color polyline.

◆ JO_VDP1_RGB_END_CODE

#define JO_VDP1_RGB_END_CODE

End code of the RGB textures: the VDP1 stops drawing a line after 2 end codes (see jo_sprite_add_end_codes()).

◆ JO_VDP1_SPRITE_ATTRIBUTE

#define JO_VDP1_SPRITE_ATTRIBUTE ( TEXTURE,
COLOR,
GOURAUD,
DRAW_MODE,
DIRECTION )

Sprite attribute initializer.

Parameters
TEXTURESprite id
COLORRGB color or palette
GOURAUDGouraud table address / 8 (JO_VDP1_NO_GOURAUD)
DRAW_MODEJO_VDP1_COLOR_MODE_xxx | JO_VDP1_COLOR_CALC_xxx | ...
DIRECTIONJO_VDP1_SPRITE_NO_FLIP, JO_VDP1_POLYGON, etc

◆ JO_VDP1_SPRITE_H_FLIP

#define JO_VDP1_SPRITE_H_FLIP

Textured sprite with horizontal flip.

◆ JO_VDP1_SPRITE_HV_FLIP

#define JO_VDP1_SPRITE_HV_FLIP

Textured sprite with horizontal and vertical flip.

◆ JO_VDP1_SPRITE_NO_FLIP

#define JO_VDP1_SPRITE_NO_FLIP

Textured sprite without flip.

◆ JO_VDP1_SPRITE_V_FLIP

#define JO_VDP1_SPRITE_V_FLIP

Textured sprite with vertical flip.

◆ JO_VDP1_TEXTURE_SIZE_SHIFT_16_COLORS

#define JO_VDP1_TEXTURE_SIZE_SHIFT_16_COLORS

Texture size shift for 16 colors textures (4 bits per pixel).

◆ JO_VDP1_TEXTURE_SIZE_SHIFT_256_COLORS

#define JO_VDP1_TEXTURE_SIZE_SHIFT_256_COLORS

Texture size shift for 64, 128 and 256 colors textures (8 bits per pixel).

◆ JO_VDP1_TEXTURE_SIZE_SHIFT_32K_COLORS

#define JO_VDP1_TEXTURE_SIZE_SHIFT_32K_COLORS

Texture size shift for RGB textures (16 bits per pixel).

◆ JO_VDP1_TRANSPARENT_PIXEL_DISABLE

#define JO_VDP1_TRANSPARENT_PIXEL_DISABLE

Disable transparent pixel (texture).

◆ JO_VDP1_WINDOW_COUNT

#define JO_VDP1_WINDOW_COUNT

3D windows (internal usage)

Number of 3D windows: near (default), far, and a second far window (see jo_3d_select_window())

◆ JO_VDP1_WINDOW_IN

#define JO_VDP1_WINDOW_IN

Draw inside the user clipping area.

◆ JO_VDP1_WINDOW_OUT

#define JO_VDP1_WINDOW_OUT

Draw outside the user clipping area.

Function Documentation

◆ __jo_sprite_attributes_of()

void __jo_sprite_attributes_of ( jo_vdp1_sprite_attribute * attr,
const int sprite_id,
const jo_sprite_attributes *const state )

Attribute of a sprite with some sprite attributes (internal usage: the slave CPU uses its copy of them, see jo_3d_slave_begin()).

Parameters
attrAttribute (output)
sprite_idSprite Id
stateSprite attributes

◆ __jo_vdp1_add_command()

jo_vdp1_command * __jo_vdp1_add_command ( const jo_fixed z)

Allocate a command for the current frame (internal usage).

Parameters
zDepth used to sort the commands (bigger = farther)
Returns
Command or JO_NULL if the table is full

◆ __jo_vdp1_commit_commands()

void __jo_vdp1_commit_commands ( const unsigned int used)

Add the first commands reserved by __jo_vdp1_reserve_commands() to the frame (internal usage).

Parameters
usedCommand count

◆ __jo_vdp1_commit_commands_without_window()

unsigned short * __jo_vdp1_commit_commands_without_window ( const unsigned int used)

Add the first commands reserved by __jo_vdp1_reserve_commands() to the frame, their windows written by the caller (internal usage: the slave CPU copies its commands, see jo_3d_slave_end()).

Parameters
usedCommand count
Returns
The windows of the commands (to write)

◆ __jo_vdp1_displayed_frame_changed()

bool __jo_vdp1_displayed_frame_changed ( unsigned int *const tag)

Called during the VBLANK, after __jo_vdp1_vblank() (internal usage, a VBLANK callback): the image of an other frame is displayed from this field.

Parameters
tagOutput: number of the frame displayed (see __jo_vdp1_frame_tag())
Returns
true if the frame displayed changes at this VBLANK

◆ __jo_vdp1_draw_sprite()

bool __jo_vdp1_draw_sprite ( const jo_vdp1_sprite_position *const pos,
const jo_vdp1_sprite_attribute *const attr,
const jo_angle angle )

Draw a sprite on the screen (internal usage).

Parameters
posPosition relative to the center of the current window, depth and scale (scale_x, negative scale: perspective scale)
attrSprite attribute
angleRotation
Returns
false if the sprite is not visible or if the command table is full

◆ __jo_vdp1_draw_sprite_3d()

bool __jo_vdp1_draw_sprite_3d ( const jo_vdp1_sprite_position *const pos,
const jo_vdp1_sprite_attribute *const attr,
const jo_angle angle )

Draw a sprite in the 3D space using the current matrix (internal usage).

Parameters
posPosition in the 3D space and scale (scale_x)
attrSprite attribute
angleRotation
Returns
false if the sprite is not visible or if the command table is full
Remarks
The sprite always faces the camera (billboard)

◆ __jo_vdp1_draw_sprite_4p()

bool __jo_vdp1_draw_sprite_4p ( const jo_pos2D_fixed *const points,
const jo_fixed z,
const jo_vdp1_sprite_attribute *const attr )

Draw a sprite or a polygon using 4 points (internal usage).

Parameters
points4 points relative to the center of the current window (clockwise from the top left corner)
zDepth
attrSprite attribute
Returns
false if the sprite is not visible or if the command table is full

◆ __jo_vdp1_draw_sprite_hv()

bool __jo_vdp1_draw_sprite_hv ( const jo_vdp1_sprite_position *const pos,
const jo_vdp1_sprite_attribute *const attr,
const jo_angle angle )

Draw a sprite on the screen with different horizontal and vertical scale (internal usage).

Parameters
posPosition relative to the center of the current window, depth and scales (negative scale: perspective scale)
attrSprite attribute
angleRotation
Returns
false if the sprite is not visible or if the command table is full

◆ __jo_vdp1_end_frame()

void __jo_vdp1_end_frame ( void )

Sort the commands of the frame and copy them into the VDP1 VRAM (internal usage).

◆ __jo_vdp1_frame_command_count()

int __jo_vdp1_frame_command_count ( void )

VDP1 commands of the frame being made by the master CPU, read without the cache (internal usage: the budget of the subdivisions, see 3d.c; the commands of the slave CPU are added at jo_3d_slave_end()).

◆ __jo_vdp1_frame_tag()

unsigned int __jo_vdp1_frame_tag ( void )

Number of the frame being built (internal usage): the VDP2 changes that must match the image of this frame are kept with this number and applied when it is displayed (see __jo_vdp1_displayed_frame_changed()).

Returns
Frame number (it increases at each frame)

◆ __jo_vdp1_init()

void __jo_vdp1_init ( void )

Initialize the VDP1 (internal usage).

◆ __jo_vdp1_near_clip()

__jo_force_inline jo_fixed __jo_vdp1_near_clip ( void )
static

Near clipping distance (internal usage).

Returns
Projection distance divided by 2^display level (Q16.16)
Remarks
Polygons and sprites nearer than this distance are not displayed

◆ __jo_vdp1_reserve_commands()

jo_vdp1_command * __jo_vdp1_reserve_commands ( const unsigned int count,
unsigned short ** keys,
unsigned int * reserved )

Reserve commands for the current frame (internal usage).

Parameters
countWanted command count
keysOutput: depth keys of the reserved commands (see __jo_vdp1_sort_key())
reservedOutput: reserved command count (less than count if the table is full)
Returns
First reserved command
Remarks
The commands are added by __jo_vdp1_commit_commands(). link must be set to 0.

◆ __jo_vdp1_select_window()

__jo_force_inline void __jo_vdp1_select_window ( const int window)
static

Select the 3D window used by the next commands (internal usage).

Parameters
window0 (near window), 1 (far window) or 2 (second far window)

◆ __jo_vdp1_set_attribute()

bool __jo_vdp1_set_attribute ( jo_vdp1_command * cmd,
const jo_vdp1_sprite_attribute * attr )

Fill the drawing part of a command from a sprite attribute (internal usage).

Parameters
cmdVDP1 command
attrSprite attribute
Returns
true if the command is textured
Remarks
The coordinates are not set

◆ __jo_vdp1_set_window()

void __jo_vdp1_set_window ( const short left,
const short top,
const short right,
const short bottom,
const short zlimit,
const short center_x,
const short center_y )

Set the current 3D window (internal usage).

Parameters
leftLeft clipping position (screen pixels)
topTop clipping position (screen pixels)
rightRight clipping position (screen pixels)
bottomBottom clipping position (screen pixels)
zlimitFar clipping distance
center_xHorizontal position of the projection center (screen pixels)
center_yVertical position of the projection center (screen pixels)
Remarks
Select the window with __jo_vdp1_select_window() first

◆ __jo_vdp1_sort_key()

__jo_force_inline unsigned short __jo_vdp1_sort_key ( const jo_fixed z)
static

Depth key of a command (internal usage).

Parameters
zDepth (bigger = farther)
Returns
Key used to sort the commands

◆ __jo_vdp1_update_near_clip()

__jo_force_inline void __jo_vdp1_update_near_clip ( void )
static

Compute the near clipping distance (internal usage).

Remarks
Must be called when __jo_vdp1_projection_distance or __jo_vdp1_display_level change

◆ __jo_vdp1_vblank()

void __jo_vdp1_vblank ( void )

Display the last complete command table (internal usage, called during VBLANK-IN).

◆ __jo_vdp1_write_sprite_4p()

bool __jo_vdp1_write_sprite_4p ( jo_vdp1_command *const cmd,
const jo_pos2D_fixed *const points,
const jo_fixed z,
const jo_vdp1_sprite_attribute *const attr,
const int window )

Write the command of a sprite using 4 points in a command table of the caller (internal usage: the slave CPU, see jo_3d_slave_draw_standing_sprite()).

Parameters
cmdCommand (its sort key is written by the caller)
points4 points relative to the center of the window (clockwise from the top left corner)
zDepth
attrSprite attribute
windowWindow (its center and its far limit)
Returns
false if the sprite is not visible (the command is not written)

◆ jo_vdp1_command_count()

int jo_vdp1_command_count ( void )

VDP1 commands of the last frame (the polygons, their parts, the sprites: see jo_vdp1_command_max()).

◆ jo_vdp1_command_max()

int jo_vdp1_command_max ( void )

Most VDP1 commands in a frame (the next ones are not drawn).

◆ jo_vdp1_redraw_last_frame()

void jo_vdp1_redraw_last_frame ( void )

Draw the last frame again (from a VBLANK callback while the main loop doesn't run: a loading). A texture of this frame changed by the callback is seen (the sand of an hourglass).

Remarks
The manual change of the frame buffers (JO_FRAMERATE > 1) draws a frame only once: the frame buffers change at the end of this VBLANK if the VDP1 finished the frame. Don't call it while the main loop sends frames

Variable Documentation

◆ __jo_vdp1_current_window

int __jo_vdp1_current_window
extern

Current 3D window (internal usage).

◆ __jo_vdp1_depth_bias

int __jo_vdp1_depth_bias
extern

Depth added to the keys of the commands (see jo_3d_set_depth_bias()).

◆ __jo_vdp1_display_level

unsigned short __jo_vdp1_display_level
extern

Near clipping divisor (internal usage, see jo_3d_display_level()).

◆ __jo_vdp1_near_z

jo_fixed __jo_vdp1_near_z
extern

Near clipping distance (internal usage, see __jo_vdp1_near_clip()).

◆ __jo_vdp1_projection_distance

jo_fixed __jo_vdp1_projection_distance
extern

Projection distance in Q16.16 (internal usage, see jo_3d_perspective_angle()).

◆ __jo_vdp1_system_clip_bottom

short __jo_vdp1_system_clip_bottom
extern

Bottom of the system clipping area (internal usage).

◆ __jo_vdp1_system_clip_right

short __jo_vdp1_system_clip_right
extern

Right of the system clipping area (internal usage).

◆ __jo_vdp1_windows

jo_vdp1_window __jo_vdp1_windows[(3)]
extern

◆ __jo_vdp1_wireframe

bool __jo_vdp1_wireframe
extern

Wireframe mode (internal usage, see jo_3d_set_wireframe()).