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];
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;
00033 } BMPHeader0;
00034
00035 typedef struct{
00036 u32 SizeofHeader;
00037 u32 Width, Height;
00038 u16 Colorplanes;
00039 u16 BitsperPixel;
00040 u32 Compression;
00041 u32 SizeofData;
00042 u32 WidthperMeter, HeightperMeter;
00043 u32 NColors, ImportantColors;
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];
00052
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 PA_DrawBg[screen][(y <<7) + (x>>1)] &= (0xff00>>((x&1)<<3));
00116 PA_DrawBg[screen][(y <<7) + (x>>1)] |= color<<((x&1)<<3);
00117
00118
00119
00120
00121
00122
00123
00124
00125
00126
00127 }
00128
00129
00130
00149 extern inline void PA_Put2_8bitPixels(bool screen, s16 x, s16 y, u16 colors) { PA_DrawBg[screen][(x >> 1) + (y << 7)] = colors;
00150 }
00151
00172 extern inline void PA_PutDouble8bitPixels(bool screen, s16 x, s16 y, u8 color1, u8 color2) {
00173 PA_Put2_8bitPixels(screen, x, y, color1 + (color2 << 8));
00174 }
00175
00176
00177
00196 extern inline void PA_Put4_8bitPixels(bool screen, s16 x, s16 y, u32 colors) {
00197
00198
00199 }
00200
00201
00216 extern inline u8 PA_Get8bitPixel(bool screen, u8 x, u8 y) {
00217 u16 pos = (x >> 1) + (y << 7);
00218 if (x&1){
00219 return (PA_DrawBg[screen][pos] >> 8);
00220 }
00221 else {
00222 return (PA_DrawBg[screen][pos]);
00223 }
00224 }
00225
00226
00227
00228
00246 extern inline void PA_Put16bitPixel(bool screen, s16 x, s16 y, u16 color) {
00247 PA_DrawBg[screen][x + (y << 8)] = color;
00248 }
00249
00250
00265 #define PA_Get16bitPixel(screen, x, y) PA_DrawBg[screen][x + (y << 8)]
00266
00267
00268
00269
00270
00271
00295 void PA_Draw8bitLine(bool screen, u16 x1, u16 y1, u16 x2, u16 y2, u8 color);
00296
00297
00298
00299
00300
00324 void PA_Draw16bitLine(bool screen, u16 x1, u16 y1, u16 x2, u16 y2, u16 color);
00325
00326
00327
00354 void PA_Draw16bitLineEx(bool screen, s16 basex, s16 basey, s16 endx, s16 endy, u16 color, s8 size);
00355
00356
00383 void PA_Draw8bitLineEx(bool screen, s16 basex, s16 basey, s16 endx, s16 endy, u8 color, s8 size);
00384
00385
00386
00410 void PA_Draw16bitRect(bool screen, s16 basex, s16 basey, s16 endx, s16 endy, u16 color);
00411
00412
00424 void PA_8bitDraw(bool screen, u8 color);
00425
00426
00438 void PA_16bitDraw(bool screen, u16 color);
00439
00440
00452 #define PA_SetDrawSize(screen, draw_size) PA_drawsize[screen] = draw_size;
00453
00454
00455
00456
00457
00469 #define PA_Load8bitBitmap(screen, bitmap) DMA_Copy(bitmap, (void*)PA_DrawBg[screen], 256*96, DMA_16NOW);
00470
00482 #define PA_Load16bitBitmap(screen, bitmap) {u32 PA_temp; \
00483 for (PA_temp = 0; PA_temp < 256*192; PA_temp++)\
00484 PA_DrawBg[screen][PA_temp] = bitmap[PA_temp] | (1 << 15);}
00485
00486
00495 #define PA_Clear8bitBg(screen) DMA_Copy(Blank, (void*)PA_DrawBg[screen], 256*96, DMA_16NOW);
00496
00505 #define PA_Clear16bitBg(screen) DMA_Copy(Blank, (void*)PA_DrawBg[screen], 256*192, DMA_16NOW)
00506
00507
00519 extern inline void PA_LoadJpeg(bool screen, void *jpeg) {
00520 REG_IME = 0x00;
00521 JPEG_DecompressImage((u8*)jpeg, PA_DrawBg[screen], 256, 192);
00522 REG_IME = 0x01;
00523 }
00524
00525
00526
00547 void PA_LoadBmpToBuffer(u16 *Buffer, s16 x, s16 y, void *bmp, s16 SWidth);
00548
00549
00567 extern inline void PA_LoadBmpEx(bool screen, s16 x, s16 y, void *bmp){
00568 PA_LoadBmpToBuffer(PA_DrawBg[screen], x, y, bmp, 256);
00569 }
00570
00571
00572
00584 extern inline void PA_LoadBmp(bool screen, void *bmp){
00585 PA_LoadBmpEx(screen, 0, 0, bmp);
00586 }
00587
00588
00589
00590
00591
00592
00593
00602 extern inline u16 PA_GetGifWidth(void* gif){
00603 u16 *temp = (u16*)gif;
00604 temp += 3;
00605 return *temp;
00606 }
00607
00608
00609
00618 extern inline u16 PA_GetGifHeight(void* gif){
00619 u16 *temp = (u16*)gif;
00620 temp += 4;
00621 return *temp;
00622 }
00623
00624
00625
00637 extern inline void PA_LoadGif(bool screen, void *gif){
00638 if (PA_nBit[screen]) DecodeGif((const u8*)gif, (u8*)PA_DrawBg[screen], (u16*)0x05000000, 1, 256);
00639
00640 else DecodeGif((const u8*)gif, (u8*)PA_DrawBg[screen], (u16*)(0x05000000+(0x400*screen)), 0, 256);
00641 }
00642
00643
00644
00645
00646
00647
00648
00649
00661 extern inline void PA_LoadGBFSImage(bool screen, s16 GBFSImage){
00662 if (PA_CompareText(PA_GBFSfile[GBFSImage].Ext, "bmp")){
00663 PA_LoadBmp(screen, PA_GBFSfile[GBFSImage].File);
00664 }
00665 if (PA_CompareText(PA_GBFSfile[GBFSImage].Ext, "jpg")){
00666 PA_LoadJpeg(screen, PA_GBFSfile[GBFSImage].File);
00667 }
00668 if (PA_CompareText(PA_GBFSfile[GBFSImage].Ext, "gif")){
00669 PA_LoadGif(screen, PA_GBFSfile[GBFSImage].File);
00670 }
00671 }
00672
00673
00674
00675
00676 extern inline void PA_LoadGBFSImageToBuffer(void *Buffer, s16 GBFSImage, s16 Width){
00677 if (PA_CompareText(PA_GBFSfile[GBFSImage].Ext, "bmp")){
00678 PA_LoadBmpToBuffer((u16*)Buffer, 0, 0, (u16*)PA_GBFSfile[GBFSImage].File, Width);
00679 }
00680
00681
00682
00683 if (PA_CompareText(PA_GBFSfile[GBFSImage].Ext, "gif")){
00684 DecodeGif((const u8*)PA_GBFSfile[GBFSImage].File, (u8*)Buffer, (u16*)0x05000000, 1, Width);
00685 }
00686 }
00687
00688
00689
00698 extern inline u16 PA_GetBmpWidth(void *bmp){
00699 u8 *temp = (u8*)bmp;
00700 BMP_Headers *Bmpinfo = (BMP_Headers*)(temp+14);
00701 return Bmpinfo->Width;
00702 }
00703
00704
00705
00714 extern inline u16 PA_GetBmpHeight(void *bmp){
00715 u8 *temp = (u8*)bmp;
00716 BMP_Headers *Bmpinfo = (BMP_Headers*)(temp+14);
00717 return Bmpinfo->Height;
00718 }
00720
00721
00722 extern inline void PA_8bit8x8Image(bool screen, u16 basex, u16 basey, u8* data){
00723 s16 x, y;
00724
00725 for (x = 0; x < 8; x++)
00726 for (y = 0; y < 8; y++)
00727 PA_Put8bitPixel(screen, x + basex, y + basey, data[x + (y << 3)]);
00728 }
00729
00730
00731
00732
00733
00734
00735
00736
00737
00738
00739
00740
00741
00742
00743
00744
00745
00746
00747
00748
00749
00750
00751
00752
00753
00754
00755
00756
00757
00758
00759
00760
00761
00762
00763
00764
00765 #ifdef __cplusplus
00766 }
00767 #endif
00768
00769
00770
00771
00772
00773
00774
00775
00776 #endif
00777
00778