BEEP-8 SDK 1.0.0
|
Picture Processing Unit (PPU) definitions for the BEEP-8 system. More...
Go to the source code of this file.
Classes | |
struct | _b8PpuCmd |
Structure representing a PPU command buffer for the BEEP-8 system. More... | |
struct | _b8PpuRect |
Structure representing a rectangle drawing command for the PPU (Pixel Processing Unit). More... | |
struct | _b8PpuSprite |
Structure representing a sprite drawing command for the PPU (Pixel Processing Unit). More... | |
struct | _b8PpuSetpal |
Structure representing a palette setting command for the PPU (Pixel Processing Unit). More... | |
struct | _b8PpuBgTile |
Structure representing a background tile for the PPU (Pixel Processing Unit). More... | |
struct | _b8PpuBg |
Structure representing a background configuration command for the PPU (Pixel Processing Unit). More... | |
struct | _b8PpuPoly |
Structure representing a polygon drawing command for the PPU (Pixel Processing Unit). More... | |
struct | _b8PpuLine |
Structure representing a line drawing command for the PPU (Pixel Processing Unit). More... | |
struct | _b8PpuScissor |
Structure representing a scissor (clipping) command for the PPU (Pixel Processing Unit). More... | |
struct | _b8PpuViewoffset |
Structure representing a view offset command for the PPU (Pixel Processing Unit). More... | |
struct | _b8PpuNop |
struct | _b8PpuFlush |
Structure representing a flush command for the PPU (Pixel Processing Unit). More... | |
struct | _b8PpuHalt |
Structure representing a halt command for the PPU (Pixel Processing Unit). More... | |
struct | _b8PpuEnable |
Structure representing an enable/disable command for the PPU (Pixel Processing Unit). More... | |
struct | _b8PpuLoadimg |
Structure representing an image loading command for the PPU (Pixel Processing Unit). More... | |
struct | _b8PpuJmp |
Structure representing a jump command for the PPU (Pixel Processing Unit). More... | |
Macros | |
#define | B8_PPU_ADDR (0xffff8000) |
#define | B8_PPU_EXEC _B8_REG(B8_PPU_ADDR + 0x00) |
#define | B8_PPU_STAT _B8_REG(B8_PPU_ADDR + 0x04) |
#define | B8_PPU_INTCTRL _B8_REG(B8_PPU_ADDR + 0x08) |
#define | B8_PPU_RESOLUTION _B8_REG(B8_PPU_ADDR + 0x0c) |
#define | B8_PPU_CMD_NOP (0x00) |
#define | B8_PPU_CMD_FLUSH (0x01) |
#define | B8_PPU_CMD_ENABLE (0x02) |
#define | B8_PPU_CMD_RECT (0x10) |
#define | B8_PPU_CMD_POLY (0x11) |
#define | B8_PPU_CMD_SPRITE (0x12) |
#define | B8_PPU_CMD_SETPAL (0x13) |
#define | B8_PPU_CMD_SETPHYPAL (0x14) |
#define | B8_PPU_CMD_BG (0x15) |
#define | B8_PPU_CMD_SCISSOR (0x16) |
#define | B8_PPU_CMD_VIEWOFFSET (0x17) |
#define | B8_PPU_CMD_LOADIMG (0x20) |
#define | B8_PPU_CMD_LINE (0x21) |
#define | B8_PPU_CMD_JMP (0xf0) |
#define | B8_PPU_CMD_HALT (0xff) |
#define | B8_PPU_COLOR_BLACK (0) |
#define | B8_PPU_COLOR_DARK_BLUE (1) |
#define | B8_PPU_COLOR_DARK_PURPLE (2) |
#define | B8_PPU_COLOR_DARK_GREEN (3) |
#define | B8_PPU_COLOR_BROWN (4) |
#define | B8_PPU_COLOR_DARK_GREY (5) |
#define | B8_PPU_COLOR_LIGHT_GREY (6) |
#define | B8_PPU_COLOR_WHITE (7) |
#define | B8_PPU_COLOR_RED (8) |
#define | B8_PPU_COLOR_ORANGE (9) |
#define | B8_PPU_COLOR_YELLOW (10) |
#define | B8_PPU_COLOR_GREEN (11) |
#define | B8_PPU_COLOR_BLUE (12) |
#define | B8_PPU_COLOR_LAVENDER (13) |
#define | B8_PPU_COLOR_PINK (14) |
#define | B8_PPU_COLOR_LIGHT_PEACH (15) |
#define | B8_PPU_EXEC_START (0x1) |
#define | B8_PPU_BG_WRAP_CLAMP (0x00) |
Background wrapping mode: Clamp. | |
#define | B8_PPU_BG_WRAP_CLAMP_TO_EDGE (0x01) |
Background wrapping mode: Clamp to edge. | |
#define | B8_PPU_BG_WRAP_REPEAT (0x02) |
Background wrapping mode: Repeat. | |
#define | PACKED_ALIGNED1 __attribute__((__packed__,aligned(1))) |
#define | PACKED_ALIGNED4 __attribute__((__packed__,aligned(4))) |
#define | B8_PPU_MAX_WTILE (64) |
Defines the maximum width of the background map in tiles. | |
#define | B8_PPU_MAX_HTILE (64) |
Defines the maximum height of the background map in tiles. | |
#define | B8_PPU_CMD_ENABLE_CULLING_OF_POLYGONS (1<<0) |
Command code for enabling back-face culling of polygons in the PPU. | |
Typedefs | |
typedef struct _b8PpuCmd | b8PpuCmd |
Structure representing a PPU command buffer for the BEEP-8 system. | |
typedef struct PACKED_ALIGNED4 _b8PpuRect | b8PpuRect |
Structure representing a rectangle drawing command for the PPU (Pixel Processing Unit). | |
typedef struct PACKED_ALIGNED4 _b8PpuSprite | b8PpuSprite |
Structure representing a sprite drawing command for the PPU (Pixel Processing Unit). | |
typedef struct PACKED_ALIGNED4 _b8PpuSetpal | b8PpuSetpal |
Structure representing a palette setting command for the PPU (Pixel Processing Unit). | |
typedef struct PACKED_ALIGNED1 _b8PpuBgTile | b8PpuBgTile |
Structure representing a background tile for the PPU (Pixel Processing Unit). | |
typedef struct PACKED_ALIGNED4 _b8PpuBg | b8PpuBg |
Structure representing a background configuration command for the PPU (Pixel Processing Unit). | |
typedef struct PACKED_ALIGNED4 _b8PpuPoly | b8PpuPoly |
Structure representing a polygon drawing command for the PPU (Pixel Processing Unit). | |
typedef struct PACKED_ALIGNED4 _b8PpuLine | b8PpuLine |
Structure representing a line drawing command for the PPU (Pixel Processing Unit). | |
typedef struct PACKED_ALIGNED4 _b8PpuScissor | b8PpuScissor |
Structure representing a scissor (clipping) command for the PPU (Pixel Processing Unit). | |
typedef struct PACKED_ALIGNED4 _b8PpuViewoffset | b8PpuViewoffset |
Structure representing a view offset command for the PPU (Pixel Processing Unit). | |
typedef struct PACKED_ALIGNED4 _b8PpuNop | b8PpuNop |
typedef struct PACKED_ALIGNED4 _b8PpuFlush | b8PpuFlush |
Structure representing a flush command for the PPU (Pixel Processing Unit). | |
typedef struct PACKED_ALIGNED4 _b8PpuHalt | b8PpuHalt |
Structure representing a halt command for the PPU (Pixel Processing Unit). | |
typedef struct PACKED_ALIGNED4 _b8PpuEnable | b8PpuEnable |
Structure representing an enable/disable command for the PPU (Pixel Processing Unit). | |
typedef struct PACKED_ALIGNED4 _b8PpuLoadimg | b8PpuLoadimg |
Structure representing an image loading command for the PPU (Pixel Processing Unit). | |
typedef struct PACKED_ALIGNED4 _b8PpuJmp | b8PpuJmp |
Structure representing a jump command for the PPU (Pixel Processing Unit). | |
Functions | |
void | b8PpuCmdSetBuff (b8PpuCmd *cmd_, u32 *buff_, u32 bytesize_) |
Sets the buffer for PPU commands. | |
void | b8PpuCmdPush (b8PpuCmd *cmd_, u32 word_) |
Pushes a command word onto the PPU command buffer. | |
b8PpuRect * | b8PpuRectAlloc (b8PpuCmd *cmd_) |
Allocates and initializes a rectangle drawing command in the PPU command buffer. | |
b8PpuRect * | b8PpuRectAllocZ (b8PpuCmd *cmd_, u32 otz_) |
Allocates and initializes a rectangle drawing command in the PPU command buffer with a specified Z-order. | |
b8PpuRect * | b8PpuRectAllocZPB (b8PpuCmd *cmd_, u32 otz_) |
Allocates and initializes a rectangle drawing command in the PPU command buffer with a specified Z-order, adding it to the back of the order table. | |
b8PpuSprite * | b8PpuSpriteAlloc (b8PpuCmd *cmd_) |
Allocates and initializes a sprite drawing command in the PPU command buffer. | |
b8PpuSprite * | b8PpuSpriteAllocZ (b8PpuCmd *cmd_, u32 otz_) |
Allocates and initializes a sprite drawing command in the PPU command buffer with a specified Z-order. | |
b8PpuSprite * | b8PpuSpriteAllocZPB (b8PpuCmd *cmd_, u32 otz_) |
Allocates and initializes a sprite drawing command in the PPU command buffer with a specified Z-order, adding it to the back of the order table. | |
b8PpuSetpal * | b8PpuSetpalAlloc (b8PpuCmd *cmd_) |
Allocates and initializes a SETPAL command in the PPU command buffer. | |
b8PpuSetpal * | b8PpuSetpalAllocZ (b8PpuCmd *cmd_, u32 otz, u8 flush) |
Allocates and initializes a palette setting command in the PPU command buffer with a specified Z-order and cache flush option. | |
b8PpuSetpal * | b8PpuSetpalAllocZPB (b8PpuCmd *cmd_, u32 otz, u8 flush) |
Allocates and initializes a palette setting command in the PPU command buffer with a specified Z-order and cache flush option, adding it to the back of the order table. | |
b8PpuBg * | b8PpuBgAlloc (b8PpuCmd *cmd_) |
Allocates and initializes a background drawing command in the PPU command buffer. | |
b8PpuBg * | b8PpuBgAllocZ (b8PpuCmd *cmd_, u32 otz_) |
Allocates and initializes a background drawing command in the PPU command buffer with a specified Z-order. | |
b8PpuBg * | b8PpuBgAllocZPB (b8PpuCmd *cmd_, u32 otz_) |
Allocates and initializes a background drawing command in the PPU command buffer with a specified Z-order, adding it to the back of the order table. | |
b8PpuPoly * | b8PpuPolyAlloc (b8PpuCmd *cmd_) |
Allocates and initializes a polygon drawing command in the PPU command buffer. | |
b8PpuPoly * | b8PpuPolyAllocZ (b8PpuCmd *cmd_, u32 otz_) |
Allocates and initializes a polygon drawing command in the PPU command buffer with a specified Z-order. | |
b8PpuPoly * | b8PpuPolyAllocZPB (b8PpuCmd *cmd_, u32 otz_) |
Allocates and initializes a polygon drawing command in the PPU command buffer with a specified Z-order, adding it to the back of the order table. | |
b8PpuLine * | b8PpuLineAlloc (b8PpuCmd *cmd_) |
Allocates and initializes a line drawing command in the PPU command buffer. | |
b8PpuLine * | b8PpuLineAllocZ (b8PpuCmd *cmd_, u32 otz_) |
Allocates and initializes a line drawing command in the PPU command buffer with a specified Z-order. | |
b8PpuLine * | b8PpuLineAllocZPB (b8PpuCmd *cmd_, u32 otz_) |
Allocates and initializes a line drawing command in the PPU command buffer with a specified Z-order, adding it to the back of the order table. | |
b8PpuScissor * | b8PpuScissorAlloc (b8PpuCmd *cmd_) |
Allocates and initializes a scissor (clipping) command in the PPU command buffer. | |
b8PpuScissor * | b8PpuScissorAllocZ (b8PpuCmd *cmd_, u32 otz_) |
Allocates and initializes a scissor (clipping) command in the PPU command buffer with a specified Z-order. | |
b8PpuScissor * | b8PpuScissorAllocZPB (b8PpuCmd *cmd_, u32 otz_) |
Allocates and initializes a scissor (clipping) command in the PPU command buffer with a specified Z-order, adding it to the back of the order table. | |
b8PpuViewoffset * | b8PpuViewoffsetAlloc (b8PpuCmd *cmd_) |
Allocates and initializes a view offset command in the PPU command buffer. | |
b8PpuViewoffset * | b8PpuViewoffsetAllocZ (b8PpuCmd *cmd_, u32 otz_) |
Allocates and initializes a view offset command in the PPU command buffer with a specified Z-order. | |
b8PpuViewoffset * | b8PpuViewoffsetAllocZPB (b8PpuCmd *cmd_, u32 otz_) |
Allocates and initializes a view offset command in the PPU command buffer with a specified Z-order, adding it to the back of the order table. | |
b8PpuNop * | b8PpuNopAlloc (b8PpuCmd *cmd_) |
Allocates and initializes a no-operation (NOP) command in the PPU command buffer. | |
b8PpuNop * | b8PpuNopAllocZ (b8PpuCmd *cmd_, u32 otz_) |
Allocates and initializes a no-operation (NOP) command in the PPU command buffer with a specified Z-order. | |
b8PpuNop * | b8PpuNopAllocZPB (b8PpuCmd *cmd_, u32 otz_) |
Allocates and initializes a no-operation (NOP) command in the PPU command buffer with a specified Z-order, adding it to the back of the order table. | |
b8PpuFlush * | b8PpuFlushAlloc (b8PpuCmd *cmd_) |
Allocates and initializes a flush command in the PPU command buffer. | |
b8PpuFlush * | b8PpuFlushAllocZ (b8PpuCmd *cmd_, u32 otz_) |
Allocates and initializes a flush command in the PPU command buffer with a specified Z-order. | |
b8PpuHalt * | b8PpuHaltAlloc (b8PpuCmd *cmd_) |
Allocates and initializes a halt command in the PPU command buffer. | |
b8PpuHalt * | b8PpuHaltAllocZ (b8PpuCmd *cmd_, u32 otz_) |
Allocates and initializes a halt command in the PPU command buffer with a specified Z-order. | |
b8PpuHalt * | b8PpuHaltAllocZPB (b8PpuCmd *cmd_, u32 otz_) |
Allocates and initializes a halt command in the PPU command buffer with a specified Z-order, adding it to the back of the order table. | |
b8PpuEnable * | b8PpuEnableAlloc (b8PpuCmd *cmd_) |
Allocates and initializes an enable/disable command in the PPU command buffer. | |
b8PpuEnable * | b8PpuEnableAllocZ (b8PpuCmd *cmd_, u32 otz_) |
Allocates and initializes an enable/disable command in the PPU command buffer with a specified Z-order. | |
b8PpuEnable * | b8PpuEnableAllocZPB (b8PpuCmd *cmd_, u32 otz_) |
Allocates and initializes an enable/disable command in the PPU command buffer with a specified Z-order, adding it to the back of the order table. | |
b8PpuLoadimg * | b8PpuLoadimgAlloc (b8PpuCmd *cmd_) |
Allocates and initializes an image loading command in the PPU command buffer. | |
b8PpuLoadimg * | b8PpuLoadimgAllocZ (b8PpuCmd *cmd_, u32 otz) |
Allocates and initializes an image loading command in the PPU command buffer with a specified Z-order. | |
b8PpuLoadimg * | b8PpuLoadimgAllocZPB (b8PpuCmd *cmd_, u32 otz) |
Allocates and initializes an image loading command in the PPU command buffer with a specified Z-order, adding it to the back of the order table. | |
b8PpuJmp * | b8PpuJmpAlloc (b8PpuCmd *cmd_, u32 *cpuaddr_) |
Allocates and initializes a PPU jump command. | |
void | b8PpuClearOT (b8PpuCmd *cmd_, u32 *ot_, u32 *ot_prev_, u32 num_) |
Allocates and initializes an Ordering Table (OT) for the PPU commands. | |
void | b8PpuPushFrontOT (b8PpuCmd *cmd_, u32 otz_, void *prim_) |
Adds a primitive to the front of the Ordering Table (OT) at the specified Z-value. | |
void | b8PpuPushBackOT (b8PpuCmd *cmd_, u32 otz_, void *prim_) |
Adds a primitive to the end of the Ordering Table (OT) at the specified Z-value. | |
void | b8PpuExec (b8PpuCmd *cmd_) |
Executes the PPU commands stored in the buffer. | |
void | b8PpuEnableVblankInterrupt (void) |
Enables the V-blank interrupt for the PPU. | |
void | b8PpuVsyncWait (void) |
Waits for the next V-blank interval. | |
void | b8PpuGetResolution (u32 *ww, u32 *hh) |
Gets the current screen resolution. | |
void | b8PpuReset (void) |
Resets the PPU system. | |
Picture Processing Unit (PPU) definitions for the BEEP-8 system.
This file contains the definitions and function prototypes for the Picture Processing Unit (PPU) in the BEEP-8 system. It includes register definitions, command codes, color definitions, and structures for various PPU operations such as drawing rectangles, polygons, sprites, and handling background tiles.
The PPU is responsible for rendering graphics and handling various graphical operations in the BEEP-8 system. It supports a range of commands for different drawing and rendering tasks, as well as configurations for color palettes, view offsets, and scissoring.
For more detailed information, please refer to the BEEP-8 data sheet.
#define B8_PPU_BG_WRAP_CLAMP (0x00) |
Background wrapping mode: Clamp.
This mode clamps the background at the edges, preventing any wrapping.
#define B8_PPU_BG_WRAP_CLAMP_TO_EDGE (0x01) |
Background wrapping mode: Clamp to edge.
This mode clamps the background to the edges, with some allowance for wrapping at the very edge.
#define B8_PPU_BG_WRAP_REPEAT (0x02) |
Background wrapping mode: Repeat.
This mode repeats the background texture, allowing it to wrap continuously.
#define B8_PPU_CMD_ENABLE_CULLING_OF_POLYGONS (1<<0) |
Command code for enabling back-face culling of polygons in the PPU.
This macro defines the bitmask used to enable back-face culling of polygons in the PPU. When this bit is set in the b8PpuEnable
structure, back-face culling will be enabled, meaning that polygons facing away from the camera or view will not be rendered. This helps improve performance by skipping the rendering of unnecessary surfaces.
#define B8_PPU_MAX_HTILE (64) |
Defines the maximum height of the background map in tiles.
This macro specifies the maximum number of vertical tiles (YTILE
) that can be used in the background map for the PPU.
#define B8_PPU_MAX_WTILE (64) |
Defines the maximum width of the background map in tiles.
This macro specifies the maximum number of horizontal tiles (XTILE
) that can be used in the background map for the PPU.
Structure representing a PPU command buffer for the BEEP-8 system.
This structure holds information about the command buffer that the PPU uses for drawing operations.
typedef struct PACKED_ALIGNED4 _b8PpuEnable b8PpuEnable |
Structure representing an enable/disable command for the PPU (Pixel Processing Unit).
This command is used to enable or disable back-face culling during rendering. When cul
is set to 1, back-face culling is enabled, meaning that certain surfaces or elements will not be rendered based on their orientation. When cul
is set to 0, back-face culling is disabled, allowing all surfaces to be rendered regardless of orientation.
typedef struct PACKED_ALIGNED4 _b8PpuFlush b8PpuFlush |
Structure representing a flush command for the PPU (Pixel Processing Unit).
The Flush
command ensures that any changes made to VRAM or the palette through drawing commands are fully committed from the cache to the actual VRAM. This operation is known as cache flushing.
Note: Frequent use of the flush command can introduce performance overhead due to the cost of cache flushing. It is recommended to minimize the number of flush operations by grouping drawing commands efficiently. Only flush when necessary, especially when working with palette or VRAM updates.
typedef struct PACKED_ALIGNED4 _b8PpuHalt b8PpuHalt |
Structure representing a halt command for the PPU (Pixel Processing Unit).
This command is used to signal the completion of the drawing commands.
Structure representing a jump command for the PPU (Pixel Processing Unit).
In the BEEP-8 system, the PPU parses drawing commands located at consecutive addresses. Similar to the CPU's JMP instruction, this command allows the PPU to jump to a different address.
typedef struct PACKED_ALIGNED4 _b8PpuLoadimg b8PpuLoadimg |
Structure representing an image loading command for the PPU (Pixel Processing Unit).
The BEEP-8 system uses tiles of size 8x8 pixels as the basic unit for BG (background) and SPRITE references. BEEP-8 has VRAM located in a different space from CPU memory, with a format of 64 tiles by 64 tiles. Both sprites and backgrounds can only reference VRAM.
The b8PpuLoadimg
structure is used to transfer tile compositions stored in CPU memory to VRAM.
typedef struct PACKED_ALIGNED4 _b8PpuViewoffset b8PpuViewoffset |
Structure representing a view offset command for the PPU (Pixel Processing Unit).
The ViewOffset
command adds an offset to all drawing coordinates, effectively shifting the entire rendered view. If this command is not set, the offset defaults to (0,0), meaning no offset is applied.
Allocates and initializes a background drawing command in the PPU command buffer.
This function allocates memory for a b8PpuBg
structure within the PPU command buffer.
cmd_ | Pointer to the b8PpuCmd structure representing the PPU command buffer. |
b8PpuBg
structure. Allocates and initializes a background drawing command in the PPU command buffer with a specified Z-order.
This function allocates memory for a b8PpuBg
structure within the PPU command buffer and sets the Z-order for rendering.
cmd_ | Pointer to the b8PpuCmd structure representing the PPU command buffer. |
otz_ | Z-order value for the background, determining its rendering order. |
b8PpuBg
structure. Allocates and initializes a background drawing command in the PPU command buffer with a specified Z-order, adding it to the back of the order table.
This function allocates memory for a b8PpuBg
structure within the PPU command buffer and sets the Z-order for rendering. The background command is added to the back of the order table, meaning it will be rendered after previously inserted elements with the same Z-order.
cmd_ | Pointer to the b8PpuCmd structure representing the PPU command buffer. |
otz_ | Z-order value for the background, determining its rendering order. |
b8PpuBg
structure.
|
extern |
Allocates and initializes an Ordering Table (OT) for the PPU commands.
This function allocates memory for an Ordering Table and sets up the necessary jump commands and a halt command to create a linked list structure for PPU commands. The OT is used to manage the order of rendering commands based on their Z-values.
The function links the OT entries in reverse order, where each entry points to the previous one, with the last entry being a halt command. This reverse linking ensures that the PPU processes commands in the correct Z-order.
cmd_ | A pointer to the PPU command structure. |
ot_ | A pointer to the memory allocated for the Ordering Table, which must be the first element of a u32 array of size num_ . This array holds the OT entries. |
ot_prev_ | A pointer to the memory allocated for the previous Ordering Table entries, also the first element of a u32 array of size num_ . This is used to link the current OT with the previous OT. |
num_ | The number of entries in the Ordering Table, which defines the size of the ot_ and ot_prev_ arrays. |
The function will initialize the OT entries with jump commands that link each entry to the previous one, with the last entry linked to a halt command. This setup ensures the correct rendering order based on Z-values.
Note: ot_
and ot_prev_
must both point to the first element of a u32
array with at least num_
entries. The function will modify these arrays as part of the linking process to manage the order of rendering commands.
Example:
|
extern |
Pushes a command word onto the PPU command buffer.
This function adds a new command word to the current position in the PPU command buffer and then advances the stack pointer.
Example usage:
cmd_ | Pointer to the b8PpuCmd structure representing the PPU command buffer. |
word_ | The command word to be pushed onto the buffer. |
|
extern |
Sets the buffer for PPU commands.
This function initializes the b8PpuCmd
structure with the given buffer and its size.
Example usage:
cmd_ | Pointer to the b8PpuCmd structure to be initialized. |
buff_ | Pointer to the buffer where PPU commands will be stored. |
bytesize_ | Size of the buffer in bytes. |
|
extern |
Allocates and initializes an enable/disable command in the PPU command buffer.
This function allocates memory for a b8PpuEnable
structure within the PPU command buffer. The enable command configures the PPU to either enable or disable back-face culling based on the cul
flag.
cmd_ | Pointer to the b8PpuCmd structure representing the PPU command buffer. |
b8PpuEnable
structure.
|
extern |
Allocates and initializes an enable/disable command in the PPU command buffer with a specified Z-order.
This function allocates memory for a b8PpuEnable
structure within the PPU command buffer and sets the Z-order for the enable/disable operation.
The enable command configures the PPU to either enable or disable back-face culling based on the cul
flag.
cmd_ | Pointer to the b8PpuCmd structure representing the PPU command buffer. |
otz_ | Z-order value for the enable/disable operation, determining its execution order relative to other commands. |
b8PpuEnable
structure.
|
extern |
Allocates and initializes an enable/disable command in the PPU command buffer with a specified Z-order, adding it to the back of the order table.
This function allocates memory for a b8PpuEnable
structure within the PPU command buffer and sets the Z-order for the enable/disable operation. The enable command configures the PPU to either enable or disable back-face culling based on the cul
flag. The command is added to the back of the order table, meaning it will be processed after previously inserted elements with the same Z-order.
cmd_ | Pointer to the b8PpuCmd structure representing the PPU command buffer. |
otz_ | Z-order value for the enable/disable operation, determining its execution order relative to other commands. |
b8PpuEnable
structure.
|
extern |
Enables the V-blank interrupt for the PPU.
This function enables the V-blank interrupt, allowing the PPU to generate an interrupt at the start of the vertical blanking interval.
|
extern |
Executes the PPU commands stored in the buffer.
This function triggers the execution of the PPU commands that have been stored in the command buffer.
cmd_ | A pointer to the PPU command structure containing the commands to be executed. |
This function sets the PPU execution register to start processing the commands from the buffer.
|
extern |
Allocates and initializes a flush command in the PPU command buffer.
This function allocates memory for a b8PpuFlush
structure within the PPU command buffer. The flush command forces the PPU to commit any cached changes to VRAM or palette to the actual hardware memory.
Note: Frequent use of this API can impact performance due to the overhead of flushing. It is recommended to limit flush operations by optimizing command ordering and only using the flush command when necessary.
cmd_ | Pointer to the b8PpuCmd structure representing the PPU command buffer. |
b8PpuFlush
structure.
|
extern |
Allocates and initializes a flush command in the PPU command buffer with a specified Z-order.
This function allocates memory for a b8PpuFlush
structure within the PPU command buffer and sets the Z-order for rendering. The flush command forces the PPU to commit any cached changes to VRAM or palette to the actual hardware memory.
Note: Frequent use of this API can impact performance due to the overhead of flushing. It is recommended to minimize flush operations and set Z-order carefully to optimize rendering and cache efficiency.
cmd_ | Pointer to the b8PpuCmd structure representing the PPU command buffer. |
otz_ | Z-order value for the flush operation, determining its rendering order. |
b8PpuFlush
structure.
|
extern |
Gets the current screen resolution.
This function retrieves the current screen width and height in pixels.
ww | A pointer to a variable where the screen width will be stored. |
hh | A pointer to a variable where the screen height will be stored. |
Allocates and initializes a halt command in the PPU command buffer.
This function allocates memory for a b8PpuHalt
structure within the PPU command buffer. The halt command signals the end of the current set of drawing commands, allowing the PPU to complete processing.
cmd_ | Pointer to the b8PpuCmd structure representing the PPU command buffer. |
b8PpuHalt
structure. Allocates and initializes a halt command in the PPU command buffer with a specified Z-order.
This function allocates memory for a b8PpuHalt
structure within the PPU command buffer and sets the Z-order for the halt operation.
The halt command signals the end of the current set of drawing commands, allowing the PPU to complete processing.
cmd_ | Pointer to the b8PpuCmd structure representing the PPU command buffer. |
otz_ | Z-order value for the halt operation, determining its execution order relative to other commands. |
b8PpuHalt
structure. Allocates and initializes a halt command in the PPU command buffer with a specified Z-order, adding it to the back of the order table.
This function allocates memory for a b8PpuHalt
structure within the PPU command buffer and sets the Z-order for the halt operation. The halt command signals the end of the current set of drawing commands, allowing the PPU to complete processing. The halt command is added to the back of the order table, meaning it will be processed after previously inserted elements with the same Z-order.
cmd_ | Pointer to the b8PpuCmd structure representing the PPU command buffer. |
otz_ | Z-order value for the halt operation, determining its execution order relative to other commands. |
b8PpuHalt
structure. Allocates and initializes a PPU jump command.
cmd_ | Pointer to the current PPU command. |
cpuaddr_ | Pointer to the CPU address where the jump should occur. |
b8PpuJmp
structure. Allocates and initializes a line drawing command in the PPU command buffer.
This function allocates memory for a b8PpuLine
structure within the PPU command buffer.
cmd_ | Pointer to the b8PpuCmd structure representing the PPU command buffer. |
b8PpuLine
structure. Allocates and initializes a line drawing command in the PPU command buffer with a specified Z-order.
This function allocates memory for a b8PpuLine
structure within the PPU command buffer and sets the Z-order for rendering.
cmd_ | Pointer to the b8PpuCmd structure representing the PPU command buffer. |
otz_ | Z-order value for the line, determining its rendering order. |
b8PpuLine
structure. Allocates and initializes a line drawing command in the PPU command buffer with a specified Z-order, adding it to the back of the order table.
This function allocates memory for a b8PpuLine
structure within the PPU command buffer and sets the Z-order for rendering. The line command is added to the back of the order table, meaning it will be rendered after previously inserted elements with the same Z-order.
cmd_ | Pointer to the b8PpuCmd structure representing the PPU command buffer. |
otz_ | Z-order value for the line, determining its rendering order. |
b8PpuLine
structure.
|
extern |
Allocates and initializes an image loading command in the PPU command buffer.
This function allocates memory for a b8PpuLoadimg
structure within the PPU command buffer. The image loading command is responsible for transferring tile data from CPU memory to VRAM.
cmd_ | Pointer to the b8PpuCmd structure representing the PPU command buffer. |
b8PpuLoadimg
structure.
|
extern |
Allocates and initializes an image loading command in the PPU command buffer with a specified Z-order.
This function allocates memory for a b8PpuLoadimg
structure within the PPU command buffer and sets the Z-order for the image loading operation.
The image loading command is responsible for transferring tile data from CPU memory to VRAM.
cmd_ | Pointer to the b8PpuCmd structure representing the PPU command buffer. |
otz | Z-order value for the image loading operation, determining its execution order relative to other commands. |
b8PpuLoadimg
structure.
|
extern |
Allocates and initializes an image loading command in the PPU command buffer with a specified Z-order, adding it to the back of the order table.
This function allocates memory for a b8PpuLoadimg
structure within the PPU command buffer and sets the Z-order for the image loading operation. The image loading command is responsible for transferring tile data from CPU memory to VRAM. The command is added to the back of the order table, meaning it will be processed after previously inserted elements with the same Z-order.
cmd_ | Pointer to the b8PpuCmd structure representing the PPU command buffer. |
otz | Z-order value for the image loading operation, determining its execution order relative to other commands. |
b8PpuLoadimg
structure.
|
extern |
Allocates and initializes a no-operation (NOP) command in the PPU command buffer.
This function allocates memory for a b8PpuNop
structure within the PPU command buffer. The NOP command is used as a placeholder or synchronization point in the command sequence and does not perform any rendering operations.
cmd_ | Pointer to the b8PpuCmd structure representing the PPU command buffer. |
b8PpuNop
structure.
|
extern |
Allocates and initializes a no-operation (NOP) command in the PPU command buffer with a specified Z-order.
This function allocates memory for a b8PpuNop
structure within the PPU command buffer and adds it to the front of the order table (OT) with a specified Z-order. The NOP command does not perform any rendering operations but will be processed before previously inserted elements with the same Z-order.
cmd_ | Pointer to the b8PpuCmd structure representing the PPU command buffer. |
otz_ | Z-order value for the NOP command, determining its position in the rendering order. |
b8PpuNop
structure.
|
extern |
Allocates and initializes a no-operation (NOP) command in the PPU command buffer with a specified Z-order, adding it to the back of the order table.
This function allocates memory for a b8PpuNop
structure within the PPU command buffer and adds it to the back of the order table (OT) with a specified Z-order. The NOP command does not perform any rendering operations but will be processed after previously inserted elements with the same Z-order.
cmd_ | Pointer to the b8PpuCmd structure representing the PPU command buffer. |
otz_ | Z-order value for the NOP command, determining its position in the rendering order. |
b8PpuNop
structure. Allocates and initializes a polygon drawing command in the PPU command buffer.
This function allocates memory for a b8PpuPoly
structure within the PPU command buffer.
cmd_ | Pointer to the b8PpuCmd structure representing the PPU command buffer. |
b8PpuPoly
structure. Allocates and initializes a polygon drawing command in the PPU command buffer with a specified Z-order.
This function allocates memory for a b8PpuPoly
structure within the PPU command buffer and sets the Z-order for rendering.
cmd_ | Pointer to the b8PpuCmd structure representing the PPU command buffer. |
otz_ | Z-order value for the polygon, determining its rendering order. |
b8PpuPoly
structure. Allocates and initializes a polygon drawing command in the PPU command buffer with a specified Z-order, adding it to the back of the order table.
This function allocates memory for a b8PpuPoly
structure within the PPU command buffer and sets the Z-order for rendering. The polygon command is added to the back of the order table, meaning it will be rendered after previously inserted elements with the same Z-order.
cmd_ | Pointer to the b8PpuCmd structure representing the PPU command buffer. |
otz_ | Z-order value for the polygon, determining its rendering order. |
b8PpuPoly
structure.
|
extern |
Adds a primitive to the end of the Ordering Table (OT) at the specified Z-value.
The Ordering Table (OT) is used in the BEEP-8 PPU (Pixel Processing Unit) for managing the rendering order of graphical primitives. This function adds a primitive command to the back of the OT at the position corresponding to the provided Z-value (otz_).
Unlike b8PpuPushFrontOT
, which inserts the primitive at the beginning of the OT for a given Z-value, this function appends the primitive to the end of the OT list for that Z-value. This ensures that the new primitive is rendered after any existing primitives at the same Z-value.
The function first validates the provided Z-value. If the Z-value is greater than or equal to the total number of Z-layers (cmd_->otnum), it returns an error code indicating an invalid value. If the Z-value is valid, the function proceeds to append the primitive at the specified Z-layer.
The function works by updating both the OT and the jump pointers that manage the rendering order. The new primitive is inserted after the last primitive in the same Z-layer, maintaining the correct rendering sequence.
Note: It is prohibited to use both b8PpuPushFrontOT
and b8PpuPushBackOT
on the same Z-value (otz_
). Doing so will result in undefined behavior.
The following diagram illustrates how the OT is updated when a primitive is pushed to the back of a Z-layer that already contains multiple primitives:
OT Index (Z-value) [0] -> Primitive A, Primitive F [1] -> Primitive B [2] -> Primitive G [3] -> Primitive C, Primitive H ----> PushBack Primitive K at Z=3 [4] -> Primitive D [5] -> Primitive E, Primitive I, Primitive J
After insertion:
OT Index (Z-value) [0] -> Primitive A, Primitive F [1] -> Primitive B [2] -> Primitive G [3] -> Primitive C, Primitive H, Primitive K ----> Updated to append Primitive K at the end [4] -> Primitive D [5] -> Primitive E, Primitive I, Primitive J
cmd_ | A pointer to the PPU command structure, which holds the OT and other related data. |
otz_ | The Z-value at which the primitive should be appended in the OT. This value determines the rendering priority of the primitive relative to others. |
prim_ | A pointer to the primitive command to be added to the OT. This command represents a graphical element that will be rendered by the PPU. |
If the specified Z-value (otz_) is greater than or equal to the number of entries in the OT, the function will return an error code (-B8_INVALID_VALUE) indicating an invalid value. Otherwise, it appends the primitive to the OT, updating the jump commands to maintain the correct rendering order based on depth.
|
extern |
Adds a primitive to the front of the Ordering Table (OT) at the specified Z-value.
The Ordering Table (OT) is used in the BEEP-8 PPU (Pixel Processing Unit) to manage the rendering order of graphical primitives. This function inserts a primitive command to the front of the OT at the position corresponding to the provided Z-value (otz_).
Unlike b8PpuPushBackOT
, which appends the primitive to the end of the OT list for a given Z-value, this function inserts the primitive at the front of the OT, ensuring that it is rendered before any existing primitives at the same Z-value.
The function first validates the provided Z-value. If the Z-value is greater than or equal to the total number of Z-layers (cmd_->otnum), it returns an error code indicating an invalid value. If the Z-value is valid, the function proceeds to insert the primitive at the specified Z-layer.
The function works by updating both the OT and the jump pointers that manage the rendering order. The new primitive is inserted before the first primitive in the same Z-layer, maintaining the correct rendering sequence with depth sorting.
Note: It is prohibited to use both b8PpuPushFrontOT
and b8PpuPushBackOT
on the same Z-value (otz_
). Doing so will result in undefined behavior.
The following diagram illustrates how the OT is updated when a primitive is pushed to the front of a Z-layer that already contains multiple primitives:
OT Index (Z-value) [0] -> Primitive A, Primitive F [1] -> Primitive B [2] -> Primitive G [3] -> Primitive C, Primitive H ----> PushFront Primitive K at Z=3 [4] -> Primitive D [5] -> Primitive E, Primitive I, Primitive J
After insertion:
OT Index (Z-value) [0] -> Primitive A, Primitive F [1] -> Primitive B [2] -> Primitive G [3] -> Primitive K, Primitive C, Primitive H ----> Updated to insert Primitive K at the front [4] -> Primitive D [5] -> Primitive E, Primitive I, Primitive J
cmd_ | A pointer to the PPU command structure, which holds the OT and other related data. |
otz_ | The Z-value at which the primitive should be inserted in the OT. This value determines the rendering priority of the primitive relative to others. |
prim_ | A pointer to the primitive command to be added to the OT. This command represents a graphical element that will be rendered by the PPU. |
If the specified Z-value (otz_) is greater than or equal to the number of entries in the OT, the function will return an error code (-B8_INVALID_VALUE) indicating an invalid value. Otherwise, it inserts the primitive to the OT, updating the jump commands to maintain the correct rendering order based on depth.
Allocates and initializes a rectangle drawing command in the PPU command buffer.
This function allocates memory for a b8PpuRect
structure within the PPU command buffer.
cmd_ | Pointer to the b8PpuCmd structure representing the PPU command buffer. |
b8PpuRect
structure. Allocates and initializes a rectangle drawing command in the PPU command buffer with a specified Z-order.
This function allocates memory for a b8PpuRect
structure within the PPU command buffer and sets the Z-order for rendering.
cmd_ | Pointer to the b8PpuCmd structure representing the PPU command buffer. |
otz_ | Z-order value for the rectangle, determining its rendering order. |
b8PpuRect
structure. Allocates and initializes a rectangle drawing command in the PPU command buffer with a specified Z-order, adding it to the back of the order table.
This function allocates memory for a b8PpuRect
structure within the PPU command buffer and sets the Z-order for rendering. The rectangle is added to the back of the order table, meaning it will be rendered after previously inserted elements with the same Z-order.
cmd_ | Pointer to the b8PpuCmd structure representing the PPU command buffer. |
otz_ | Z-order value for the rectangle, determining its rendering order. |
b8PpuRect
structure.
|
extern |
Resets the PPU system.
This function resets the PPU system and sets up the V-blank interrupt. Note: This API is reserved for the BEEP-8 system. Users should not call this function directly.
|
extern |
Allocates and initializes a scissor (clipping) command in the PPU command buffer.
This function allocates memory for a b8PpuScissor
structure within the PPU command buffer. The scissor command defines a rectangular area within which rendering is allowed. Anything outside this area will be clipped and not rendered.
cmd_ | Pointer to the b8PpuCmd structure representing the PPU command buffer. |
b8PpuScissor
structure.
|
extern |
Allocates and initializes a scissor (clipping) command in the PPU command buffer with a specified Z-order.
This function allocates memory for a b8PpuScissor
structure within the PPU command buffer and sets the Z-order for rendering.
cmd_ | Pointer to the b8PpuCmd structure representing the PPU command buffer. |
otz_ | Z-order value for the scissor rectangle, determining its rendering order. |
b8PpuScissor
structure.
|
extern |
Allocates and initializes a scissor (clipping) command in the PPU command buffer with a specified Z-order, adding it to the back of the order table.
This function allocates memory for a b8PpuScissor
structure within the PPU command buffer and sets the Z-order for rendering. The scissor command is added to the back of the order table, meaning it will be applied after previously inserted elements with the same Z-order.
cmd_ | Pointer to the b8PpuCmd structure representing the PPU command buffer. |
otz_ | Z-order value for the scissor rectangle, determining its rendering order. |
b8PpuScissor
structure.
|
extern |
Allocates and initializes a SETPAL command in the PPU command buffer.
This function allocates memory for a b8PpuSetpal
structure within the PPU command buffer and initializes the palette selection, write mask, and default palette indices.
The command sets the palsel
(palette selection index) to 0 by default and applies the write mask wmask
to allow updates to all 16 palette entries. Only the palette entries corresponding to bits set to 1
in wmask
will be updated. The palette entries (pidx0
to pidx15
) are initialized sequentially from 0 to 15, mapping to the respective color values in the selected palette.
cmd_ | Pointer to the b8PpuCmd structure representing the PPU command buffer. |
b8PpuSetpal
structure.
|
extern |
Allocates and initializes a palette setting command in the PPU command buffer with a specified Z-order and cache flush option.
This function allocates memory for a b8PpuSetpal
structure within the PPU command buffer, sets the Z-order for rendering, and optionally flushes the palette cache.
Note: Modifying the contents of the palette can incur significant runtime costs. It is recommended to use this API with caution. Since there are 16 palettes available, it is advisable to initialize their contents only during application startup to minimize performance impact during runtime.
cmd_ | Pointer to the b8PpuCmd structure representing the PPU command buffer. |
otz | Z-order value for the palette, determining its rendering order. |
flush | Flag to control whether the palette image cache should be flushed. Set to 1 to ensure the palette change is applied immediately. If setting multiple palettes, you can set flush to 0 for all but the final palette setting to minimize the number of cache flushes. However, use this with caution. |
b8PpuSetpal
structure.
|
extern |
Allocates and initializes a palette setting command in the PPU command buffer with a specified Z-order and cache flush option, adding it to the back of the order table.
This function allocates memory for a b8PpuSetpal
structure within the PPU command buffer, sets the Z-order for rendering, and optionally flushes the palette cache. The palette setting command is added to the back of the order table, meaning it will be processed after previously inserted elements with the same Z-order.
Note: Modifying the contents of the palette can incur significant runtime costs. It is recommended to use this API with caution. Since there are 16 palettes available, it is advisable to initialize their contents only during application startup to minimize performance impact during runtime.
cmd_ | Pointer to the b8PpuCmd structure representing the PPU command buffer. |
otz | Z-order value for the palette, determining its rendering order. |
flush | Flag to control whether the palette image cache should be flushed. Set to 1 to ensure the palette change is applied immediately. If setting multiple palettes, you can set flush to 0 for all but the final palette setting to minimize the number of cache flushes. However, use this with caution. |
b8PpuSetpal
structure.
|
extern |
Allocates and initializes a sprite drawing command in the PPU command buffer.
This function allocates memory for a b8PpuSprite
structure within the PPU command buffer.
cmd_ | Pointer to the b8PpuCmd structure representing the PPU command buffer. |
b8PpuSprite
structure.
|
extern |
Allocates and initializes a sprite drawing command in the PPU command buffer with a specified Z-order.
This function allocates memory for a b8PpuSprite
structure within the PPU command buffer and sets the Z-order for rendering.
cmd_ | Pointer to the b8PpuCmd structure representing the PPU command buffer. |
otz_ | Z-order value for the sprite, determining its rendering order. |
b8PpuSprite
structure.
|
extern |
Allocates and initializes a sprite drawing command in the PPU command buffer with a specified Z-order, adding it to the back of the order table.
This function allocates memory for a b8PpuSprite
structure within the PPU command buffer and sets the Z-order for rendering. The sprite is added to the back of the order table, meaning it will be rendered after previously inserted elements with the same Z-order.
cmd_ | Pointer to the b8PpuCmd structure representing the PPU command buffer. |
otz_ | Z-order value for the sprite, determining its rendering order. |
b8PpuSprite
structure.
|
extern |
Allocates and initializes a view offset command in the PPU command buffer.
This function allocates memory for a b8PpuViewoffset
structure within the PPU command buffer. The view offset adds the specified X and Y offsets to all subsequent drawing coordinates.
cmd_ | Pointer to the b8PpuCmd structure representing the PPU command buffer. |
b8PpuViewoffset
structure.
|
extern |
Allocates and initializes a view offset command in the PPU command buffer with a specified Z-order.
This function allocates memory for a b8PpuViewoffset
structure within the PPU command buffer and sets the Z-order for rendering. The view offset adds the specified X and Y offsets to all subsequent drawing coordinates.
cmd_ | Pointer to the b8PpuCmd structure representing the PPU command buffer. |
otz_ | Z-order value for the view offset, determining its rendering order. |
b8PpuViewoffset
structure.
|
extern |
Allocates and initializes a view offset command in the PPU command buffer with a specified Z-order, adding it to the back of the order table.
This function allocates memory for a b8PpuViewoffset
structure within the PPU command buffer and sets the Z-order for rendering. The view offset adds the specified X and Y offsets to all subsequent drawing coordinates. The command is added to the back of the order table, meaning it will be applied after previously inserted elements with the same Z-order.
cmd_ | Pointer to the b8PpuCmd structure representing the PPU command buffer. |
otz_ | Z-order value for the view offset, determining its rendering order. |
b8PpuViewoffset
structure.
|
extern |
Waits for the next V-blank interval.
This function blocks the current thread until the next vertical blanking interval occurs, ensuring synchronization with the display refresh rate.