PA_Draw.h

Go to the documentation of this file.
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(bool screen, s16 x, s16 y, void *gif);
00058 int DecodeGif(const u8 *userData, u8 *ScreenBuff, u16* Palette, u8 nBits, s16 SWidth);
00059 
00060 
00061 
00079 void PA_Init8bitBg(bool screen, u8 bg_priority);
00080 
00081 
00093 void PA_Init16bitBg(bool screen, u8 bg_priority);
00094 
00095 
00096 
00114 extern inline void PA_Put8bitPixel(bool screen, s16 x, s16 y, u8 color) {
00115        s32 pos = (x >> 1) + (y << 7);
00116        u16 pixel = PA_DrawBg[screen][pos];
00117        if (x&1){
00118               PA_DrawBg[screen][pos] = (color << 8) | (pixel&0x00FF);               
00119        }
00120        else {
00121               PA_DrawBg[screen][pos] = color | (pixel&0xFF00); 
00122        }
00123 }
00124 
00125 
00126 
00145 extern inline void PA_Put2_8bitPixels(bool screen, s16 x, s16 y, u16 colors) {             PA_DrawBg[screen][(x >> 1) + (y << 7)] = colors;
00146 }
00147 
00168 extern inline void PA_PutDouble8bitPixels(bool screen, s16 x, s16 y, u8 color1, u8 color2) {
00169        PA_Put2_8bitPixels(screen, x, y, color1 + (color2 << 8));             
00170 }
00171 
00172 
00173 
00192 extern inline void PA_Put4_8bitPixels(bool screen, s16 x, s16 y, u32 colors) {
00193 /*
00194        (*u32*)(PA_DrawBg[screen] + (x >> 1) + (y << 7)) = colors;*/
00195 }
00196 
00197 
00212 extern inline u8 PA_Get8bitPixel(bool screen, u8 x, u8 y) {
00213        u16 pos =     (x >> 1) + (y << 7);
00214        if (x&1){
00215               return (PA_DrawBg[screen][pos] >> 8);
00216        }
00217        else {
00218               return (PA_DrawBg[screen][pos]);
00219        }
00220 }
00221 
00222 
00223 
00224 
00242 extern inline void PA_Put16bitPixel(bool screen, s16 x, s16 y, u16 color) {
00243        PA_DrawBg[screen][x + (y << 8)] = color;
00244 }
00245 
00246 
00261 #define PA_Get16bitPixel(screen, x, y) PA_DrawBg[screen][x + (y << 8)]
00262 
00263 
00264 
00265 
00266 
00267 
00291 void PA_Draw8bitLine(bool screen, u16 x1, u16 y1, u16 x2, u16 y2, u8 color);
00292 
00293 
00294 
00295 
00296 
00320 void PA_Draw16bitLine(bool screen, u16 x1, u16 y1, u16 x2, u16 y2, u16 color);
00321 
00322 
00323 
00350 void PA_Draw16bitLineEx(bool screen, s16 basex, s16 basey, s16 endx, s16 endy, u16 color, s8 size);
00351 
00352 
00379 void PA_Draw8bitLineEx(bool screen, s16 basex, s16 basey, s16 endx, s16 endy, u8 color, s8 size);
00380 
00381 
00382 
00406 void PA_Draw16bitRect(bool screen, s16 basex, s16 basey, s16 endx, s16 endy, u16 color);
00407 
00408 
00420 void PA_8bitDraw(bool screen, u8 color);
00421 
00422 
00434 void PA_16bitDraw(bool screen, u16 color);
00435 
00436 
00448 #define PA_SetDrawSize(screen, draw_size) PA_drawsize[screen] = draw_size;
00449 
00450 
00451 
00452 
00453 
00465 #define PA_Load8bitBitmap(screen, bitmap) DMA_Copy(bitmap, (void*)PA_DrawBg[screen], 256*96, DMA_16NOW);
00466 
00478 #define PA_Load16bitBitmap(screen, bitmap) {u32 PA_temp; \
00479 for (PA_temp = 0; PA_temp < 256*192; PA_temp++)\
00480 PA_DrawBg[screen][PA_temp] = bitmap[PA_temp] | (1 << 15);}
00481 
00482 
00491 #define PA_Clear8bitBg(screen) DMA_Copy(Blank, (void*)PA_DrawBg[screen], 256*96, DMA_16NOW);
00492 
00501 #define PA_Clear16bitBg(screen) DMA_Copy(Blank, (void*)PA_DrawBg[screen], 256*192, DMA_16NOW)
00502 
00503 
00515 extern inline void PA_LoadJpeg(bool screen, void *jpeg) {
00516        REG_IME = 0x00;
00517        JPEG_DecompressImage((u8*)jpeg, PA_DrawBg[screen], 256, 192);
00518        REG_IME = 0x01;      
00519 }
00520 
00521 
00522 
00543 void PA_LoadBmpToBuffer(u16 *Buffer, s16 x, s16 y, void *bmp, s16 SWidth);
00544 
00545 
00563 extern inline void PA_LoadBmpEx(bool screen, s16 x, s16 y, void *bmp){
00564 PA_LoadBmpToBuffer(PA_DrawBg[screen], x, y, bmp, 256);
00565 }
00566 
00567 
00568 
00580 extern inline void PA_LoadBmp(bool screen, void *bmp){
00581        PA_LoadBmpEx(screen, 0, 0, bmp);
00582 }
00583 
00584 
00585 
00586 
00587 
00588 
00589 
00598 extern inline u16 PA_GetGifWidth(void* gif){
00599        u16 *temp = (u16*)gif;
00600        temp += 3;
00601        return *temp;
00602 }
00603 
00604 
00605 
00614 extern inline u16 PA_GetGifHeight(void* gif){
00615        u16 *temp = (u16*)gif;
00616        temp += 4;
00617        return *temp;
00618 }
00619 
00620 
00621 
00633 extern inline void PA_LoadGif(bool screen, void *gif){
00634        if (PA_nBit[screen]) DecodeGif((const u8*)gif, (u8*)PA_DrawBg[screen], (u16*)0x05000000, 1, 256);
00635        //PA_Load16bitGif(screen, 0, 0, gif); // 16 bit...
00636        else DecodeGif((const u8*)gif, (u8*)PA_DrawBg[screen], (u16*)(0x05000000+(0x400*screen)), 0, 256);
00637 }
00638 
00639 
00640 
00641 /* // Les différentes fonctions images...
00642 extern inline void PA_LoadJpeg(bool screen, void *jpeg)
00643 void PA_LoadBmp(bool screen, s16 x, s16 y, void *bmp);*/
00644 
00645 
00657 extern inline void PA_LoadGBFSImage(bool screen, s16 GBFSImage){
00658        if (PA_CompareText(PA_GBFSfile[GBFSImage].Ext, "bmp")){
00659               PA_LoadBmp(screen, PA_GBFSfile[GBFSImage].File);
00660        }
00661        if (PA_CompareText(PA_GBFSfile[GBFSImage].Ext, "jpg")){ 
00662               PA_LoadJpeg(screen, PA_GBFSfile[GBFSImage].File);
00663        }      
00664        if (PA_CompareText(PA_GBFSfile[GBFSImage].Ext, "gif")){ 
00665               PA_LoadGif(screen, PA_GBFSfile[GBFSImage].File);
00666        }             
00667 }
00668 
00669 
00670 
00671 
00672 extern inline void PA_LoadGBFSImageToBuffer(void *Buffer, s16 GBFSImage, s16 Width){
00673        if (PA_CompareText(PA_GBFSfile[GBFSImage].Ext, "bmp")){
00674               PA_LoadBmpToBuffer((u16*)Buffer, 0, 0, (u16*)PA_GBFSfile[GBFSImage].File, Width);
00675        }
00676        /*if (PA_CompareText(PA_GBFSfile[GBFSImage].Ext, "jpg")){ 
00677               PA_LoadJpeg(screen, PA_GBFSfile[GBFSImage].File);
00678        }      */
00679        if (PA_CompareText(PA_GBFSfile[GBFSImage].Ext, "gif")){ 
00680               DecodeGif((const u8*)PA_GBFSfile[GBFSImage].File, (u8*)Buffer, (u16*)0x05000000, 1, Width);
00681        }             
00682 }
00683 
00684 
00685 
00694 extern inline u16 PA_GetBmpWidth(void *bmp){
00695        u8 *temp = (u8*)bmp;
00696        BMP_Headers *Bmpinfo = (BMP_Headers*)(temp+14);
00697        return Bmpinfo->Width;
00698 }
00699 
00700 
00701 
00710 extern inline u16 PA_GetBmpHeight(void *bmp){
00711        u8 *temp = (u8*)bmp;
00712        BMP_Headers *Bmpinfo = (BMP_Headers*)(temp+14);
00713        return Bmpinfo->Height;
00714 } // end of Draw
00716 
00717 
00718 extern inline void PA_8bit8x8Image(bool screen, u16 basex, u16 basey, u8* data){
00719 s16 x, y;
00720 
00721 for (x = 0; x < 8; x++)
00722        for (y = 0; y < 8; y++)
00723               PA_Put8bitPixel(screen, x + basex, y + basey, data[x + (y << 3)]);
00724 }
00725 
00726 /*
00727 extern inline void PA_DrawImage(bool screen, s16 x, s16 y, s16 lx, s16 ly, u8* data){
00728 s16 i, j;
00729 u16* data2 = (u16*)data;
00730 
00731 if (x&1){ // Premier pixel à mettre tout seul peut-etre
00732        for (j = 0; j < ly; j++) PA_Put8bitPixel(screen, x, j + y, data[0]);
00733        x++;
00734        data2 = (u16*)(data + 1);
00735 }
00736 
00737 i = 0;
00738 // Tant qu'il reste au moins 2 pixels à mettre, on fait 2 par 2
00739 while(i < (lx-2)){
00740        for (j = 0; j < ly; j++) {
00741               PA_PutDouble8bitPixels(screen, i + x, j + y, data2[(i >> 1) + (j*lx)]);
00742        }
00743        i+=2;
00744 }
00745 
00746 if (!((i + x)&1)){ // Dernier pixel à mettre tout seul peut-etre
00747        for (j = 0; j < ly; j++) PA_Put8bitPixel(screen, i + x, j + y, data2[(i >> 1) + (j*lx)]&255);
00748 }
00749 
00750 }
00751 */
00752 
00753 
00754 
00755 
00756 
00757 
00758 
00759 
00760 
00761 #ifdef __cplusplus
00762 }
00763 #endif
00764 
00765 
00766 
00767 
00768 
00769 
00770 
00771 
00772 #endif
00773 
00774 

Generated on Sun Feb 19 12:06:13 2006 for PAlib by  doxygen 1.3.9.1