#include "PA_Math.h"
Data Structures | |
struct | PA_sizes |
struct | mem_usage |
struct | obj_inf |
struct | spriteanim |
Defines | |
#define | EWRAM_DATA __attribute__((section(".ewram"))) |
#define | EWRAM_BSS __attribute__((section(".sbss"))) |
#define | PA_Cos(angle) PA_SIN[((angle) + 128)&511] |
#define | PA_Sin(angle) PA_SIN[((angle))&511] |
#define | MAX_DRAW 16 |
#define | OBJ_SIZE_8X8 0,0 |
#define | OBJ_SIZE_16X16 0,1 |
#define | OBJ_SIZE_32X32 0,2 |
#define | OBJ_SIZE_64X64 0,3 |
#define | OBJ_SIZE_16X8 1,0 |
#define | OBJ_SIZE_32X8 1,1 |
#define | OBJ_SIZE_32X16 1,2 |
#define | OBJ_SIZE_64X32 1,3 |
#define | OBJ_SIZE_8X16 2,0 |
#define | OBJ_SIZE_8X32 2,1 |
#define | OBJ_SIZE_16X32 2,2 |
#define | OBJ_SIZE_32X64 2,3 |
#define | BITS_16 65535 |
#define | ALL_BUT(ATR) (BITS_16 - ATR) |
#define | PA_OBJ_X 511 |
#define | PA_OBJ_Y 255 |
#define | OBJ_ROT 256 |
#define | ALL_BUT_ROTSET 49663 |
#define | ALL_BUT_PAL 4095 |
#define | DBLSIZE 512 |
#define | N_COLORS (1 << 13) |
#define | OBJ_MODE 3072 |
#define | OBJ_MOSAIC 4096 |
#define | OBJ_HFLIP 4096 |
#define | OBJ_VFLIP 8192 |
#define | OBJ_GFX 1023 |
#define | OBJ_PRIO 3072 |
#define | COLORS_256 1 |
#define | COLORS_16 0 |
#define | MEM_DECAL 5 |
#define | NUMBER_DECAL 7 |
#define | ANIM_LOOP 0 |
#define | ANIM_UPDOWN 1 |
#define | ANIM_ONESHOT ANIM_LOOP, 1 |
#define | ANIM_INFINITE ANIM_LOOP, -1 |
#define | OAM0 0x07000000 |
#define | OAM1 0x07000400 |
#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(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) {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 | |
obj_inf PA_obj[2][128] | __attribute__ ((aligned(4))) |
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_ResetSpriteSysScreen (u8 screen) |
void | PA_ResetSpriteSys (void) |
Reset the sprite system, memory, etc... | |
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. | |
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. | |
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... | |
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. | |
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... | |
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. | |
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. | |
void | PA_UpdateGfx (u8 screen, u16 gfx_number, void *obj_data) |
Update a given Gfx. | |
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. | |
void | PA_SetRotset (u8 screen, u8 rotset, s16 angle, u16 zoomx, u16 zoomy) |
Rotate and zoom a sprite. | |
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. | |
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. | |
void | PA_SetSpriteXY (u8 screen, u8 sprite, s16 x, s16 y) |
Set the X and Y position of a sprite on screen. | |
void | PA_Set16bitSpriteAlpha (u8 screen, u8 sprite, u8 alpha) |
Set the X position of a sprite on screen. | |
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... | |
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 ! | |
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 ! | |
void | PA_StopSpriteAnim (u8 screen, u8 sprite) |
Stop a sprite animation. | |
void | PA_SetSpriteAnimFrame (u8 screen, u8 sprite, u16 frame) |
Set the current animation frame number. | |
u16 | PA_GetSpriteAnimFrame (u8 screen, u8 sprite) |
Returns the current animation frame number. | |
void | PA_SetSpriteAnimSpeed (u8 screen, u8 sprite, s16 speed) |
Set the current animation speed. | |
u16 | PA_GetSpriteAnimSpeed (u8 screen, u8 sprite) |
Returns the current animation speed. | |
void | PA_SetSpriteNCycles (u8 screen, u8 sprite, s32 NCycles) |
Set the current animation cycles left (-1 for inifinite loop). | |
s32 | PA_GetSpriteNCycles (u8 screen, u8 sprite) |
Returns the current number of animation cycles left. | |
void | PA_SpriteAnimPause (u8 screen, u8 sprite, u8 pause) |
Pause or UnPause a sprite animation. | |
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. | |
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. | |
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 ! | |
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). | |
void | PA_SetSpriteExtPrio (u8 screen, u8 sprite, u8 prio) |
void | PA_UpdateSpriteAnims (void) |
Variables | |
const s16 | PA_SIN [512] |
const PA_sizes | PA_size [3][4] |
u16 | n_free_mem [2] |
u8 | used_mem [2][1024] |
u8 | obj_per_gfx [2][1024] |
mem_usage | free_mem [2][1024] |
u16 | FirstGfx [2] |
const u16 | PA_obj_sizes [4][3] |
u8 | PA_SpritePrio [2][128] |
unsigned char * | PA_SpriteBuffer [MAX_DRAW] |
u16 * | PA_SpriteAnimP [2][1024] |
s16 | nspriteanims |
spriteanim | spriteanims [2][128] |
u8 | PA_SpriteExtPrio |
This file contains all macros, variables, and prototypes regarding the sprite system (OAM, Sprite mouvement, Gfx loading...)
#define ALL_BUT | ( | ATR | ) | (BITS_16 - ATR) |
#define ALL_BUT_PAL 4095 |
#define ALL_BUT_ROTSET 49663 |
#define ANIM_INFINITE ANIM_LOOP, -1 |
#define ANIM_LOOP 0 |
#define ANIM_ONESHOT ANIM_LOOP, 1 |
#define ANIM_UPDOWN 1 |
#define BITS_16 65535 |
#define COLORS_16 0 |
#define COLORS_256 1 |
#define DBLSIZE 512 |
#define EWRAM_BSS __attribute__((section(".sbss"))) |
#define EWRAM_DATA __attribute__((section(".ewram"))) |
#define MAX_DRAW 16 |
#define MEM_DECAL 5 |
#define N_COLORS (1 << 13) |
#define NUMBER_DECAL 7 |
#define OAM0 0x07000000 |
#define OAM1 0x07000400 |
#define OBJ_GFX 1023 |
#define OBJ_HFLIP 4096 |
#define OBJ_MODE 3072 |
#define OBJ_MOSAIC 4096 |
#define OBJ_PRIO 3072 |
#define OBJ_ROT 256 |
#define OBJ_SIZE_16X16 0,1 |
#define OBJ_SIZE_16X32 2,2 |
#define OBJ_SIZE_16X8 1,0 |
#define OBJ_SIZE_32X16 1,2 |
#define OBJ_SIZE_32X32 0,2 |
#define OBJ_SIZE_32X64 2,3 |
#define OBJ_SIZE_32X8 1,1 |
#define OBJ_SIZE_64X32 1,3 |
#define OBJ_SIZE_64X64 0,3 |
#define OBJ_SIZE_8X16 2,0 |
#define OBJ_SIZE_8X32 2,1 |
#define OBJ_SIZE_8X8 0,0 |
#define OBJ_VFLIP 8192 |
#define PA_Cos | ( | angle | ) | PA_SIN[((angle) + 128)&511] |
#define PA_OBJ_X 511 |
#define PA_OBJ_Y 255 |
#define PA_Sin | ( | angle | ) | PA_SIN[((angle))&511] |
obj_inf PA_obj [2][128] __attribute__ | ( | (aligned(4)) | ) |
void PA_UpdateSpriteAnims | ( | void | ) |
u16 FirstGfx[2] |
u16 n_free_mem[2] |
s16 nspriteanims |
u8 obj_per_gfx[2][1024] |
const u16 PA_obj_sizes[4][3] |
const s16 PA_SIN[512] |
u16* PA_SpriteAnimP[2][1024] |
unsigned char* PA_SpriteBuffer[MAX_DRAW] |
u8 PA_SpritePrio[2][128] |
spriteanim spriteanims[2][128] |
u8 used_mem[2][1024] |