PA_Draw.h

Go to the documentation of this file.
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 void PA_Draw8bitLineEx(bool screen, s16 basex, s16 basey, s16 endx, s16 endy, u16 color, s8 size);
00345 
00346 
00347 
00371 void PA_Draw16bitRect(bool screen, s16 basex, s16 basey, s16 endx, s16 endy, u16 color);
00372 
00373 
00385 void PA_8bitDraw(bool screen, u8 color);
00386 
00387 
00399 void PA_16bitDraw(bool screen, u16 color);
00400 
00401 
00413 #define PA_SetDrawSize(screen, draw_size) PA_drawsize[screen] = draw_size;
00414 
00415 
00416 
00417 
00418 
00430 #define PA_Load8bitBitmap(screen, bitmap) DMA_Copy(bitmap, (void*)PA_DrawBg[screen], 256*96, DMA_16NOW);
00431 
00443 #define PA_Load16bitBitmap(screen, bitmap) {u32 PA_temp; \
00444 for (PA_temp = 0; PA_temp < 256*192; PA_temp++)\
00445 PA_DrawBg[screen][PA_temp] = bitmap[PA_temp] | (1 << 15);}
00446 
00447 
00456 #define PA_Clear8bitBg(screen) DMA_Copy(Blank, (void*)PA_DrawBg[screen], 256*96, DMA_16NOW);
00457 
00466 #define PA_Clear16bitBg(screen) DMA_Copy(Blank, (void*)PA_DrawBg[screen], 256*192, DMA_16NOW)
00467 
00468 
00480 extern inline void PA_LoadJpeg(bool screen, void *jpeg) {
00481        REG_IME = 0x00;
00482        JPEG_DecompressImage((u8*)jpeg, PA_DrawBg[screen], 256, 192);
00483        REG_IME = 0x01;      
00484 }
00485 
00486 
00487 
00508 void PA_LoadBmpToBuffer(u16 *Buffer, s16 x, s16 y, void *bmp, s16 SWidth);
00509 
00510 
00528 extern inline void PA_LoadBmpEx(bool screen, s16 x, s16 y, void *bmp){
00529 PA_LoadBmpToBuffer(PA_DrawBg[screen], x, y, bmp, 256);
00530 }
00531 
00532 
00533 
00545 extern inline void PA_LoadBmp(bool screen, void *bmp){
00546        PA_LoadBmpEx(screen, 0, 0, bmp);
00547 }
00548 
00549 
00550 
00551 
00552 
00553 
00554 
00563 extern inline u16 PA_GetGifWidth(void* gif){
00564        u16 *temp = (u16*)gif;
00565        temp += 3;
00566        return *temp;
00567 }
00568 
00569 
00570 
00579 extern inline u16 PA_GetGifHeight(void* gif){
00580        u16 *temp = (u16*)gif;
00581        temp += 4;
00582        return *temp;
00583 }
00584 
00585 
00586 
00598 extern inline void PA_LoadGif(bool screen, void *gif){
00599        if (PA_nBit[screen]) DecodeGif((const u8*)gif, (u8*)PA_DrawBg[screen], (u16*)0x05000000, 1, 256);
00600        //PA_Load16bitGif(screen, 0, 0, gif); // 16 bit...
00601        else DecodeGif((const u8*)gif, (u8*)PA_DrawBg[screen], (u16*)(0x05000000+(0x400*screen)), 0, 256);
00602 }
00603 
00604 
00605 /* // Les différentes fonctions images...
00606 extern inline void PA_LoadJpeg(bool screen, void *jpeg)
00607 void PA_LoadBmp(bool screen, s16 x, s16 y, void *bmp);*/
00608 
00609 
00621 extern inline void PA_LoadGBFSImage(bool screen, s16 GBFSImage){
00622        if (PA_CompareText(PA_GBFSfile[GBFSImage].Ext, "bmp")){
00623               PA_LoadBmp(screen, PA_GBFSfile[GBFSImage].File);
00624        }
00625        if (PA_CompareText(PA_GBFSfile[GBFSImage].Ext, "jpg")){ 
00626               PA_LoadJpeg(screen, PA_GBFSfile[GBFSImage].File);
00627        }      
00628        if (PA_CompareText(PA_GBFSfile[GBFSImage].Ext, "gif")){ 
00629               PA_LoadGif(screen, PA_GBFSfile[GBFSImage].File);
00630        }             
00631 }
00632 
00633 extern inline void PA_LoadGBFSImageToBuffer(void *Buffer, s16 GBFSImage, s16 Width){
00634        if (PA_CompareText(PA_GBFSfile[GBFSImage].Ext, "bmp")){
00635               PA_LoadBmpToBuffer((u16*)Buffer, 0, 0, (u16*)PA_GBFSfile[GBFSImage].File, Width);
00636        }
00637        /*if (PA_CompareText(PA_GBFSfile[GBFSImage].Ext, "jpg")){ 
00638               PA_LoadJpeg(screen, PA_GBFSfile[GBFSImage].File);
00639        }      */
00640        if (PA_CompareText(PA_GBFSfile[GBFSImage].Ext, "gif")){ 
00641               DecodeGif((const u8*)PA_GBFSfile[GBFSImage].File, (u8*)Buffer, (u16*)0x05000000, 1, Width);
00642        }             
00643 }
00644 
00645 extern inline u16 PA_GetBmpWidth(void *bmp){
00646        u8 *temp = (u8*)bmp;
00647        BMP_Headers *Bmpinfo = (BMP_Headers*)(temp+14);
00648        return Bmpinfo->Width;
00649 }
00650 extern inline u16 PA_GetBmpHeight(void *bmp){
00651        u8 *temp = (u8*)bmp;
00652        BMP_Headers *Bmpinfo = (BMP_Headers*)(temp+14);
00653        return Bmpinfo->Height;
00654 } // end of Draw
00656 
00657 
00658 extern inline void PA_8bit8x8Image(bool screen, u16 basex, u16 basey, u8* data){
00659 s16 x, y;
00660 
00661 for (x = 0; x < 8; x++)
00662        for (y = 0; y < 8; y++)
00663               PA_Put8bitPixel(screen, x + basex, y + basey, data[x + (y << 3)]);
00664 }
00665 
00666 /*
00667 extern inline void PA_DrawImage(bool screen, s16 x, s16 y, s16 lx, s16 ly, u8* data){
00668 s16 i, j;
00669 u16* data2 = (u16*)data;
00670 
00671 if (x&1){ // Premier pixel à mettre tout seul peut-etre
00672        for (j = 0; j < ly; j++) PA_Put8bitPixel(screen, x, j + y, data[0]);
00673        x++;
00674        data2 = (u16*)(data + 1);
00675 }
00676 
00677 i = 0;
00678 // Tant qu'il reste au moins 2 pixels à mettre, on fait 2 par 2
00679 while(i < (lx-2)){
00680        for (j = 0; j < ly; j++) {
00681               PA_PutDouble8bitPixels(screen, i + x, j + y, data2[(i >> 1) + (j*lx)]);
00682        }
00683        i+=2;
00684 }
00685 
00686 if (!((i + x)&1)){ // Dernier pixel à mettre tout seul peut-etre
00687        for (j = 0; j < ly; j++) PA_Put8bitPixel(screen, i + x, j + y, data2[(i >> 1) + (j*lx)]&255);
00688 }
00689 
00690 }
00691 */
00692 
00693 
00694 
00695 
00696 
00697 
00698 
00699 
00700 
00701 
00702 
00703 
00704 
00705 
00706 
00707 
00708 
00709 
00710 
00711 
00712 #endif
00713 
00714 

Generated on Wed Dec 21 17:41:56 2005 for PAlib by  doxygen 1.3.9.1