head 1.1; branch 1.1.1; access ; symbols start:1.1.1.1 PAlibDoc:1.1.1; locks ; strict; comment @# @; 1.1 date 2005.11.02.08.30.31; author jandujar; state Exp; branches 1.1.1.1; next ; 1.1.1.1 date 2005.11.02.08.30.31; author jandujar; state Exp; branches ; next ; desc @@ 1.1 log @Initial revision @ text @ PA_lib: Fichier source de PA_Draw.h

PA_Draw.h

Aller à la documentation de ce fichier.
00001 #ifndef _PA_Buffer
00002 #define _PA_Buffer
00003 
00004 
00005 
00012 #include "PA9.h"
00013 
00014 #include "PA_Interrupt.h"
00015 #include "gif/gif_lib.h"
00016 
00017 extern GifFileType* gifinfo;
00018 extern s16 gifwidth, gifheight; 
00019 extern u8 PA_nBit[2]; // 8 or 16 bit Bg
00020 
00021 
00022 #define PA_RGB8(r,g,b)      ((((b)>>3)<<10)|(((g)>>3)<<5)|((r)>>3)|(1 << 15))
00023 
00024 
00025 typedef struct{
00026        u16 Id; // ?
00027        u32 Length;
00028        u16 Nothing1, Nothing2; // ?
00029        u32 ImageStart; // Offset of start of image
00030 } BMPHeader0;
00031 
00032 typedef struct{
00033        u32 SizeofHeader; // 40
00034        u32 Width, Height;
00035        u16 Colorplanes; // Usually 1
00036        u16 BitsperPixel; //1, 2, 4, 8, 16, 24, 32
00037        u32 Compression;  // 0 for none, 1...
00038        u32 SizeofData; // Not reliable
00039        u32 WidthperMeter, HeightperMeter; // Don't care
00040        u32 NColors, ImportantColors; // Number of colors used, important colors ?
00041 } BMP_Headers;
00042 
00043 
00044 extern u16 PA_oldx[2];
00045 extern u16 PA_oldy[2];
00046 extern u8 PA_drawsize[2];
00047 extern u16 *PA_DrawBg[2];
00048 extern u8 PA_nBit[2]; // 8 or 16 bit Bg
00049 //extern PA_SCreen
00050 
00051 void PA_Load16bitGif(bool screen, s16 x, s16 y, void *gif);
00052 int DecodeGif(const u8 *userData, u8 *ScreenBuff, u16* Palette, u8 nBits, s16 SWidth);
00053 
00054 
00055 
00073 void PA_Init8bitBg(bool screen, u8 bg_priority);
00074 
00075 
00087 void PA_Init16bitBg(bool screen, u8 bg_priority);
00088 
00089 
00090 
00108 extern inline void PA_Put8bitPixel(bool screen, s16 x, s16 y, u8 color) {
00109        u16 pos =     (x >> 1) + (y << 7);
00110        if (x&1){
00111               PA_DrawBg[screen][pos] &= 255;
00112               PA_DrawBg[screen][pos] |= color << 8;                   
00113        }
00114        else {
00115               PA_DrawBg[screen][pos] &= 255 << 8;
00116               PA_DrawBg[screen][pos] |= color;
00117        }
00118 }
00119 
00120 
00139 extern inline void PA_Put2_8bitPixels(bool screen, s16 x, s16 y, u16 colors) {             PA_DrawBg[screen][(x >> 1) + (y << 7)] = colors;
00140 }
00141 
00162 extern inline void PA_PutDouble8bitPixels(bool screen, s16 x, s16 y, u8 color1, u8 color2) {
00163        PA_Put2_8bitPixels(screen, x, y, color1 + (color2 << 8));             
00164 }
00165 
00166 
00167 
00186 extern inline void PA_Put4_8bitPixels(bool screen, s16 x, s16 y, u32 colors) {
00187 /*
00188        (*u32*)(PA_DrawBg[screen] + (x >> 1) + (y << 7)) = colors;*/
00189 }
00190 
00191 
00206 extern inline u8 PA_Get8bitPixel(bool screen, u8 x, u8 y) {
00207        u16 pos =     (x >> 1) + (y << 7);
00208        if (x&1){
00209               return (PA_DrawBg[screen][pos] >> 8);
00210        }
00211        else {
00212               return (PA_DrawBg[screen][pos]);
00213        }
00214 }
00215 
00216 
00217 
00218 
00236 extern inline void PA_Put16bitPixel(bool screen, s16 x, s16 y, u16 color) {
00237        PA_DrawBg[screen][x + (y << 8)] = color;
00238 }
00239 
00240 
00255 #define PA_Get16bitPixel(screen, x, y) PA_DrawBg[screen][x + (y << 8)]
00256 
00257 
00258 
00259 
00260 
00261 
00285 void PA_Draw8bitLine(bool screen, u16 x1, u16 y1, u16 x2, u16 y2, u8 color);
00286 
00287 
00288 
00289 
00290 
00314 void PA_Draw16bitLine(bool screen, u16 x1, u16 y1, u16 x2, u16 y2, u16 color);
00315 
00342 void PA_Draw16bitLineEx(bool screen, s16 basex, s16 basey, s16 endx, s16 endy, u16 color, s8 size);
00343 
00344 
00345 
00346 
00370 void PA_Draw16bitRect(bool screen, s16 basex, s16 basey, s16 endx, s16 endy, u16 color);
00371 
00372 
00384 void PA_8bitDraw(bool screen, u8 color);
00385 
00386 
00398 void PA_16bitDraw(bool screen, u16 color);
00399 
00400 
00412 #define PA_SetDrawSize(screen, draw_size) PA_drawsize[screen] = draw_size;
00413 
00414 
00415 
00416 
00417 
00429 #define PA_Load8bitBitmap(screen, bitmap) DMA_Copy(bitmap, (void*)PA_DrawBg[screen], 256*96, DMA_16NOW);
00430 
00442 #define PA_Load16bitBitmap(screen, bitmap) {u32 PA_temp; \
00443 for (PA_temp = 0; PA_temp < 256*192; PA_temp++)\
00444 PA_DrawBg[screen][PA_temp] = bitmap[PA_temp] + (1 << 15);}
00445 
00446 
00455 #define PA_Clear8bitBg(screen) DMA_Copy(Blank, (void*)PA_DrawBg[screen], 256*96, DMA_16NOW);
00456 
00465 #define PA_Clear16bitBg(screen) DMA_Copy(Blank, (void*)PA_DrawBg[screen], 256*192, DMA_16NOW)
00466 
00467 
00479 extern inline void PA_LoadJpeg(bool screen, void *jpeg) {
00480        REG_IME = 0x00;
00481        JPEG_DecompressImage((u8*)jpeg, PA_DrawBg[screen], 256, 192);
00482        REG_IME = 0x01;      
00483 }
00484 
00485 
00486 
00507 void PA_LoadBmpToBuffer(u16 *Buffer, s16 x, s16 y, void *bmp, s16 SWidth);
00508 
00509 
00527 extern inline void PA_LoadBmpEx(bool screen, s16 x, s16 y, void *bmp){
00528 PA_LoadBmpToBuffer(PA_DrawBg[screen], x, y, bmp, 256);
00529 }
00530 
00531 
00532 
00544 extern inline void PA_LoadBmp(bool screen, void *bmp){
00545        PA_LoadBmpEx(screen, 0, 0, bmp);
00546 }
00547 
00559 extern inline void PA_LoadGif(bool screen, void *gif){
00560        if (PA_nBit[screen]) DecodeGif(gif, (void*)PA_DrawBg[screen], (u16*)0x05000000, 1, 256);
00561        //PA_Load16bitGif(screen, 0, 0, gif); // 16 bit...
00562        else DecodeGif(gif, (void*)PA_DrawBg[screen], (u16*)(0x05000000+(0x400*screen)), 0, 256);
00563 }
00564 
00565 
00566 /* // Les différentes fonctions images...
00567 extern inline void PA_LoadJpeg(bool screen, void *jpeg)
00568 void PA_LoadBmp(bool screen, s16 x, s16 y, void *bmp);*/
00569 
00570 
00582 extern inline void PA_LoadGBFSImage(bool screen, s16 GBFSImage){
00583        if (PA_CompareText(PA_GBFSfile[GBFSImage].Ext, "bmp")){
00584               PA_LoadBmp(screen, PA_GBFSfile[GBFSImage].File);
00585        }
00586        if (PA_CompareText(PA_GBFSfile[GBFSImage].Ext, "jpg")){ 
00587               PA_LoadJpeg(screen, PA_GBFSfile[GBFSImage].File);
00588        }      
00589        if (PA_CompareText(PA_GBFSfile[GBFSImage].Ext, "gif")){ 
00590               PA_LoadGif(screen, PA_GBFSfile[GBFSImage].File);
00591        }             
00592 }
00593 
00594 extern inline void PA_LoadGBFSImageToBuffer(void *Buffer, s16 GBFSImage, s16 Width){
00595        if (PA_CompareText(PA_GBFSfile[GBFSImage].Ext, "bmp")){
00596               PA_LoadBmpToBuffer(Buffer, 0, 0, PA_GBFSfile[GBFSImage].File, Width);
00597        }
00598        /*if (PA_CompareText(PA_GBFSfile[GBFSImage].Ext, "jpg")){ 
00599               PA_LoadJpeg(screen, PA_GBFSfile[GBFSImage].File);
00600        }      */
00601        if (PA_CompareText(PA_GBFSfile[GBFSImage].Ext, "gif")){ 
00602               DecodeGif(PA_GBFSfile[GBFSImage].File, Buffer, (u16*)0x05000000, 1, Width);
00603        }             
00604 }
00605 
00606 extern inline u16 PA_GetBmpWidth(void *bmp){
00607        u8 *temp = (u8*)bmp;
00608        BMP_Headers *Bmpinfo = (BMP_Headers*)(temp+14);
00609        return Bmpinfo->Width;
00610 }
00611 extern inline u16 PA_GetBmpHeight(void *bmp){
00612        u8 *temp = (u8*)bmp;
00613        BMP_Headers *Bmpinfo = (BMP_Headers*)(temp+14);
00614        return Bmpinfo->Height;
00615 } // end of Draw
00617 
00618 
00619 extern inline void PA_8bit8x8Image(bool screen, u16 basex, u16 basey, u8* data){
00620 s16 x, y;
00621 
00622 for (x = 0; x < 8; x++)
00623        for (y = 0; y < 8; y++)
00624               PA_Put8bitPixel(screen, x + basex, y + basey, data[x + (y << 3)]);
00625 }
00626 
00627 /*
00628 extern inline void PA_DrawImage(bool screen, s16 x, s16 y, s16 lx, s16 ly, u8* data){
00629 s16 i, j;
00630 u16* data2 = (u16*)data;
00631 
00632 if (x&1){ // Premier pixel à mettre tout seul peut-etre
00633        for (j = 0; j < ly; j++) PA_Put8bitPixel(screen, x, j + y, data[0]);
00634        x++;
00635        data2 = (u16*)(data + 1);
00636 }
00637 
00638 i = 0;
00639 // Tant qu'il reste au moins 2 pixels à mettre, on fait 2 par 2
00640 while(i < (lx-2)){
00641        for (j = 0; j < ly; j++) {
00642               PA_PutDouble8bitPixels(screen, i + x, j + y, data2[(i >> 1) + (j*lx)]);
00643        }
00644        i+=2;
00645 }
00646 
00647 if (!((i + x)&1)){ // Dernier pixel à mettre tout seul peut-etre
00648        for (j = 0; j < ly; j++) PA_Put8bitPixel(screen, i + x, j + y, data2[(i >> 1) + (j*lx)]&255);
00649 }
00650 
00651 }
00652 */
00653 
00654 
00655 
00656 
00657 
00658 
00659 
00660 
00661 
00662 
00663 
00664 
00665 
00666 
00667 
00668 
00669 
00670 
00671 
00672 
00673 #endif
00674 
00675 

Généré le Fri Oct 28 23:18:12 2005 pour PA_lib par  doxygen 1.3.9.1
@ 1.1.1.1 log @Initial import of PalibDoc, begin on PAlib0.64b @ text @@