PA_Draw.h

Aller à la documentation de ce fichier.
00001 #ifndef _PA_Buffer
00002 #define _PA_Buffer
00003 
00004 #ifdef __cplusplus
00005 extern "C" {
00006 #endif
00007 
00014 #include "PA9.h"
00015 
00016 #include "PA_Interrupt.h"
00017 #include "PA_Palette.h"
00018 #include "gif/gif_lib.h"
00019 
00020 extern GifFileType* gifinfo;
00021 extern s16 gifwidth, gifheight; 
00022 extern u8 PA_nBit[2]; // 8 or 16 bit Bg
00023 
00024 
00025 #define PA_RGB8(r,g,b)      ((((b)>>3)<<10)|(((g)>>3)<<5)|((r)>>3)|(1 << 15))
00026 
00027 
00028 typedef struct{
00029        u16 Id; // ?
00030        u32 Length;
00031        u16 Nothing1, Nothing2; // ?
00032        u32 ImageStart; // Offset of start of image
00033 } BMPHeader0;
00034 
00035 typedef struct{
00036        u32 SizeofHeader; // 40
00037        u32 Width, Height;
00038        u16 Colorplanes; // Usually 1
00039        u16 BitsperPixel; //1, 2, 4, 8, 16, 24, 32
00040        u32 Compression;  // 0 for none, 1...
00041        u32 SizeofData; // Not reliable
00042        u32 WidthperMeter, HeightperMeter; // Don't care
00043        u32 NColors, ImportantColors; // Number of colors used, important colors ?
00044 } BMP_Headers;
00045 
00046 
00047 extern u16 PA_oldx[2];
00048 extern u16 PA_oldy[2];
00049 extern u8 PA_drawsize[2];
00050 extern u16 *PA_DrawBg[2];
00051 extern u8 PA_nBit[2]; // 8 or 16 bit Bg
00052 //extern PA_SCreen
00053 
00054 extern u16 PA_temppal[256];
00055 
00056 
00057 void PA_Load16bitGif(u8 screen, s16 x, s16 y, void *gif);
00058 
00059 int DecodeGif(const u8 *userData, u8 *ScreenBuff, u16* Palette, u8 nBits, s16 SWidth);
00060 
00061 
00062 
00080 void PA_Init8bitBg(u8 screen, u8 bg_priority);
00081 
00082 
00094 void PA_Init16bitBg(u8 screen, u8 bg_priority);
00095 
00096 
00097 
00115 extern inline void PA_Put8bitPixel(u8 screen, s16 x, s16 y, u8 color) {
00116    PA_DrawBg[screen][(y <<7) + (x>>1)] &= (0xff00>>((x&1)<<3));
00117    PA_DrawBg[screen][(y <<7) + (x>>1)] |= color<<((x&1)<<3);
00118 
00119        //s32 pos = (x >> 1) + (y << 7);
00120        //u16 pixel = PA_DrawBg[screen][pos];
00121        //PA_DrawBg[screen][pos] = (color << ((x&1)<<3)) | (pixel&(0xFF00>>((x&1)<<3)));
00122        /*if (x&1){
00123               PA_DrawBg[screen][pos] = (color << 8) | (pixel&0x00FF);               
00124        }
00125        else {
00126               PA_DrawBg[screen][pos] = color | (pixel&0xFF00); 
00127        }*/
00128 }
00129 
00130 
00131 
00150 extern inline void PA_Put2_8bitPixels(u8 screen, s16 x, s16 y, u16 colors) {        PA_DrawBg[screen][(x >> 1) + (y << 7)] = colors;
00151 }
00152 
00173 extern inline void PA_PutDouble8bitPixels(u8 screen, s16 x, s16 y, u8 color1, u8 color2) {
00174        PA_Put2_8bitPixels(screen, x, y, color1 + (color2 << 8));             
00175 }
00176 
00177 
00178 
00197 extern inline void PA_Put4_8bitPixels(u8 screen, s16 x, s16 y, u32 colors) {
00198 /*
00199        (*u32*)(PA_DrawBg[screen] + (x >> 1) + (y << 7)) = colors;*/
00200 }
00201 
00202 
00217 extern inline u8 PA_Get8bitPixel(u8 screen, u8 x, u8 y) {
00218        u16 pos =     (x >> 1) + (y << 7);
00219        if (x&1){
00220               return (PA_DrawBg[screen][pos] >> 8);
00221        }
00222        else {
00223               return (PA_DrawBg[screen][pos]);
00224        }
00225 }
00226 
00227 
00228 
00229 
00247 extern inline void PA_Put16bitPixel(u8 screen, s16 x, s16 y, u16 color) {
00248        PA_DrawBg[screen][x + (y << 8)] = color;
00249 }
00250 
00251 
00266 #define PA_Get16bitPixel(screen, x, y) PA_DrawBg[screen][x + (y << 8)]
00267 
00268 
00269 
00270 
00271 
00272 
00296 void PA_Draw8bitLine(u8 screen, u16 x1, u16 y1, u16 x2, u16 y2, u8 color);
00297 
00298 
00299 
00300 
00301 
00325 void PA_Draw16bitLine(u8 screen, u16 x1, u16 y1, u16 x2, u16 y2, u16 color);
00326 
00327 
00328 
00355 void PA_Draw16bitLineEx(u8 screen, s16 basex, s16 basey, s16 endx, s16 endy, u16 color, s8 size);
00356 
00357 
00384 void PA_Draw8bitLineEx(u8 screen, s16 basex, s16 basey, s16 endx, s16 endy, u8 color, s8 size);
00385 
00386 
00387 
00411 void PA_Draw16bitRect(u8 screen, s16 basex, s16 basey, s16 endx, s16 endy, u16 color);
00412 
00413 
00425 void PA_8bitDraw(u8 screen, u8 color);
00426 
00427 
00439 void PA_16bitDraw(u8 screen, u16 color);
00440 
00441 
00453 #define PA_SetDrawSize(screen, draw_size) PA_drawsize[screen] = draw_size;
00454 
00455 
00456 
00457 
00458 
00470 #define PA_Load8bitBitmap(screen, bitmap) DMA_Copy(bitmap, (void*)PA_DrawBg[screen], 256*96, DMA_16NOW);
00471 
00483 #define PA_Load16bitBitmap(screen, bitmap) {u32 PA_temp; \
00484 for (PA_temp = 0; PA_temp < 256*192; PA_temp++)\
00485 PA_DrawBg[screen][PA_temp] = bitmap[PA_temp] | (1 << 15);}
00486 
00487 
00496 #define PA_Clear8bitBg(screen) DMA_Copy(Blank, (void*)PA_DrawBg[screen], 256*96, DMA_16NOW);
00497 
00506 #define PA_Clear16bitBg(screen) DMA_Copy(Blank, (void*)PA_DrawBg[screen], 256*192, DMA_16NOW)
00507 
00508 
00520 extern inline void PA_LoadJpeg(u8 screen, void *jpeg) {
00521        REG_IME = 0x00;
00522        JPEG_DecompressImage((u8*)jpeg, PA_DrawBg[screen], 256, 192);
00523        REG_IME = 0x01;      
00524 }
00525 
00526 
00527 
00548 void PA_LoadBmpToBuffer(u16 *Buffer, s16 x, s16 y, void *bmp, s16 SWidth);
00549 
00550 
00568 extern inline void PA_LoadBmpEx(u8 screen, s16 x, s16 y, void *bmp){
00569 PA_LoadBmpToBuffer(PA_DrawBg[screen], x, y, bmp, 256);
00570 }
00571 
00572 
00573 
00585 extern inline void PA_LoadBmp(u8 screen, void *bmp){
00586        PA_LoadBmpEx(screen, 0, 0, bmp);
00587 }
00588 
00589 
00590 
00591 
00592 
00593 
00594 
00603 extern inline u16 PA_GetGifWidth(void* gif){
00604        u16 *temp = (u16*)gif;
00605        temp += 3;
00606        return *temp;
00607 }
00608 
00609 
00610 
00619 extern inline u16 PA_GetGifHeight(void* gif){
00620        u16 *temp = (u16*)gif;
00621        temp += 4;
00622        return *temp;
00623 }
00624 
00625 
00626 
00638 extern inline void PA_LoadGif(u8 screen, void *gif){
00639        if (PA_nBit[screen]) DecodeGif((const u8*)gif, (u8*)PA_DrawBg[screen], (u16*)0x05000000, 1, 256);
00640        //PA_Load16bitGif(screen, 0, 0, gif); // 16 bit...
00641        else DecodeGif((const u8*)gif, (u8*)PA_DrawBg[screen], (u16*)(0x05000000+(0x400*screen)), 0, 256);
00642 }
00643 
00644 
00645 
00646 /* // Les différentes fonctions images...
00647 extern inline void PA_LoadJpeg(u8 screen, void *jpeg)
00648 void PA_LoadBmp(u8 screen, s16 x, s16 y, void *bmp);*/
00649 
00650 
00662 extern inline void PA_LoadGBFSImage(u8 screen, s16 GBFSImage){
00663        if (PA_CompareText(PA_GBFSfile[GBFSImage].Ext, "bmp")){
00664               PA_LoadBmp(screen, PA_GBFSfile[GBFSImage].File);
00665        }
00666        if (PA_CompareText(PA_GBFSfile[GBFSImage].Ext, "jpg")){ 
00667               PA_LoadJpeg(screen, PA_GBFSfile[GBFSImage].File);
00668        }      
00669        if (PA_CompareText(PA_GBFSfile[GBFSImage].Ext, "gif")){ 
00670               PA_LoadGif(screen, PA_GBFSfile[GBFSImage].File);
00671        }             
00672 }
00673 
00674 
00675 
00676 
00677 extern inline void PA_LoadGBFSImageToBuffer(void *Buffer, s16 GBFSImage, s16 Width){
00678        if (PA_CompareText(PA_GBFSfile[GBFSImage].Ext, "bmp")){
00679               PA_LoadBmpToBuffer((u16*)Buffer, 0, 0, (u16*)PA_GBFSfile[GBFSImage].File, Width);
00680        }
00681        /*if (PA_CompareText(PA_GBFSfile[GBFSImage].Ext, "jpg")){ 
00682               PA_LoadJpeg(screen, PA_GBFSfile[GBFSImage].File);
00683        }      */
00684        if (PA_CompareText(PA_GBFSfile[GBFSImage].Ext, "gif")){ 
00685               DecodeGif((const u8*)PA_GBFSfile[GBFSImage].File, (u8*)Buffer, (u16*)0x05000000, 1, Width);
00686        }             
00687 }
00688 
00689 
00690 
00699 extern inline u16 PA_GetBmpWidth(void *bmp){
00700        u8 *temp = (u8*)bmp;
00701        BMP_Headers *Bmpinfo = (BMP_Headers*)(temp+14);
00702        return Bmpinfo->Width;
00703 }
00704 
00705 
00706 
00715 extern inline u16 PA_GetBmpHeight(void *bmp){
00716        u8 *temp = (u8*)bmp;
00717        BMP_Headers *Bmpinfo = (BMP_Headers*)(temp+14);
00718        return Bmpinfo->Height;
00719 } // end of Draw
00721 
00722 
00723 extern inline void PA_8bit8x8Image(u8 screen, u16 basex, u16 basey, u8* data){
00724 s16 x, y;
00725 
00726 for (x = 0; x < 8; x++)
00727        for (y = 0; y < 8; y++)
00728               PA_Put8bitPixel(screen, x + basex, y + basey, data[x + (y << 3)]);
00729 }
00730 
00731 /*
00732 extern inline void PA_DrawImage(u8 screen, s16 x, s16 y, s16 lx, s16 ly, u8* data){
00733 s16 i, j;
00734 u16* data2 = (u16*)data;
00735 
00736 if (x&1){ // Premier pixel à mettre tout seul peut-etre
00737        for (j = 0; j < ly; j++) PA_Put8bitPixel(screen, x, j + y, data[0]);
00738        x++;
00739        data2 = (u16*)(data + 1);
00740 }
00741 
00742 i = 0;
00743 // Tant qu'il reste au moins 2 pixels à mettre, on fait 2 par 2
00744 while(i < (lx-2)){
00745        for (j = 0; j < ly; j++) {
00746               PA_PutDouble8bitPixels(screen, i + x, j + y, data2[(i >> 1) + (j*lx)]);
00747        }
00748        i+=2;
00749 }
00750 
00751 if (!((i + x)&1)){ // Dernier pixel à mettre tout seul peut-etre
00752        for (j = 0; j < ly; j++) PA_Put8bitPixel(screen, i + x, j + y, data2[(i >> 1) + (j*lx)]&255);
00753 }
00754 
00755 }
00756 */
00757 
00758 
00759 
00760 
00761 
00762 
00763 
00764 
00765 
00766 #ifdef __cplusplus
00767 }
00768 #endif
00769 
00770 
00771 
00772 
00773 
00774 
00775 
00776 
00777 #endif
00778 
00779 

Généré le Wed Aug 30 21:07:40 2006 pour PAlib par  doxygen 1.3.9.1