![]() |
Jo Engine 2026.11.6
Jo Sega Saturn Engine
|
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_PRE_CLIPPING_DISABLE |
| Pre-clipping disabled: for a command entirely inside of the clipping area (the VDP1 tests each line of a command against the clipping area before it draws it: about 4 cycles per line, for nothing when no line is out of it; the pixels out of the clipping area are not drawn anyway). | |
| #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 |
| Number of 3D windows: near (default), far, a second far window and the window of the transparency layer (see jo_3d_select_window()). | |
| #define | JO_VDP1_OFF_SCREEN_WINDOW |
| The window that draws beyond the screen (the frame buffer at its right: the transparency layer, see jo/transparency.h): the system clipping of the other windows stays on the screen, whatever the system clipping area. | |
| #define | JO_VDP1_MAX_KEY |
| Biggest depth key. | |
Functions | |
| 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). | |
| static __jo_force_inline void | __jo_vdp1_update_near_clip (void) |
| Compute the near clipping distance (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). | |
| void | jo_3d_set_depth_limit (const int z) |
| Depth limit of the current window (the far clipping distance of jo_3d_window()): the polygons beyond it are not drawn (all their vertices farther, in the view space). A wall that fills the screen: nothing behind it is seen, the polygons of the room behind it cost VDP1 time for nothing (up to 50 ms against a wall). | |
| static __jo_force_inline void | jo_3d_set_frame_clear (const bool enabled) |
| Clear the frame buffer at the start of each frame (the default), or not. | |
| void | __jo_vdp1_set_window_clip (const bool clip) |
| The 3D polygons of the current window clipped to its rectangle (internal usage, see jo_3d_window_clip()). | |
| 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 now by the master CPU (the polygons, their parts, the sprites added since the start of the frame, see jo_vdp1_command_count() for the last frame and jo_vdp1_command_max()). | |
| int | jo_vdp1_command_max (void) |
| Most VDP1 commands in a frame (the next ones are not drawn). | |
Variables | |
| 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()). | |
| 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()). | |
| bool | __jo_vdp1_windows_apart |
| The windows drawn one after the other (internal usage, see jo_3d_set_windows_apart()). | |
| bool | __jo_vdp1_frame_clear |
| The frame buffer is cleared at the start of each frame (see jo_3d_set_frame_clear()). | |
VDP1 command table handling.
| struct jo_vdp1_command |
| struct jo_vdp1_sprite_attribute |
| struct jo_vdp1_sprite_position |
| 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 | origin_x | |
| short | origin_y | |
| short | right | |
| bool | screen | |
| short | top | |
| jo_fixed | zlimit | |
| #define JO_VDP1_CLIP_GOURAUD_TABLE_COUNT |
Gouraud tables of the clipped and subdivided 3D polygons (8 bytes each).
| #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_CMD_DISTORTED_SPRITE |
| #define JO_VDP1_CMD_END |
| #define JO_VDP1_CMD_LINE |
| #define JO_VDP1_CMD_LOCAL_COORD |
| #define JO_VDP1_CMD_NORMAL_SPRITE |
VDP1 command types (CMDCTRL).
| #define JO_VDP1_CMD_POLYGON |
| #define JO_VDP1_CMD_POLYLINE |
| #define JO_VDP1_CMD_SCALED_SPRITE |
| #define JO_VDP1_CMD_SKIP_ASSIGN |
| #define JO_VDP1_CMD_SYSTEM_CLIP |
| #define JO_VDP1_CMD_USER_CLIP |
| #define JO_VDP1_COLOR_CALC_GOURAUD |
Color calculation: gouraud shading.
| #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_MASK |
Color calculation mask.
| #define JO_VDP1_COLOR_CALC_REPLACE |
Color calculation: replace.
| #define JO_VDP1_COLOR_CALC_SHADOW |
Color calculation: shadow.
| #define JO_VDP1_COLOR_MODE_128_BANK |
Texture color mode: 128 colors (color bank).
| #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_256_BANK |
Texture color mode: 256 colors (color bank).
| #define JO_VDP1_COLOR_MODE_64_BANK |
Texture color mode: 64 colors (color bank).
| #define JO_VDP1_COLOR_MODE_MASK |
Color mode mask.
| #define JO_VDP1_COLOR_MODE_RGB |
Texture color mode: RGB (32768 colors).
| #define JO_VDP1_DIRECTION_COMMAND | ( | DIRECTION | ) |
Command bits of a direction attribute (drawing function and flip).
| DIRECTION | JO_VDP1_SPRITE_NO_FLIP, JO_VDP1_POLYGON, etc |
| #define JO_VDP1_DIRECTION_DRAW_MODE | ( | DIRECTION | ) |
Draw mode bits of a direction attribute (JO_VDP1_END_CODE_DISABLE, JO_VDP1_TRANSPARENT_PIXEL_DISABLE).
| DIRECTION | JO_VDP1_SPRITE_NO_FLIP, JO_VDP1_POLYGON, etc |
| #define JO_VDP1_DIRECTION_FLIP_MASK |
Flip mask of the direction attribute (CMDCTRL layout).
| #define JO_VDP1_DIRECTION_FUNCTION_MASK |
Drawing function mask of the direction attribute.
| #define JO_VDP1_DIRECTION_OPTIONS | ( | DIRECTION | ) |
Options of a direction attribute (JO_VDP1_OPTION_USE_TEXTURE).
| DIRECTION | JO_VDP1_SPRITE_NO_FLIP, JO_VDP1_POLYGON, etc |
| #define JO_VDP1_END_CODE_DISABLE |
Disable end code (texture).
| #define JO_VDP1_FUNCTION_LINE |
Line.
| #define JO_VDP1_FUNCTION_LOCAL_COORDINATES |
Local coordinates.
| #define JO_VDP1_FUNCTION_POLYGON |
Polygon.
| #define JO_VDP1_FUNCTION_POLYLINE |
Polyline.
| #define JO_VDP1_FUNCTION_SPRITE |
Normal sprite.
| #define JO_VDP1_FUNCTION_SYSTEM_CLIP |
System clipping area.
| #define JO_VDP1_FUNCTION_TEXTURE |
Textured polygon (distorted sprite).
| #define JO_VDP1_FUNCTION_USER_CLIP |
User clipping area.
| #define JO_VDP1_H_FLIP |
Horizontal flip bit of the direction attribute (CMDCTRL layout).
| #define JO_VDP1_HIGH_SPEED_SHRINK |
High speed shrink.
| #define JO_VDP1_LIGHT_TABLE_OFFSET |
Gouraud tables used for 3D lighting (32 brightness levels, 16 is neutral).
| #define JO_VDP1_LINE |
Flat color line.
| #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_MAX_KEY |
Biggest depth key.
| #define JO_VDP1_MESH |
Mesh (screen door).
| #define JO_VDP1_MSB_ON |
Write the MSB of the frame buffer (shadow).
| #define JO_VDP1_NO_GOURAUD |
No gouraud table.
| #define JO_VDP1_NO_MESH |
No mesh.
| #define JO_VDP1_NO_PALETTE |
No palette (color).
| #define JO_VDP1_NO_WINDOW |
No clipping window.
| #define JO_VDP1_OFF_SCREEN_WINDOW |
The window that draws beyond the screen (the frame buffer at its right: the transparency layer, see jo/transparency.h): the system clipping of the other windows stays on the screen, whatever the system clipping area.
| #define JO_VDP1_OPTION_USE_TEXTURE |
Option (bits 16-23 of the direction attribute): the polygon is textured.
| #define JO_VDP1_POLYGON |
Flat color polygon.
| #define JO_VDP1_POLYLINE |
Flat color polyline.
| #define JO_VDP1_PRE_CLIPPING_DISABLE |
Pre-clipping disabled: for a command entirely inside of the clipping area (the VDP1 tests each line of a command against the clipping area before it draws it: about 4 cycles per line, for nothing when no line is out of it; the pixels out of the clipping area are not drawn anyway).
| #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_SPRITE_ATTRIBUTE | ( | TEXTURE, | |
| COLOR, | |||
| GOURAUD, | |||
| DRAW_MODE, | |||
| DIRECTION ) |
Sprite attribute initializer.
| TEXTURE | Sprite id |
| COLOR | RGB color or palette |
| GOURAUD | Gouraud table address / 8 (JO_VDP1_NO_GOURAUD) |
| DRAW_MODE | JO_VDP1_COLOR_MODE_xxx | JO_VDP1_COLOR_CALC_xxx | ... |
| DIRECTION | JO_VDP1_SPRITE_NO_FLIP, JO_VDP1_POLYGON, etc |
| #define JO_VDP1_SPRITE_H_FLIP |
Textured sprite with horizontal flip.
| #define JO_VDP1_SPRITE_HV_FLIP |
Textured sprite with horizontal and vertical flip.
| #define JO_VDP1_SPRITE_NO_FLIP |
Textured sprite without flip.
| #define JO_VDP1_SPRITE_V_FLIP |
Textured sprite with vertical flip.
| #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_TRANSPARENT_PIXEL_DISABLE |
Disable transparent pixel (texture).
| #define JO_VDP1_WINDOW_COUNT |
Number of 3D windows: near (default), far, a second far window and the window of the transparency layer (see jo_3d_select_window()).
| #define JO_VDP1_WINDOW_IN |
Draw inside the user clipping area.
| #define JO_VDP1_WINDOW_OUT |
Draw outside the user clipping area.
|
static |
Select the 3D window used by the next commands (internal usage).
| window | 0 (near window), 1 (far window), 2 (second far window) or 3 (transparency layer) |
| 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).
| left | Left clipping position (screen pixels) |
| top | Top clipping position (screen pixels) |
| right | Right clipping position (screen pixels) |
| bottom | Bottom clipping position (screen pixels) |
| zlimit | Far clipping distance |
| center_x | Horizontal position of the projection center (screen pixels) |
| center_y | Vertical position of the projection center (screen pixels) |
| void __jo_vdp1_set_window_clip | ( | const bool | clip | ) |
The 3D polygons of the current window clipped to its rectangle (internal usage, see jo_3d_window_clip()).
|
static |
Compute the near clipping distance (internal usage).
| void jo_3d_set_depth_limit | ( | const int | z | ) |
Depth limit of the current window (the far clipping distance of jo_3d_window()): the polygons beyond it are not drawn (all their vertices farther, in the view space). A wall that fills the screen: nothing behind it is seen, the polygons of the room behind it cost VDP1 time for nothing (up to 50 ms against a wall).
| z | Depth limit (world units), -1: none (the default) |
|
static |
Clear the frame buffer at the start of each frame (the default), or not.
| enabled | false: the frame buffer is not cleared, what the frame does not draw keeps the pixels of the frame drawn 2 frames before (the frame buffers alternate) |
| 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_command_max | ( | void | ) |
Most VDP1 commands in a frame (the next ones are not drawn).
| int jo_vdp1_frame_command_count | ( | void | ) |
VDP1 commands of the frame being made now by the master CPU (the polygons, their parts, the sprites added since the start of the frame, see jo_vdp1_command_count() for the last frame and jo_vdp1_command_max()).
| 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).
|
extern |
Current 3D window (internal usage).
|
extern |
Depth added to the keys of the commands (see jo_3d_set_depth_bias()).
|
extern |
Near clipping divisor (internal usage, see jo_3d_display_level()).
|
extern |
The frame buffer is cleared at the start of each frame (see jo_3d_set_frame_clear()).
|
extern |
Near clipping distance (internal usage, see __jo_vdp1_near_clip()).
|
extern |
Projection distance in Q16.16 (internal usage, see jo_3d_perspective_angle()).
|
extern |
The windows drawn one after the other (internal usage, see jo_3d_set_windows_apart()).
|
extern |
Wireframe mode (internal usage, see jo_3d_set_wireframe()).