Skip to content

All Functions, datatypes, etc.

BtheDestroyer edited this page Jan 8, 2017 · 10 revisions

This page is updated for SpriteTools Release 2.1

Table of Contents

Functions

spritetools.h

spritetools_debug.h

General Debugging

Button Debugging

spritetools_input.h

spritetools_textcolors.h

Standard Foreground Colors

Standard Background Colors

Effects

spritetools_spritesheet.h

spritetools_render.h

General Functions

Render Spritesheets

Render Frames

Render Animations

Render Entities

spritetools_splash.h

spritetools_animation.h

Frame Functions

Animation Functions

spritetools_time.h

spritetools_entity.h

Entity Creation

Setting Values

Modifying Values

Non-Wrapping Modifying Values

Flags

Datatypes

spritetools_debug.h

spritetools_animation.h

spritetools_entity.h

Macros/Definitions

spritetools_debug.h

spritetools_spritesheet.h

Functions

spritetools.h

/* Inits all modules and sets up */
/* Returns 1 on success, 0 on failure */
int ST_Init(void);

/* Cleans up all modules */
/* Returns 1 on success, 0 on failure */
int ST_Fini(void);

spritetools_debug.h

General Debugging

/* Sets up debug variables */
/* Returns 1 on success */
/* Returns 0 if DEBUGVars cannot be allocated */
u8 ST_DebugInit(void);

/* Cleans up all modules */
u8 ST_DebugFini(void);

/* Returns DEBUG State */
u8 ST_DebugGet(void);

/* Sets DEBUG State to on */
/* Returns DEBUG State */
u8 ST_DebugSetOn(void);

/* Sets DEBUG State to off */
/* Returns DEBUG State */
u8 ST_DebugSetOff(void);

/* Prints a string if DEBUG is on */
/* Takes string to print */
/* Returns characters printed */
u8 ST_DebugPrint(char *str);

/* Adds Variable to debug list */
/* Takes name of variable, pointer to variable (void *), and type of variable */
/* Returns id of var */
/*   Will return -1 if name allocation had an error */
s8 ST_DebugAddVar(char *name, void *varp, ST_PointerType datatype);

/* Removes Variable with given id from DEBUGVars array */
/* Takes id of variable */
/* Returns 1 when the variable was cleared */
/*   Returns 0 when the variable was already empty */
u8 ST_DebugRemoveId(u8 id);

/* Removes Variable with given name from DEBUGVars array */
/* Takes name of variable */
/* Returns 1 when the variable was cleared */
/*   Returns 0 when there is no variable by that name */
u8 ST_DebugRemoveName(char *name);

/* Removes last variable from DEBUGVars array */
/* Returns index of cleared variable */
/*   Returns -1 when all indexes are open */
s8 ST_DebugRemoveLast(void);

/* DebugPrints the given id in the DEBUGVars array */
/* Takes id of variable */
/* Returns pointer of var (void *) */
void *ST_DebugPrintVarId(u8 id);

/* Just runs ST_DebugPrintVarId but sets the cursor position first */
/* Takes id of variable, x of cursor, and y of cursor */
/* Returns pointer of var (void *) */
void *ST_DebugPrintVarIdPosition(u8 id, s8 x, s8 y);

/* DebugPrints the given name in the DEBUGVars array */
/* Takes name of variable in DEBUGVars */
/* Returns pointer of var (void *) */
void *ST_DebugPrintVarName(char *name);

/* Just runs ST_DebugPrintVarName but sets the cursor position first */
/* Takes name of variable, x of cursor, and y of cursor */
/* Returns pointer of var (void *) */
void *ST_DebugPrintVarNamePosition(char *name, s8 x, s8 y);

/* DebugPrints all variables in the DEBUGVars array */
void ST_DebugPrintVarAll(void);

/* DebugPrints all variables in the DEBUGVars array at given x and y */
/* Takes x and y of cursor */
void ST_DebugPrintVarAllPosition(s8 x, s8 y);

/* DebugPrints all variables in the DEBUGVars array until given id */
/* Takes max id of array to be printed */
void ST_DebugPrintVarAllUntil(u8 max);

/* DebugPrints all variables in the DEBUGVars array at given x and y */
/* Takes max id of array to be printed and x and y of cursor */
void ST_DebugPrintVarAllUntilPosition(u8 max, s8 x, s8 y);

/* DebugPrints all variables in the DEBUGVars array starting at given id */
/* Takes starting id of array to be printed */
void ST_DebugPrintVarAllFrom(u8 start);

/* DebugPrints all variables in the DEBUGVars array starting at given id */
/*   at given x and y */
/* Takes starting id of array to be printed and x and y of cursor */
void ST_DebugPrintVarAllFromPosition(u8 start, s8 x, s8 y);

/* DebugPrints all variables in the DEBUGVars array starting at given id */
/*   and ending at given id */
/* Takes starting and ending ids of array to be printed */
void ST_DebugPrintVarAllFromUntil(u8 start, u8 max);

/* DebugPrints all variables in the DEBUGVars array starting at given id */
/*   and ending at given id at given x and y */
/* Takes starting and ending ids of array to be printed and x and y of cursor */
void ST_DebugPrintVarAllFromUntilPosition(u8 start, u8 max, s8 x, s8 y);

/* Scrolls up on the Debug Variable list */
/* Takes number of lines to scroll by */
/* Returns number of lines scrolled */
u8 ST_DebugScrollUp(s8 scroll);

/* Scrolls down on the Debug Variable list */
/* Takes number of lines to scroll by */
/* Returns number of lines scrolled */
u8 ST_DebugScrollDown(s8 scroll);

/* Returns DEBUGScroll */
u8 ST_DebugGetScroll(void);

/* Clears the console */
void ST_DebugClear(void);

/* Displays generic debug info if DEBUG is on */
/* Returns 1 if debug was on and 0 if it was off */
u16 ST_DebugDisplay(void);

Button Debugging

/* Displays status of A button */
/* Will print [ ] and return 0 if A is up */
/* Will print <A> and return 1 when A is pressed */
/* Will print [A] and return 2 if A is down */
u8 ST_DebugButtonA(void);

/* Displays status of B button */
/* Will print [ ] and return 0 if B is up */
/* Will print <B> and return 1 when B is pressed */
/* Will print [B] and return 2 if B is down */
u8 ST_DebugButtonB(void);

/* Displays status of X button */
/* Will print [ ] and return 0 if X is up */
/* Will print <X> and return 1 when X is pressed */
/* Will print [X] and return 2 if X is down */
u8 ST_DebugButtonX(void);

/* Displays status of Y button */
/* Will print [ ] and return 0 if Y is up */
/* Will print <Y> and return 1 when Y is pressed */
/* Will print [Y] and return 2 if Y is down */
u8 ST_DebugButtonY(void);

/* Displays status of Start button */
/* Will print [  ] and return 0 if Start is up */
/* Will print <St> and return 1 when Start is pressed */
/* Will print [St] and return 2 if Start is down */
u8 ST_DebugButtonStart(void);

/* Displays status of Select button */
/* Will print [  ] and return 0 if Select is up */
/* Will print <Se> and return 1 when Select is pressed */
/* Will print [Se] and return 2 if Select is down */
u8 ST_DebugButtonSelect(void);

/* Displays status of R button */
/* Will print [ ] and return 0 if R is up */
/* Will print <R> and return 1 when R is pressed */
/* Will print [R] and return 2 if R is down */
u8 ST_DebugButtonR(void);

/* Displays status of L button */
/* Will print [ ] and return 0 if L is up */
/* Will print <L> and return 1 when L is pressed */
/* Will print [L] and return 2 if L is down */
u8 ST_DebugButtonL(void);

/* Displays status of Dpad's Up button */
/* Will print [ ] and return 0 if Up is up */
/* Will print <^> and return 1 when Up is pressed */
/* Will print [^] and return 2 if Up is down */
u8 ST_DebugButtonDUp(void);

/* Displays status of Dpad's Right button */
/* Will print [ ] and return 0 if Right is up */
/* Will print <>> and return 1 when Right is pressed */
/* Will print [>] and return 2 if Right is down */
u8 ST_DebugButtonDRight(void);

/* Displays status of Dpad's Down button */
/* Will print [ ] and return 0 if Down is up */
/* Will print <v> and return 1 when Down is pressed */
/* Will print [v] and return 2 if Down is down */
u8 ST_DebugButtonDDown(void);

/* Displays status of Dpad's Left button */
/* Will print [ ] and return 0 if Left is up */
/* Will print <<> and return 1 when Left is pressed */
/* Will print [<] and return 2 if Left is down */
u8 ST_DebugButtonDLeft(void);

/* Displays status of all buttons */
/* Will print a formatted set of all buttons using the above functions */
void ST_DebugButtonFormatted(void);

/* Displays status of all buttons at given position */
/* Takes X and Y of where to start printing from */
/* Will print a formatted set of all buttons using the above functions */
void ST_DebugButtonFormattedAtPosition(s8 x, s8 y);

spritetools_input.h

/* Enables the Accelerometer and Gyroscope at startup */
/* Returns 1 on success and 0 on failure */
u8 ST_InputInit(void);

/* Scans Keys down, held, and up as well as circle and touch positions */
/*   All values are stored in static variables */
void ST_InputScan(void);

/* Checks for if a button was just pressed. Requires ST_InputScan before it */
/* Takes key value enum from ctrulib to check */
/* Returns 1 if the button has just been pressed. 0 if not */
u8 ST_InputButtonPressed(u32 key);

/* Checks for if a button is being pressed. Requires ST_InputScan before it */
/* Takes key value enum from ctrulib to check */
/* Returns 1 if the button is currently down. 0 if not */
u8 ST_InputButtonDown(u32 key);

/* Checks for if a button was just released. Requires ST_InputScan before it */
/* Takes key value enum from ctrulib to check */
/* Returns 1 if the button was just released. 0 if not */
u8 ST_InputButtonReleased(u32 key);

/* Returns X position of touch. Requires ST_InputScan before it */
/* Returns -1 if the touch screen is currently not being touched */
s16 ST_InputTouchX(void);

/* Returns Y position of touch. Requires ST_InputScan before it */
/* Returns -1 if the touch screen is currently not being touched */
s16 ST_InputTouchY(void);

/* Returns X position of where the touch started. */
/*   Requires ST_InputScan before it */
/* Returns -1 if the touch screen is currently not being touched */
s16 ST_InputTouchOriginX(void);

/* Returns Y position of where the touch started. */
/*   Requires ST_InputScan before it */
/* Returns -1 if the touch screen is currently not being touched */
s16 ST_InputTouchOriginY(void);

/* Returns X difference between where the touch is and where it started. */
/*   Requires ST_InputScan before it */
/* Returns -1 if the touch screen is currently not being touched */
s16 ST_InputTouchDistanceX(void);

/* Returns Y difference between where the touch is and where it started. */
/*   Requires ST_InputScan before it */
/* Returns -1 if the touch screen is currently not being touched */
s16 ST_InputTouchDistanceY(void);

/* Returns distance between where the touch is and where it started. */
/*   Requires ST_InputScan before it */
/* Returns -1 if the touch screen is currently not being touched */
s16 ST_InputTouchDistance(void);

/* Returns length of line drawn on touchscreen. */
/*   Requires ST_InputScan before it */
/* Returns -1 if the touch screen is currently not being touched */
s64 ST_InputTouchLength(void);

/* Returns X position of Circle Pad. Requires ST_InputScan before it */
s16 ST_InputCirclePadX(void);

/* Returns Y position of Circle Pad. Requires ST_InputScan before it */
s16 ST_InputCirclePadY(void);

/* Returns Accelerometer Vector. Requires ST_InputScan before it */
accelVector ST_InputAccel(void);

/* Returns x of Accelerometer Vector. Requires ST_InputScan before it */
s16 ST_InputAccelX(void);

/* Returns y of Accelerometer Vector. Requires ST_InputScan before it */
s16 ST_InputAccelY(void);

/* Returns z of Accelerometer Vector. Requires ST_InputScan before it */
s16 ST_InputAccelZ(void);

/* Returns Gyroscope's angular Rate. Requires ST_InputScan before it */
angularRate ST_InputGyro(void);

/* Returns x of Gyroscope's angular Rate. Requires ST_InputScan before it */
s16 ST_InputGyroRoll(void);

/* Returns y of Gyroscope's angular Rate. Requires ST_InputScan before it */
s16 ST_InputGyroYaw(void);

/* Returns z of Gyroscope's angular Rate. Requires ST_InputScan before it */
s16 ST_InputGyroPitch(void);

spritetools_textcolors.h

Standard Foreground Colors

/* Sets foreground to black */
void ST_TextBlackFore(void);

/* Sets foreground to red */
void ST_TextRedFore(void);

/* Sets foreground to green */
void ST_TextGreenFore(void);

/* Sets foreground to yellow */
void ST_TextYellowFore(void);

/* Sets foreground to blue */
void ST_TextBlueFore(void);

/* Sets foreground to magenta */
void ST_TextMagentaFore(void);

/* Sets foreground to cyan */
void ST_TextCyanFore(void);

/* Sets foreground to white */
void ST_TextWhiteFore(void);

/* Sets foreground to the default color */
void ST_TextDefaultFore(void);

Standard Background Colors

/* Sets background to black */
void ST_TextBlackBack(void);

/* Sets background to red */
void ST_TextRedBack(void);

/* Sets background to green */
void ST_TextGreenBack(void);

/* Sets background to yellow */
void ST_TextYellowBack(void);

/* Sets background to blue */
void ST_TextBlueBack(void);

/* Sets background to magenta */
void ST_TextMagentaBack(void);

/* Sets background to cyan */
void ST_TextCyanBack(void);

/* Sets background to white */
void ST_TextWhiteBack(void);

/* Sets background to the default color */
void ST_TextDefaultBack(void);

Effects

/* Sets foreground to be a brighter shade */
void ST_TextBright(void);

/* Sets foreground to be a darker shade */
void ST_TextDark(void);

/* Sets foreground to be a standard shade */
void ST_TextNoBright(void);

/* Turns on underlining */
void ST_TextUnderline(void);

/* Turns off underlining */
void ST_TextNoUnderline(void);

/* Turns on inverted colors (background <-> foreground) */
void ST_TextNegative(void);

/* Turns off inverted colors (background <-> foreground) */
void ST_TextPositive(void);

/* Turns on strikethrough */
void ST_TextStrikethrough(void);

/* Turns off strikethrough */
void ST_TextNoStrikethrough(void);

/* Text with all default settings */
void ST_TextDefault(void);

spritetools_spritesheet.h

/* Load spritesheet from image */
/* Takes image */
/* Returns pointer to st_spritesheet */
st_spritesheet *ST_SpritesheetCreateSpritesheet(const unsigned char *pixel_data,
    unsigned int width, unsigned int height);

/* Free spritesheet */
/* Takes st_spritesheet */
void ST_SpritesheetFreeSpritesheet(st_spritesheet *spritesheet);

spritetools_render.h

General Functions

/* Inits rendering */
/* Returns 1 on success and 0 on failure */
u8 ST_RenderInit(void);

/* Finishes rendering */
u8 ST_RenderFini(void);

/* Start frame */
/* Takes screen (GFX_TOP or GFX_BOTTOM) */
void ST_RenderStartFrame(gfxScreen_t screen);

/* Ends rendering the current frame (for both screens) */
void ST_RenderEndRender(void);

/* Returns current screen */
gfxScreen_t ST_RenderCurrentScreen(void);

/* Returns current fps */
float ST_RenderFPS(void);

/* Sets background to given color */
void ST_RenderSetBackground(u8 red, u8 green, u8 blue);

/* Returns background color in the RGBA8 format */
u32 ST_RenderGetBackground(void);

Render Spritesheets

/* Draw Spritesheet at Position */
/* Takes spritesheet and x and y of position to render on screen */
void ST_RenderSpritesheetPosition(st_spritesheet *spritesheet, s64 x, s64 y);

/* Draw Spritesheet at 0,0 */
/* Takes spritesheet */
void ST_RenderSpritesheet(st_spritesheet *spritesheet);

/* Draw Sprite in Spritesheet at Position */
/* Takes spritesheet */
/*   Takes x and y of the top left pixel of the sprite in the spritesheet */
/*   Takes width and height of the sprite in the spritesheet */
/*   Takes position to print the sprite on screen */
void ST_RenderSpritePosition(st_spritesheet *spritesheet,
  u32 xleft, u32 ytop,
  u32 width, u32 height,
  s64 x, s64 y);

/* Draw Sprite in Spritesheet at 0,0 */
/* Takes spritesheet */
/*   Takes x and y of the top left pixel of the sprite in the spritesheet */
/*   Takes width and height of the sprite in the spritesheet */
void ST_RenderSprite(st_spritesheet *spritesheet,
  u32 xleft, u32 ytop,
  u32 width, u32 height);

/* Draw Scaled Sprite in Spritesheet at Position */
/* Takes spritesheet */
/*   Takes x and y of the top left pixel of the sprite in the spritesheet */
/*   Takes width and height of the sprite in the spritesheet */
/*   Takes position to print the sprite on screen */
/*   Takes value to scale by */
void ST_RenderSpritePositionScale(st_spritesheet *spritesheet,
  u32 xleft, u32 ytop,
  u32 width, u32 height,
  s64 x, s64 y,
  double scale);

/* Draw Rotated Sprite in Spritesheet at Position */
/* Takes spritesheet */
/*   Takes x and y of the top left pixel of the sprite in the spritesheet */
/*   Takes width and height of the sprite in the spritesheet */
/*   Takes position to print the sprite on screen */
/*   Takes radian value to rotate by */
void ST_RenderSpritePositionRotate(st_spritesheet *spritesheet,
  u32 xleft, u32 ytop,
  u32 width, u32 height,
  s64 x, s64 y,
  double rotate);

/* Draw Scaled and Rotated Sprite in Spritesheet at Position */
/* Takes spritesheet */
/*   Takes x and y of the top left pixel of the sprite in the spritesheet */
/*   Takes width and height of the sprite in the spritesheet */
/*   Takes position to print the sprite on screen */
/*   Takes value to scale by */
/*   Takes value to rotate by */
void ST_RenderSpritePositionScaleRotate(st_spritesheet *spritesheet,
  u32 xleft, u32 ytop,
  u32 width, u32 height,
  s64 x, s64 y,
  double scale,
  double rotate);

/* Draw Scaled, Rotated, and Blended Sprite in Spritesheet at Position */
/* Takes spritesheet */
/*   Takes x and y of the top left pixel of the sprite in the spritesheet */
/*   Takes width and height of the sprite in the spritesheet */
/*   Takes position to print the sprite on screen */
/*   Takes value to scale by */
/*   Takes value to rotate by */
/*   Takes color to blend with (rgba8) */
void ST_RenderSpriteAdvanced(st_spritesheet *spritesheet,
  u32 xleft, u32 ytop,
  u32 width, u32 height,
  s64 x, s64 y,
  double scale,
  double rotate,
  u8 red, u8 green, u8 blue, u8 alpha);

Render Frames

/* Draw frame at given position */
/* Takes spritesheet and position at which to draw */
void ST_RenderFramePosition(st_frame *frame, s64 x, s64 y);

/* Draw scaled frame at given position */
/* Takes spritesheet, position at which to draw and a scalar multiplier */
void ST_RenderFrameScale(st_frame *frame, s64 x, s64 y, double scale);

/* Draw rotated frame at given position */
/* Takes spritesheet, position at which to draw and a rotation in radians */
void ST_RenderFrameRotate(st_frame *frame, s64 x, s64 y, double rotate);

/* Draw scaled, rotated, and blended frame at given position */
/* Takes spritesheet and position at which to draw */
/*   Takes scalar multiplier and rotation in radians */
/*   Takes red, green, blue, and alpha of color to blend */
void ST_RenderFramePositionAdvanced(st_frame *frame, s64 x, s64 y,
  double scale, double rotate,
  u8 red, u8 green, u8 blue, u8 alpha);

Render Animations

/* Draw the current frame of an animation at given position */
/* Takes a pointer to an animation and a position */
void ST_RenderAnimationCurrent(st_animation *animation, s64 x, s64 y);

/* Draw the next frame of an animation at given position */
/*   Also adds 1 to the current frame */
/* Takes a pointer to an animation and a position */
void ST_RenderAnimationNext(st_animation *animation, s64 x, s64 y);

/* Draw the previous frame of an animation at given position */
/*   Also subtracts 1 from the current frame */
/* Takes a pointer to an animation and a position */
void ST_RenderAnimationPrevious(st_animation *animation, s64 x, s64 y);

/* Plays an animation at given position */
/*   This also accounts for the animation's speed */
/* Takes a pointer to an animation and a position */
void ST_RenderAnimationPlay(st_animation *animation, s64 x, s64 y);

/* The following functions also take a scalar multiplier, */
/*   rotation in radians, and red, green, blue, and alpha of a */
/*   color to blend with */

void ST_RenderAnimationCurrentAdvanced(st_animation *animation, s64 x, s64 y,
  double scale, double rotate,
  u8 red, u8 green, u8 blue, u8 alpha);

void ST_RenderAnimationNextAdvanced(st_animation *animation, s64 x, s64 y,
  double scale, double rotate,
  u8 red, u8 green, u8 blue, u8 alpha);

void ST_RenderAnimationPreviousAdvanced(st_animation *animation, s64 x, s64 y,
  double scale, double rotate,
  u8 red, u8 green, u8 blue, u8 alpha);

void ST_RenderAnimationPlayAdvanced(st_animation *animation, s64 x, s64 y,
  double scale, double rotate,
  u8 red, u8 green, u8 blue, u8 alpha);

Entity Rendering

/* Plays the current animation of an entity by name */
/* Takes a pointer to an entity */
/* Returns 1 on success and 0 on failure */
u8 ST_RenderEntity(st_entity *entity);

spritetools_splash.h

/* Displays splashscreen */
/* Takes time to display in ms */
void ST_Splashscreen(u64 time);

spritetools_animation.h

Frame Functions

/* Returns a pointer to a frame */
/*   Returns NULL if failed */
/* Takes a pointer to a spritesheet */
/*   Takes the position of the frame in the spritesheet */
/*   Takes the dimensions of the frame */
st_frame *ST_AnimationCreateFrame(st_spritesheet *spritesheet,
  u32 xleft, u32 ytop, u32 width, u32 height);

/* Returns a pointer to a frame */
/*   Returns NULL if failed */
/* Takes a pointer to a spritesheet */
/*   Takes the position of the frame in the spritesheet */
/*   Takes the dimensions of the frame */
/*   Takes offset for rendering (hotspot) */
st_frame *ST_AnimationCreateFrameOffset(st_spritesheet *spritesheet,
  u32 xleft, u32 ytop, u32 width, u32 height, s32 xoff, s32 yoff);

/* Frees frame from memory */
/* Takes a pointer to a frame */
void ST_AnimationFreeFrame(st_frame *frame);

Animation Functions

/* Returns a pointer to an animation */
/*   Returns NULL if failed */
/* Takes speed of animation (in frames between each frame of animation) */
/*   Takes frame to loop to when the animation has reached its end */
/*   Takes length of animation in frames */
/*   Takes a list of pointers to frames */
st_animation *ST_AnimationCreateAnimation(s16 fpf, u16 loopFrame,
  u16 length, ...);

/* Frees an animation and all of its frames from memory */
/* Takes a pointer to an animation */
void ST_AnimationFreeAnimation(st_animation *animation);

/* Sets the current frame of an animation */
/* Takes a pointer to an animation and frame to go to */
void ST_AnimationSetFrame(st_animation *animation, u16 frame);

/* Adds 1 to the current frame of an animation. Wraps to 0 if needed */
/* Takes a pointer to an animation */
void ST_AnimationNextFrame(st_animation *animation);

/* Subs 1 from the current frame of an animation */
/*   Wraps to the last frame if needed */
/* Takes a pointer to an animation */
void ST_AnimationPreviousFrame(st_animation *animation);

/* Sets the speed (fpf) of an animation */
/* Takes a pointer to an animation and frame to go to */
void ST_AnimationSetSpeed(st_animation *animation, s16 speed);

spritetools_time.h

/* Inits times */
u8 ST_TimeInit(void);

/* Returns time since program started in ms */
u64 ST_TimeRunning(void);

/* Returns time (since January 1st, 1990) when the program started in ms */
u64 ST_TimeStarted(void);

/* Returns time since January 1st, 1990 in ms */
u64 ST_TimeOS(void);

spritetools_entity.h

Entity Creation

/* Returns a pointer to an entity */
/*   Returns NULL if failed */
/* Takes a position and number of animations */
st_entity *ST_EntityCreateEntity(s64 x, s64 y, u8 animCount);

/* Frees frame from memory */
/* Takes a pointer to a frame */
void ST_EntityFreeEntity(st_entity *entity);

/* Adds an animation to an entity */
/* Takes a pointer to an entity, a pointer to an animation, */
/*   and a name for the animation */
/* Returns 1 on success and 0 on failure */
u8 ST_EntityAddAnimation(st_entity *entity, st_animation *anim, char *name);

Setting Values

/* Sets the x position of a given entity */
/* Takes a pointer to an entity and a position */
void ST_EntitySetXPosition(st_entity *entity, s64 x);

/* Sets the y position of a given entity */
/* Takes a pointer to an entity and a position */
void ST_EntitySetYPosition(st_entity *entity, s64 y);

/* Sets the position of a given entity */
/* Takes a pointer to an entity and a position */
void ST_EntitySetPosition(st_entity *entity, s64 x, s64 y);

/* Sets the scale of an entity */
/* Takes a pointer to an entity and a scale */
void ST_EntitySetScale(st_entity *entity, double scale);

/* Sets the rotation of an entity */
/* Takes a pointer to an entity and a rotation value */
void ST_EntitySetRotation(st_entity *entity, double rotation);

/* Sets the red value of the color to blend an entity with when rendering */
/* Takes a pointer to an entity and a red value */
void ST_EntitySetRed(st_entity *entity, u8 red);

/* Sets the green value of the color to blend an entity with when rendering */
/* Takes a pointer to an entity and a green value */
void ST_EntitySetGreen(st_entity *entity, u8 green);

/* Sets the blue value of the color to blend an entity with when rendering */
/* Takes a pointer to an entity and a blue value */
void ST_EntitySetBlue(st_entity *entity, u8 blue);

/* Sets the alpha value of the color to blend an entity with when rendering */
/* Takes a pointer to an entity and a alpha value */
void ST_EntitySetAlpha(st_entity *entity, u8 alpha);

/* Sets the values of the color to blend an entity with when rendering */
/* Takes a pointer to an entity and red, green, blue, and alpha values */
void ST_EntitySetColor(st_entity *entity, u8 red, u8 green, u8 blue, u8 alpha);

/* Sets the direction of an entity */
/* Takes a pointer to an entity and a direction */
/* Returns 1 on success and 0 on failure */
u8 ST_EntitySetDirection(st_entity *entity, char *dir);

/* Sets the direction of an entity */
/* Takes a pointer to an entity and a direction id */
/*   0 = east */
/*   1 = south east */
/*   2 = south */
/*   3 = south west */
/*   4 = west */
/*   5 = north west */
/*   6 = north */
/*   7 = north east */
/* Returns 1 on success and 0 on failure */
u8 ST_EntitySetDirectionId(st_entity *entity, u8 dir);

/* Sets the current animation of an entity by name */
/* Takes a pointer to an entity and the name of the animation to set */
/* Returns 1 on success and 0 on failure */
u8 ST_EntitySetAnimationName(st_entity *entity, char *name);

/* Sets the current animation of an entity by id */
/* Takes a pointer to an entity and the id of the animation to set */
/* Returns 1 on success and 0 on failure */
u8 ST_EntitySetAnimationId(st_entity *entity, u8 id);

Modifying Values

/* Modifies the x position of a given entity by a given amount */
/* Takes a pointer to an entity and an amount to change the position by */
void ST_EntityModifyXPosition(st_entity *entity, s64 x);

/* Modifies the y position of a given entity by a given amount */
/* Takes a pointer to an entity and an amount to change the position by */
void ST_EntityModifyYPosition(st_entity *entity, s64 y);

/* Modifies the position of a given entity by a given amount */
/* Takes a pointer to an entity and an amount to change the position by */
void ST_EntityModifyPosition(st_entity *entity, s64 x, s64 y);

/* Modifies the scale of an entity by a given amount */
/* Takes a pointer to an entity and a value to modify its scale by */
void ST_EntityModifyScale(st_entity *entity, double scale);

/* Modifies the rotation of an entity by a given amount */
/* Takes a pointer to an entity and a value to modify its rotation by */
void ST_EntityModifyRotation(st_entity *entity, double rotation);

/* Modifies the red of the blend color of an entity by a given amount */
/* Takes a pointer to an entity and a red value */
void ST_EntityModifyRed(st_entity *entity, u8 red);

/* Modifies the green of the blend color of an entity by a given amount */
/* Takes a pointer to an entity and a green value */
void ST_EntityModifyGreen(st_entity *entity, u8 green);

/* Modifies the blue of the blend color of an entity by a given amount */
/* Takes a pointer to an entity and a blue value */
void ST_EntityModifyBlue(st_entity *entity, u8 blue);

/* Modifies the alpha of the blend color of an entity by a given amount */
/* Takes a pointer to an entity and a alpha value */
void ST_EntityModifyAlpha(st_entity *entity, u8 alpha);

/* Modifies the values of the blend color of an entity by a given amount */
/* Takes a pointer to an entity and red, green, blue, and alpha values */
void ST_EntityModifyColor(st_entity *entity,
  u8 red, u8 green, u8 blue, u8 alpha);

/* Modifies the direction of an entity */
/* Takes a pointer to an entity and a value to turn by */
/*   Positive turns right, negative turns left */
void ST_EntityModifyDirection(st_entity *entity, s8 dir);

Non-Wrapping Modifying Values

/* The following are just like the above, but they will not wrap */
/*   (Values greater than the maximum will be reduced to the maximum) */
/*   (Values lower than the minimum will be raised to the minimum) */

void ST_EntityModifyRotationNoWrap(st_entity *entity, double rotation);

void ST_EntityModifyRedNoWrap(st_entity *entity, u8 red);

void ST_EntityModifyGreenNoWrap(st_entity *entity, u8 green);

void ST_EntityModifyBlueNoWrap(st_entity *entity, u8 blue);

void ST_EntityModifyAlphaNoWrap(st_entity *entity, u8 alpha);

void ST_EntityModifyColorNoWrap(st_entity *entity,
  u8 red, u8 green, u8 blue, u8 alpha);

Flags

/* Turns on a given flag (sets it to 1) */
/* Takes a pointer to an entity and the id of the flag */
void ST_EntityFlagOn(st_entity *entity, u8 flag);

/* Turns off a given flag (sets it to 0) */
/* Takes a pointer to an entity and the id of the flag */
void ST_EntityFlagOff(st_entity *entity, u8 flag);

/* Toggles the given flag (1->0 and 0->1) */
/* Takes a pointer to an entity and the id of the flag */
void ST_EntityFlagToggle(st_entity *entity, u8 flag);

/* Returns the current state of a flag (1 or 0) */
/* Takes a pointer to an entity and the id of the flag */
u8 ST_EntityFlagGet(st_entity *entity, u8 flag);

Datatypes

spritetools_debug.h

typedef enum {
  UNK,
  VOID,
  PTR,
  CHAR,
  STR,
  INT,
  DOUBLE,
  FLOAT,
  U8,
  U16,
  U32,
  U64,
  S8,
  S16,
  S32,
  S64,
  VU8,
  VU16,
  VU32,
  VU64,
  VS8,
  VS16,
  VS32,
  VS64,
  ST_NAMEDPOINTER
} ST_PointerType;

typedef struct NamedPointer {
  char *name;
  void *pointer;
  ST_PointerType type;
} ST_NamedPointer;

spritetools_animation.h

/* Frame of animation from a spritesheet */
typedef struct {
  st_spritesheet *spritesheet;
  u32 xleft;
  u32 ytop;
  u32 width;
  u32 height;
  s32 xoff;
  s32 yoff;
} st_frame;

/* Animation of frames */
typedef struct {
  s16 fpf; /* Number of frames to wait between each frame of animation */
  u16 ftn; /* Counts number of frames between displayed frame */
  u16 loopFrame; /* Frame to jump to when an animation loops */
  u16 length; /* Number of frames in the animation */
  st_frame **frames;
  u16 currentFrame;
} st_animation;

spritetools_entity.h

/* Entity with a ton of rendering info */
typedef struct {
  st_animation **animations;
  char **names;
  char *dir;
  s64 xpos;
  s64 ypos;
  double scale;
  double rotation;
  u32 flags;
  u8 animationCount;
  u8 totalAnims;
  u8 currentAnim;
  u8 red;
  u8 green;
  u8 blue;
  u8 alpha;
} st_entity;

Macros/Definitions

spritetools_debug.h

/* Current version of SpriteTools */
#define SPRITETOOLS_VERSION "Release 2.1"

/* Maximum number of variables that can be debugged at once */
#define ST_DEBUG_MAX_VAR 64

spritetools_spritesheet.h

/* Temporary define until this is split from sf2d */
#define st_spritesheet sf2d_texture
/* image structure */
#define st_image struct {\
  unsigned int width;\
  unsigned int height;\
  unsigned int bytes_per_pixel;\
  unsigned char pixel_data[];\
}