BEEP-8 Helper Lib 1.0.0
Loading...
Searching...
No Matches
sprprint Namespace Reference

This namespace contains functions and structures for managing sprite printing and positioning using the BEEP-8 PPU. More...

Classes

struct  Context
 Holds the command context for sprite printing operations. More...
 
struct  Info
 Contains information about the current sprite printing state. More...
 

Enumerations

enum  EnCmd { SET_SLOT_CONTEXT , GET_INFO }
 Commands for controlling the sprite printing system. More...
 
enum  EnCh { CH0 , CH1 , CHMAX }
 Enumeration for selecting the channel used for sprite printing. More...
 

Functions

void Reset ()
 Resets the sprite printing system.
 
int GetInfo (FILE *fp_, Info &dest)
 Retrieves information about the current state of sprite printing.
 
FILE * Open (EnCh ch_, sprprint::Context &ctx)
 Opens a sprite printing channel.
 
void Locate (FILE *fp_, s16 lx_, s16 ly_, u16 otz_)
 Sets the pixel location and Z-index for sprite printing.
 
void LocateZ (FILE *fp_, u16 otz_)
 
void Color (FILE *fp_, b8PpuColor b8col_)
 

Detailed Description

This namespace contains functions and structures for managing sprite printing and positioning using the BEEP-8 PPU.

Sample usage of the sprite printing system with various ANSI escape sequences.

This sample demonstrates how to set up and use sprite printing using BEEP-8 PPU with different escape sequences for cursor movement, foreground/background color, and Z-index.

static b8PpuCmd _ppu_cmd;
static FILE* _fp_sprprint;
void start_sprprint_sample() {
// Initialize the sprite printing system and open a channel
ctx._cmd = &_ppu_cmd;
_fp_sprprint = sprprint::Open(sprprint::CH1, ctx);
// Set cursor position to x=113, y=37 in pixel units (note: coordinates are (y, x)), and Z-index to 3
// Unlike typical systems, cursor movement is in pixel units, not character cells.
fprintf(_fp_sprprint, "\e[37;113H\e[3z");
// Set foreground color to red and background color to blue
fprintf(_fp_sprprint, "\e[31;44m");
fprintf(_fp_sprprint, "Red text on blue background\n");
// Reset color settings
fprintf(_fp_sprprint, "\e[0m");
fprintf(_fp_sprprint, "Default text color\n");
// Set foreground color to BEEP-8 green and background color to BEEP-8 dark blue
// Foreground color codes 50-65 correspond to BEEP-8 color indices 0-15.
// Background color codes 70-85 correspond to BEEP-8 color indices 0-15.
fprintf(_fp_sprprint, "\e[61;71m");
// Enable shadow effect
fprintf(_fp_sprprint, "\e[101mShadow enabled\n");
// Disable shadow effect
fprintf(_fp_sprprint, "\e[100mShadow disabled\n");
}
FILE * Open(EnCh ch_, sprprint::Context &ctx)
Opens a sprite printing channel.
Definition sprprint.cpp:285
void Reset()
Resets the sprite printing system.
Definition sprprint.cpp:264
@ CH1
Channel 1.
Definition sprprint.h:76
Holds the command context for sprite printing operations.
Definition sprprint.h:86
b8PpuCmd * _cmd
Pointer to PPU command list.
Definition sprprint.h:87

Enumeration Type Documentation

◆ EnCh

Enumeration for selecting the channel used for sprite printing.

  • CH0: First channel.
  • CH1: Second channel.
  • CHMAX: Maximum number of channels.
Enumerator
CH0 

Channel 0.

CH1 

Channel 1.

CHMAX 

Maximum number of channels.

◆ EnCmd

Commands for controlling the sprite printing system.

  • SET_SLOT_CONTEXT: Sets the context for the slot.
  • GET_INFO: Retrieves the current state information.
Enumerator
SET_SLOT_CONTEXT 

Command to set the slot context.

GET_INFO 

Command to retrieve information.

Function Documentation

◆ GetInfo()

int sprprint::GetInfo ( FILE * fp_,
Info & dest )

Retrieves information about the current state of sprite printing.

Parameters
fp_The file pointer to the current open sprite printing context.
destThe structure to store the retrieved information.
Returns
int Returns 0 on success, or a negative value on failure. Negative values indicate different error conditions (-1, -2, -3, etc.).

◆ Locate()

void sprprint::Locate ( FILE * fp_,
s16 lx_,
s16 ly_,
u16 otz_ )

Sets the pixel location and Z-index for sprite printing.

This function positions the cursor at a specific pixel location and sets the Z-index (depth) for drawing operations.

Parameters
fp_The file pointer to the sprite printing context.
lx_The X pixel location.
ly_The Y pixel location.
otz_The Z-index (depth) for drawing.

◆ Open()

FILE * sprprint::Open ( EnCh ch_,
sprprint::Context & ctx )

Opens a sprite printing channel.

This function opens a channel for sprite printing, assigns it a context, and returns a file pointer for use in further operations.

Parameters
ch_The channel to open (CH0 or CH1).
ctxThe context to be used with the opened channel.
Returns
FILE* Returns a file pointer to the opened channel, or NULL on failure.

◆ Reset()

void sprprint::Reset ( )

Resets the sprite printing system.

This function initializes the system and registers the necessary drivers. It must be called before any sprite printing operations.