sgdk
|
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 void PAL_setColorsDMA(u16 index, const u16* pal, u16 count); 00221 void PAL_setPaletteColorsDMA(u16 index, const Palette* pal); 00226 void PAL_setPaletteDMA(u16 numPal, const u16* pal); 00227 00228 00229 // these functions should be private as they are called by PAL_fadeXXX functions internally 00230 // but they can be useful sometime for better control on the fading processus 00231 bool PAL_initFade(u16 fromCol, u16 toCol, const u16* palSrc, const u16* palDst, u16 numFrame); 00232 bool PAL_doFadeStep(); 00233 00234 00257 void PAL_fade(u16 fromCol, u16 toCol, const u16* palSrc, const u16* palDst, u16 numFrame, bool async); 00276 void PAL_fadeTo(u16 fromCol, u16 toCol, const u16* pal, u16 numFrame, bool async); 00293 void PAL_fadeOut(u16 fromCol, u16 toCol, u16 numFrame, bool async); 00312 void PAL_fadeIn(u16 fromCol, u16 toCol, const u16* pal, u16 numFrame, bool async); 00313 00333 void PAL_fadePalette(u16 numPal, const u16* palSrc, const u16* palDst, u16 numFrame, bool async); 00350 void PAL_fadeToPalette(u16 numPal, const u16* pal, u16 numFrame, bool async); 00365 void PAL_fadeOutPalette(u16 numPal, u16 numFrame, bool async); 00382 void PAL_fadeInPalette(u16 numPal, const u16* pal, u16 numFrame, bool async); 00383 00400 void PAL_fadeAll(const u16* palSrc, const u16* palDst, u16 numFrame, bool async); 00416 void PAL_fadeToAll(const u16* pal, u16 numFrame, bool async); 00430 void PAL_fadeOutAll(u16 numFrame, bool async); 00446 void PAL_fadeInAll(const u16* pal, u16 numFrame, bool async); 00447 00452 bool PAL_isDoingFade(); 00457 void PAL_waitFadeCompletion(); 00462 void PAL_interruptFade(); 00463 00464 00465 #endif // _VDP_PAL_H_