PAlib: Sprite system

Main Page | Modules | File List | Globals | Search for

# Sprite system

## Defines

#define | PA_UpdateOAM0() DMA_Copy((void*)PA_obj, (void*)OAM0, 256, DMA_32NOW)
| Update the sprite infos for screen 0 only. Do this in the VBL
#define | PA_UpdateOAM1() DMA_Copy((void*)PA_obj + 256, (void*)OAM1, 256, DMA_32NOW)
| Update the sprite infos for screen 1 only. Do this in the VBL
#define | PA_UpdateSpriteGfx(screen, obj_number, obj_data) PA_UpdateGfx(screen, PA_GetSpriteGfx(screen, obj_number), obj_data)
| Update the Gfx of a given sprite
#define | PA_SetSpriteRotEnable(screen, sprite, rotset) {PA_obj[screen][sprite].atr0 |= OBJ_ROT; PA_obj[screen][sprite].atr1 = (PA_obj[screen][sprite].atr1 & ALL_BUT_ROTSET) + ((rotset) << 9);}
| Rotate and zoom a sprite
#define | PA_SetSpriteRotDisable(screen, sprite) {PA_obj[screen][sprite].atr0 &= ALL_BUT(OBJ_ROT); PA_obj[screen][sprite].atr1 &= ALL_BUT_ROTSET;}
| Stop rotating and zooming a sprite
#define | PA_SetSpriteX(screen, obj, x) PA_obj[screen][obj].atr1 = (PA_obj[screen][obj].atr1 & ALL_BUT(OBJ_X)) + ((x) & OBJ_X)
| Set the X position of a sprite on screen
#define | PA_GetSpriteX(screen, obj) (PA_obj[screen][obj].atr1 & (OBJ_X))
| Get the X position of a sprite on screen
#define | PA_SetSpriteY(screen, obj, y) PA_obj[screen][obj].atr0 = (PA_obj[screen][obj].atr0 & ALL_BUT(OBJ_Y)) + ((y) & OBJ_Y)
| Set the Y position of a sprite on screen
#define | PA_GetSpriteY(screen, obj) (PA_obj[screen][obj].atr0 & OBJ_Y)
| Get the Y position of a sprite on screen
#define | PA_SetSpritePal(screen, obj, pal) PA_obj[screen][obj].atr2 = (PA_obj[screen][obj].atr2 & ALL_BUT_PAL) + ((pal) << 12)
| Set the sprite's palette number
#define | PA_GetSpritePal(screen, obj) (PA_obj[screen][obj].atr2 >> 12)
| Get thepalette used by a sprite
#define | PA_SetSpriteDblsize(screen, obj, dblsize) PA_obj[screen][obj].atr0 = (PA_obj[screen][obj].atr0 & ALL_BUT(DBLSIZE)) + ((dblsize) << 9)
| Enable or disable double size for a given sprite
#define | PA_GetSpriteDblsize(screen, obj) ((PA_obj[screen][obj].atr0 & DBLSIZE) >> 9)
| Get the double size state for a given sprite
#define | PA_SetSpriteColors(screen, sprite, n_colors) PA_obj[screen][sprite].atr0 = (PA_obj[screen][sprite].atr0 & ALL_BUT(N_COLORS)) + ((n_colors) << 13)
| Change the sprite's color mode
#define | PA_GetSpriteColors(screen, sprite) ((PA_obj[screen][sprite].atr0 & N_COLORS) >> 13)
| Get a sprite's color mode
#define | PA_SetSpriteMode(screen, sprite, obj_mode) PA_obj[screen][sprite].atr0 = (PA_obj[screen][sprite].atr0 & ALL_BUT(OBJ_MODE)) + ((obj_mode) << 10)
| Set the sprite's mode : 0 for normal, 1 for alpha blending, 2 for window
#define | PA_GetSpriteMode(screen, obj) ((PA_obj[screen][obj].atr0 & OBJ_MODE) >> 10)
| Get the sprite's mode : 0 for normal, 1 for alpha blending, 2 for window
#define | PA_SetSpriteMosaic(screen, obj, mosaic) PA_obj[screen][obj].atr0 = (PA_obj[screen][obj].atr0 & ALL_BUT(OBJ_MOSAIC)) + ((mosaic) << 12)
| Enable or disable mosaic mode for a given sprite
#define | PA_GetSpriteMosaic(screen, obj) ((PA_obj[screen][obj].atr0 & OBJ_MOSAIC) >> 12)
| Get the mosaic mode for a given sprite
#define | PA_SetSpriteHflip(screen, obj, hflip) PA_obj[screen][obj].atr1 = (PA_obj[screen][obj].atr1 & ALL_BUT(OBJ_HFLIP)) + ((hflip) << 12)
| Enable or disable horizontal flip for a given sprite
#define | PA_GetSpriteHflip(screen, obj) ((PA_obj[screen][obj].atr1 & OBJ_HFLIP) >> 12)
| Get the horizontal flip state for a given sprite
#define | PA_SetSpriteVflip(screen, obj, vflip) PA_obj[screen][obj].atr1 = (PA_obj[screen][obj].atr1 & ALL_BUT(OBJ_VFLIP)) + ((vflip) << 13)
| Enable or disable vertical flip for a given sprite
#define | PA_GetSpriteVflip(screen, obj) ((PA_obj[screen][obj].atr1 & OBJ_VFLIP) >> 13)
| Get the vertical flip state for a given sprite
#define | PA_SetSpriteGfx(screen, obj, gfx) PA_obj[screen][obj].atr2 = (PA_obj[screen][obj].atr2 & ALL_BUT(OBJ_GFX)) + ((gfx) & OBJ_GFX)
| Change the gfx used by a sprite
#define | PA_GetSpriteGfx(screen, obj) (PA_obj[screen][obj].atr2 & OBJ_GFX)
| Get the gfx used by a sprite
#define | PA_SetSpritePrio(screen, obj, prio) PA_obj[screen][obj].atr2 = (PA_obj[screen][obj].atr2 & ALL_BUT(OBJ_PRIO)) + ((prio) << 10)
| Set a sprite's Background priority
#define | PA_GetSpritePrio(screen, obj) ((PA_obj[screen][obj].atr2 & OBJ_PRIO) >> 10)
| Get a sprite's Background priority
#define | PA_GetSpriteLx(screen, sprite) PA_size[PA_obj[screen][sprite].atr0 >> 14][PA_obj[screen][sprite].atr1 >> 14].lx
| Get a sprite's length
#define | PA_GetSpriteLy(screen, sprite) PA_size[PA_obj[screen][sprite].atr0 >> 14][PA_obj[screen][sprite].atr1 >> 14].ly
| Get a sprite's height
#define | PA_CloneSprite(screen, obj, target) {PA_obj[screen][obj].atr0 = PA_obj[screen][target].atr0; PA_obj[screen][obj].atr1 = PA_obj[screen][target].atr1; PA_obj[screen][obj].atr2 = PA_obj[screen][target].atr2; ++obj_per_gfx[screen][PA_GetSpriteGfx(screen, target)];}
| Clone a sprite. Works only for sprites on the same screen

## Functions

void | PA_UpdateOAM (void)
| Update the sprite infos for both screens. Do this in the VBL
u16 | PA_CreateGfx (bool screen, void *obj_data, u8 obj_shape, u8 obj_size, u8 color_mode)
| Load in mémory a gfx to use later on for a sprite. Returns the gfx's number in memory
void | PA_ResetSpriteSys (void)
| Reset the sprite system, memory, etc...
void | PA_CreateSprite (bool screen, u8 obj_number, void *obj_data, u8 obj_shape, u8 obj_size, u8 color_mode, u8 palette, s16 x, s16 y)
| Create a sprite with it's gfx. This is the simple version of the function
void | PA_CreateSpriteEx (bool screen, u8 obj_number, void *obj_data, u8 obj_shape, u8 obj_size, u8 color_mode, u8 palette, u8 obj_mode, bool mosaic, bool hflip, bool vflip, u8 prio, bool dblsize, s16 x, s16 y)
| Create a sprite with it's gfx. This is the complex version of the function
void | PA_Create16bitSpriteEx (bool screen, u8 obj_number, void *obj_data, u8 obj_shape, u8 obj_size, bool mosaic, bool hflip, bool vflip, u8 prio, bool dblsize, s16 x, s16 y)
| Create a 16 bit sprite with it's gfx. This is the complex version of the function. Warning : a 16bit sprite MUST be 128 pixels large, even if you sprite only takes up a small part on the left...
void | PA_Create16bitSpriteFromGfx (bool screen, u8 obj_number, u16 gfx, u8 obj_shape, u8 obj_size, s16 x, s16 y)
| Create a 16 bit sprite using a given gfx.
void | PA_Create16bitSprite (bool screen, u8 obj_number, void *obj_data, u8 obj_shape, u8 obj_size, s16 x, s16 y)
| Create a 16 bit sprite with it's gfx. This is the simple version of the function. Warning : a 16bit sprite MUST be 128 pixels large, even if you sprite only takes up a small part on the left...
void | PA_CreateSpriteFromGfx (bool screen, u8 obj_number, u16 obj_gfx, u8 obj_shape, u8 obj_size, u8 color_mode, u8 palette, s16 x, s16 y)
| Create a sprite with it's gfx. This is the simple version of the function
void | PA_CreateSpriteExFromGfx (bool screen, u8 obj_number, u16 obj_gfx, u8 obj_shape, u8 obj_size, u8 color_mode, u8 palette, u8 obj_mode, bool mosaic, bool hflip, bool vflip, u8 prio, bool dblsize, s16 x, s16 y)
| Create a sprite with it's gfx. This is the complex version of the function
void | PA_UpdateGfx (bool screen, u16 gfx_number, void *obj_data)
| Update a given Gfx
void | PA_UpdateGfxAndMem (bool screen, u8 gfx_number, void *obj_data)
| Update the Gfx of a given sprite and updates the PAlib animation pointer... Only for advanced users
void | PA_DeleteGfx (bool screen, u16 obj_gfx)
| Delete a given Gfx. If a sprite uses this gfx, it'll become invisible
void | PA_DeleteSprite (bool screen, u8 obj_number)
| Delete a given sprite. If it is the only one to use it's gfx, it'll be deleted too.
void | PA_SetRotset (bool screen, u8 rotset, s16 angle, u16 zoomx, u16 zoomy)
| Rotate and zoom a sprite
void | PA_SetRotsetNoZoom (bool screen, u8 rotset, s16 angle)
| Rotate a sprite without zooming. It's a bit faster than the normal PA_SetRotset function
void | PA_SetRotsetNoAngle (bool screen, u8 rotset, u16 zoomx, u16 zoomy)
| Zoom a sprite without rotating. It's a bit faster than the normal PA_SetRotset function
void | PA_SetSpriteXY (bool screen, u8 sprite, s16 x, s16 y)
| Set the X and Y position of a sprite on screen
void | PA_SetSpriteAnimEx (bool screen, u8 sprite, u8 lx, u8 ly, u8 ncolors, s16 animframe)
| Set the animation frame for a given sprite. This function is faster than the normal PA_SetSpriteAnim because it doesn't have to lookup the sprite dimensions...
void | PA_SetSpriteAnim (bool screen, u8 sprite, s16 animframe)
| Set the animation frame for a given sprite. Same as PA_SetSpriteAnimEx, but a bit slower and easier to use...
void | PA_StartSpriteAnimEx (bool screen, u8 sprite, s16 firstframe, s16 lastframe, s16 speed, u8 type, s16 ncycles)
| Start a sprite animation. Once started, it continues on and on by itself until you stop it !
void | PA_StartSpriteAnim (bool screen, u8 sprite, s16 firstframe, s16 lastframe, s16 speed)
| Start a sprite animation. Once started, it continues on and on by itself until you stop it !
void | PA_StopSpriteAnim (bool screen, u8 sprite)
| Stop a sprite animation
void | PA_SetSpriteAnimFrame (bool screen, u8 sprite, u16 frame)
| Set the current animation frame number
u16 | PA_GetSpriteAnimFrame (bool screen, u8 sprite)
| Returns the current animation frame number
void | PA_SetSpriteAnimSpeed (bool screen, u8 sprite, s16 speed)
| Set the current animation speed
u16 | PA_GetSpriteAnimSpeed (bool screen, u8 sprite)
| Returns the current animation speed
void | PA_SetSpriteNCycles (bool screen, u8 sprite, s16 NCycles)
| Set the current animation cycles left (-1 for inifinite loop)
u16 | PA_GetSpriteNCycles (bool screen, u8 sprite)
| Returns the current number of animation cycles left
void | PA_SpriteAnimPause (bool screen, u8 sprite, bool pause)
| Pause or UnPause a sprite animation
void | PA_SetSpritePixel (bool screen, u8 sprite, u8 x, u8 y, u8 color)
| Set a sprite's pixel to a given palette color. Like PA_SetSpritePixelEx, with less options, but a little slower
u8 | PA_GetSpritePixel (bool screen, u8 sprite, u8 x, u8 y)
| Get a sprite's pixel color. Like PA_GetSpritePixelEx, with less options, but a little slower
void | PA_InitSpriteDraw (bool screen, u8 sprite)
| Initialise a sprite to be able to draw on it !
void | PA_InitAllSpriteDraw (void)
| Initialise all the onscreen sprites to draw on them
void | PA_InitSpriteExtPrio (bool SpritePrio)
| Enable the PAlib sprite priority system. Slower than the normal priority system, but offering 256 levels of priority for the sprites (overrides the sprite number's priority)
void | PA_SetSPriteExtPrio (bool screen, u8 sprite, u8 prio)

## Detailed Description

Load Sprite, move them around, rotate them...

## Define Documentation

#define PA_CloneSprite | ( | screen,
|  | obj,
|  | target |  | ) | {PA_obj[screen][obj].atr0 = PA_obj[screen][target].atr0; PA_obj[screen][obj].atr1 = PA_obj[screen][target].atr1; PA_obj[screen][obj].atr2 = PA_obj[screen][target].atr2; ++obj_per_gfx[screen][PA_GetSpriteGfx(screen, target)];}

Clone a sprite. Works only for sprites on the same screen

Parameters:

  | screen | Chose de screen (0 or 1)
  | obj | Object number in the sprite system
  | target | Target sprite to clone

#define PA_GetSpriteColors | ( | screen,
|  | sprite |  | ) | ((PA_obj[screen][sprite].atr0 & N_COLORS) >> 13)

Get a sprite's color mode

Parameters:

  | screen | Chose de screen (0 or 1)
  | sprite | Object number in the sprite system

#define PA_GetSpriteDblsize | ( | screen,
|  | obj |  | ) | ((PA_obj[screen][obj].atr0 & DBLSIZE) >> 9)

Get the double size state for a given sprite

Parameters:

  | screen | Chose de screen (0 or 1)
  | obj | Object number in the sprite system

#define PA_GetSpriteGfx | ( | screen,
|  | obj |  | ) | (PA_obj[screen][obj].atr2 & OBJ_GFX)

Get the gfx used by a sprite

Parameters:

  | screen | Chose de screen (0 or 1)
  | obj | Object number in the sprite system

#define PA_GetSpriteHflip | ( | screen,
|  | obj |  | ) | ((PA_obj[screen][obj].atr1 & OBJ_HFLIP) >> 12)

Get the horizontal flip state for a given sprite

Parameters:

  | screen | Chose de screen (0 or 1)
  | obj | Object number in the sprite system

#define PA_GetSpriteLx | ( | screen,
|  | sprite |  | ) | PA_size[PA_obj[screen][sprite].atr0 >> 14][PA_obj[screen][sprite].atr1 >> 14].lx

Get a sprite's length

Parameters:

  | screen | Chose de screen (0 or 1)
  | sprite | Object number in the sprite system

#define PA_GetSpriteLy | ( | screen,
|  | sprite |  | ) | PA_size[PA_obj[screen][sprite].atr0 >> 14][PA_obj[screen][sprite].atr1 >> 14].ly

Get a sprite's height

Parameters:

  | screen | Chose de screen (0 or 1)
  | sprite | Object number in the sprite system

#define PA_GetSpriteMode | ( | screen,
|  | obj |  | ) | ((PA_obj[screen][obj].atr0 & OBJ_MODE) >> 10)

Get the sprite's mode : 0 for normal, 1 for alpha blending, 2 for window

Parameters:

  | screen | Chose de screen (0 or 1)
  | obj | Object number in the sprite system

#define PA_GetSpriteMosaic | ( | screen,
|  | obj |  | ) | ((PA_obj[screen][obj].atr0 & OBJ_MOSAIC) >> 12)

Get the mosaic mode for a given sprite

Parameters:

  | screen | Chose de screen (0 or 1)
  | obj | Object number in the sprite system

#define PA_GetSpritePal | ( | screen,
|  | obj |  | ) | (PA_obj[screen][obj].atr2 >> 12)

Get thepalette used by a sprite

Parameters:

  | screen | Chose de screen (0 or 1)
  | obj | Object number in the sprite system

#define PA_GetSpritePrio | ( | screen,
|  | obj |  | ) | ((PA_obj[screen][obj].atr2 & OBJ_PRIO) >> 10)

Get a sprite's Background priority

Parameters:

  | screen | Chose de screen (0 or 1)
  | obj | Object number in the sprite system

#define PA_GetSpriteVflip | ( | screen,
|  | obj |  | ) | ((PA_obj[screen][obj].atr1 & OBJ_VFLIP) >> 13)

Get the vertical flip state for a given sprite

Parameters:

  | screen | Chose de screen (0 or 1)
  | obj | Object number in the sprite system

#define PA_GetSpriteX | ( | screen,
|  | obj |  | ) | (PA_obj[screen][obj].atr1 & (OBJ_X))

Get the X position of a sprite on screen

Parameters:

  | screen | Chose de screen (0 or 1)
  | obj | Object number in the sprite system

#define PA_GetSpriteY | ( | screen,
|  | obj |  | ) | (PA_obj[screen][obj].atr0 & OBJ_Y)

Get the Y position of a sprite on screen

Parameters:

  | screen | Chose de screen (0 or 1)
  | obj | Object number in the sprite system

#define PA_SetSpriteColors | ( | screen,
|  | sprite,
|  | n_colors |  | ) | PA_obj[screen][sprite].atr0 = (PA_obj[screen][sprite].atr0 & ALL_BUT(N_COLORS)) + ((n_colors) << 13)

Change the sprite's color mode

Parameters:

  | screen | Chose de screen (0 or 1)
  | sprite | Object number in the sprite system
  | n_colors | 0 for 16 colors, 1 for 256

#define PA_SetSpriteDblsize | ( | screen,
|  | obj,
|  | dblsize |  | ) | PA_obj[screen][obj].atr0 = (PA_obj[screen][obj].atr0 & ALL_BUT(DBLSIZE)) + ((dblsize) << 9)

Enable or disable double size for a given sprite

Parameters:

  | screen | Chose de screen (0 or 1)
  | obj | Object number in the sprite system
  | dblsize | 1 to enable doublesize, 0 to disable it...

#define PA_SetSpriteGfx | ( | screen,
|  | obj,
|  | gfx |  | ) | PA_obj[screen][obj].atr2 = (PA_obj[screen][obj].atr2 & ALL_BUT(OBJ_GFX)) + ((gfx) & OBJ_GFX)

Change the gfx used by a sprite

Parameters:

  | screen | Chose de screen (0 or 1)
  | obj | Object number in the sprite system
  | gfx | Gfx number ; you can get one by using PA_CreateGfx or PA_GetSpriteGfx(obj_number);

#define PA_SetSpriteHflip | ( | screen,
|  | obj,
|  | hflip |  | ) | PA_obj[screen][obj].atr1 = (PA_obj[screen][obj].atr1 & ALL_BUT(OBJ_HFLIP)) + ((hflip) << 12)

Enable or disable horizontal flip for a given sprite

Parameters:

  | screen | Chose de screen (0 or 1)
  | obj | Object number in the sprite system
  | hflip | Horizontal flip, 1 to enable, 0 to disable...

#define PA_SetSpriteMode | ( | screen,
|  | sprite,
|  | obj_mode |  | ) | PA_obj[screen][sprite].atr0 = (PA_obj[screen][sprite].atr0 & ALL_BUT(OBJ_MODE)) + ((obj_mode) << 10)

Set the sprite's mode : 0 for normal, 1 for alpha blending, 2 for window

Parameters:

  | screen | Chose de screen (0 or 1)
  | sprite | Object number in the sprite system
  | obj_mode | Object mode : 0 for normal, 1 for alpha blending, 2 for window ; not working yet

#define PA_SetSpriteMosaic | ( | screen,
|  | obj,
|  | mosaic |  | ) | PA_obj[screen][obj].atr0 = (PA_obj[screen][obj].atr0 & ALL_BUT(OBJ_MOSAIC)) + ((mosaic) << 12)

Enable or disable mosaic mode for a given sprite

Parameters:

  | screen | Chose de screen (0 or 1)
  | obj | Object number in the sprite system
  | mosaic | Set mosaic on (1) or off (0)

#define PA_SetSpritePal | ( | screen,
|  | obj,
|  | pal |  | ) | PA_obj[screen][obj].atr2 = (PA_obj[screen][obj].atr2 & ALL_BUT_PAL) + ((pal) << 12)

Set the sprite's palette number

Parameters:

  | screen | Chose de screen (0 or 1)
  | obj | Object number in the sprite system
  | pal | Palette number (0 - 15)

#define PA_SetSpritePrio | ( | screen,
|  | obj,
|  | prio |  | ) | PA_obj[screen][obj].atr2 = (PA_obj[screen][obj].atr2 & ALL_BUT(OBJ_PRIO)) + ((prio) << 10)

Set a sprite's Background priority

Parameters:

  | screen | Chose de screen (0 or 1)
  | obj | Object number in the sprite system
  | prio | Sprite priority : 0 is over background 0, 1 over Bg 1, etc... (0-3)

#define PA_SetSpriteRotDisable | ( | screen,
|  | sprite |  | ) | {PA_obj[screen][sprite].atr0 &= ALL_BUT(OBJ_ROT); PA_obj[screen][sprite].atr1 &= ALL_BUT_ROTSET;}

Stop rotating and zooming a sprite

Parameters:

  | screen | Chose de screen (0 or 1)
  | sprite | Sprite you want to rotate

#define PA_SetSpriteRotEnable | ( | screen,
|  | sprite,
|  | rotset |  | ) | {PA_obj[screen][sprite].atr0 |= OBJ_ROT; PA_obj[screen][sprite].atr1 = (PA_obj[screen][sprite].atr1 & ALL_BUT_ROTSET) + ((rotset) << 9);}

Rotate and zoom a sprite

Parameters:

  | screen | Chose de screen (0 or 1)
  | sprite | Sprite you want to rotate
  | rotset | Rotset you want to give to that sprite (0-31). You can apparently use a rotset for multiple sprites if zoomed/rotated identically...

#define PA_SetSpriteVflip | ( | screen,
|  | obj,
|  | vflip |  | ) | PA_obj[screen][obj].atr1 = (PA_obj[screen][obj].atr1 & ALL_BUT(OBJ_VFLIP)) + ((vflip) << 13)

Enable or disable vertical flip for a given sprite

Parameters:

  | screen | Chose de screen (0 or 1)
  | obj | Object number in the sprite system
  | vflip | Vertical flip, 1 to enable, 0 to disable...

#define PA_SetSpriteX | ( | screen,
|  | obj,
|  | x |  | ) | PA_obj[screen][obj].atr1 = (PA_obj[screen][obj].atr1 & ALL_BUT(OBJ_X)) + ((x) & OBJ_X)

Set the X position of a sprite on screen

Parameters:

  | screen | Chose de screen (0 or 1)
  | obj | Object number in the sprite system
  | x | X position

#define PA_SetSpriteY | ( | screen,
|  | obj,
|  | y |  | ) | PA_obj[screen][obj].atr0 = (PA_obj[screen][obj].atr0 & ALL_BUT(OBJ_Y)) + ((y) & OBJ_Y)

Set the Y position of a sprite on screen

Parameters:

  | screen | Chose de screen (0 or 1)
  | obj | Object number in the sprite system
  | y | Y position

#define PA_UpdateSpriteGfx | ( | screen,
|  | obj_number,
|  | obj_data |  | ) | PA_UpdateGfx(screen, PA_GetSpriteGfx(screen, obj_number), obj_data)

Update the Gfx of a given sprite

Parameters:

  | screen | Chose de screen (0 or 1)
  | obj_number | Object number in the sprite system
  | obj_data | Gfx to load

## Function Documentation

inline void PA_Create16bitSprite | ( | bool | screen,
|  | u8 | obj_number,
|  | void * | obj_data,
|  | u8 | obj_shape,
|  | u8 | obj_size,
|  | s16 | x,
|  | s16 | y
| ) | `[inline]`

Create a 16 bit sprite with it's gfx. This is the simple version of the function. Warning : a 16bit sprite MUST be 128 pixels large, even if you sprite only takes up a small part on the left...

Parameters:

  | screen | Chose de screen (0 or 1)
  | obj_number | Object number you want to use (0-127 for each screen seperately).
  | obj_data | Gfx to load
  | obj_shape | Object shape, from 0 to 2. Use the OBJ_SIZE_32X32 (...) macros for object shape and obj_size...
  | obj_size | Object size. Use the OBJ_SIZE_32X32 (...) macros for object shape and obj_size...
  | x | X position of the sprite
  | y | Y position of the sprite

inline void PA_Create16bitSpriteEx | ( | bool | screen,
|  | u8 | obj_number,
|  | void * | obj_data,
|  | u8 | obj_shape,
|  | u8 | obj_size,
|  | bool | mosaic,
|  | bool | hflip,
|  | bool | vflip,
|  | u8 | prio,
|  | bool | dblsize,
|  | s16 | x,
|  | s16 | y
| ) | `[inline]`

Create a 16 bit sprite with it's gfx. This is the complex version of the function. Warning : a 16bit sprite MUST be 128 pixels large, even if you sprite only takes up a small part on the left...

Parameters:

  | screen | Chose de screen (0 or 1)
  | obj_number | Object number you want to use (0-127 for each screen seperately).
  | obj_data | Gfx to load
  | obj_shape | Object shape, from 0 to 2. Use the OBJ_SIZE_32X32 (...) macros for object shape and obj_size...
  | obj_size | Object size. Use the OBJ_SIZE_32X32 (...) macros for object shape and obj_size...
  | mosaic | Activate Mosaic for the sprite or not. Not yet functionnal either :p
  | hflip | Horizontal flip on or off...
  | vflip | Vertical flip...
  | prio | Sprite priority regarding backgrounds : in front of which background to show it (0-3)
  | dblsize | Double the possible sprite size. Activate only if you are going to rotate and zoom in the sprite
  | x | X position of the sprite
  | y | Y position of the sprite

inline void PA_Create16bitSpriteFromGfx | ( | bool | screen,
|  | u8 | obj_number,
|  | u16 | gfx,
|  | u8 | obj_shape,
|  | u8 | obj_size,
|  | s16 | x,
|  | s16 | y
| ) | `[inline]`

Create a 16 bit sprite using a given gfx.

Parameters:

  | screen | Chose de screen (0 or 1)
  | obj_number | Object number you want to use (0-127 for each screen seperately).
  | gfx | Gfx to use
  | obj_shape | Object shape, from 0 to 2. Use the OBJ_SIZE_32X32 (...) macros for object shape and obj_size...
  | obj_size | Object size. Use the OBJ_SIZE_32X32 (...) macros for object shape and obj_size...
  | x | X position of the sprite
  | y | Y position of the sprite

u16 PA_CreateGfx | ( | bool | screen,
|  | void * | obj_data,
|  | u8 | obj_shape,
|  | u8 | obj_size,
|  | u8 | color_mode
| ) |

Load in mémory a gfx to use later on for a sprite. Returns the gfx's number in memory

Parameters:

  | screen | Chose de screen (0 or 1)
  | obj_data | Gfx to load
  | obj_shape | Object shape, from 0 to 2. Use the OBJ_SIZE_32X32 (...) macros for object shape and obj_size...
  | obj_size | Object size. Use the OBJ_SIZE_32X32 (...) macros for object shape and obj_size...
  | color_mode | 256 or 16 color mode (1 or 0), or 2 for 16bit

inline void PA_CreateSprite | ( | bool | screen,
|  | u8 | obj_number,
|  | void * | obj_data,
|  | u8 | obj_shape,
|  | u8 | obj_size,
|  | u8 | color_mode,
|  | u8 | palette,
|  | s16 | x,
|  | s16 | y
| ) | `[inline]`

Create a sprite with it's gfx. This is the simple version of the function

Parameters:

  | screen | Chose de screen (0 or 1)
  | obj_number | Object number you want to use (0-127 for each screen seperately).
  | obj_data | Gfx to load
  | obj_shape | Object shape, from 0 to 2. Use the OBJ_SIZE_32X32 (...) macros for object shape and obj_size...
  | obj_size | Object size. Use the OBJ_SIZE_32X32 (...) macros for object shape and obj_size...
  | color_mode | 256 or 16 color mode (1 or 0).
  | palette | Palette to use (0-15).
  | x | X position of the sprite
  | y | Y position of the sprite

inline void PA_CreateSpriteEx | ( | bool | screen,
|  | u8 | obj_number,
|  | void * | obj_data,
|  | u8 | obj_shape,
|  | u8 | obj_size,
|  | u8 | color_mode,
|  | u8 | palette,
|  | u8 | obj_mode,
|  | bool | mosaic,
|  | bool | hflip,
|  | bool | vflip,
|  | u8 | prio,
|  | bool | dblsize,
|  | s16 | x,
|  | s16 | y
| ) | `[inline]`

Create a sprite with it's gfx. This is the complex version of the function

Parameters:

  | screen | Chose de screen (0 or 1)
  | obj_number | Object number you want to use (0-127 for each screen seperately).
  | obj_data | Gfx to load
  | obj_shape | Object shape, from 0 to 2. Use the OBJ_SIZE_32X32 (...) macros for object shape and obj_size...
  | obj_size | Object size. Use the OBJ_SIZE_32X32 (...) macros for object shape and obj_size...
  | color_mode | 256 or 16 color mode (1 or 0).
  | palette | Palette to use (0-15).
  | obj_mode | Object mode (normal, transparent, window). Not functionnal yet, please leave to 0 for now
  | mosaic | Activate Mosaic for the sprite or not. Not yet functionnal either :p
  | hflip | Horizontal flip on or off...
  | vflip | Vertical flip...
  | prio | Sprite priority regarding backgrounds : in front of which background to show it (0-3)
  | dblsize | Double the possible sprite size. Activate only if you are going to rotate and zoom in the sprite
  | x | X position of the sprite
  | y | Y position of the sprite

inline void PA_CreateSpriteExFromGfx | ( | bool | screen,
|  | u8 | obj_number,
|  | u16 | obj_gfx,
|  | u8 | obj_shape,
|  | u8 | obj_size,
|  | u8 | color_mode,
|  | u8 | palette,
|  | u8 | obj_mode,
|  | bool | mosaic,
|  | bool | hflip,
|  | bool | vflip,
|  | u8 | prio,
|  | bool | dblsize,
|  | s16 | x,
|  | s16 | y
| ) | `[inline]`

Create a sprite with it's gfx. This is the complex version of the function

Parameters:

  | screen | Chose de screen (0 or 1)
  | obj_number | Object number you want to use (0-127 for each screen seperately).
  | obj_gfx | Memory gfx to use. Get it by using PA_GetSpriteGfx or PA_CreateGfx
  | obj_shape | Object shape, from 0 to 2. Use the OBJ_SIZE_32X32 (...) macros for object shape and obj_size...
  | obj_size | Object size. Use the OBJ_SIZE_32X32 (...) macros for object shape and obj_size...
  | color_mode | 256 or 16 color mode (1 or 0).
  | palette | Palette to use (0-15).
  | obj_mode | Object mode (normal, transparent, window). Not functionnal yet, please leave to 0 for now
  | mosaic | Activate Mosaic for the sprite or not. Not yet functionnal either :p
  | hflip | Horizontal flip on or off...
  | vflip | Vertical flip...
  | prio | Sprite priority regarding backgrounds : in front of which background to show it (0-3)
  | dblsize | Double the possible sprite size. Activate only if you are going to rotate and zoom in the sprite
  | x | X position of the sprite
  | y | Y position of the sprite

inline void PA_CreateSpriteFromGfx | ( | bool | screen,
|  | u8 | obj_number,
|  | u16 | obj_gfx,
|  | u8 | obj_shape,
|  | u8 | obj_size,
|  | u8 | color_mode,
|  | u8 | palette,
|  | s16 | x,
|  | s16 | y
| ) | `[inline]`

Create a sprite with it's gfx. This is the simple version of the function

Parameters:

  | screen | Chose de screen (0 or 1)
  | obj_number | Object number you want to use (0-127 for each screen seperately).
  | obj_gfx | Memory gfx to use. Get it by using PA_GetSpriteGfx or PA_CreateGfx
  | obj_shape | Object shape, from 0 to 2. Use the OBJ_SIZE_32X32 (...) macros for object shape and obj_size...
  | obj_size | Object size. Use the OBJ_SIZE_32X32 (...) macros for object shape and obj_size...
  | color_mode | 256 or 16 color mode (1 or 0).
  | palette | Palette to use (0-15).
  | x | X position of the sprite
  | y | Y position of the sprite

void PA_DeleteGfx | ( | bool | screen,
|  | u16 | obj_gfx
| ) |

Delete a given Gfx. If a sprite uses this gfx, it'll become invisible

Parameters:

  | screen | Chose de screen (0 or 1)
  | obj_gfx | Gfx number in memory

void PA_DeleteSprite | ( | bool | screen,
|  | u8 | obj_number
| ) |

Delete a given sprite. If it is the only one to use it's gfx, it'll be deleted too.

Parameters:

  | screen | Chose de screen (0 or 1)
  | obj_number | Sprite number

inline u16 PA_GetSpriteAnimFrame | ( | bool | screen,
|  | u8 | sprite
| ) | `[inline]`

Returns the current animation frame number

Parameters:

  | screen | Chose de screen (0 or 1)
  | sprite | sprite number in the sprite system

inline u16 PA_GetSpriteAnimSpeed | ( | bool | screen,
|  | u8 | sprite
| ) | `[inline]`

Returns the current animation speed

Parameters:

  | screen | Chose de screen (0 or 1)
  | sprite | sprite number in the sprite system

inline u16 PA_GetSpriteNCycles | ( | bool | screen,
|  | u8 | sprite
| ) | `[inline]`

Returns the current number of animation cycles left

Parameters:

  | screen | Chose de screen (0 or 1)
  | sprite | sprite number in the sprite system

inline u8 PA_GetSpritePixel | ( | bool | screen,
|  | u8 | sprite,
|  | u8 | x,
|  | u8 | y
| ) | `[inline]`

Get a sprite's pixel color. Like PA_GetSpritePixelEx, with less options, but a little slower

Parameters:

  | screen | Chose de screen (0 or 1)
  | sprite | Sprite number in the sprite system
  | x | X coordinate of the pixel
  | y | Y coordinate of the pixel

void PA_InitSpriteDraw | ( | bool | screen,
|  | u8 | sprite
| ) |

Initialise a sprite to be able to draw on it !

Parameters:

  | screen | Chose de screen (0 or 1)
  | sprite | Sprite number in the sprite system

void PA_InitSpriteExtPrio | ( | bool | SpritePrio | ) |

Enable the PAlib sprite priority system. Slower than the normal priority system, but offering 256 levels of priority for the sprites (overrides the sprite number's priority)

Parameters:

  | SpritePrio | 1 for on, 0 for off...

inline void PA_SetRotset | ( | bool | screen,
|  | u8 | rotset,
|  | s16 | angle,
|  | u16 | zoomx,
|  | u16 | zoomy
| ) | `[inline]`

Rotate and zoom a sprite

Parameters:

  | screen | Chose de screen (0 or 1)
  | rotset | Rotset you want to change. To give a sprite a rotset, use PA_SetSpriteRotEnable...
  | angle | Angle, between 0 and 512 (not 360, be carefull)
  | zoomx | Horizontal zoom. 256 is unzoomed, 512 is 2 times smaller, and 128 twice as big... So adjust at will ! :p
  | zoomy | Vertical zoom. 256 is unzoomed, 512 is 2 times smaller, and 128 twice as big... So adjust at will ! :p

inline void PA_SetRotsetNoAngle | ( | bool | screen,
|  | u8 | rotset,
|  | u16 | zoomx,
|  | u16 | zoomy
| ) | `[inline]`

Zoom a sprite without rotating. It's a bit faster than the normal PA_SetRotset function

Parameters:

  | screen | Chose de screen (0 or 1)
  | rotset | Rotset you want to change. To give a sprite a rotset, use PA_SetSpriteRotEnable...
  | zoomx | Horizontal zoom. 256 is unzoomed, 512 is 2 times smaller, and 128 twice as big... So adjust at will ! :p
  | zoomy | Vertical zoom. 256 is unzoomed, 512 is 2 times smaller, and 128 twice as big... So adjust at will ! :p

inline void PA_SetRotsetNoZoom | ( | bool | screen,
|  | u8 | rotset,
|  | s16 | angle
| ) | `[inline]`

Rotate a sprite without zooming. It's a bit faster than the normal PA_SetRotset function

Parameters:

  | screen | Chose de screen (0 or 1)
  | rotset | Rotset you want to change. To give a sprite a rotset, use PA_SetSpriteRotEnable...
  | angle | Angle, between 0 and 512 (not 360, be carefull)

inline void PA_SetSpriteAnim | ( | bool | screen,
|  | u8 | sprite,
|  | s16 | animframe
| ) | `[inline]`

Set the animation frame for a given sprite. Same as PA_SetSpriteAnimEx, but a bit slower and easier to use...

Parameters:

  | screen | Chose de screen (0 or 1)
  | sprite | sprite number in the sprite system
  | animframe | Sprite animation frame (0, 1, 2, etc...)

inline void PA_SetSpriteAnimEx | ( | bool | screen,
|  | u8 | sprite,
|  | u8 | lx,
|  | u8 | ly,
|  | u8 | ncolors,
|  | s16 | animframe
| ) | `[inline]`

Set the animation frame for a given sprite. This function is faster than the normal PA_SetSpriteAnim because it doesn't have to lookup the sprite dimensions...

Parameters:

  | screen | Chose de screen (0 or 1)
  | sprite | sprite number in the sprite system
  | lx | Sprite width (8, 16, 32, 64)
  | ly | Sprite height (8, 16, 32, 64)
  | ncolors | Sprite color mode (0 for 16 colors, 1 for 256)
  | animframe | Sprite animation frame (0, 1, 2, etc...)

inline void PA_SetSpriteAnimFrame | ( | bool | screen,
|  | u8 | sprite,
|  | u16 | frame
| ) | `[inline]`

Set the current animation frame number

Parameters:

  | screen | Chose de screen (0 or 1)
  | sprite | sprite number in the sprite system
  | frame | Frame number to use...

inline void PA_SetSpriteAnimSpeed | ( | bool | screen,
|  | u8 | sprite,
|  | s16 | speed
| ) | `[inline]`

Set the current animation speed

Parameters:

  | screen | Chose de screen (0 or 1)
  | sprite | sprite number in the sprite system
  | speed | Speed, in fps...

inline void PA_SetSpriteNCycles | ( | bool | screen,
|  | u8 | sprite,
|  | s16 | NCycles
| ) | `[inline]`

Set the current animation cycles left (-1 for inifinite loop)

Parameters:

  | screen | Chose de screen (0 or 1)
  | sprite | sprite number in the sprite system
  | NCycles | Number of cycles

inline void PA_SetSpritePixel | ( | bool | screen,
|  | u8 | sprite,
|  | u8 | x,
|  | u8 | y,
|  | u8 | color
| ) | `[inline]`

Set a sprite's pixel to a given palette color. Like PA_SetSpritePixelEx, with less options, but a little slower

Parameters:

  | screen | Chose de screen (0 or 1)
  | sprite | Sprite number in the sprite system
  | x | X coordinate of the pixel to change
  | y | Y coordinate of the pixel to change
  | color | New palette color to put

inline void PA_SetSpriteXY | ( | bool | screen,
|  | u8 | sprite,
|  | s16 | x,
|  | s16 | y
| ) | `[inline]`

Set the X and Y position of a sprite on screen

Parameters:

  | screen | Chose de screen (0 or 1)
  | sprite | sprite number in the sprite system
  | x | X position
  | y | X position

inline u16 PA_SpriteAnimPause | ( | bool | screen,
|  | u8 | sprite,
|  | bool | pause
| ) | `[inline]`

Pause or UnPause a sprite animation

Parameters:

  | screen | Chose de screen (0 or 1)
  | sprite | sprite number in the sprite system
  | pause | 1 for pause, 0 for unpause

inline void PA_StartSpriteAnim | ( | bool | screen,
|  | u8 | sprite,
|  | s16 | firstframe,
|  | s16 | lastframe,
|  | s16 | speed
| ) | `[inline]`

Start a sprite animation. Once started, it continues on and on by itself until you stop it !

Parameters:

  | screen | Chose de screen (0 or 1)
  | sprite | sprite number in the sprite system
  | firstframe | First frame of the animation sequence, most of the time 0...
  | lastframe | Last frame to be displayed. When it gets there, it loops back to the first frame
  | speed | Speed, in frames per second. So speed 1 would mean 1 image per second, so 1 image every game frame

void PA_StartSpriteAnimEx | ( | bool | screen,
|  | u8 | sprite,
|  | s16 | firstframe,
|  | s16 | lastframe,
|  | s16 | speed,
|  | u8 | type,
|  | s16 | ncycles
| ) |

Start a sprite animation. Once started, it continues on and on by itself until you stop it !

Parameters:

  | screen | Chose de screen (0 or 1)
  | sprite | sprite number in the sprite system
  | firstframe | First frame of the animation sequence, most of the time 0...
  | lastframe | Last frame to be displayed. When it gets there, it loops back to the first frame
  | speed | Speed, in frames per second. So speed 1 would mean 1 image per second, so 1 image every game frame
  | type | Defines how you want it to loop. ANIM_LOOP (0) for a normal loop, ANIM_UPDOWN (1) for back and forth animation.
  | ncycles | Number of animation cycles before stopping. If using ANIM_UPDOWN, it takes 2 cycles to come back to the original image

inline void PA_StopSpriteAnim | ( | bool | screen,
|  | u8 | sprite
| ) | `[inline]`

Stop a sprite animation

Parameters:

  | screen | Chose de screen (0 or 1)
  | sprite | sprite number in the sprite system

inline void PA_UpdateGfx | ( | bool | screen,
|  | u16 | gfx_number,
|  | void * | obj_data
| ) | `[inline]`

Update a given Gfx

Parameters:

  | screen | Chose de screen (0 or 1)
  | gfx_number | Gfx number in memory
  | obj_data | Gfx to load

inline void PA_UpdateGfxAndMem | ( | bool | screen,
|  | u8 | gfx_number,
|  | void * | obj_data
| ) | `[inline]`

Update the Gfx of a given sprite and updates the PAlib animation pointer... Only for advanced users

Parameters:

  | screen | Chose de screen (0 or 1)
  | gfx_number | Gfx number in memory
  | obj_data | Gfx to load