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 "PA_Splash.h"
00019 #include "PA_Gif.h"
00020 
00021 extern u8 PA_nBit[2]; // 8 or 16 bit Bg
00022 
00023 extern u16 tempvar;
00024 
00025 
00026 #define PA_RGB8(r,g,b)      ((((b)>>3)<<10)|(((g)>>3)<<5)|((r)>>3)|(1 << 15))
00027 
00028 
00029 typedef struct{
00030        u16 Id; // ?
00031        u32 Length;
00032        u16 Nothing1, Nothing2; // ?
00033        u32 ImageStart; // Offset of start of image
00034 } BMPHeader0;
00035 
00036 typedef struct{
00037        u32 SizeofHeader; // 40
00038        u32 Width, Height;
00039        u16 Colorplanes; // Usually 1
00040        u16 BitsperPixel; //1, 2, 4, 8, 16, 24, 32
00041        u32 Compression;  // 0 for none, 1...
00042        u32 SizeofData; // Not reliable
00043        u32 WidthperMeter, HeightperMeter; // Don't care
00044        u32 NColors, ImportantColors; // Number of colors used, important colors ?
00045 } BMP_Headers;
00046 
00047 
00048 extern u16 PA_oldx[2];
00049 extern u16 PA_oldy[2];
00050 extern u8 PA_drawsize[2];
00051 extern u16 *PA_DrawBg[2];
00052 extern u32 *PA_DrawBg32[2];
00053 extern u8 PA_nBit[2]; // 8 or 16 bit Bg
00054 //extern PA_SCreen
00055 
00056 extern u16 PA_temppal[256];
00057 //extern s32 PA_GifSpeed;
00058 
00059 
00060 
00078 void PA_Init8bitBg(u8 screen, u8 bg_priority);
00079 
00080 
00081 
00093 void PA_InitBig8bitBg(u8 screen, u8 bg_priority);
00094 
00095 
00107 void PA_Init16bitBg(u8 screen, u8 bg_priority);
00108 
00109 
00110 
00128 extern inline void PA_Put8bitPixel(u8 screen, s16 x, s16 y, u8 color) {
00129    PA_DrawBg[screen][(y <<7) + (x>>1)] &= (0xff00>>((x&1)<<3));
00130    PA_DrawBg[screen][(y <<7) + (x>>1)] |= color<<((x&1)<<3);
00131 
00132        //s32 pos = (x >> 1) + (y << 7);
00133        //u16 pixel = PA_DrawBg[screen][pos];
00134        //PA_DrawBg[screen][pos] = (color << ((x&1)<<3)) | (pixel&(0xFF00>>((x&1)<<3)));
00135        /*if (x&1){
00136               PA_DrawBg[screen][pos] = (color << 8) | (pixel&0x00FF);               
00137        }
00138        else {
00139               PA_DrawBg[screen][pos] = color | (pixel&0xFF00); 
00140        }*/
00141 }
00142 
00143 
00144 
00163 extern inline void PA_Put2_8bitPixels(u8 screen, s16 x, s16 y, u16 colors) {        PA_DrawBg[screen][(x >> 1) + (y << 7)] = colors;
00164 }
00165 
00186 extern inline void PA_PutDouble8bitPixels(u8 screen, s16 x, s16 y, u8 color1, u8 color2) {
00187        PA_Put2_8bitPixels(screen, x, y, color1 + (color2 << 8));             
00188 }
00189 
00190 
00191 
00210 extern inline void PA_Put4_8bitPixels(u8 screen, s16 x, s16 y, u32 colors) {
00211 
00212        PA_DrawBg32[screen][(x >> 2) + (y << 6)] = colors;
00213 }
00214 
00215 
00230 extern inline u8 PA_Get8bitPixel(u8 screen, u8 x, u8 y) {
00231        u16 pos =     (x >> 1) + (y << 7);
00232        if (x&1){
00233               return (PA_DrawBg[screen][pos] >> 8);
00234        }
00235        else {
00236               return (PA_DrawBg[screen][pos]);
00237        }
00238 }
00239 
00240 
00241 
00242 
00260 extern inline void PA_Put16bitPixel(u8 screen, s16 x, s16 y, u16 color) {
00261        PA_DrawBg[screen][x + (y << 8)] = color;
00262 }
00263 
00264 
00279 #define PA_Get16bitPixel(screen, x, y) PA_DrawBg[screen][(x) + ((y) << 8)]
00280 
00281 
00282 
00283 
00284 
00285 
00309 void PA_Draw8bitLine(u8 screen, u16 x1, u16 y1, u16 x2, u16 y2, u8 color);
00310 
00311 
00312 
00313 
00314 
00338 void PA_Draw16bitLine(u8 screen, u16 x1, u16 y1, u16 x2, u16 y2, u16 color);
00339 
00340 
00341 
00368 void PA_Draw16bitLineEx(u8 screen, s16 basex, s16 basey, s16 endx, s16 endy, u16 color, s8 size);
00369 
00370 
00397 void PA_Draw8bitLineEx(u8 screen, s16 basex, s16 basey, s16 endx, s16 endy, u8 color, s8 size);
00398 
00399 
00400 
00424 void PA_Draw16bitRect(u8 screen, s16 basex, s16 basey, s16 endx, s16 endy, u16 color);
00425 
00426 
00438 void PA_8bitDraw(u8 screen, u8 color);
00439 
00440 
00452 void PA_16bitDraw(u8 screen, u16 color);
00453 
00454 
00466 #define PA_SetDrawSize(screen, draw_size) PA_drawsize[screen] = draw_size;
00467 
00468 
00469 
00470 
00471 
00483 #define PA_Load8bitBitmap(screen, bitmap) DMA_Copy(bitmap, (void*)PA_DrawBg[screen], 256*96, DMA_16NOW)
00484 
00496 #define PA_Load16bitBitmap(screen, bitmap) {u32 PA_temp; \
00497 for (PA_temp = 0; PA_temp < 256*192; PA_temp++)\
00498 PA_DrawBg[screen][PA_temp] = bitmap[PA_temp] | (1 << 15);}
00499 
00500 
00509 #define PA_Clear8bitBg(screen) DMA_Copy(Blank, (void*)PA_DrawBg[screen], 256*96, DMA_16NOW);
00510 
00519 #define PA_Clear16bitBg(screen) DMA_Copy(Blank, (void*)PA_DrawBg[screen], 256*192, DMA_16NOW)
00520 
00521 
00533 extern inline void PA_LoadJpeg(u8 screen, void *jpeg) {
00534        REG_IME = 0x00;
00535        JPEG_DecompressImage((u8*)jpeg, PA_DrawBg[screen], 256, 192);
00536        REG_IME = 0x01;      
00537 }
00538 
00539 
00540 
00561 void PA_LoadBmpToBuffer(u16 *Buffer, s16 x, s16 y, void *bmp, s16 SWidth);
00562 
00563 
00581 extern inline void PA_LoadBmpEx(u8 screen, s16 x, s16 y, void *bmp){
00582 PA_LoadBmpToBuffer(PA_DrawBg[screen], x, y, bmp, 256);
00583 }
00584 
00585 
00586 
00598 extern inline void PA_LoadBmp(u8 screen, void *bmp){
00599        PA_LoadBmpEx(screen, 0, 0, bmp);
00600 }
00601 
00602 
00603 
00604 
00605 
00606 
00607 /* // Les différentes fonctions images...
00608 extern inline void PA_LoadJpeg(u8 screen, void *jpeg)
00609 void PA_LoadBmp(u8 screen, s16 x, s16 y, void *bmp);*/
00610 
00611 
00623 extern inline void PA_LoadFSImage(u8 screen, s16 FSImage){
00624        if (PA_CompareText(PA_FSFile[FSImage].Ext, "bmp")){
00625               PA_LoadBmp(screen, PA_PAFSFile(FSImage));
00626        }
00627        if (PA_CompareText(PA_FSFile[FSImage].Ext, "jpg")){ 
00628               PA_LoadJpeg(screen, PA_PAFSFile(FSImage));
00629        }      
00630        if (PA_CompareText(PA_FSFile[FSImage].Ext, "gif")){ 
00631               PA_LoadGif(screen, PA_PAFSFile(FSImage));
00632        }             
00633 }
00634 
00635 
00636 
00637 
00638 /*
00639 extern inline void PA_LoadGBFSImage(u8 screen, s16 GBFSImage){
00640        if (PA_CompareText(PA_GBFSfile[GBFSImage].Ext, "bmp")){
00641               PA_LoadBmp(screen, PA_GBFSfile[GBFSImage].File);
00642        }
00643        if (PA_CompareText(PA_GBFSfile[GBFSImage].Ext, "jpg")){ 
00644               PA_LoadJpeg(screen, PA_GBFSfile[GBFSImage].File);
00645        }      
00646        if (PA_CompareText(PA_GBFSfile[GBFSImage].Ext, "gif")){ 
00647               PA_LoadGif(screen, PA_GBFSfile[GBFSImage].File);
00648        }             
00649 }
00650 */
00651 extern inline void PA_LoadGBFSImageToBuffer(void *Buffer, s16 GBFSImage, s16 Width){
00652        if (PA_CompareText(PA_GBFSfile[GBFSImage].Ext, "bmp")){
00653               PA_LoadBmpToBuffer((u16*)Buffer, 0, 0, (u16*)PA_GBFSfile[GBFSImage].File, Width);
00654        }
00655        /*if (PA_CompareText(PA_GBFSfile[GBFSImage].Ext, "jpg")){ 
00656               PA_LoadJpeg(screen, PA_GBFSfile[GBFSImage].File);
00657        }      */
00658        if (PA_CompareText(PA_GBFSfile[GBFSImage].Ext, "gif")){ 
00659               DecodeGif((const u8*)PA_GBFSfile[GBFSImage].File, (u8*)Buffer, (u16*)0x05000000, 1, Width);
00660        }             
00661 }
00662 
00663 
00664 
00673 extern inline u16 PA_GetBmpWidth(void *bmp){
00674        u8 *temp = (u8*)bmp;
00675        BMP_Headers *Bmpinfo = (BMP_Headers*)(temp+14);
00676        return Bmpinfo->Width;
00677 }
00678 
00679 
00680 
00689 extern inline u16 PA_GetBmpHeight(void *bmp){
00690        u8 *temp = (u8*)bmp;
00691        BMP_Headers *Bmpinfo = (BMP_Headers*)(temp+14);
00692        return Bmpinfo->Height;
00693 } // end of Draw
00695 
00696 
00697 extern inline void PA_8bit8x8Image(u8 screen, u16 basex, u16 basey, u8* data){
00698 s16 x, y;
00699 
00700 for (x = 0; x < 8; x++)
00701        for (y = 0; y < 8; y++)
00702               PA_Put8bitPixel(screen, x + basex, y + basey, data[x + (y << 3)]);
00703 }
00704 
00705 /*
00706 extern inline void PA_DrawImage(u8 screen, s16 x, s16 y, s16 lx, s16 ly, u8* data){
00707 s16 i, j;
00708 u16* data2 = (u16*)data;
00709 
00710 if (x&1){ // Premier pixel à mettre tout seul peut-etre
00711        for (j = 0; j < ly; j++) PA_Put8bitPixel(screen, x, j + y, data[0]);
00712        x++;
00713        data2 = (u16*)(data + 1);
00714 }
00715 
00716 i = 0;
00717 // Tant qu'il reste au moins 2 pixels à mettre, on fait 2 par 2
00718 while(i < (lx-2)){
00719        for (j = 0; j < ly; j++) {
00720               PA_PutDouble8bitPixels(screen, i + x, j + y, data2[(i >> 1) + (j*lx)]);
00721        }
00722        i+=2;
00723 }
00724 
00725 if (!((i + x)&1)){ // Dernier pixel à mettre tout seul peut-etre
00726        for (j = 0; j < ly; j++) PA_Put8bitPixel(screen, i + x, j + y, data2[(i >> 1) + (j*lx)]&255);
00727 }
00728 
00729 }
00730 */
00731 
00732 
00733 
00734 
00735 /*
00744 extern inline void PA_SetGifSpeed(s32 NVBLs){
00745        PA_GifSpeed = NVBLs;
00746 }*/
00747 
00748 
00749 
00750 
00751 #ifdef __cplusplus
00752 }
00753 #endif
00754 
00755 
00756 
00757 
00758 
00759 
00760 
00761 
00762 #endif
00763 
00764 

Generated on Tue Jan 30 23:00:22 2007 for PAlib by  doxygen 1.5.1-p1