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 "gif/gif_lib.h"
00018
00019 extern GifFileType* gifinfo;
00020 extern s16 gifwidth, gifheight;
00021 extern u8 PA_nBit[2];
00022
00023
00024 #define PA_RGB8(r,g,b) ((((b)>>3)<<10)|(((g)>>3)<<5)|((r)>>3)|(1 << 15))
00025
00026
00027 typedef struct{
00028 u16 Id;
00029 u32 Length;
00030 u16 Nothing1, Nothing2;
00031 u32 ImageStart;
00032 } BMPHeader0;
00033
00034 typedef struct{
00035 u32 SizeofHeader;
00036 u32 Width, Height;
00037 u16 Colorplanes;
00038 u16 BitsperPixel;
00039 u32 Compression;
00040 u32 SizeofData;
00041 u32 WidthperMeter, HeightperMeter;
00042 u32 NColors, ImportantColors;
00043 } BMP_Headers;
00044
00045
00046 extern u16 PA_oldx[2];
00047 extern u16 PA_oldy[2];
00048 extern u8 PA_drawsize[2];
00049 extern u16 *PA_DrawBg[2];
00050 extern u8 PA_nBit[2];
00051
00052
00053 void PA_Load16bitGif(bool screen, s16 x, s16 y, void *gif);
00054 int DecodeGif(const u8 *userData, u8 *ScreenBuff, u16* Palette, u8 nBits, s16 SWidth);
00055
00056
00057
00075 void PA_Init8bitBg(bool screen, u8 bg_priority);
00076
00077
00089 void PA_Init16bitBg(bool screen, u8 bg_priority);
00090
00091
00092
00110 extern inline void PA_Put8bitPixel(bool screen, s16 x, s16 y, u8 color) {
00111 u16 pos = (x >> 1) + (y << 7);
00112 if (x&1){
00113 PA_DrawBg[screen][pos] &= 255;
00114 PA_DrawBg[screen][pos] |= color << 8;
00115 }
00116 else {
00117 PA_DrawBg[screen][pos] &= 255 << 8;
00118 PA_DrawBg[screen][pos] |= color;
00119 }
00120 }
00121
00122
00141 extern inline void PA_Put2_8bitPixels(bool screen, s16 x, s16 y, u16 colors) { PA_DrawBg[screen][(x >> 1) + (y << 7)] = colors;
00142 }
00143
00164 extern inline void PA_PutDouble8bitPixels(bool screen, s16 x, s16 y, u8 color1, u8 color2) {
00165 PA_Put2_8bitPixels(screen, x, y, color1 + (color2 << 8));
00166 }
00167
00168
00169
00188 extern inline void PA_Put4_8bitPixels(bool screen, s16 x, s16 y, u32 colors) {
00189
00190
00191 }
00192
00193
00208 extern inline u8 PA_Get8bitPixel(bool screen, u8 x, u8 y) {
00209 u16 pos = (x >> 1) + (y << 7);
00210 if (x&1){
00211 return (PA_DrawBg[screen][pos] >> 8);
00212 }
00213 else {
00214 return (PA_DrawBg[screen][pos]);
00215 }
00216 }
00217
00218
00219
00220
00238 extern inline void PA_Put16bitPixel(bool screen, s16 x, s16 y, u16 color) {
00239 PA_DrawBg[screen][x + (y << 8)] = color;
00240 }
00241
00242
00257 #define PA_Get16bitPixel(screen, x, y) PA_DrawBg[screen][x + (y << 8)]
00258
00259
00260
00261
00262
00263
00287 void PA_Draw8bitLine(bool screen, u16 x1, u16 y1, u16 x2, u16 y2, u8 color);
00288
00289
00290
00291
00292
00316 void PA_Draw16bitLine(bool screen, u16 x1, u16 y1, u16 x2, u16 y2, u16 color);
00317
00344 void PA_Draw16bitLineEx(bool screen, s16 basex, s16 basey, s16 endx, s16 endy, u16 color, s8 size);
00345
00346 void PA_Draw8bitLineEx(bool screen, s16 basex, s16 basey, s16 endx, s16 endy, u16 color, s8 size);
00347
00348
00349
00373 void PA_Draw16bitRect(bool screen, s16 basex, s16 basey, s16 endx, s16 endy, u16 color);
00374
00375
00387 void PA_8bitDraw(bool screen, u8 color);
00388
00389
00401 void PA_16bitDraw(bool screen, u16 color);
00402
00403
00415 #define PA_SetDrawSize(screen, draw_size) PA_drawsize[screen] = draw_size;
00416
00417
00418
00419
00420
00432 #define PA_Load8bitBitmap(screen, bitmap) DMA_Copy(bitmap, (void*)PA_DrawBg[screen], 256*96, DMA_16NOW);
00433
00445 #define PA_Load16bitBitmap(screen, bitmap) {u32 PA_temp; \
00446 for (PA_temp = 0; PA_temp < 256*192; PA_temp++)\
00447 PA_DrawBg[screen][PA_temp] = bitmap[PA_temp] | (1 << 15);}
00448
00449
00458 #define PA_Clear8bitBg(screen) DMA_Copy(Blank, (void*)PA_DrawBg[screen], 256*96, DMA_16NOW);
00459
00468 #define PA_Clear16bitBg(screen) DMA_Copy(Blank, (void*)PA_DrawBg[screen], 256*192, DMA_16NOW)
00469
00470
00482 extern inline void PA_LoadJpeg(bool screen, void *jpeg) {
00483 REG_IME = 0x00;
00484 JPEG_DecompressImage((u8*)jpeg, PA_DrawBg[screen], 256, 192);
00485 REG_IME = 0x01;
00486 }
00487
00488
00489
00510 void PA_LoadBmpToBuffer(u16 *Buffer, s16 x, s16 y, void *bmp, s16 SWidth);
00511
00512
00530 extern inline void PA_LoadBmpEx(bool screen, s16 x, s16 y, void *bmp){
00531 PA_LoadBmpToBuffer(PA_DrawBg[screen], x, y, bmp, 256);
00532 }
00533
00534
00535
00547 extern inline void PA_LoadBmp(bool screen, void *bmp){
00548 PA_LoadBmpEx(screen, 0, 0, bmp);
00549 }
00550
00551
00552
00553
00554
00555
00556
00565 extern inline u16 PA_GetGifWidth(void* gif){
00566 u16 *temp = (u16*)gif;
00567 temp += 3;
00568 return *temp;
00569 }
00570
00571
00572
00581 extern inline u16 PA_GetGifHeight(void* gif){
00582 u16 *temp = (u16*)gif;
00583 temp += 4;
00584 return *temp;
00585 }
00586
00587
00588
00600 extern inline void PA_LoadGif(bool screen, void *gif){
00601 if (PA_nBit[screen]) DecodeGif((const u8*)gif, (u8*)PA_DrawBg[screen], (u16*)0x05000000, 1, 256);
00602
00603 else DecodeGif((const u8*)gif, (u8*)PA_DrawBg[screen], (u16*)(0x05000000+(0x400*screen)), 0, 256);
00604 }
00605
00606
00607
00608
00609
00610
00611
00623 extern inline void PA_LoadGBFSImage(bool screen, s16 GBFSImage){
00624 if (PA_CompareText(PA_GBFSfile[GBFSImage].Ext, "bmp")){
00625 PA_LoadBmp(screen, PA_GBFSfile[GBFSImage].File);
00626 }
00627 if (PA_CompareText(PA_GBFSfile[GBFSImage].Ext, "jpg")){
00628 PA_LoadJpeg(screen, PA_GBFSfile[GBFSImage].File);
00629 }
00630 if (PA_CompareText(PA_GBFSfile[GBFSImage].Ext, "gif")){
00631 PA_LoadGif(screen, PA_GBFSfile[GBFSImage].File);
00632 }
00633 }
00634
00635 extern inline void PA_LoadGBFSImageToBuffer(void *Buffer, s16 GBFSImage, s16 Width){
00636 if (PA_CompareText(PA_GBFSfile[GBFSImage].Ext, "bmp")){
00637 PA_LoadBmpToBuffer((u16*)Buffer, 0, 0, (u16*)PA_GBFSfile[GBFSImage].File, Width);
00638 }
00639
00640
00641
00642 if (PA_CompareText(PA_GBFSfile[GBFSImage].Ext, "gif")){
00643 DecodeGif((const u8*)PA_GBFSfile[GBFSImage].File, (u8*)Buffer, (u16*)0x05000000, 1, Width);
00644 }
00645 }
00646
00647 extern inline u16 PA_GetBmpWidth(void *bmp){
00648 u8 *temp = (u8*)bmp;
00649 BMP_Headers *Bmpinfo = (BMP_Headers*)(temp+14);
00650 return Bmpinfo->Width;
00651 }
00652 extern inline u16 PA_GetBmpHeight(void *bmp){
00653 u8 *temp = (u8*)bmp;
00654 BMP_Headers *Bmpinfo = (BMP_Headers*)(temp+14);
00655 return Bmpinfo->Height;
00656 }
00658
00659
00660 extern inline void PA_8bit8x8Image(bool screen, u16 basex, u16 basey, u8* data){
00661 s16 x, y;
00662
00663 for (x = 0; x < 8; x++)
00664 for (y = 0; y < 8; y++)
00665 PA_Put8bitPixel(screen, x + basex, y + basey, data[x + (y << 3)]);
00666 }
00667
00668
00669
00670
00671
00672
00673
00674
00675
00676
00677
00678
00679
00680
00681
00682
00683
00684
00685
00686
00687
00688
00689
00690
00691
00692
00693
00694
00695
00696
00697
00698
00699
00700
00701
00702
00703 #ifdef __cplusplus
00704 }
00705 #endif
00706
00707
00708
00709
00710
00711
00712
00713
00714 #endif
00715
00716