PAlib
Macros | Functions
Sprite system

Macros

#define PA_UpdateOAM0()   dmaCopyWords(3, (void*)PA_obj, (void*)OAM0, 256 * 4)
 Update the sprite infos for screen 0 only. Do this in the VBL.
 
#define PA_UpdateOAM1()   dmaCopyWords(3, (void*)PA_obj + 256, (void*)OAM1, 256 * 4)
 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)   do{PA_obj[screen][sprite].atr0 |= OBJ_ROT; PA_obj[screen][sprite].atr1 = (PA_obj[screen][sprite].atr1 & ALL_BUT_ROTSET) + ((rotset) << 9);}while(0)
 Rotate and zoom a sprite.
 
#define PA_SetSpriteRotDisable(screen, sprite)   do{PA_obj[screen][sprite].atr0 &= ALL_BUT(OBJ_ROT); PA_obj[screen][sprite].atr1 &= ALL_BUT_ROTSET;}while(0)
 Stop rotating and zooming a sprite.
 
#define PA_SetSpriteX(screen, obj, x)   PA_obj[screen][obj].atr1 = (PA_obj[screen][obj].atr1 & ALL_BUT(PA_OBJ_X)) + ((x) & PA_OBJ_X)
 Set the X position of a sprite on screen.
 
#define PA_GetSpriteX(screen, obj)   (PA_obj[screen][obj].atr1 & (PA_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(PA_OBJ_Y)) + ((y) & PA_OBJ_Y)
 Set the Y position of a sprite on screen.
 
#define PA_GetSpriteY(screen, obj)   (PA_obj[screen][obj].atr0 & PA_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)   do{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)];}while(0)
 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 (u8 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...
 
static void PA_CreateSprite (u8 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.
 
static void PA_CreateSpriteEx (u8 screen, u8 obj_number, void *obj_data, u8 obj_shape, u8 obj_size, u8 color_mode, u8 palette, u8 obj_mode, u8 mosaic, u8 hflip, u8 vflip, u8 prio, u8 dblsize, s16 x, s16 y)
 Create a sprite with it's gfx. This is the complex version of the function.
 
static void PA_Create16bitSpriteEx (u8 screen, u8 obj_number, void *obj_data, u8 obj_shape, u8 obj_size, u8 mosaic, u8 hflip, u8 vflip, u8 prio, u8 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...
 
static void PA_Create16bitSpriteFromGfx (u8 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.
 
static void PA_Create16bitSprite (u8 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...
 
static void PA_CreateSpriteFromGfx (u8 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.
 
static void PA_CreateSpriteExFromGfx (u8 screen, u8 obj_number, u16 obj_gfx, u8 obj_shape, u8 obj_size, u8 color_mode, u8 palette, u8 obj_mode, u8 mosaic, u8 hflip, u8 vflip, u8 prio, u8 dblsize, s16 x, s16 y)
 Create a sprite with it's gfx. This is the complex version of the function.
 
static void PA_UpdateGfx (u8 screen, u16 gfx_number, void *obj_data)
 Update a given Gfx.
 
static void PA_UpdateGfxAndMem (u8 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 (u8 screen, u16 obj_gfx)
 Delete a given Gfx. If a sprite uses this gfx, it'll become invisible.
 
void PA_DeleteSprite (u8 screen, u8 obj_number)
 Delete a given sprite. If it is the only one to use it's gfx, it'll be deleted too.
 
static void PA_SetRotset (u8 screen, u8 rotset, s16 angle, u16 zoomx, u16 zoomy)
 Rotate and zoom a sprite.
 
static void PA_SetRotsetNoZoom (u8 screen, u8 rotset, s16 angle)
 Rotate a sprite without zooming. It's a bit faster than the normal PA_SetRotset function.
 
static void PA_SetRotsetNoAngle (u8 screen, u8 rotset, u16 zoomx, u16 zoomy)
 Zoom a sprite without rotating. It's a bit faster than the normal PA_SetRotset function.
 
static void PA_SetSpriteXY (u8 screen, u8 sprite, s16 x, s16 y)
 Set the X and Y position of a sprite on screen.
 
static void PA_Set16bitSpriteAlpha (u8 screen, u8 sprite, u8 alpha)
 Set the X position of a sprite on screen.
 
static void PA_SetSpriteAnimEx (u8 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...
 
static void PA_SetSpriteAnim (u8 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 (u8 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 !
 
static void PA_StartSpriteAnim (u8 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 !
 
static void PA_StopSpriteAnim (u8 screen, u8 sprite)
 Stop a sprite animation.
 
static void PA_SetSpriteAnimFrame (u8 screen, u8 sprite, u16 frame)
 Set the current animation frame number.
 
static u16 PA_GetSpriteAnimFrame (u8 screen, u8 sprite)
 Returns the current animation frame number.
 
static void PA_SetSpriteAnimSpeed (u8 screen, u8 sprite, s16 speed)
 Set the current animation speed.
 
static u16 PA_GetSpriteAnimSpeed (u8 screen, u8 sprite)
 Returns the current animation speed.
 
static void PA_SetSpriteNCycles (u8 screen, u8 sprite, s32 NCycles)
 Set the current animation cycles left (-1 for inifinite loop)
 
static s32 PA_GetSpriteNCycles (u8 screen, u8 sprite)
 Returns the current number of animation cycles left.
 
static void PA_SpriteAnimPause (u8 screen, u8 sprite, u8 pause)
 Pause or UnPause a sprite animation.
 
static void PA_SetSpritePixel (u8 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.
 
static u8 PA_GetSpritePixel (u8 screen, u8 sprite, u8 x, u8 y)
 Get a sprite's pixel color. Like PA_GetSpritePixelEx, with less options, but a little slower.
 
static u8 PA_GetSprite16cPixel (u8 screen, u8 sprite, u8 x, u8 y)
 Get a 16 color sprite's pixel color.
 
void PA_InitSpriteDraw (u8 screen, u8 sprite)
 Initialise a sprite to be able to draw on it !
 
static void PA_InitAllSpriteDraw (void)
 Initialise all the onscreen sprites to draw on them.
 
void PA_InitSpriteExtPrio (u8 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)
 

Detailed Description

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

Macro Definition Documentation

◆ PA_UpdateSpriteGfx

#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
screenChose de screen (0 or 1)
obj_numberObject number in the sprite system
obj_dataGfx to load

◆ PA_SetSpriteRotEnable

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

Rotate and zoom a sprite.

Parameters
screenChose de screen (0 or 1)
spriteSprite you want to rotate
rotsetRotset you want to give to that sprite (0-31). You can apparently use a rotset for multiple sprites if zoomed/rotated identically...

◆ PA_SetSpriteRotDisable

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

Stop rotating and zooming a sprite.

Parameters
screenChose de screen (0 or 1)
spriteSprite you want to rotate

◆ PA_SetSpriteX

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

Set the X position of a sprite on screen.

Parameters
screenChose de screen (0 or 1)
objObject number in the sprite system
xX position

◆ PA_GetSpriteX

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

Get the X position of a sprite on screen.

Parameters
screenChose de screen (0 or 1)
objObject number in the sprite system

◆ PA_SetSpriteY

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

Set the Y position of a sprite on screen.

Parameters
screenChose de screen (0 or 1)
objObject number in the sprite system
yY position

◆ PA_GetSpriteY

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

Get the Y position of a sprite on screen.

Parameters
screenChose de screen (0 or 1)
objObject number in the sprite system

◆ PA_SetSpritePal

#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
screenChose de screen (0 or 1)
objObject number in the sprite system
palPalette number (0 - 15)

◆ PA_GetSpritePal

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

Get thepalette used by a sprite.

Parameters
screenChose de screen (0 or 1)
objObject number in the sprite system

◆ PA_SetSpriteDblsize

#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
screenChose de screen (0 or 1)
objObject number in the sprite system
dblsize1 to enable doublesize, 0 to disable it...

◆ PA_GetSpriteDblsize

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

Get the double size state for a given sprite.

Parameters
screenChose de screen (0 or 1)
objObject number in the sprite system

◆ PA_SetSpriteColors

#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
screenChose de screen (0 or 1)
spriteObject number in the sprite system
n_colors0 for 16 colors, 1 for 256

◆ PA_GetSpriteColors

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

Get a sprite's color mode.

Parameters
screenChose de screen (0 or 1)
spriteObject number in the sprite system

◆ PA_SetSpriteMode

#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
screenChose de screen (0 or 1)
spriteObject number in the sprite system
obj_modeObject mode : 0 for normal, 1 for alpha blending, 2 for window ; not working yet

◆ PA_GetSpriteMode

#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
screenChose de screen (0 or 1)
objObject number in the sprite system

◆ PA_SetSpriteMosaic

#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
screenChose de screen (0 or 1)
objObject number in the sprite system
mosaicSet mosaic on (1) or off (0)

◆ PA_GetSpriteMosaic

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

Get the mosaic mode for a given sprite.

Parameters
screenChose de screen (0 or 1)
objObject number in the sprite system

◆ PA_SetSpriteHflip

#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
screenChose de screen (0 or 1)
objObject number in the sprite system
hflipHorizontal flip, 1 to enable, 0 to disable...

◆ PA_GetSpriteHflip

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

Get the horizontal flip state for a given sprite.

Parameters
screenChose de screen (0 or 1)
objObject number in the sprite system

◆ PA_SetSpriteVflip

#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
screenChose de screen (0 or 1)
objObject number in the sprite system
vflipVertical flip, 1 to enable, 0 to disable...

◆ PA_GetSpriteVflip

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

Get the vertical flip state for a given sprite.

Parameters
screenChose de screen (0 or 1)
objObject number in the sprite system

◆ PA_SetSpriteGfx

#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
screenChose de screen (0 or 1)
objObject number in the sprite system
gfxGfx number ; you can get one by using PA_CreateGfx or PA_GetSpriteGfx(obj_number);

◆ PA_GetSpriteGfx

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

Get the gfx used by a sprite.

Parameters
screenChose de screen (0 or 1)
objObject number in the sprite system

◆ PA_SetSpritePrio

#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
screenChose de screen (0 or 1)
objObject number in the sprite system
prioSprite priority : 0 is over background 0, 1 over Bg 1, etc... (0-3)

◆ PA_GetSpritePrio

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

Get a sprite's Background priority.

Parameters
screenChose de screen (0 or 1)
objObject number in the sprite system

◆ PA_GetSpriteLx

#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
screenChose de screen (0 or 1)
spriteObject number in the sprite system

◆ PA_GetSpriteLy

#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
screenChose de screen (0 or 1)
spriteObject number in the sprite system

◆ PA_CloneSprite

#define PA_CloneSprite (   screen,
  obj,
  target 
)    do{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)];}while(0)

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

Parameters
screenChose de screen (0 or 1)
objObject number in the sprite system
targetTarget sprite to clone

Function Documentation

◆ PA_CreateGfx()

u16 PA_CreateGfx ( u8  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
screenChose de screen (0 or 1)
obj_dataGfx to load
obj_shapeObject shape, from 0 to 2. Use the OBJ_SIZE_32X32 (...) macros for object shape and obj_size...
obj_sizeObject size. Use the OBJ_SIZE_32X32 (...) macros for object shape and obj_size...
color_mode256 or 16 color mode (1 or 0), or 2 for 16bit

◆ PA_CreateSprite()

static inline void PA_CreateSprite ( u8  screen,
u8  obj_number,
void *  obj_data,
u8  obj_shape,
u8  obj_size,
u8  color_mode,
u8  palette,
s16  x,
s16  y 
)
inlinestatic

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

Parameters
screenChose de screen (0 or 1)
obj_numberObject number you want to use (0-127 for each screen seperately).
obj_dataGfx to load
obj_shapeObject shape, from 0 to 2. Use the OBJ_SIZE_32X32 (...) macros for object shape and obj_size...
obj_sizeObject size. Use the OBJ_SIZE_32X32 (...) macros for object shape and obj_size...
color_mode256 or 16 color mode (1 or 0).
palettePalette to use (0-15).
xX position of the sprite
yY position of the sprite

◆ PA_CreateSpriteEx()

static inline void PA_CreateSpriteEx ( u8  screen,
u8  obj_number,
void *  obj_data,
u8  obj_shape,
u8  obj_size,
u8  color_mode,
u8  palette,
u8  obj_mode,
u8  mosaic,
u8  hflip,
u8  vflip,
u8  prio,
u8  dblsize,
s16  x,
s16  y 
)
inlinestatic

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

Parameters
screenChose de screen (0 or 1)
obj_numberObject number you want to use (0-127 for each screen seperately).
obj_dataGfx to load
obj_shapeObject shape, from 0 to 2. Use the OBJ_SIZE_32X32 (...) macros for object shape and obj_size...
obj_sizeObject size. Use the OBJ_SIZE_32X32 (...) macros for object shape and obj_size...
color_mode256 or 16 color mode (1 or 0).
palettePalette to use (0-15).
obj_modeObject mode (normal, transparent, window). Not functionnal yet, please leave to 0 for now
mosaicActivate Mosaic for the sprite or not. Not yet functionnal either :p
hflipHorizontal flip on or off...
vflipVertical flip...
prioSprite priority regarding backgrounds : in front of which background to show it (0-3)
dblsizeDouble the possible sprite size. Activate only if you are going to rotate and zoom in the sprite
xX position of the sprite
yY position of the sprite

◆ PA_Create16bitSpriteEx()

static inline void PA_Create16bitSpriteEx ( u8  screen,
u8  obj_number,
void *  obj_data,
u8  obj_shape,
u8  obj_size,
u8  mosaic,
u8  hflip,
u8  vflip,
u8  prio,
u8  dblsize,
s16  x,
s16  y 
)
inlinestatic

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
screenChose de screen (0 or 1)
obj_numberObject number you want to use (0-127 for each screen seperately).
obj_dataGfx to load
obj_shapeObject shape, from 0 to 2. Use the OBJ_SIZE_32X32 (...) macros for object shape and obj_size...
obj_sizeObject size. Use the OBJ_SIZE_32X32 (...) macros for object shape and obj_size...
mosaicActivate Mosaic for the sprite or not. Not yet functionnal either :p
hflipHorizontal flip on or off...
vflipVertical flip...
prioSprite priority regarding backgrounds : in front of which background to show it (0-3)
dblsizeDouble the possible sprite size. Activate only if you are going to rotate and zoom in the sprite
xX position of the sprite
yY position of the sprite

◆ PA_Create16bitSpriteFromGfx()

static inline void PA_Create16bitSpriteFromGfx ( u8  screen,
u8  obj_number,
u16  gfx,
u8  obj_shape,
u8  obj_size,
s16  x,
s16  y 
)
inlinestatic

Create a 16 bit sprite using a given gfx.

Parameters
screenChose de screen (0 or 1)
obj_numberObject number you want to use (0-127 for each screen seperately).
gfxGfx to use
obj_shapeObject shape, from 0 to 2. Use the OBJ_SIZE_32X32 (...) macros for object shape and obj_size...
obj_sizeObject size. Use the OBJ_SIZE_32X32 (...) macros for object shape and obj_size...
xX position of the sprite
yY position of the sprite

◆ PA_Create16bitSprite()

static inline void PA_Create16bitSprite ( u8  screen,
u8  obj_number,
void *  obj_data,
u8  obj_shape,
u8  obj_size,
s16  x,
s16  y 
)
inlinestatic

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
screenChose de screen (0 or 1)
obj_numberObject number you want to use (0-127 for each screen seperately).
obj_dataGfx to load
obj_shapeObject shape, from 0 to 2. Use the OBJ_SIZE_32X32 (...) macros for object shape and obj_size...
obj_sizeObject size. Use the OBJ_SIZE_32X32 (...) macros for object shape and obj_size...
xX position of the sprite
yY position of the sprite

◆ PA_CreateSpriteFromGfx()

static inline void PA_CreateSpriteFromGfx ( u8  screen,
u8  obj_number,
u16  obj_gfx,
u8  obj_shape,
u8  obj_size,
u8  color_mode,
u8  palette,
s16  x,
s16  y 
)
inlinestatic

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

Parameters
screenChose de screen (0 or 1)
obj_numberObject number you want to use (0-127 for each screen seperately).
obj_gfxMemory gfx to use. Get it by using PA_GetSpriteGfx or PA_CreateGfx
obj_shapeObject shape, from 0 to 2. Use the OBJ_SIZE_32X32 (...) macros for object shape and obj_size...
obj_sizeObject size. Use the OBJ_SIZE_32X32 (...) macros for object shape and obj_size...
color_mode256 or 16 color mode (1 or 0).
palettePalette to use (0-15).
xX position of the sprite
yY position of the sprite

◆ PA_CreateSpriteExFromGfx()

static inline void PA_CreateSpriteExFromGfx ( u8  screen,
u8  obj_number,
u16  obj_gfx,
u8  obj_shape,
u8  obj_size,
u8  color_mode,
u8  palette,
u8  obj_mode,
u8  mosaic,
u8  hflip,
u8  vflip,
u8  prio,
u8  dblsize,
s16  x,
s16  y 
)
inlinestatic

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

Parameters
screenChose de screen (0 or 1)
obj_numberObject number you want to use (0-127 for each screen seperately).
obj_gfxMemory gfx to use. Get it by using PA_GetSpriteGfx or PA_CreateGfx
obj_shapeObject shape, from 0 to 2. Use the OBJ_SIZE_32X32 (...) macros for object shape and obj_size...
obj_sizeObject size. Use the OBJ_SIZE_32X32 (...) macros for object shape and obj_size...
color_mode256 or 16 color mode (1 or 0).
palettePalette to use (0-15).
obj_modeObject mode (normal, transparent, window). Not functionnal yet, please leave to 0 for now
mosaicActivate Mosaic for the sprite or not. Not yet functionnal either :p
hflipHorizontal flip on or off...
vflipVertical flip...
prioSprite priority regarding backgrounds : in front of which background to show it (0-3)
dblsizeDouble the possible sprite size. Activate only if you are going to rotate and zoom in the sprite
xX position of the sprite
yY position of the sprite

◆ PA_UpdateGfx()

static inline void PA_UpdateGfx ( u8  screen,
u16  gfx_number,
void *  obj_data 
)
inlinestatic

Update a given Gfx.

Parameters
screenChose de screen (0 or 1)
gfx_numberGfx number in memory
obj_dataGfx to load

◆ PA_UpdateGfxAndMem()

static inline void PA_UpdateGfxAndMem ( u8  screen,
u8  gfx_number,
void *  obj_data 
)
inlinestatic

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

Parameters
screenChose de screen (0 or 1)
gfx_numberGfx number in memory
obj_dataGfx to load

◆ PA_DeleteGfx()

void PA_DeleteGfx ( u8  screen,
u16  obj_gfx 
)

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

Parameters
screenChose de screen (0 or 1)
obj_gfxGfx number in memory

◆ PA_DeleteSprite()

void PA_DeleteSprite ( u8  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
screenChose de screen (0 or 1)
obj_numberSprite number

◆ PA_SetRotset()

static inline void PA_SetRotset ( u8  screen,
u8  rotset,
s16  angle,
u16  zoomx,
u16  zoomy 
)
inlinestatic

Rotate and zoom a sprite.

Parameters
screenChose de screen (0 or 1)
rotsetRotset you want to change. To give a sprite a rotset, use PA_SetSpriteRotEnable...
angleAngle, between 0 and 512 (not 360, be carefull)
zoomxHorizontal zoom. 256 is unzoomed, 512 is 2 times smaller, and 128 twice as big... So adjust at will ! :p
zoomyVertical zoom. 256 is unzoomed, 512 is 2 times smaller, and 128 twice as big... So adjust at will ! :p

◆ PA_SetRotsetNoZoom()

static inline void PA_SetRotsetNoZoom ( u8  screen,
u8  rotset,
s16  angle 
)
inlinestatic

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

Parameters
screenChose de screen (0 or 1)
rotsetRotset you want to change. To give a sprite a rotset, use PA_SetSpriteRotEnable...
angleAngle, between 0 and 512 (not 360, be carefull)

◆ PA_SetRotsetNoAngle()

static inline void PA_SetRotsetNoAngle ( u8  screen,
u8  rotset,
u16  zoomx,
u16  zoomy 
)
inlinestatic

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

Parameters
screenChose de screen (0 or 1)
rotsetRotset you want to change. To give a sprite a rotset, use PA_SetSpriteRotEnable...
zoomxHorizontal zoom. 256 is unzoomed, 512 is 2 times smaller, and 128 twice as big... So adjust at will ! :p
zoomyVertical zoom. 256 is unzoomed, 512 is 2 times smaller, and 128 twice as big... So adjust at will ! :p

◆ PA_SetSpriteXY()

static inline void PA_SetSpriteXY ( u8  screen,
u8  sprite,
s16  x,
s16  y 
)
inlinestatic

Set the X and Y position of a sprite on screen.

Parameters
screenChose de screen (0 or 1)
spritesprite number in the sprite system
xX position
yX position

◆ PA_Set16bitSpriteAlpha()

static inline void PA_Set16bitSpriteAlpha ( u8  screen,
u8  sprite,
u8  alpha 
)
inlinestatic

Set the X position of a sprite on screen.

Parameters
screenChose de screen (0 or 1)
spriteObject number in the sprite system, only for 16bit sprites
alphaAlpha parameter, 0-15

◆ PA_SetSpriteAnimEx()

static inline void PA_SetSpriteAnimEx ( u8  screen,
u8  sprite,
u8  lx,
u8  ly,
u8  ncolors,
s16  animframe 
)
inlinestatic

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
screenChose de screen (0 or 1)
spritesprite number in the sprite system
lxSprite width (8, 16, 32, 64)
lySprite height (8, 16, 32, 64)
ncolorsSprite color mode (0 for 16 colors, 1 for 256)
animframeSprite animation frame (0, 1, 2, etc...)

◆ PA_SetSpriteAnim()

static inline void PA_SetSpriteAnim ( u8  screen,
u8  sprite,
s16  animframe 
)
inlinestatic

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

Parameters
screenChose de screen (0 or 1)
spritesprite number in the sprite system
animframeSprite animation frame (0, 1, 2, etc...)

◆ PA_StartSpriteAnimEx()

void PA_StartSpriteAnimEx ( u8  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
screenChose de screen (0 or 1)
spritesprite number in the sprite system
firstframeFirst frame of the animation sequence, most of the time 0...
lastframeLast frame to be displayed. When it gets there, it loops back to the first frame
speedSpeed, in frames per second. So speed 1 would mean 1 image per second, so 1 image every game frame
typeDefines how you want it to loop. ANIM_LOOP (0) for a normal loop, ANIM_UPDOWN (1) for back and forth animation.
ncyclesNumber of animation cycles before stopping. If using ANIM_UPDOWN, it takes 2 cycles to come back to the original image

◆ PA_StartSpriteAnim()

static inline void PA_StartSpriteAnim ( u8  screen,
u8  sprite,
s16  firstframe,
s16  lastframe,
s16  speed 
)
inlinestatic

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

Parameters
screenChose de screen (0 or 1)
spritesprite number in the sprite system
firstframeFirst frame of the animation sequence, most of the time 0...
lastframeLast frame to be displayed. When it gets there, it loops back to the first frame
speedSpeed, in frames per second. So speed 1 would mean 1 image per second, so 1 image every game frame

◆ PA_StopSpriteAnim()

static inline void PA_StopSpriteAnim ( u8  screen,
u8  sprite 
)
inlinestatic

Stop a sprite animation.

Parameters
screenChose de screen (0 or 1)
spritesprite number in the sprite system

◆ PA_SetSpriteAnimFrame()

static inline void PA_SetSpriteAnimFrame ( u8  screen,
u8  sprite,
u16  frame 
)
inlinestatic

Set the current animation frame number.

Parameters
screenChose de screen (0 or 1)
spritesprite number in the sprite system
frameFrame number to use...

◆ PA_GetSpriteAnimFrame()

static inline u16 PA_GetSpriteAnimFrame ( u8  screen,
u8  sprite 
)
inlinestatic

Returns the current animation frame number.

Parameters
screenChose de screen (0 or 1)
spritesprite number in the sprite system

◆ PA_SetSpriteAnimSpeed()

static inline void PA_SetSpriteAnimSpeed ( u8  screen,
u8  sprite,
s16  speed 
)
inlinestatic

Set the current animation speed.

Parameters
screenChose de screen (0 or 1)
spritesprite number in the sprite system
speedSpeed, in fps...

◆ PA_GetSpriteAnimSpeed()

static inline u16 PA_GetSpriteAnimSpeed ( u8  screen,
u8  sprite 
)
inlinestatic

Returns the current animation speed.

Parameters
screenChose de screen (0 or 1)
spritesprite number in the sprite system

◆ PA_SetSpriteNCycles()

static inline void PA_SetSpriteNCycles ( u8  screen,
u8  sprite,
s32  NCycles 
)
inlinestatic

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

Parameters
screenChose de screen (0 or 1)
spritesprite number in the sprite system
NCyclesNumber of cycles

◆ PA_GetSpriteNCycles()

static inline s32 PA_GetSpriteNCycles ( u8  screen,
u8  sprite 
)
inlinestatic

Returns the current number of animation cycles left.

Parameters
screenChose de screen (0 or 1)
spritesprite number in the sprite system

◆ PA_SpriteAnimPause()

static inline u16 PA_SpriteAnimPause ( u8  screen,
u8  sprite,
u8  pause 
)
inlinestatic

Pause or UnPause a sprite animation.

Parameters
screenChose de screen (0 or 1)
spritesprite number in the sprite system
pause1 for pause, 0 for unpause

◆ PA_SetSpritePixel()

static inline void PA_SetSpritePixel ( u8  screen,
u8  sprite,
u8  x,
u8  y,
u8  color 
)
inlinestatic

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

Parameters
screenChose de screen (0 or 1)
spriteSprite number in the sprite system
xX coordinate of the pixel to change
yY coordinate of the pixel to change
colorNew palette color to put

◆ PA_GetSpritePixel()

static inline u8 PA_GetSpritePixel ( u8  screen,
u8  sprite,
u8  x,
u8  y 
)
inlinestatic

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

Parameters
screenChose de screen (0 or 1)
spriteSprite number in the sprite system
xX coordinate of the pixel
yY coordinate of the pixel

◆ PA_GetSprite16cPixel()

static inline u8 PA_GetSprite16cPixel ( u8  screen,
u8  sprite,
u8  x,
u8  y 
)
inlinestatic

Get a 16 color sprite's pixel color.

Parameters
screenChose de screen (0 or 1)
spriteSprite number in the sprite system
xX coordinate of the pixel
yY coordinate of the pixel

◆ PA_InitSpriteDraw()

void PA_InitSpriteDraw ( u8  screen,
u8  sprite 
)

Initialise a sprite to be able to draw on it !

Parameters
screenChose de screen (0 or 1)
spriteSprite number in the sprite system

◆ PA_InitSpriteExtPrio()

void PA_InitSpriteExtPrio ( u8  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
SpritePrio1 for on, 0 for off...