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 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
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
00348 void PA_Draw16bitLineEx(bool screen, s16 basex, s16 basey, s16 endx, s16 endy, u16 color, s8 size);
00349
00350 void PA_Draw8bitLineEx(bool screen, s16 basex, s16 basey, s16 endx, s16 endy, u8 color, s8 size);
00351
00352
00353
00377 void PA_Draw16bitRect(bool screen, s16 basex, s16 basey, s16 endx, s16 endy, u16 color);
00378
00379
00391 void PA_8bitDraw(bool screen, u8 color);
00392
00393
00405 void PA_16bitDraw(bool screen, u16 color);
00406
00407
00419 #define PA_SetDrawSize(screen, draw_size) PA_drawsize[screen] = draw_size;
00420
00421
00422
00423
00424
00436 #define PA_Load8bitBitmap(screen, bitmap) DMA_Copy(bitmap, (void*)PA_DrawBg[screen], 256*96, DMA_16NOW);
00437
00449 #define PA_Load16bitBitmap(screen, bitmap) {u32 PA_temp; \
00450 for (PA_temp = 0; PA_temp < 256*192; PA_temp++)\
00451 PA_DrawBg[screen][PA_temp] = bitmap[PA_temp] | (1 << 15);}
00452
00453
00462 #define PA_Clear8bitBg(screen) DMA_Copy(Blank, (void*)PA_DrawBg[screen], 256*96, DMA_16NOW);
00463
00472 #define PA_Clear16bitBg(screen) DMA_Copy(Blank, (void*)PA_DrawBg[screen], 256*192, DMA_16NOW)
00473
00474
00486 extern inline void PA_LoadJpeg(bool screen, void *jpeg) {
00487 REG_IME = 0x00;
00488 JPEG_DecompressImage((u8*)jpeg, PA_DrawBg[screen], 256, 192);
00489 REG_IME = 0x01;
00490 }
00491
00492
00493
00514 void PA_LoadBmpToBuffer(u16 *Buffer, s16 x, s16 y, void *bmp, s16 SWidth);
00515
00516
00534 extern inline void PA_LoadBmpEx(bool screen, s16 x, s16 y, void *bmp){
00535 PA_LoadBmpToBuffer(PA_DrawBg[screen], x, y, bmp, 256);
00536 }
00537
00538
00539
00551 extern inline void PA_LoadBmp(bool screen, void *bmp){
00552 PA_LoadBmpEx(screen, 0, 0, bmp);
00553 }
00554
00555
00556
00557
00558
00559
00560
00569 extern inline u16 PA_GetGifWidth(void* gif){
00570 u16 *temp = (u16*)gif;
00571 temp += 3;
00572 return *temp;
00573 }
00574
00575
00576
00585 extern inline u16 PA_GetGifHeight(void* gif){
00586 u16 *temp = (u16*)gif;
00587 temp += 4;
00588 return *temp;
00589 }
00590
00591
00592
00604 extern inline void PA_LoadGif(bool screen, void *gif){
00605 if (PA_nBit[screen]) DecodeGif((const u8*)gif, (u8*)PA_DrawBg[screen], (u16*)0x05000000, 1, 256);
00606
00607 else DecodeGif((const u8*)gif, (u8*)PA_DrawBg[screen], (u16*)(0x05000000+(0x400*screen)), 0, 256);
00608 }
00609
00610
00611
00612
00613
00614
00615
00616
00617
00618
00619
00620
00621
00622
00623
00624
00625
00626
00638 extern inline void PA_LoadGBFSImage(bool screen, s16 GBFSImage){
00639 if (PA_CompareText(PA_GBFSfile[GBFSImage].Ext, "bmp")){
00640 PA_LoadBmp(screen, PA_GBFSfile[GBFSImage].File);
00641 }
00642 if (PA_CompareText(PA_GBFSfile[GBFSImage].Ext, "jpg")){
00643 PA_LoadJpeg(screen, PA_GBFSfile[GBFSImage].File);
00644 }
00645 if (PA_CompareText(PA_GBFSfile[GBFSImage].Ext, "gif")){
00646 PA_LoadGif(screen, PA_GBFSfile[GBFSImage].File);
00647 }
00648 }
00649
00650 extern inline void PA_LoadGBFSImageToBuffer(void *Buffer, s16 GBFSImage, s16 Width){
00651 if (PA_CompareText(PA_GBFSfile[GBFSImage].Ext, "bmp")){
00652 PA_LoadBmpToBuffer((u16*)Buffer, 0, 0, (u16*)PA_GBFSfile[GBFSImage].File, Width);
00653 }
00654
00655
00656
00657 if (PA_CompareText(PA_GBFSfile[GBFSImage].Ext, "gif")){
00658 DecodeGif((const u8*)PA_GBFSfile[GBFSImage].File, (u8*)Buffer, (u16*)0x05000000, 1, Width);
00659 }
00660 }
00661
00662 extern inline u16 PA_GetBmpWidth(void *bmp){
00663 u8 *temp = (u8*)bmp;
00664 BMP_Headers *Bmpinfo = (BMP_Headers*)(temp+14);
00665 return Bmpinfo->Width;
00666 }
00667 extern inline u16 PA_GetBmpHeight(void *bmp){
00668 u8 *temp = (u8*)bmp;
00669 BMP_Headers *Bmpinfo = (BMP_Headers*)(temp+14);
00670 return Bmpinfo->Height;
00671 }
00673
00674
00675 extern inline void PA_8bit8x8Image(bool screen, u16 basex, u16 basey, u8* data){
00676 s16 x, y;
00677
00678 for (x = 0; x < 8; x++)
00679 for (y = 0; y < 8; y++)
00680 PA_Put8bitPixel(screen, x + basex, y + basey, data[x + (y << 3)]);
00681 }
00682
00683
00684
00685
00686
00687
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
00713
00714
00715
00716
00717
00718 #ifdef __cplusplus
00719 }
00720 #endif
00721
00722
00723
00724
00725
00726
00727
00728
00729 #endif
00730
00731