PAlib: PA_Palette.h Source File

Main Page | Modules | File List | Globals | Search for

# PA_Palette.h

Go to the documentation of this file.

    00001 #ifndef _PA_Palette
    00002 #define _PA_Palette
    00003
    00004
    00005
    00006 void PA_LoadSpriteExtPal(bool screen, u16 palette_number, void* palette);
    00007 void PA_LoadBgExtPal(bool screen, u16 palette_number, void* palette);
    00008
    00009
    00016 //#include "../PA.h"
    00017
    00018
    00020 // Système pour les palettes
    00022 #define PAL_BG0 0x05000000
    00023 #define PAL_SPRITE0 0x05000200
    00024 #define PAL_BG1 0x05000400
    00025 #define PAL_SPRITE1 0x05000600
    00026
    00027 #define REG_BRIGHT 0x0400006C  // Brightness
    00028
    00029
    00030
    00048 #define PA_LoadPal(palette, source) {\
    00049        DMA_Copy((void*)source, (void*)palette, 256, DMA_16NOW);\
    00050        if (palette == PAL_SPRITE0) PA_LoadSpritePal(0, 0, (void*)source);\
    00051        if (palette == PAL_SPRITE1) PA_LoadSpritePal(1, 0, (void*)source);\
    00052        if (palette == PAL_BG0) {u8 itemp; for (itemp = 0; itemp < 4; itemp++) PA_LoadBgPal(0, itemp, (void*)source);}\
    00053        if (palette == PAL_BG1) {u8 itemp; for (itemp = 0; itemp < 4; itemp++) PA_LoadBgPal(1, itemp, (void*)source);}}
    00054
    00055
    00067 extern inline void PA_LoadNormalBgPal(bool screen, void *Pal){
    00068 u32 dest = PAL_BG0 + (screen<<10);
    00069        DMA_Copy((void*)Pal, (void*)dest, 256, DMA_16NOW);\
    00070
    00071 }
    00072
    00073
    00074
    00090 #define PA_LoadPal16(palette, n_palette, source)   DMA_Copy((void*)source, (void*)(palette + (n_palette << 5)), 16, DMA_16NOW);
    00091
    00092
    00108 #define PA_RGB(r,g,b) ((1 << 15) + (r) + ((g)<<5) + ((b)<<10))
    00109
    00123 void PA_SetBrightness(bool screen, s8 bright);
    00124
    00125
    00126
    00135 extern inline void PA_SetPalNeg(u32 palette) {
    00136 u16* pal = (u16*)palette;
    00137 u16 i;
    00138
    00139 for (i = 0; i < 256; i++) pal[i] = ~pal[i]; // On fout le négatif...
    00140 }
    00141
    00142
    00143
    00144
    00156 extern inline void PA_SetPal16Neg(u32 palette, u8 n_palette) {
    00157 u16* pal = (u16*)palette;
    00158 u16 i;
    00159
    00160 for (i = (n_palette << 4); i < ((n_palette + 1) << 4); i++) pal[i] = ~pal[i]; // On fout le négatif...
    00161 }
    00162
    00163
    00169 void PA_InitSpriteExtPal(void);
    00170
    00171
    00172
    00178 void PA_InitBgExtPal(void);
    00179
    00180
    00181
    00196 extern inline void PA_LoadSpritePal(bool screen, u8 palette_number, void* palette)
    00197 {
    00198        PA_LoadSpriteExtPal(screen, palette_number, palette);
    00199 }
    00200
    00201
    00202
    00203
    00218 extern inline void PA_LoadBgPal(bool screen, u16 bg_number, void* palette){
    00219        PA_LoadBgExtPal(screen, bg_number, palette);
    00220 }
    00221
    00239 void PA_LoadBgPalN(bool screen, u8 bg_number, u8 pal_number, void* palette);
    00240
    00241
    00242
    00243
    00258 #define PA_SetBgPalCol(screen, color_number, colorRGB) BG_PALETTE[color_number + (screen << 9)] = colorRGB
    00259
    00260
    00261
    00282 void PA_SetBgPalNCol(bool screen, u8 bg_number, u8 pal_number, u8 color_number, u16 color);
    00283
    00284
    00285
    00286
    00287
    00299 extern inline void PA_SetBgColor(bool screen, u16 color){
    00300        BG_PALETTE[screen<<7] = color;
    00301 }
    00302
    00303
    00321 void PA_SetSpritePalCol(bool screen, u8 pal_number, u8 color_number, u16 color);
    00322
    00323
    00324
    00325
    00326
    00327 #define PA_AdjustCol(color, bright) color+= bright; if (color < 0) color = 0; if (color > 31) color = 31
    00328
    00329 void PA_CreatePalBright(u16 *pal, u16 *newpal, s8 bright);
    00330
    00331 void PA_CreatePalTransition(u16 *pal, u16 *newpal, s8 level, u8 destr, u8 destg, u8 destb);
    00332
    00333
    00334
    00335
    00336
    00337
    00338
    00339
    00340
    00341
    00342
    00343
    00344
    00345
    00346  // end of Palette
    00349 extern inline void* PA_GetBgPal(bool screen, u8 bg_number){
    00350        if (screen == 0) return (void*)(VRAM_E + (bg_number << 12));
    00351        else return (void*)(VRAM_H + (bg_number << 12));
    00352 }
    00353
    00354
    00369 /*#define PA_SetSpritePalCol(screen, color_number, colorRGB) BG_PALETTE[256 + color_number + (screen << 9)] = colorRGB*/
    00370
    00371
    00372
    00373
    00374 #endif
    00375
    00376