PAlib
Functions
Sprite system for Dual Screen

Functions

static void PA_SetScreenSpace (s16 ScreenSpace)
 Set the space between the 2 screens for the Dual Fonctions. 48 pixels by default.
 
static void PA_DualSetSpriteX (u8 obj, s16 x)
 Set the X position of a sprite on screen.
 
static void PA_DualSetSpriteY (u8 obj, s16 y)
 Set the Y position of a sprite on screen.
 
static void PA_DualSetSpriteXY (u8 sprite, s16 x, s16 y)
 Set the X and Y position of a sprite on screen.
 
static void PA_DualCreateSprite (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, on 2 screens.
 
static void PA_DualCreateSpriteEx (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_DualCreate16bitSpriteEx (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_DualCreate16bitSprite (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_DualCreateSpriteFromGfx (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_DualCreateSpriteExFromGfx (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_DualUpdateSpriteGfx (u8 obj_number, void *obj_data)
 Update the Gfx of a given sprite.
 
static void PA_DualUpdateGfx (u16 gfx_number, void *obj_data)
 Update the Gfx of a given sprite.
 
static void PA_DualDeleteSprite (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_DualSetSpriteRotEnable (u8 sprite, u8 rotset)
 Rotate and zoom a sprite.
 
static void PA_DualSetSpriteRotDisable (u8 sprite)
 Stop rotating and zooming a sprite.
 
static void PA_DualSetRotset (u8 rotset, s16 angle, u16 zoomx, u16 zoomy)
 Rotate and zoom a sprite.
 
static void PA_DualSetRotsetNoZoom (u8 rotset, s16 angle)
 Rotate a sprite without zooming. It's a bit faster than the normal PA_SetRotset function.
 
static void PA_DualSetRotsetNoAngle (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_DualSetSpritePal (u8 obj, u8 pal)
 Set the color palette used by a sprite.
 
static void PA_DualSetSpriteDblsize (u8 obj, u8 dblsize)
 Enable or disable double size for a given sprite.
 
static void PA_DualSetSpriteColors (u8 sprite, u8 n_colors)
 Change the sprite's color mode.
 
static void PA_DualSetSpriteMode (u8 sprite, u8 obj_mode)
 Set the sprite's mode : 0 for normal, 1 for alpha blending, 2 for window.
 
static void PA_DualSetSpriteMosaic (u8 obj, u8 mosaic)
 Enable or disable mosaic mode for a given sprite.
 
static void PA_DualSetSpriteHflip (u8 obj, u8 hflip)
 Enable or disable horizontal flip for a given sprite.
 
static void PA_DualSetSpriteVflip (u8 obj, u8 vflip)
 Enable or disable vertical flip for a given sprite.
 
static void PA_DualSetSpriteGfx (u8 obj, u16 *gfx)
 Change the gfx used by a sprite.
 
static void PA_DualSetSpritePrio (u8 obj, u8 prio)
 Set a sprite's Background priority.
 
static void PA_DualCloneSprite (u8 obj, u8 target)
 Clone a sprite. Works only for sprites on the same screen.
 
static void PA_DualSetSpriteAnimEx (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_DualSetSpriteAnim (u8 sprite, s16 animframe)
 Set the animation frame for a given sprite. Same as PA_SetSpriteAnimEx, but a bit slower and easier to use...
 
static void PA_DualStartSpriteAnimEx (u8 sprite, s16 firstframe, s16 lastframe, s16 speed, u8 type, s16 ncycles)
 Start a sprite animation for DualSprites. Once started, it continues on and on by itself until you stop it !
 
static void PA_DualStartSpriteAnim (u8 sprite, s16 firstframe, s16 lastframe, s16 speed)
 Start a sprite animation for DualSprite. Once started, it continues on and on by itself until you stop it !
 
static void PA_DualStopSpriteAnim (u8 sprite)
 Stop a sprite animation for DualSprites.
 
static void PA_DualSetSpriteAnimFrame (u8 sprite, u16 frame)
 Set the current animation frame number for DualSprites.
 
static u16 PA_DualGetSpriteAnimFrame (u8 sprite)
 Returns the current animation frame number for DualSprites.
 
static void PA_DualSetSpriteAnimSpeed (u8 sprite, s16 speed)
 Set the current animation speed for DualSprites.
 
static u16 PA_DualGetSpriteAnimSpeed (u8 sprite)
 Returns the current animation speed for DualSprites.
 
static void PA_DualSpriteAnimPause (u8 sprite, u8 pause)
 Pause or UnPause a sprite animation for DualSprites.
 

Detailed Description

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

Function Documentation

◆ PA_SetScreenSpace()

static inline void PA_SetScreenSpace ( s16  ScreenSpace)
inlinestatic

Set the space between the 2 screens for the Dual Fonctions. 48 pixels by default.

Parameters
ScreenSpaceSpace in pixels

◆ PA_DualSetSpriteX()

static inline void PA_DualSetSpriteX ( u8  obj,
s16  x 
)
inlinestatic

Set the X position of a sprite on screen.

Parameters
objObject number in the sprite system
xX position

◆ PA_DualSetSpriteY()

static inline void PA_DualSetSpriteY ( u8  obj,
s16  y 
)
inlinestatic

Set the Y position of a sprite on screen.

Parameters
objObject number in the sprite system
yY position

◆ PA_DualSetSpriteXY()

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

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

Parameters
spritesprite number in the sprite system
xX position
yX position

◆ PA_DualCreateSprite()

static inline void PA_DualCreateSprite ( 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, on 2 screens.

Parameters
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_DualCreateSpriteEx()

static inline void PA_DualCreateSpriteEx ( 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
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_DualCreate16bitSpriteEx()

static inline void PA_DualCreate16bitSpriteEx ( 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
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_DualCreate16bitSprite()

static inline void PA_DualCreate16bitSprite ( 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
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_DualCreateSpriteFromGfx()

static inline void PA_DualCreateSpriteFromGfx ( 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
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_DualCreateSpriteExFromGfx()

static inline void PA_DualCreateSpriteExFromGfx ( 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
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_DualUpdateSpriteGfx()

static inline void PA_DualUpdateSpriteGfx ( u8  obj_number,
void *  obj_data 
)
inlinestatic

Update the Gfx of a given sprite.

Parameters
obj_numberObject number in the sprite system
obj_dataGfx to load

◆ PA_DualUpdateGfx()

static inline void PA_DualUpdateGfx ( u16  gfx_number,
void *  obj_data 
)
inlinestatic

Update the Gfx of a given sprite.

Parameters
gfx_numberGfx number in memory
obj_dataGfx to load

◆ PA_DualDeleteSprite()

static inline void PA_DualDeleteSprite ( u8  obj_number)
inlinestatic

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

Parameters
obj_numberSprite number

◆ PA_DualSetSpriteRotEnable()

static inline void PA_DualSetSpriteRotEnable ( u8  sprite,
u8  rotset 
)
inlinestatic

Rotate and zoom a sprite.

Parameters
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_DualSetSpriteRotDisable()

static inline void PA_DualSetSpriteRotDisable ( u8  sprite)
inlinestatic

Stop rotating and zooming a sprite.

Parameters
spriteSprite you want to rotate

◆ PA_DualSetRotset()

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

Rotate and zoom a sprite.

Parameters
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_DualSetRotsetNoZoom()

static inline void PA_DualSetRotsetNoZoom ( u8  rotset,
s16  angle 
)
inlinestatic

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

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

◆ PA_DualSetRotsetNoAngle()

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

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

Parameters
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_DualSetSpritePal()

static inline void PA_DualSetSpritePal ( u8  obj,
u8  pal 
)
inlinestatic

Set the color palette used by a sprite.

Parameters
objObject number in the sprite system
palPalette number (0 - 15)

◆ PA_DualSetSpriteDblsize()

static inline void PA_DualSetSpriteDblsize ( u8  obj,
u8  dblsize 
)
inlinestatic

Enable or disable double size for a given sprite.

Parameters
objObject number in the sprite system
dblsize1 to enable doublesize, 0 to disable it...

◆ PA_DualSetSpriteColors()

static inline void PA_DualSetSpriteColors ( u8  sprite,
u8  n_colors 
)
inlinestatic

Change the sprite's color mode.

Parameters
spriteObject number in the sprite system
n_colors0 for 16 colors, 1 for 256

◆ PA_DualSetSpriteMode()

static inline void PA_DualSetSpriteMode ( u8  sprite,
u8  obj_mode 
)
inlinestatic

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

Parameters
spriteObject number in the sprite system
obj_modeObject mode : 0 for normal, 1 for alpha blending, 2 for window ; not working yet

◆ PA_DualSetSpriteMosaic()

static inline void PA_DualSetSpriteMosaic ( u8  obj,
u8  mosaic 
)
inlinestatic

Enable or disable mosaic mode for a given sprite.

Parameters
objObject number in the sprite system
mosaicSet mosaic on (1) or off (0)

◆ PA_DualSetSpriteHflip()

static inline void PA_DualSetSpriteHflip ( u8  obj,
u8  hflip 
)
inlinestatic

Enable or disable horizontal flip for a given sprite.

Parameters
objObject number in the sprite system
hflipHorizontal flip, 1 to enable, 0 to disable...

◆ PA_DualSetSpriteVflip()

static inline void PA_DualSetSpriteVflip ( u8  obj,
u8  vflip 
)
inlinestatic

Enable or disable vertical flip for a given sprite.

Parameters
objObject number in the sprite system
vflipVertical flip, 1 to enable, 0 to disable...

◆ PA_DualSetSpriteGfx()

static inline void PA_DualSetSpriteGfx ( u8  obj,
u16 *  gfx 
)
inlinestatic

Change the gfx used by a sprite.

Parameters
objObject number in the sprite system
gfxGfx number ; you can get one by using PA_CreateGfx or PA_GetSpriteGfx(obj_number);

◆ PA_DualSetSpritePrio()

static inline void PA_DualSetSpritePrio ( u8  obj,
u8  prio 
)
inlinestatic

Set a sprite's Background priority.

Parameters
objObject number in the sprite system
prioSprite priority : 0 is over background 0, 1 over Bg 1, etc... (0-3)

◆ PA_DualCloneSprite()

static inline void PA_DualCloneSprite ( u8  obj,
u8  target 
)
inlinestatic

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

Parameters
objObject number in the sprite system
targetTarget sprite to clone

◆ PA_DualSetSpriteAnimEx()

static inline void PA_DualSetSpriteAnimEx ( 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
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_DualSetSpriteAnim()

static inline void PA_DualSetSpriteAnim ( 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
spritesprite number in the sprite system
animframeSprite animation frame (0, 1, 2, etc...)

◆ PA_DualStartSpriteAnimEx()

static inline void PA_DualStartSpriteAnimEx ( u8  sprite,
s16  firstframe,
s16  lastframe,
s16  speed,
u8  type,
s16  ncycles 
)
inlinestatic

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

Parameters
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_DualStartSpriteAnim()

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

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

Parameters
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_DualStopSpriteAnim()

static inline void PA_DualStopSpriteAnim ( u8  sprite)
inlinestatic

Stop a sprite animation for DualSprites.

Parameters
spritesprite number in the sprite system

◆ PA_DualSetSpriteAnimFrame()

static inline void PA_DualSetSpriteAnimFrame ( u8  sprite,
u16  frame 
)
inlinestatic

Set the current animation frame number for DualSprites.

Parameters
spritesprite number in the sprite system
frameFrame number to use...

◆ PA_DualGetSpriteAnimFrame()

static inline u16 PA_DualGetSpriteAnimFrame ( u8  sprite)
inlinestatic

Returns the current animation frame number for DualSprites.

Parameters
spritesprite number in the sprite system

◆ PA_DualSetSpriteAnimSpeed()

static inline void PA_DualSetSpriteAnimSpeed ( u8  sprite,
s16  speed 
)
inlinestatic

Set the current animation speed for DualSprites.

Parameters
spritesprite number in the sprite system
speedSpeed, in fps...

◆ PA_DualGetSpriteAnimSpeed()

static inline u16 PA_DualGetSpriteAnimSpeed ( u8  sprite)
inlinestatic

Returns the current animation speed for DualSprites.

Parameters
spritesprite number in the sprite system

◆ PA_DualSpriteAnimPause()

static inline void PA_DualSpriteAnimPause ( u8  sprite,
u8  pause 
)
inlinestatic

Pause or UnPause a sprite animation for DualSprites.

Parameters
spritesprite number in the sprite system
pause1 for pause, 0 for unpause