PAlib: Fichier source de PA_SpriteDual.h

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

# PA_SpriteDual.h

Aller à la documentation de ce fichier.

    00001 #ifndef _PA_SpriteDual
    00002 #define _PA_SpriteDual
    00003
    00004
    00005
    00012 #include "PA_Sprite.h"
    00013
    00014
    00029 extern inline void PA_SetScreenSpace(s16 ScreenSpace){
    00030        PA_ScreenSpace = 192 + ScreenSpace;
    00031 }
    00032
    00033
    00034
    00035
    00036
    00037
    00049 extern inline void PA_DualSetSpriteY(u8 obj, s16 y){
    00050 s16 y0 = 192; s16 y1 = 192;
    00051        if (y < 192) y1 = y;
    00052        if (y > PA_ScreenSpace-64) y0 = y - PA_ScreenSpace;
    00053        PA_SetSpriteY(0, obj, y0);
    00054        PA_SetSpriteY(1, obj, y1);
    00055 }
    00056
    00057
    00058
    00088 extern 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) {
    00089        PA_CreateSprite(0, obj_number, obj_data, obj_shape, obj_size, color_mode, palette, x, 192);
    00090        PA_CreateSprite(1, obj_number, obj_data, obj_shape, obj_size, color_mode, palette, x, 192);
    00091        PA_DualSetSpriteY(obj_number, y);
    00092 };
    00093
    00141 extern inline void PA_DualCreateSpriteEx(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){
    00142        PA_CreateSpriteEx(0, obj_number, obj_data, obj_shape, obj_size, color_mode, palette, obj_mode, mosaic, hflip, vflip, prio, dblsize, x, 192);
    00143        PA_CreateSpriteEx(1, obj_number, obj_data, obj_shape, obj_size, color_mode, palette, obj_mode, mosaic, hflip, vflip, prio, dblsize, x, 192);
    00144        PA_DualSetSpriteY(obj_number, y);
    00145 }
    00146
    00147
    00148
    00149
    00150
    00189 extern inline void PA_DualCreate16bitSpriteEx(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){
    00190 u16 mem_size = PA_obj_sizes[obj_size][obj_shape] << 1;
    00191 u16 *gfx = (u16*)malloc(mem_size);
    00192 mem_size = mem_size >> 1;
    00193 s32 i;
    00194 u16 *data = (u16*)obj_data;
    00195 for (i = 0; i < mem_size; i++) gfx[i] = data[i] + (1 << 15);
    00196
    00197    PA_obj[0][obj_number].atr2 = PA_CreateGfx(0, gfx, obj_shape, obj_size, 2) + (prio << 10) + (15 << 12);
    00198    PA_obj[1][obj_number].atr2 = PA_CreateGfx(1, gfx, obj_shape, obj_size, 2) + (prio << 10) + (15 << 12);
    00199    PA_obj[1][obj_number].atr0 = PA_obj[0][obj_number].atr0 = (192 & OBJ_Y) + (dblsize << 9) + (3 << 10) + (mosaic << 12) + (0 << 13) + (obj_shape << 14);
    00200    PA_obj[1][obj_number].atr1 = PA_obj[0][obj_number].atr1 = (x & OBJ_X) + (hflip << 12) + (vflip << 13) + (obj_size << 14);
    00201    PA_DualSetSpriteY(obj_number, y);
    00202
    00203 free(gfx);
    00204 }
    00205
    00206
    00207
    00231 extern inline void PA_DualCreate16bitSprite(u8 obj_number, void* obj_data, u8 obj_shape, u8 obj_size, s16 x, s16 y){
    00232 PA_DualCreate16bitSpriteEx(obj_number, obj_data, obj_shape, obj_size, 0, 0, 0, 0, 0, x, y);
    00233 }
    00234
    00235
    00236
    00237
    00267 extern 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) {
    00268    PA_CreateSpriteFromGfx(0, obj_number, obj_gfx[0], obj_shape, obj_size, color_mode, palette, x, 192);
    00269    PA_CreateSpriteFromGfx(1, obj_number, obj_gfx[1], obj_shape, obj_size, color_mode, palette, x, 192);
    00270 PA_DualSetSpriteY(obj_number, y);
    00271 }
    00272
    00320 extern inline void PA_DualCreateSpriteExFromGfx(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) {
    00321 PA_CreateSpriteExFromGfx(0, obj_number, obj_gfx[0], obj_shape, obj_size, color_mode, palette, obj_mode, mosaic, hflip, vflip, prio, dblsize, x, 192);
    00322 PA_CreateSpriteExFromGfx(1, obj_number, obj_gfx[1], obj_shape, obj_size, color_mode, palette, obj_mode, mosaic, hflip, vflip, prio, dblsize, x, 192);
    00323 PA_DualSetSpriteY(obj_number, y);
    00324 }
    00325
    00326
    00338 extern inline void PA_DualUpdateSpriteGfx(u8 obj_number, void *obj_data){
    00339        PA_UpdateSpriteGfx(0, obj_number, obj_data);
    00340        PA_UpdateSpriteGfx(1, obj_number, obj_data);
    00341 }
    00342
    00343
    00355 extern inline void PA_DualUpdateGfx(u16 gfx_number, void *obj_data){
    00356        PA_UpdateGfx(0, gfx_number, obj_data);
    00357        PA_UpdateGfx(1, gfx_number, obj_data);
    00358 }
    00359
    00360
    00361
    00362
    00371 extern inline void PA_DualDeleteSprite(u8 obj_number){
    00372        PA_DeleteSprite(0, obj_number);
    00373        PA_DeleteSprite(1, obj_number);
    00374 }
    00375
    00376
    00377
    00389 extern inline void PA_DualSetSpriteRotEnable(u8 sprite, u8 rotset){
    00390        PA_SetSpriteRotEnable(0, sprite, rotset);
    00391        PA_SetSpriteRotEnable(1, sprite, rotset);
    00392 }
    00393
    00394
    00395
    00404 extern inline void PA_DualSetSpriteRotDisable(u8 sprite){
    00405        PA_SetSpriteRotDisable(0, sprite);
    00406        PA_SetSpriteRotDisable(1, sprite);
    00407 }
    00408
    00427 extern inline void PA_DualSetRotset(u8 rotset, s16 angle, u16 zoomx, u16 zoomy) {
    00428 u8 obj_num = (rotset << 2);
    00429        PA_obj[0][obj_num].atr3 = PA_obj[1][obj_num].atr3 = (PA_Cos(angle) * zoomx) >> 8;
    00430        PA_obj[0][obj_num + 1].atr3 = PA_obj[1][obj_num + 1].atr3 = (-PA_Sin(angle) * zoomy) >> 8;
    00431        PA_obj[0][obj_num + 2].atr3 = PA_obj[1][obj_num + 2].atr3 = (PA_Sin(angle) * zoomx) >> 8;
    00432        PA_obj[0][obj_num + 2].atr3 = PA_obj[1][obj_num + 2].atr3 = (PA_Sin(angle) * zoomx) >> 8;
    00433        PA_obj[0][obj_num + 3].atr3 = PA_obj[1][obj_num + 3].atr3 = (PA_Cos(angle) * zoomy) >> 8;
    00434 }
    00435
    00447 extern inline void PA_DualSetRotsetNoZoom(u8 rotset, s16 angle)   {
    00448 u8 obj_num = (rotset << 2);
    00449        PA_obj[0][obj_num].atr3 = PA_obj[1][obj_num].atr3 = PA_Cos(angle);
    00450        PA_obj[0][obj_num + 1].atr3 = PA_obj[1][obj_num + 1].atr3 = -PA_Sin(angle);
    00451        PA_obj[0][obj_num + 2].atr3 = PA_obj[1][obj_num + 2].atr3 = PA_Sin(angle);
    00452        PA_obj[0][obj_num + 3].atr3 = PA_obj[1][obj_num + 3].atr3 = PA_Cos(angle);
    00453 }
    00454
    00455
    00470 extern inline void PA_DualSetRotsetNoAngle(u8 rotset, u16 zoomx, u16 zoomy) {
    00471 u8 obj_num = (rotset << 2);
    00472        PA_obj[0][obj_num].atr3 = PA_obj[1][obj_num].atr3 = zoomx;
    00473        PA_obj[0][obj_num + 1].atr3 = PA_obj[1][obj_num + 1].atr3 = 0;
    00474        PA_obj[0][obj_num + 2].atr3 = PA_obj[1][obj_num + 2].atr3 = 0;
    00475        PA_obj[0][obj_num + 3].atr3 = PA_obj[1][obj_num + 3].atr3 = zoomy;
    00476 }
    00477
    00478
    00479
    00480
    00481
    00482
    00483
    00495 extern inline void PA_DualSetSpriteX(u8 obj, s16 x){
    00496        PA_obj[0][obj].atr1 = PA_obj[1][obj].atr1 = (PA_obj[0][obj].atr1 & ALL_BUT(OBJ_X)) + ((x) & OBJ_X);
    00497 }
    00498
    00499
    00500
    00501
    00502
    00503
    00504
    00505
    00520 extern inline void PA_DualSetSpriteXY(u8 sprite, s16 x, s16 y) {
    00521        PA_DualSetSpriteX(sprite, x);
    00522        PA_DualSetSpriteY(sprite, y);
    00523 }
    00524
    00525
    00526
    00538 extern inline void PA_DualSetSpritePal(u8 obj, u8 pal){
    00539        PA_SetSpritePal(0, obj, pal);
    00540        PA_SetSpritePal(1, obj, pal);
    00541 }
    00542
    00543
    00544
    00556 extern inline void PA_DualSetSpriteDblsize(u8 obj, bool dblsize){
    00557        PA_SetSpriteDblsize(0, obj, dblsize);
    00558        PA_SetSpriteDblsize(1, obj, dblsize);
    00559 }
    00560
    00561
    00562
    00563
    00575 extern inline void PA_DualSetSpriteColors(u8 sprite, bool n_colors){
    00576        PA_SetSpriteColors(0, sprite, n_colors);
    00577        PA_SetSpriteColors(1, sprite, n_colors);
    00578
    00579 }
    00580
    00581
    00582
    00583
    00595 extern inline void PA_DualSetSpriteMode(u8 sprite, u8 obj_mode){
    00596        PA_SetSpriteMode(0, sprite, obj_mode);
    00597        PA_SetSpriteMode(1, sprite, obj_mode);
    00598 }
    00599
    00600
    00601
    00602
    00603
    00604
    00616 extern inline void PA_DualSetSpriteMosaic(u8 obj, bool mosaic){
    00617        PA_SetSpriteMosaic(0, obj, mosaic);
    00618        PA_SetSpriteMosaic(1, obj, mosaic);
    00619 }
    00620
    00621
    00622
    00623
    00624
    00625
    00637 extern inline void PA_DualSetSpriteHflip(u8 obj, bool hflip){
    00638        PA_SetSpriteHflip(0, obj, hflip);
    00639        PA_SetSpriteHflip(1, obj, hflip);
    00640 }
    00641
    00642
    00643
    00644
    00656 extern inline void PA_DualSetSpriteVflip(u8 obj, bool vflip){
    00657        PA_SetSpriteVflip(0, obj, vflip);
    00658        PA_SetSpriteVflip(1, obj, vflip);
    00659 }
    00660
    00661
    00662
    00663
    00664
    00665
    00677 extern inline void PA_DualSetSpriteGfx(u8 obj, u16 *gfx){
    00678        PA_SetSpriteGfx(0, obj, gfx[0]);
    00679        PA_SetSpriteGfx(1, obj, gfx[1]);
    00680 }
    00681
    00682
    00683
    00684
    00685
    00697 extern inline void PA_DualSetSpritePrio(u8 obj, u8 prio){
    00698        PA_SetSpritePrio(0, obj, prio);
    00699        PA_SetSpritePrio(1, obj, prio);
    00700 }
    00701
    00702
    00703
    00704
    00705
    00717 extern inline void PA_DualCloneSprite(u8 obj, u8 target){
    00718        PA_CloneSprite(0, obj, target);
    00719        PA_CloneSprite(1, obj, target);
    00720 }
    00721
    00722
    00723
    00724
    00725
    00726
    00727
    00748 extern inline void PA_DualSetSpriteAnimEx(u8 sprite, u8 lx, u8 ly, u8 ncolors, s16 animframe){
    00749        PA_SetSpriteAnimEx(0, sprite, lx, ly, ncolors, animframe);
    00750        PA_SetSpriteAnimEx(1, sprite, lx, ly, ncolors, animframe);
    00751 }
    00752
    00753
    00754
    00755
    00756
    00768 extern inline void PA_DualSetSpriteAnim(u8 sprite, s16 animframe){
    00769 u8 lx = PA_GetSpriteLx(0, sprite); u8 ly = PA_GetSpriteLy(0, sprite);
    00770 bool ncolors = PA_GetSpriteColors(0, sprite);
    00771        PA_SetSpriteAnimEx(0, sprite, lx, ly, ncolors, animframe);
    00772        PA_SetSpriteAnimEx(1, sprite, lx, ly, ncolors, animframe);
    00773 }
    00774
    00775
    00776
    00777
    00801 extern inline void PA_DualStartSpriteAnimEx(u8 sprite, s16 firstframe, s16 lastframe, s16 speed, u8 type, s16 ncycles){
    00802        PA_StartSpriteAnimEx(0, sprite, firstframe, lastframe, speed, type, ncycles);
    00803        PA_StartSpriteAnimEx(1, sprite, firstframe, lastframe, speed, type, ncycles);
    00804 }
    00805
    00806
    00807
    00825 extern inline void PA_DualStartSpriteAnim(u8 sprite, s16 firstframe, s16 lastframe, s16 speed){
    00826        PA_StartSpriteAnim(0, sprite, firstframe, lastframe, speed);
    00827        PA_StartSpriteAnim(1, sprite, firstframe, lastframe, speed);
    00828 }
    00829
    00830
    00831
    00840 extern inline void PA_DualStopSpriteAnim(u8 sprite)
    00841 {
    00842        PA_StopSpriteAnim(0, sprite);
    00843        PA_StopSpriteAnim(1, sprite);
    00844 }
    00845
    00846
    00858 extern inline void PA_DualSetSpriteAnimFrame(u8 sprite, u16 frame)
    00859 {
    00860        PA_SetSpriteAnimFrame(0, sprite, frame);
    00861        PA_SetSpriteAnimFrame(1, sprite, frame);
    00862 }
    00863
    00864
    00873 extern inline u16 PA_DualGetSpriteAnimFrame(u8 sprite)
    00874 {
    00875        return spriteanims[0][sprite].currentframe;
    00876 }
    00877
    00878
    00879
    00891 extern inline void PA_DualSetSpriteAnimSpeed(u8 sprite, s16 speed)
    00892 {
    00893        PA_SetSpriteAnimSpeed(0, sprite, speed);
    00894        PA_SetSpriteAnimSpeed(1, sprite, speed);
    00895 }
    00896
    00897
    00898
    00899
    00908 extern inline u16 PA_DualGetSpriteAnimSpeed(u8 sprite)
    00909 {
    00910        return spriteanims[0][sprite].speed;
    00911 }
    00912
    00913
    00914
    00926 extern inline void PA_DualSpriteAnimPause(u8 sprite, bool pause)
    00927 {
    00928        PA_SpriteAnimPause(0, sprite, pause);
    00929        PA_SpriteAnimPause(1, sprite, pause);
    00930 }
    00931
    00932
    00933
    00934
    00935
    00936 /*
    00960 extern inline void PA_DualSetSpritePixelEx(u8 sprite, u8 hsize, u8 n_colors, u8 x, u8 y, u8 color){
    00961        PA_SetSpritePixelEx(0, sprite, hsize, n_colors, x, y, color);
    00962        PA_SetSpritePixelEx(1, sprite, hsize, n_colors, x, y, color);
    00963 }*/
    00964
    00965
    00966
    00967
    00968
    00969 /*
    00987 extern inline void PA_DualSetSpritePixel(u8 sprite, s16 x, s16 y, bool color){
    00988 PA_DualSetSpritePixelEx(sprite, PA_GetSpriteLx(0, sprite), PA_GetSpriteColors(0, sprite), x, y, color);
    00989 }*/
    00990
    00991
    00992
    00993
    00994
    00995  // end of Sprite
    00997
    00998
    00999
    01000
    01001
    01002
    01003
    01004
    01005
    01006
    01007
    01008
    01009
    01010 #endif
    01011
    01012