PAlib: PA_Sprite.h Source File

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

# PA_Sprite.h

Go to the documentation of this file.

    00001 #ifndef _PA_Sprite
    00002 #define _PA_Sprite
    00003
    00004
    00005
    00012 //#include <PA9.h>
    00013
    00014
    00015
    00016 #define EWRAM_DATA   __attribute__((section(".ewram")))
    00017 #define EWRAM_BSS    __attribute__((section(".sbss")))
    00018 #define PA_Cos(angle) PA_SIN[((angle) + 128)&511]
    00019 #define PA_Sin(angle) PA_SIN[((angle))&511]
    00020 extern const s16 PA_SIN[512];
    00021
    00022 #define MAX_DRAW 16  // Maximum 16 sprites dessinables...
    00023
    00024
    00026 // Système de sprites
    00028
    00029
    00030 #define OBJ_SIZE_8X8      0,0
    00031 #define OBJ_SIZE_16X16    0,1
    00032 #define OBJ_SIZE_32X32    0,2
    00033 #define OBJ_SIZE_64X64    0,3
    00034 #define OBJ_SIZE_16X8     1,0
    00035 #define OBJ_SIZE_32X8     1,1
    00036 #define OBJ_SIZE_32X16    1,2
    00037 #define OBJ_SIZE_64X32    1,3
    00038 #define OBJ_SIZE_8X16     2,0
    00039 #define OBJ_SIZE_8X32     2,1
    00040 #define OBJ_SIZE_16X32    2,2
    00041 #define OBJ_SIZE_32X64    2,3
    00042
    00043 typedef struct {
    00044        u8 lx, ly;
    00045 } PA_sizes;
    00046
    00047 extern const PA_sizes PA_size[3][4];
    00048
    00049
    00050 #define BITS_16 65535
    00051 #define ALL_BUT(ATR) (BITS_16 - ATR)
    00052
    00053 #define OBJ_X 511 //511, debugging...
    00054 #define OBJ_Y 255
    00055 #define OBJ_ROT 256
    00056 #define ALL_BUT_ROTSET 49663  // Numéro du rotset
    00057 #define ALL_BUT_PAL 4095
    00058
    00059 #define DBLSIZE 512
    00060 #define N_COLORS (1 << 13)
    00061 #define OBJ_MODE 3072
    00062 #define OBJ_MOSAIC 4096
    00063 #define OBJ_HFLIP 4096
    00064 #define OBJ_VFLIP 8192
    00065
    00066 #define OBJ_GFX 1023
    00067 #define OBJ_PRIO 3072
    00068
    00069 #define COLORS_256 1
    00070 #define COLORS_16 0
    00071
    00072
    00073
    00074 #define MEM_DECAL 5
    00075 #define NUMBER_DECAL 7
    00076
    00077
    00078
    00079 // Mémoire gfx
    00080 typedef struct {
    00081    u16 mem_block;  // Emplacement en mémoire, de 0 à 1023
    00082    u16 free; // Doonées libres en ce point
    00083 } mem_usage;
    00084
    00085 extern u16 n_free_mem[2]; // nombre d'emplacements libres
    00086 extern u8 used_mem[2][1024]; // Note la quantité de mémoire utilisée en chaque point de la mémoire pour pouvoir effacer les gfx...
    00087 extern u8 obj_per_gfx[2][1024]; // Nombre de sprites utilisant un gfx donné...
    00088 extern mem_usage free_mem[2][1024];
    00089
    00090 extern u16 FirstGfx[2];
    00091
    00092 extern const u16 PA_obj_sizes[4][3];
    00093
    00094 typedef struct {
    00095    u16 atr0, atr1, atr2, atr3;
    00096 }obj_inf;
    00097 extern obj_inf PA_obj[2][128];  // Les 128 premiers pour l'écran du haut, et encore 128 pour l'écran du bas...
    00098
    00099 extern u8 PA_SpritePrio[2][128]; // Set the sprite priorities...
    00100
    00101 // Infos pour dessiner sur les sprites
    00102 /*
    00103 typedef struct {
    00104        bool screen; // Ecran
    00105        u8 sprite;           // Numéro du sprite
    00106        bool wasdrawing; // Si on dessinait dessus ou pas avant
    00107        s8 x, y;  // Position x et y d'avant
    00108        u8 hsize, vsize; // Tailles
    00109        u8 n_colors; // Nombre de couleurs
    00110        u8 drawsize;
    00111        u32 *gfxpointer; // Pour dessiner à l'écran directement
    00112 } PA_DrawSprites;
    00113 */
    00114
    00115
    00116 //extern PA_DrawSprites PA_DrawSprite[MAX_DRAW];
    00117
    00118 // Pour le dessin sur sprite
    00119 extern unsigned char *PA_SpriteBuffer[MAX_DRAW]; // Pointeurs vers les buffers  que l'on créera à la volée
    00120
    00121 extern u16 *PA_SpriteAnimP[2][1024];
    00122
    00123
    00124 #define ANIM_LOOP 0 // loop around
    00125 #define ANIM_UPDOWN 1 // back and forth animation
    00126
    00127 #define ANIM_ONESHOT ANIM_LOOP, 1
    00128 #define ANIM_INFINITE ANIM_LOOP, -1
    00129
    00130
    00131
    00132 extern s16 nspriteanims; // Number of animated sprites currently...
    00133 typedef struct{
    00134        s32 firstframe, lastframe, currentframe; // frames...
    00135        s8 framechange; // 1 by default, -1 to go back...
    00136        s32 time; // Time...
    00137        u8 lx, ly; // Sprite sizes
    00138        bool colors;
    00139        s16 speed;
    00140        bool play;
    00141        u16 *gfx; // gfx pointer
    00142        u8 type;
    00143        s32 ncycles;
    00144 } spriteanim;
    00145 extern spriteanim spriteanims[2][128]; // Init the array on PAlib init...
    00146
    00147 //#define spriteanimsize 40
    00148
    00149
    00150
    00151 extern bool PA_SpriteExtPrio;
    00152
    00153
    00154
    00155
    00156
    00157
    00158 #define OAM0 0x07000000
    00159 #define OAM1 0x07000400
    00160
    00161
    00174 #define PA_UpdateOAM0() DMA_Copy((void*)PA_obj, (void*)OAM0, 256, DMA_32NOW)
    00175
    00181 #define PA_UpdateOAM1() DMA_Copy((void*)PA_obj + 256, (void*)OAM1, 256, DMA_32NOW)
    00182
    00183
    00184
    00185
    00186
    00187
    00194 //#define PA_UpdateOAM() DMA_Copy((void*)PA_obj, (void*)OAM0, 512, DMA_32NOW)
    00195 extern inline void PA_UpdateOAM(void){
    00196 // Update OAM
    00197 //PA_UpdateOAM0();
    00198 //PA_UpdateOAM1();
    00199 u16 i, screen;
    00200 u16 value = 0;
    00201        for (i = 0; i < 256; i++){ // copy
    00202               OAM[value] = PA_obj[0][i].atr0;
    00203               OAM[value + 1] = PA_obj[0][i].atr1;
    00204               OAM[value + 2] = PA_obj[0][i].atr2;
    00205               OAM[value + 3] = PA_obj[0][i].atr3;
    00206               value += 4;
    00207        }
    00208
    00209 if (PA_SpriteExtPrio){ // Use the extended priorities
    00210        s8 next[2][128];
    00211        s8 first[2][256]; // Sprite at given priority...
    00212
    00213        value = 0;
    00214        s8 sprite;
    00215
    00216        for (i = 0; i < 256; i++) first[0][i] = first[1][i] = -1;
    00217        for (i = 0; i < 128; i++){ // sort
    00218               next[0][i] = first[0][PA_SpritePrio[0][i]];
    00219               first[0][PA_SpritePrio[0][i]] = i;
    00220               next[1][i] = first[1][PA_SpritePrio[1][i]];
    00221               first[1][PA_SpritePrio[1][i]] = i;
    00222        }
    00223        for (screen = 0; screen < 2; screen++){
    00224               value = screen << 9; // 512 start for the top screen
    00225               for (i = 0; i < 256; i++){ // copy
    00226                      sprite = first[screen][i];
    00227                      while(sprite != -1){
    00228                             //PA_OutputText(1, value, 0, "%d   ", sprite);
    00229                             OAM[value] = PA_obj[screen][sprite].atr0;
    00230                             OAM[value + 1] = PA_obj[screen][sprite].atr1;
    00231                             OAM[value + 2] = PA_obj[screen][sprite].atr2;
    00232                             value += 4;
    00233                             sprite = next[screen][sprite];
    00234                      }
    00235               }
    00236        }
    00237 }
    00238
    00239 }
    00240
    00241
    00263 u16 PA_CreateGfx(bool screen, void* obj_data, u8 obj_shape, u8 obj_size, u8 color_mode);
    00264
    00270 void PA_ResetSpriteSys(void);
    00271
    00272
    00273
    00306 extern 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) {
    00307    PA_obj[screen][obj_number].atr2 = PA_CreateGfx(screen, obj_data, obj_shape, obj_size, color_mode) + (palette << 12);
    00308    PA_obj[screen][obj_number].atr0 = (y&OBJ_Y) + (color_mode << 13) + (obj_shape << 14);
    00309    PA_obj[screen][obj_number].atr1 = (x & OBJ_X) + (obj_size << 14);
    00310 };
    00311
    00362 extern 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) {
    00363    PA_obj[screen][obj_number].atr2 = PA_CreateGfx(screen, obj_data, obj_shape, obj_size, color_mode) + (prio << 10) + (palette << 12);
    00364    PA_obj[screen][obj_number].atr0 = (y&OBJ_Y) + (dblsize << 9) + (obj_mode << 10) + (mosaic << 12) + ((color_mode) << 13) + (obj_shape << 14);
    00365    PA_obj[screen][obj_number].atr1 = (x & OBJ_X) + (hflip << 12) + (vflip << 13) + (obj_size << 14);
    00366 };
    00367
    00368
    00369
    00370
    00371
    00413 extern 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){
    00414    PA_obj[screen][obj_number].atr2 = PA_CreateGfx(screen, obj_data, obj_shape, obj_size, 2) + (prio << 10) + (15 << 12);
    00415    PA_obj[screen][obj_number].atr0 = (y&OBJ_Y) + (dblsize << 9) + (3 << 10) + (mosaic << 12) + (0 << 13) + (obj_shape << 14);
    00416    PA_obj[screen][obj_number].atr1 = (x & OBJ_X) + (hflip << 12) + (vflip << 13) + (obj_size << 14);
    00417 }
    00418
    00419
    00420
    00421
    00448 extern inline void PA_Create16bitSpriteFromGfx(bool screen, u8 obj_number, u16 gfx, u8 obj_shape, u8 obj_size, s16 x, s16 y){
    00449    PA_obj[screen][obj_number].atr2 = gfx + (15 << 12);
    00450    PA_obj[screen][obj_number].atr0 = (y&OBJ_Y) + (3 << 10) + (obj_shape << 14);
    00451    PA_obj[screen][obj_number].atr1 = (x & OBJ_X) + (obj_size << 14);
    00452 }
    00453
    00454
    00455
    00456
    00457
    00484 extern inline void PA_Create16bitSprite(bool screen, u8 obj_number, void* obj_data, u8 obj_shape, u8 obj_size, s16 x, s16 y){
    00485 PA_Create16bitSpriteEx(screen, obj_number, obj_data, obj_shape, obj_size, 0, 0, 0, 0, 0, x, y);
    00486 }
    00487
    00488
    00489
    00490
    00523 extern 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) {
    00524    PA_obj[screen][obj_number].atr2 = obj_gfx + (palette << 12);
    00525    PA_obj[screen][obj_number].atr0 = (y&OBJ_Y) + (color_mode << 13) + (obj_shape << 14);
    00526    PA_obj[screen][obj_number].atr1 = (x & OBJ_X) + (obj_size << 14);
    00527    ++obj_per_gfx[screen][obj_gfx];
    00528 };
    00529
    00580 extern 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) {
    00581    PA_obj[screen][obj_number].atr2 = obj_gfx + (prio << 10) + (palette << 12);
    00582    PA_obj[screen][obj_number].atr0 = (y&OBJ_Y) + (dblsize << 9) + (obj_mode << 10) + (mosaic << 12) + (color_mode << 13) + (obj_shape << 14);
    00583    PA_obj[screen][obj_number].atr1 = (x & OBJ_X) + (hflip << 12) + (vflip << 13) + (obj_size << 14);
    00584    ++obj_per_gfx[screen][obj_gfx];
    00585 };
    00586
    00587
    00602 #define PA_UpdateSpriteGfx(screen, obj_number, obj_data) PA_UpdateGfx(screen, PA_GetSpriteGfx(screen, obj_number), obj_data)
    00603
    00618 #include "PA_Text.h"
    00619 #include "PA_Math.h"
    00620
    00621 extern inline void PA_UpdateGfx(bool screen, u16 gfx_number, void *obj_data) {
    00622        DMA_Copy((obj_data), (void*)(SPRITE_GFX1 + (0x200000 *  (screen)) + ((gfx_number) << NUMBER_DECAL)), (used_mem[screen][gfx_number] << MEM_DECAL), DMA_32NOW);
    00623 //     PA_OutputText(1, 25, PA_Rand()&15, "%dgfx   ", gfx_number);
    00624 }
    00625
    00626
    00642 extern inline void PA_UpdateGfxAndMem(bool screen, u8 gfx_number, void *obj_data){
    00643        DMA_Copy((obj_data), (void*)(SPRITE_GFX1 + (0x200000 *  (screen)) + ((gfx_number) << NUMBER_DECAL)), (used_mem[screen][gfx_number] << MEM_DECAL), DMA_32NOW);
    00644        PA_SpriteAnimP[screen][gfx_number] = (u16*)obj_data; // mémorise la source de l'image...
    00645 }
    00646
    00647
    00648
    00649
    00661 void PA_DeleteGfx(bool screen, u16 obj_gfx);
    00662
    00663
    00675 void PA_DeleteSprite(bool screen, u8 obj_number);
    00676
    00677
    00693 #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);}
    00694
    00706 #define PA_SetSpriteRotDisable(screen, sprite) {PA_obj[screen][sprite].atr0 &= ALL_BUT(OBJ_ROT);  PA_obj[screen][sprite].atr1 &= ALL_BUT_ROTSET;}
    00707
    00708
    00730 extern inline void PA_SetRotset(bool screen, u8 rotset, s16 angle, u16 zoomx, u16 zoomy) {
    00731 u8 obj_num = (rotset << 2);
    00732        PA_obj[screen][obj_num].atr3 = (PA_Cos(angle) * zoomx) >> 8;
    00733        PA_obj[screen][obj_num + 1].atr3 = (-PA_Sin(angle) * zoomy) >> 8;
    00734        PA_obj[screen][obj_num + 2].atr3 = (PA_Sin(angle) * zoomx) >> 8;
    00735        PA_obj[screen][obj_num + 3].atr3 = (PA_Cos(angle) * zoomy) >> 8;
    00736 }
    00737
    00752 extern inline void PA_SetRotsetNoZoom(bool screen, u8 rotset, s16 angle)   {
    00753 u8 obj_num = (rotset << 2);
    00754        PA_obj[screen][obj_num].atr3 = PA_Cos(angle);
    00755        PA_obj[screen][obj_num + 1].atr3 = -PA_Sin(angle);
    00756        PA_obj[screen][obj_num + 2].atr3 = PA_Sin(angle);
    00757        PA_obj[screen][obj_num + 3].atr3 = PA_Cos(angle);
    00758 }
    00759
    00777 extern inline void PA_SetRotsetNoAngle(bool screen, u8 rotset, u16 zoomx, u16 zoomy) {
    00778 u8 obj_num = (rotset << 2);
    00779        PA_obj[screen][obj_num].atr3 = zoomx;
    00780        PA_obj[screen][obj_num + 1].atr3 = 0;
    00781        PA_obj[screen][obj_num + 2].atr3 = 0;
    00782        PA_obj[screen][obj_num + 3].atr3 = zoomy;
    00783 }
    00784
    00785
    00786
    00787
    00788
    00789
    00790
    00807 #define PA_SetSpriteX(screen, obj, x) PA_obj[screen][obj].atr1 = (PA_obj[screen][obj].atr1 & ALL_BUT(OBJ_X)) + ((x) & OBJ_X)
    00808
    00821 #define PA_GetSpriteX(screen, obj) (PA_obj[screen][obj].atr1 & (OBJ_X))
    00822
    00823
    00838 #define PA_SetSpriteY(screen, obj, y) PA_obj[screen][obj].atr0 = (PA_obj[screen][obj].atr0 & ALL_BUT(OBJ_Y)) + ((y) & OBJ_Y)
    00839
    00852 #define PA_GetSpriteY(screen, obj) (PA_obj[screen][obj].atr0 & OBJ_Y)
    00853
    00854
    00855
    00873 extern inline void PA_SetSpriteXY(bool screen, u8 sprite, s16 x, s16 y) {
    00874        PA_SetSpriteX(screen, sprite, x);
    00875        PA_SetSpriteY(screen, sprite, y);
    00876 }
    00877
    00878
    00879
    00894 #define PA_SetSpritePal(screen, obj, pal) PA_obj[screen][obj].atr2 = (PA_obj[screen][obj].atr2 & ALL_BUT_PAL) + ((pal) << 12)
    00895
    00907 #define PA_GetSpritePal(screen, obj) (PA_obj[screen][obj].atr2 >> 12)
    00908
    00909
    00924 #define PA_SetSpriteDblsize(screen, obj, dblsize) PA_obj[screen][obj].atr0 = (PA_obj[screen][obj].atr0 & ALL_BUT(DBLSIZE)) + ((dblsize) << 9)
    00925
    00937 #define PA_GetSpriteDblsize(screen, obj) ((PA_obj[screen][obj].atr0 & DBLSIZE) >> 9)
    00938
    00939
    00954 #define PA_SetSpriteColors(screen, sprite, n_colors) PA_obj[screen][sprite].atr0 = (PA_obj[screen][sprite].atr0 & ALL_BUT(N_COLORS)) + ((n_colors) << 13)
    00955
    00967 #define PA_GetSpriteColors(screen, sprite) ((PA_obj[screen][sprite].atr0 & N_COLORS) >> 13)
    00968
    00969
    00970
    00985 #define PA_SetSpriteMode(screen, sprite, obj_mode) PA_obj[screen][sprite].atr0 = (PA_obj[screen][sprite].atr0 & ALL_BUT(OBJ_MODE)) + ((obj_mode) << 10)
    00986
    00998 #define PA_GetSpriteMode(screen, obj) ((PA_obj[screen][obj].atr0 & OBJ_MODE) >> 10)
    00999
    01000
    01015 #define PA_SetSpriteMosaic(screen, obj, mosaic) PA_obj[screen][obj].atr0 = (PA_obj[screen][obj].atr0 & ALL_BUT(OBJ_MOSAIC)) + ((mosaic) << 12)
    01016
    01028 #define PA_GetSpriteMosaic(screen, obj) ((PA_obj[screen][obj].atr0 & OBJ_MOSAIC) >> 12)
    01029
    01030
    01031
    01046 #define PA_SetSpriteHflip(screen, obj, hflip) PA_obj[screen][obj].atr1 = (PA_obj[screen][obj].atr1 & ALL_BUT(OBJ_HFLIP)) + ((hflip) << 12)
    01047
    01059 #define PA_GetSpriteHflip(screen, obj) ((PA_obj[screen][obj].atr1 & OBJ_HFLIP) >> 12)
    01060
    01061
    01076 #define PA_SetSpriteVflip(screen, obj, vflip) PA_obj[screen][obj].atr1 = (PA_obj[screen][obj].atr1 & ALL_BUT(OBJ_VFLIP)) + ((vflip) << 13)
    01077
    01089 #define PA_GetSpriteVflip(screen, obj) ((PA_obj[screen][obj].atr1 & OBJ_VFLIP) >> 13)
    01090
    01091
    01106 #define PA_SetSpriteGfx(screen, obj, gfx) PA_obj[screen][obj].atr2 = (PA_obj[screen][obj].atr2 & ALL_BUT(OBJ_GFX)) + ((gfx) & OBJ_GFX)
    01107
    01119 #define PA_GetSpriteGfx(screen, obj) (PA_obj[screen][obj].atr2 & OBJ_GFX)
    01120
    01121
    01122
    01137 #define PA_SetSpritePrio(screen, obj, prio) PA_obj[screen][obj].atr2 = (PA_obj[screen][obj].atr2 & ALL_BUT(OBJ_PRIO)) + ((prio) << 10)
    01138
    01150 #define PA_GetSpritePrio(screen, obj) ((PA_obj[screen][obj].atr2 & OBJ_PRIO) >> 10)
    01151
    01152
    01164 #define PA_GetSpriteLx(screen, sprite) PA_size[PA_obj[screen][sprite].atr0 >> 14][PA_obj[screen][sprite].atr1 >> 14].lx
    01165
    01166
    01178 #define PA_GetSpriteLy(screen, sprite)PA_size[PA_obj[screen][sprite].atr0 >> 14][PA_obj[screen][sprite].atr1 >> 14].ly
    01179
    01180
    01195 #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)];}
    01196
    01197
    01198
    01199
    01200
    01201
    01202
    01203
    01227 extern inline void PA_SetSpriteAnimEx(bool screen, u8 sprite, u8 lx, u8 ly, u8 ncolors, s16 animframe){
    01228        u16 gfx = PA_GetSpriteGfx(screen, sprite);
    01229        //PA_OutputText(1, 0, PA_Rand()&15, "%03d - %03d   ", gfx, sprite);
    01230        PA_UpdateGfx(screen, gfx, (void*)(PA_SpriteAnimP[screen][gfx] + (animframe * (lx * ly) >> (2 - ncolors))));
    01231 }
    01232
    01247 extern inline void PA_SetSpriteAnim(bool screen, u8 sprite, s16 animframe){
    01248        PA_SetSpriteAnimEx(screen, sprite, PA_GetSpriteLx(screen, sprite), PA_GetSpriteLy(screen, sprite), PA_GetSpriteColors(screen, sprite), animframe);
    01249 }
    01250
    01251
    01252
    01279 void PA_StartSpriteAnimEx(bool screen, u8 sprite, s16 firstframe, s16 lastframe, s16 speed, u8 type, s16 ncycles);
    01280
    01281
    01282
    01283
    01304 extern inline void PA_StartSpriteAnim(bool screen, u8 sprite, s16 firstframe, s16 lastframe, s16 speed){
    01305        PA_StartSpriteAnimEx(screen, sprite, firstframe, lastframe, speed, ANIM_INFINITE);
    01306 }
    01307
    01308
    01309
    01310
    01322 extern inline void PA_StopSpriteAnim(bool screen, u8 sprite)
    01323 {
    01324        if (spriteanims[screen][sprite].play) nspriteanims--;
    01325        spriteanims[screen][sprite].play = 0;
    01326 }
    01327
    01342 extern inline void PA_SetSpriteAnimFrame(bool screen, u8 sprite, u16 frame)
    01343 {
    01344        if(spriteanims[screen][sprite].currentframe != frame){
    01345               PA_SetSpriteAnimEx(screen, sprite, spriteanims[screen][sprite].lx, spriteanims[screen][sprite].ly, spriteanims[screen][sprite].colors, spriteanims[screen][sprite].currentframe);
    01346               spriteanims[screen][sprite].currentframe = frame;
    01347        }
    01348 }
    01349
    01350
    01362 extern inline u16 PA_GetSpriteAnimFrame(bool screen, u8 sprite)
    01363 {
    01364        return spriteanims[screen][sprite].currentframe;
    01365 }
    01366
    01367
    01368
    01383 extern inline void PA_SetSpriteAnimSpeed(bool screen, u8 sprite, s16 speed)
    01384 {
    01385        spriteanims[screen][sprite].speed = speed;
    01386 }
    01387
    01399 extern inline u16 PA_GetSpriteAnimSpeed(bool screen, u8 sprite)
    01400 {
    01401        return spriteanims[screen][sprite].speed;
    01402 }
    01403
    01404
    01419 extern inline void PA_SetSpriteNCycles(bool screen, u8 sprite, s16 NCycles)
    01420 {
    01421        spriteanims[screen][sprite].ncycles = NCycles;
    01422 }
    01423
    01424
    01425
    01437 extern inline u16 PA_GetSpriteNCycles(bool screen, u8 sprite)
    01438 {
    01439        return spriteanims[screen][sprite].speed;
    01440 }
    01441
    01442
    01443
    01444
    01445
    01460 extern inline void PA_SpriteAnimPause(bool screen, u8 sprite, bool pause)
    01461 {
    01462        if (pause&&spriteanims[screen][sprite].play) nspriteanims--;
    01463        else if ((!pause)&&(!spriteanims[screen][sprite].play)) nspriteanims++;
    01464        spriteanims[screen][sprite].play = !pause;
    01465 }
    01466
    01467
    01468
    01469
    01470
    01471
    01492 extern inline void PA_SetSpritePixel(bool screen, u8 sprite, u8 x, u8 y, u8 color){
    01493 u8 hsize = spriteanims[screen][sprite].lx>>3;
    01494
    01495        s32 pos = (x >> 3) + ((y >> 3) * hsize);
    01496        x&=7; y&=7;
    01497
    01498        pos = (pos << 5) + (x >> 1) + (y << 2);
    01499
    01500        u16 pixel = spriteanims[screen][sprite].gfx[pos];
    01501
    01502        if (x&1){
    01503               spriteanims[screen][sprite].gfx[pos] = (color << 8) | (pixel&0x00FF);
    01504        }
    01505        else {
    01506               spriteanims[screen][sprite].gfx[pos] = color | (pixel&0xFF00);
    01507        }
    01508 }
    01509
    01510
    01528 extern inline u8 PA_GetSpritePixel(bool screen, u8 sprite, u8 x, u8 y) {
    01529 u8 hsize = spriteanims[screen][sprite].lx>>3;
    01530
    01531        s32 pos = (x >> 3) + ((y >> 3) * hsize);
    01532        x&=7; y&=7;
    01533
    01534        pos = (pos << 5) + (x >> 1) + (y << 2);
    01535
    01536        u16 pixel = spriteanims[screen][sprite].gfx[pos];
    01537
    01538        if (x&1){
    01539               return ((pixel>>8)&255);
    01540        }
    01541        else {
    01542               return (pixel&255);
    01543        }
    01544 }
    01545
    01546
    01558 void PA_InitSpriteDraw(bool screen, u8 sprite);
    01559
    01560
    01561
    01567 extern inline void PA_InitAllSpriteDraw(void){
    01568 u8 i, j;
    01569 for (j = 0; j < 2; j++)
    01570        for (i = 0; i < 128; i++)
    01571               PA_InitSpriteDraw(j, i);
    01572 }
    01573
    01574
    01575
    01576
    01585 void PA_InitSpriteExtPrio(bool SpritePrio);
    01586
    01587 extern inline void PA_SetSPriteExtPrio(bool screen, u8 sprite, u8 prio){
    01588        PA_SpritePrio[screen][sprite] = prio;
    01589 }
    01590
    01591
    01592
    01593  // end of Sprite
    01595
    01596
    01597
    01598
    01599
    01600 void PA_UpdateSpriteAnims(void);
    01601
    01602
    01603
    01604
    01605
    01606
    01607
    01608
    01609
    01610
    01611
    01612 #endif
    01613
    01614