sgdk
pal.h
Go to the documentation of this file.
00001 
00012 #include "config.h"
00013 #include "types.h"
00014 #include "dma.h"
00015 
00016 #ifndef _PAL_H_
00017 #define _PAL_H_
00018 
00019 #define VDPPALETTE_REDSFT           1
00020 #define VDPPALETTE_GREENSFT         5
00021 #define VDPPALETTE_BLUESFT          9
00022 
00023 #define VDPPALETTE_REDMASK          0x000E
00024 #define VDPPALETTE_GREENMASK        0x00E0
00025 #define VDPPALETTE_BLUEMASK         0x0E00
00026 #define VDPPALETTE_COLORMASK        0x0EEE
00027 
00035 #define RGB24_TO_VDPCOLOR(color)    ((((((color) + 0x100000) < 0xFF0000 ? (color) + 0x100000 : 0xFF0000) >> (20)) & VDPPALETTE_REDMASK) | ((((((color) & 0xff00) + 0x1000) < 0xFF00 ? ((color) & 0xff00) + 0x1000 : 0xFF00) >> ((1 * 4) + 4)) & VDPPALETTE_GREENMASK) | ((((((color) & 0xff) + 0x10) < 0xFF ? ((color) & 0xff) + 0x10 : 0xFF) << 4) & VDPPALETTE_BLUEMASK))
00036 
00048 #define RGB3_3_3_TO_VDPCOLOR(r, g, b) ((((r) & 7) << VDPPALETTE_REDSFT) | (((g) & 7) << VDPPALETTE_GREENSFT) | (((b) & 7) << VDPPALETTE_BLUESFT))
00049 
00061 #define RGB8_8_8_TO_VDPCOLOR(r, g, b) RGB24_TO_VDPCOLOR(((((b) << 0) & 0xFF) | (((g) & 0xFF) << 8) | (((r) & 0xFF) << 16)))
00062 
00072 typedef struct
00073 {
00074     u16 length;
00075     u16* data;
00076 } Palette;
00077 
00078 
00083 extern const u16* const palette_black;
00088 extern const u16 palette_grey[16];
00093 extern const u16 palette_red[16];
00098 extern const u16 palette_green[16];
00103 extern const u16 palette_blue[16];
00104 
00109 extern u16 fadeCurrentPal[64];
00114 extern u16 fadeEndPal[64];
00115 
00124 u16  PAL_getColor(u16 index);
00136 void  PAL_getColors(u16 index, u16* dest, u16 count);
00146 void PAL_getPalette(u16 numPal, u16* dest);
00147 
00157 void PAL_setColor(u16 index, u16 value);
00176 void PAL_setColors(u16 index, const u16* pal, u16 count, TransferMethod tm);
00193 void PAL_setPaletteColors(u16 index, const Palette* pal, TransferMethod tm);
00210 void PAL_setPalette(u16 numPal, const u16* pal, TransferMethod tm);
00211 
00216 #define PAL_setColorsDMA(index, pal, count)     _Pragma("GCC error \"This method is deprecated, use PAL_setColors(..) instead.\"")
00217 
00221 #define PAL_setPaletteColorsDMA(index, pal)     _Pragma("GCC error \"This method is deprecated, use PAL_setPaletteColors(..) instead.\"")
00222 
00226 #define PAL_setPaletteDMA(numPal, pal)          _Pragma("GCC error \"This method is deprecated, use PAL_setPalette(..) instead.\"")
00227 
00245 bool PAL_initFade(u16 fromCol, u16 toCol, const u16* palSrc, const u16* palDst, u16 numFrame);
00254 bool PAL_doFadeStep(void);
00255 
00278 void PAL_fade(u16 fromCol, u16 toCol, const u16* palSrc, const u16* palDst, u16 numFrame, bool async);
00297 void PAL_fadeTo(u16 fromCol, u16 toCol, const u16* pal, u16 numFrame, bool async);
00314 void PAL_fadeOut(u16 fromCol, u16 toCol, u16 numFrame, bool async);
00333 void PAL_fadeIn(u16 fromCol, u16 toCol, const u16* pal, u16 numFrame, bool async);
00334 
00354 void PAL_fadePalette(u16 numPal, const u16* palSrc, const u16* palDst, u16 numFrame, bool async);
00371 void PAL_fadeToPalette(u16 numPal, const u16* pal, u16 numFrame, bool async);
00386 void PAL_fadeOutPalette(u16 numPal, u16 numFrame, bool async);
00403 void PAL_fadeInPalette(u16 numPal, const u16* pal, u16 numFrame, bool async);
00404 
00421 void PAL_fadeAll(const u16* palSrc, const u16* palDst, u16 numFrame, bool async);
00437 void PAL_fadeToAll(const u16* pal, u16 numFrame, bool async);
00451 void PAL_fadeOutAll(u16 numFrame, bool async);
00467 void PAL_fadeInAll(const u16* pal, u16 numFrame, bool async);
00468 
00473 bool PAL_isDoingFade(void);
00478 void PAL_waitFadeCompletion(void);
00483 void PAL_interruptFade(void);
00484 
00485 
00486 #endif // _VDP_PAL_H_
 All Classes Files Functions Variables Typedefs Enumerations Enumerator Defines