PAlib: Fichier source de PA_Sprite.h

Page principale | Modules | Liste des fichiers | Portée globale | Rechercher

# PA_Sprite.h

Aller à la documentation de ce fichier.

    00001 #ifndef _PA_Sprite
    00002 #define _PA_Sprite
    00003
    00004
    00005
    00012 #include "PA_Text.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        u8 screen; // Ecran
    00105        u8 sprite;           // Numéro du sprite
    00106        u8 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        u8 colors;
    00139        s16 speed;
    00140        u8 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 u8 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 void PA_UpdateOAM(void);
    00195
    00196
    00218 u16 PA_CreateGfx(u8 screen, void* obj_data, u8 obj_shape, u8 obj_size, u8 color_mode);
    00219
    00225 void PA_ResetSpriteSys(void);
    00226
    00227
    00228
    00261 extern 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) {
    00262    PA_obj[screen][obj_number].atr2 = PA_CreateGfx(screen, obj_data, obj_shape, obj_size, color_mode) + (palette << 12);
    00263    PA_obj[screen][obj_number].atr0 = (y&OBJ_Y) + (color_mode << 13) + (obj_shape << 14);
    00264    PA_obj[screen][obj_number].atr1 = (x & OBJ_X) + (obj_size << 14);
    00265 };
    00266
    00317 extern 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) {
    00318    PA_obj[screen][obj_number].atr2 = PA_CreateGfx(screen, obj_data, obj_shape, obj_size, color_mode) + (prio << 10) + (palette << 12);
    00319    PA_obj[screen][obj_number].atr0 = (y&OBJ_Y) + (dblsize << 9) + (obj_mode << 10) + (mosaic << 12) + ((color_mode) << 13) + (obj_shape << 14);
    00320    PA_obj[screen][obj_number].atr1 = (x & OBJ_X) + (hflip << 12) + (vflip << 13) + (obj_size << 14);
    00321 };
    00322
    00323
    00324
    00325
    00326
    00368 extern 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){
    00369    PA_obj[screen][obj_number].atr2 = PA_CreateGfx(screen, obj_data, obj_shape, obj_size, 2) + (prio << 10) + (15 << 12);
    00370    PA_obj[screen][obj_number].atr0 = (y&OBJ_Y) + (dblsize << 9) + (3 << 10) + (mosaic << 12) + (0 << 13) + (obj_shape << 14);
    00371    PA_obj[screen][obj_number].atr1 = (x & OBJ_X) + (hflip << 12) + (vflip << 13) + (obj_size << 14);
    00372 }
    00373
    00374
    00375
    00376
    00403 extern inline void PA_Create16bitSpriteFromGfx(u8 screen, u8 obj_number, u16 gfx, u8 obj_shape, u8 obj_size, s16 x, s16 y){
    00404    PA_obj[screen][obj_number].atr2 = gfx + (15 << 12);
    00405    PA_obj[screen][obj_number].atr0 = (y&OBJ_Y) + (3 << 10) + (obj_shape << 14);
    00406    PA_obj[screen][obj_number].atr1 = (x & OBJ_X) + (obj_size << 14);
    00407 }
    00408
    00409
    00410
    00411
    00412
    00439 extern inline void PA_Create16bitSprite(u8 screen, u8 obj_number, void* obj_data, u8 obj_shape, u8 obj_size, s16 x, s16 y){
    00440 PA_Create16bitSpriteEx(screen, obj_number, obj_data, obj_shape, obj_size, 0, 0, 0, 0, 0, x, y);
    00441 }
    00442
    00443
    00444
    00445
    00478 extern 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) {
    00479    PA_obj[screen][obj_number].atr2 = obj_gfx + (palette << 12);
    00480    PA_obj[screen][obj_number].atr0 = (y&OBJ_Y) + (color_mode << 13) + (obj_shape << 14);
    00481    PA_obj[screen][obj_number].atr1 = (x & OBJ_X) + (obj_size << 14);
    00482    ++obj_per_gfx[screen][obj_gfx];
    00483 };
    00484
    00535 extern 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) {
    00536    PA_obj[screen][obj_number].atr2 = obj_gfx + (prio << 10) + (palette << 12);
    00537    PA_obj[screen][obj_number].atr0 = (y&OBJ_Y) + (dblsize << 9) + (obj_mode << 10) + (mosaic << 12) + (color_mode << 13) + (obj_shape << 14);
    00538    PA_obj[screen][obj_number].atr1 = (x & OBJ_X) + (hflip << 12) + (vflip << 13) + (obj_size << 14);
    00539    ++obj_per_gfx[screen][obj_gfx];
    00540 };
    00541
    00542
    00557 #define PA_UpdateSpriteGfx(screen, obj_number, obj_data) PA_UpdateGfx(screen, PA_GetSpriteGfx(screen, obj_number), obj_data)
    00558
    00573 #include "PA_Text.h"
    00574 #include "PA_Math.h"
    00575
    00576 extern inline void PA_UpdateGfx(u8 screen, u16 gfx_number, void *obj_data) {
    00577        DMA_Copy((obj_data), (void*)(SPRITE_GFX1 + (0x200000 *  (screen)) + ((gfx_number) << NUMBER_DECAL)), (used_mem[screen][gfx_number] << MEM_DECAL), DMA_32NOW);
    00578 //     PA_OutputText(1, 25, PA_Rand()&15, "%dgfx   ", gfx_number);
    00579 }
    00580
    00581
    00597 extern inline void PA_UpdateGfxAndMem(u8 screen, u8 gfx_number, void *obj_data){
    00598        DMA_Copy((obj_data), (void*)(SPRITE_GFX1 + (0x200000 *  (screen)) + ((gfx_number) << NUMBER_DECAL)), (used_mem[screen][gfx_number] << MEM_DECAL), DMA_32NOW);
    00599        PA_SpriteAnimP[screen][gfx_number] = (u16*)obj_data; // mémorise la source de l'image...
    00600 }
    00601
    00602
    00603
    00604
    00616 void PA_DeleteGfx(u8 screen, u16 obj_gfx);
    00617
    00618
    00630 void PA_DeleteSprite(u8 screen, u8 obj_number);
    00631
    00632
    00648 #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);}
    00649
    00661 #define PA_SetSpriteRotDisable(screen, sprite) {PA_obj[screen][sprite].atr0 &= ALL_BUT(OBJ_ROT);  PA_obj[screen][sprite].atr1 &= ALL_BUT_ROTSET;}
    00662
    00663
    00685 extern inline void PA_SetRotset(u8 screen, u8 rotset, s16 angle, u16 zoomx, u16 zoomy) {
    00686 u8 obj_num = (rotset << 2);
    00687        PA_obj[screen][obj_num].atr3 = (PA_Cos(angle) * zoomx) >> 8;
    00688        PA_obj[screen][obj_num + 1].atr3 = (-PA_Sin(angle) * zoomy) >> 8;
    00689        PA_obj[screen][obj_num + 2].atr3 = (PA_Sin(angle) * zoomx) >> 8;
    00690        PA_obj[screen][obj_num + 3].atr3 = (PA_Cos(angle) * zoomy) >> 8;
    00691 }
    00692
    00707 extern inline void PA_SetRotsetNoZoom(u8 screen, u8 rotset, s16 angle)   {
    00708 u8 obj_num = (rotset << 2);
    00709        PA_obj[screen][obj_num].atr3 = PA_Cos(angle);
    00710        PA_obj[screen][obj_num + 1].atr3 = -PA_Sin(angle);
    00711        PA_obj[screen][obj_num + 2].atr3 = PA_Sin(angle);
    00712        PA_obj[screen][obj_num + 3].atr3 = PA_Cos(angle);
    00713 }
    00714
    00732 extern inline void PA_SetRotsetNoAngle(u8 screen, u8 rotset, u16 zoomx, u16 zoomy) {
    00733 u8 obj_num = (rotset << 2);
    00734        PA_obj[screen][obj_num].atr3 = zoomx;
    00735        PA_obj[screen][obj_num + 1].atr3 = 0;
    00736        PA_obj[screen][obj_num + 2].atr3 = 0;
    00737        PA_obj[screen][obj_num + 3].atr3 = zoomy;
    00738 }
    00739
    00740
    00741
    00742
    00743
    00744
    00745
    00762 #define PA_SetSpriteX(screen, obj, x) PA_obj[screen][obj].atr1 = (PA_obj[screen][obj].atr1 & ALL_BUT(OBJ_X)) + ((x) & OBJ_X)
    00763
    00776 #define PA_GetSpriteX(screen, obj) (PA_obj[screen][obj].atr1 & (OBJ_X))
    00777
    00778
    00793 #define PA_SetSpriteY(screen, obj, y) PA_obj[screen][obj].atr0 = (PA_obj[screen][obj].atr0 & ALL_BUT(OBJ_Y)) + ((y) & OBJ_Y)
    00794
    00807 #define PA_GetSpriteY(screen, obj) (PA_obj[screen][obj].atr0 & OBJ_Y)
    00808
    00809
    00810
    00828 extern inline void PA_SetSpriteXY(u8 screen, u8 sprite, s16 x, s16 y) {
    00829        PA_SetSpriteX(screen, sprite, x);
    00830        PA_SetSpriteY(screen, sprite, y);
    00831 }
    00832
    00833
    00834
    00849 #define PA_SetSpritePal(screen, obj, pal) PA_obj[screen][obj].atr2 = (PA_obj[screen][obj].atr2 & ALL_BUT_PAL) + ((pal) << 12)
    00850
    00862 #define PA_GetSpritePal(screen, obj) (PA_obj[screen][obj].atr2 >> 12)
    00863
    00864
    00879 #define PA_SetSpriteDblsize(screen, obj, dblsize) PA_obj[screen][obj].atr0 = (PA_obj[screen][obj].atr0 & ALL_BUT(DBLSIZE)) + ((dblsize) << 9)
    00880
    00892 #define PA_GetSpriteDblsize(screen, obj) ((PA_obj[screen][obj].atr0 & DBLSIZE) >> 9)
    00893
    00894
    00909 #define PA_SetSpriteColors(screen, sprite, n_colors) PA_obj[screen][sprite].atr0 = (PA_obj[screen][sprite].atr0 & ALL_BUT(N_COLORS)) + ((n_colors) << 13)
    00910
    00922 #define PA_GetSpriteColors(screen, sprite) ((PA_obj[screen][sprite].atr0 & N_COLORS) >> 13)
    00923
    00924
    00925
    00940 #define PA_SetSpriteMode(screen, sprite, obj_mode) PA_obj[screen][sprite].atr0 = (PA_obj[screen][sprite].atr0 & ALL_BUT(OBJ_MODE)) + ((obj_mode) << 10)
    00941
    00953 #define PA_GetSpriteMode(screen, obj) ((PA_obj[screen][obj].atr0 & OBJ_MODE) >> 10)
    00954
    00955
    00970 #define PA_SetSpriteMosaic(screen, obj, mosaic) PA_obj[screen][obj].atr0 = (PA_obj[screen][obj].atr0 & ALL_BUT(OBJ_MOSAIC)) + ((mosaic) << 12)
    00971
    00983 #define PA_GetSpriteMosaic(screen, obj) ((PA_obj[screen][obj].atr0 & OBJ_MOSAIC) >> 12)
    00984
    00985
    00986
    01001 #define PA_SetSpriteHflip(screen, obj, hflip) PA_obj[screen][obj].atr1 = (PA_obj[screen][obj].atr1 & ALL_BUT(OBJ_HFLIP)) + ((hflip) << 12)
    01002
    01014 #define PA_GetSpriteHflip(screen, obj) ((PA_obj[screen][obj].atr1 & OBJ_HFLIP) >> 12)
    01015
    01016
    01031 #define PA_SetSpriteVflip(screen, obj, vflip) PA_obj[screen][obj].atr1 = (PA_obj[screen][obj].atr1 & ALL_BUT(OBJ_VFLIP)) + ((vflip) << 13)
    01032
    01044 #define PA_GetSpriteVflip(screen, obj) ((PA_obj[screen][obj].atr1 & OBJ_VFLIP) >> 13)
    01045
    01046
    01061 #define PA_SetSpriteGfx(screen, obj, gfx) PA_obj[screen][obj].atr2 = (PA_obj[screen][obj].atr2 & ALL_BUT(OBJ_GFX)) + ((gfx) & OBJ_GFX)
    01062
    01074 #define PA_GetSpriteGfx(screen, obj) (PA_obj[screen][obj].atr2 & OBJ_GFX)
    01075
    01076
    01077
    01092 #define PA_SetSpritePrio(screen, obj, prio) PA_obj[screen][obj].atr2 = (PA_obj[screen][obj].atr2 & ALL_BUT(OBJ_PRIO)) + ((prio) << 10)
    01093
    01105 #define PA_GetSpritePrio(screen, obj) ((PA_obj[screen][obj].atr2 & OBJ_PRIO) >> 10)
    01106
    01107
    01119 #define PA_GetSpriteLx(screen, sprite) PA_size[PA_obj[screen][sprite].atr0 >> 14][PA_obj[screen][sprite].atr1 >> 14].lx
    01120
    01121
    01133 #define PA_GetSpriteLy(screen, sprite)PA_size[PA_obj[screen][sprite].atr0 >> 14][PA_obj[screen][sprite].atr1 >> 14].ly
    01134
    01135
    01150 #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)];}
    01151
    01152
    01153
    01154
    01155
    01156
    01157
    01158
    01182 extern inline void PA_SetSpriteAnimEx(u8 screen, u8 sprite, u8 lx, u8 ly, u8 ncolors, s16 animframe){
    01183        u16 gfx = PA_GetSpriteGfx(screen, sprite);
    01184        //PA_OutputText(1, 0, PA_Rand()&15, "%03d - %03d   ", gfx, sprite);
    01185        PA_UpdateGfx(screen, gfx, (void*)(PA_SpriteAnimP[screen][gfx] + (animframe * (lx * ly) >> (2 - ncolors))));
    01186 }
    01187
    01202 extern inline void PA_SetSpriteAnim(u8 screen, u8 sprite, s16 animframe){
    01203        PA_SetSpriteAnimEx(screen, sprite, PA_GetSpriteLx(screen, sprite), PA_GetSpriteLy(screen, sprite), PA_GetSpriteColors(screen, sprite), animframe);
    01204 }
    01205
    01206
    01207
    01234 void PA_StartSpriteAnimEx(u8 screen, u8 sprite, s16 firstframe, s16 lastframe, s16 speed, u8 type, s16 ncycles);
    01235
    01236
    01237
    01238
    01259 extern inline void PA_StartSpriteAnim(u8 screen, u8 sprite, s16 firstframe, s16 lastframe, s16 speed){
    01260        PA_StartSpriteAnimEx(screen, sprite, firstframe, lastframe, speed, ANIM_INFINITE);
    01261 }
    01262
    01263
    01264
    01265
    01277 extern inline void PA_StopSpriteAnim(u8 screen, u8 sprite)
    01278 {
    01279        if (spriteanims[screen][sprite].play) nspriteanims--;
    01280        spriteanims[screen][sprite].play = 0;
    01281 }
    01282
    01297 extern inline void PA_SetSpriteAnimFrame(u8 screen, u8 sprite, u16 frame)
    01298 {
    01299        if(spriteanims[screen][sprite].currentframe != frame){
    01300               PA_SetSpriteAnimEx(screen, sprite, spriteanims[screen][sprite].lx, spriteanims[screen][sprite].ly, spriteanims[screen][sprite].colors, spriteanims[screen][sprite].currentframe);
    01301               spriteanims[screen][sprite].currentframe = frame;
    01302        }
    01303 }
    01304
    01305
    01317 extern inline u16 PA_GetSpriteAnimFrame(u8 screen, u8 sprite)
    01318 {
    01319        return spriteanims[screen][sprite].currentframe;
    01320 }
    01321
    01322
    01323
    01338 extern inline void PA_SetSpriteAnimSpeed(u8 screen, u8 sprite, s16 speed)
    01339 {
    01340        spriteanims[screen][sprite].speed = speed;
    01341 }
    01342
    01354 extern inline u16 PA_GetSpriteAnimSpeed(u8 screen, u8 sprite)
    01355 {
    01356        return spriteanims[screen][sprite].speed;
    01357 }
    01358
    01359
    01374 extern inline void PA_SetSpriteNCycles(u8 screen, u8 sprite, s16 NCycles)
    01375 {
    01376        spriteanims[screen][sprite].ncycles = NCycles;
    01377 }
    01378
    01379
    01380
    01392 extern inline u16 PA_GetSpriteNCycles(u8 screen, u8 sprite)
    01393 {
    01394        return spriteanims[screen][sprite].speed;
    01395 }
    01396
    01397
    01398
    01399
    01400
    01415 extern inline void PA_SpriteAnimPause(u8 screen, u8 sprite, u8 pause)
    01416 {
    01417        if (pause&&spriteanims[screen][sprite].play) nspriteanims--;
    01418        else if ((!pause)&&(!spriteanims[screen][sprite].play)) nspriteanims++;
    01419        spriteanims[screen][sprite].play = !pause;
    01420 }
    01421
    01422
    01423
    01424
    01425
    01426
    01447 extern inline void PA_SetSpritePixel(u8 screen, u8 sprite, u8 x, u8 y, u8 color){
    01448 u8 hsize = spriteanims[screen][sprite].lx>>3;
    01449
    01450        s32 pos = (x >> 3) + ((y >> 3) * hsize);
    01451        x&=7; y&=7;
    01452
    01453        pos = (pos << 5) + (x >> 1) + (y << 2);
    01454
    01455        u16 pixel = spriteanims[screen][sprite].gfx[pos];
    01456
    01457        if (x&1){
    01458               spriteanims[screen][sprite].gfx[pos] = (color << 8) | (pixel&0x00FF);
    01459        }
    01460        else {
    01461               spriteanims[screen][sprite].gfx[pos] = color | (pixel&0xFF00);
    01462        }
    01463 }
    01464
    01465
    01483 extern inline u8 PA_GetSpritePixel(u8 screen, u8 sprite, u8 x, u8 y) {
    01484 u8 hsize = spriteanims[screen][sprite].lx>>3;
    01485
    01486        s32 pos = (x >> 3) + ((y >> 3) * hsize);
    01487        x&=7; y&=7;
    01488
    01489        pos = (pos << 5) + (x >> 1) + (y << 2);
    01490
    01491        u16 pixel = spriteanims[screen][sprite].gfx[pos];
    01492
    01493        if (x&1){
    01494               return ((pixel>>8)&255);
    01495        }
    01496        else {
    01497               return (pixel&255);
    01498        }
    01499 }
    01500
    01501
    01513 void PA_InitSpriteDraw(u8 screen, u8 sprite);
    01514
    01515
    01516
    01522 extern inline void PA_InitAllSpriteDraw(void){
    01523 u8 i, j;
    01524 for (j = 0; j < 2; j++)
    01525        for (i = 0; i < 128; i++)
    01526               PA_InitSpriteDraw(j, i);
    01527 }
    01528
    01529
    01530
    01531
    01540 void PA_InitSpriteExtPrio(u8 SpritePrio);
    01541
    01542 extern inline void PA_SetSPriteExtPrio(u8 screen, u8 sprite, u8 prio){
    01543        PA_SpritePrio[screen][sprite] = prio;
    01544 }
    01545
    01546
    01547
    01548  // end of Sprite
    01550
    01551
    01552
    01553
    01554
    01555 void PA_UpdateSpriteAnims(void);
    01556
    01557
    01558
    01559
    01560
    01561
    01562
    01563
    01564
    01565
    01566
    01567 #endif
    01568
    01569