⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 ppu_palette.c

📁 凌阳32位单片机开发的小游戏
💻 C
字号:
/******************************************************************************
 *
 *     The information contained herein is the exclusive property of
 *   Sunplus Technology Co. And shall not be distributed, reproduced,
 *   or disclosed in whole in part without prior written permission.
 *
 *         (C) COPYRIGHT 2005   SUNPLUS TECHNOLOGY CO.
 *                        ALL RIGHTS RESERVED
 *
 * The entire notice above must be reproduced on all authorized copies.
 *
 *****************************************************************************/

/******************************************************************************
 *  Filename:   	PPU_Palette.c
 *  Author:     	Robin.xjliu  (eMail: xjliu@sunplus.com)
 *  Tel:        	00885-028-87848688-5884
 *  Date:       	2005-11-10
 *  Description:	color palette control lib
 *  Reference:
 *  Version history:
 *-----------------------------------------------------------------------------
 *	Version   YYYY-MM-DD-INDEX   Modified By         Description
 *	1.0.0     2005-11-10           xjliu               Create
 *
 *****************************************************************************/
#include "Include/PPU_Palette.h"

bool	g_bInitPaletteFlag;

/**
 * PPU_SP_InitPalette - initialize sprite palette.
 * @SPPalAddr: sprite palette data start address
 */
void PPU_SP_InitPalette(U32 *pSPPalAddr)
{
	U32 i;
	for (i = 0; i < 512; i++)
		*(P_SP_COLOR_PALETTE + i)	= *(pSPPalAddr + i);
}

/**
 * PPU_BG_InitPalette - initialize texture palette.
 * @BGPalAddr: texture palette data start address
 */
void PPU_BG_InitPalette(U32 *pBGPalAddr)
{
	U32 i;
	for (i = 0; i < 512; i++)
		*(P_BG_COLOR_PALETTE + i)	= *(pBGPalAddr + i);
}
//====================================================================================================
//	Description:	Fade Out Effect
//	Function:		FadeOut()
//	Syntax:			void	FadeOut(void);
//	Input Paramter:	none
//	Return: 		none
//====================================================================================================
void FadeOut(void)    
{
	U32 i, j;
	for(i=0; i<256; i++)
	{
		*P_TV_FADE = i;
		for(j=0; j<1024*6; j++);
	}
}
//====================================================================================================
//	Description:	Fade In Effect
//	Function:		FadeIn()
//	Syntax:			void	FadeIn(void);
//	Input Paramter:	none
//	Return: 		none
//====================================================================================================
void FadeIn(void)     
{
	U32 i, j;
	for(i=0; i<256; i++)
	{
		*P_TV_FADE = 255-i;
		for(j=0; j<1024*8; j++);
	}
}

//==========================================
// Function:     SetColorPalette();
// Syntax:       void PPU_SP_SetPalette(U16 col_st, U16 number, U32 *pSPPalAddr)
// Description:  Set One Color to Palette
// Notes:        none
// parameters:	 int col_st: Color Start Index
//				 int col_end: Color End Index
//				 int value: Color Value
// returns: 	 none
//==========================================
void PPU_SP_SetPalette(U16 col_st, U16 number, U32 *pSPPalAddr)
{
	U32 i,j;

	for (i = col_st, j = 0; i < (col_st+number); i++,j++)
		*(P_SP_COLOR_PALETTE + i)	= *(pSPPalAddr + j);
}
/*
void PPU_DimOut(U8 nPaletteBank,U16 nColorNum,U8 nLevel)
{
	 
	 U16 i;
	 U32 DiData;
	 U32 RedColor,GreenColor,BlueColor;
	 U32 DiRedColor,DiGreenColor,DiBlueColor,nColor;
     U16 nStartBank;
     
     nColor=nPaletteBank*16+nColorNum;
     nStartBank=nPaletteBank*16;

	for(i=0; i<512; i++)
	{
		DiData = *((U32 *)P_BG_COLOR_PALETTE + i );
		DiBlueColor = DiData & 0x1f;
		DiGreenColor = ( DiData>>5 )& 0x1f;
		DiRedColor = ( DiData>>10 )& 0x1f;

		BlueColor = DiBlueColor;
		GreenColor = DiGreenColor;
		RedColor = DiRedColor;
		*(P_BG_COLOR_PALETTE + i) =  (DiData&0x8000) + BlueColor + (GreenColor<<5) + (RedColor<<10);
	}
	
	for(i=nStartBank; i<nColor; i++)
	{
		DiData = *((U32 *)P_SP_COLOR_PALETTE + i );
		DiBlueColor = DiData & 0x1f;
		DiGreenColor = ( DiData>>5 )& 0x1f;
		DiRedColor = ( DiData>>10 )& 0x1f;

		BlueColor = DiBlueColor/nLevel;
		GreenColor = DiGreenColor/nLevel;
		RedColor = DiRedColor/nLevel;
		*(P_SP_COLOR_PALETTE + i) =  (DiData&0x8000) + BlueColor + (GreenColor<<5) + (RedColor<<10);
	}
}
*/

/*
void 	PPU_LightIn(U8 nPaletteBank,U16 nColorNum,U8 nLevel)
{
	 U16 i,j;
	 U32 LiData;
	 U32 RedColor,GreenColor,BlueColor;
	 U32 LiRedColor,LiGreenColor,LiBlueColor,nLastColorB,nLastColorG,nLastColorR;
	 U16 nLevelLacal,nStartBank,nColor;
	 
	 nLevelLacal=64-nLevel;
	 nStartBank=nPaletteBank*16;
	 nColor=nPaletteBank*16+nColorNum;
	 nLastColorB=*((U32 *)BG_PAL_ADDR+i)&0x0000001f;
	 nLastColorG=*((U32 *)BG_PAL_ADDR+i)&0x000003E0;
	 nLastColorR=*((U32 *)BG_PAL_ADDR+i)&0x00007C00;
	 
  	 for(i=nStartBank; i<nColor; i++)
		{    
			   *(P_BG_COLOR_PALETTE+i)=*((U32 *)BG_PAL_ADDR+i);
	 }
}*/

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -