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

📄 ppu_control.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_Control.c
 *  Author:     	Robin.xjliu  (eMail: xjliu@sunplus.com)
 *  Tel:        	00885-028-87848688-5884
 *  Date:       	2005-11-16
 *  Description:	other register about PPU control lib
 *  Reference:
 *  Version history:
 *-----------------------------------------------------------------------------
 *	Version   YYYY-MM-DD-INDEX   Modified By         Description
 *	1.0.0     2005-11-16          xjliu               Create
 *
 *****************************************************************************/
#include "Include/PPU_Control.h"
#include "Include/PPU_Sprite.h"
#include "Include/PPU_Palette.h"
#include "Include/PPU_Texture.h"
#include "Include/Tve_Control.h"
#include "Include/GPIO_Joystick.h"

U32	old_game_time, game_time;
extern const U32 Sp_Palette[];
extern const U32 Sp_BackupPalette[];
extern bool	g_bScoreColor;
extern bool	g_bCompleteColor;
extern bool	g_bMenuColor;
extern bool g_bHMovementFlag;
extern const S8 pScanline[];
extern void LCD_Paint(void);
/**
 * InitPPU - initialize PPU control register
 */
void InitPPU(void)
{
	//set ppu mode
 	*P_TV_CONTROL 	= TVEN | TVRGB2YUV | TVLPF1 & (~TVVGA);	// CIF Mode	
	*P_PPU_CONTROL 	= PPUEN & (~PPUVGA);				// CIF
	*P_TV_CONTROL 	|= TVVGA;			// VGA Mode
	*P_PPU_CONTROL	|= PPUVGA;			// VGA	
	
	//Initialize Palette
	g_bInitPaletteFlag = true;

    //Initialize Text
    //if( pAniTextHead->textnum != 0 )
    {
    	PPU_InitTexture();
    }

	//Initialize Sprite
	PPU_InitSprite();
}

/**
 * PPU_Service - access PPU's register in every intermit.
 * @Note:	on IRQ0 write Sprite register, palette, Text move
 */
void PPU_Service(void)
{
	unsigned int *port;
	game_time++;
	
	//write sprite register
	if(g_bShowSpriteFlag)
	{
		PPU_PaintSprite();
	}

	//scroll texture
	if(g_bTextScrollFlag)
	{
		g_bTextScrollFlag = false;
		PPU_ScrollScreen(&g_aPNTPtrFlag);
	}
	
	//initialize palette
	if(g_bInitPaletteFlag)
	{
	    PPU_BG_InitPalette( (U32 *)BG_PAL_ADDR );
		PPU_SP_InitPalette( (U32 *)(&Sp_Palette) );
		g_bInitPaletteFlag = false;
	}

	if ( g_bScoreColor )
	{
		PPU_SP_SetPalette(SP_PALETTE31*16, 15, (U32*)(&Sp_BackupPalette[64]) );
		g_bScoreColor = false;
	}

	if (g_bCompleteColor)
	{
		PPU_SP_SetPalette(SP_PALETTE0*16, 64, (U32*)(&Sp_BackupPalette[0]) );
		g_bCompleteColor = false;
	}
	/*if ( g_bMenuColor )
	{
		PPU_DimOut(SP_PALETTE4, 432, 8);
		g_bMenuColor = false;
	}*/

	if ( g_bHMovementFlag )
	{
		g_bHMovementFlag = false;
		TX_HMovement(1,0,512,0,&pScanline[0],80);
	}
	//Check Joystick info
	//GetJoystickKeyCode();
//	port = 0x88040000;
//	if(((*port)&0x01000000)==1)	
	LCD_Paint();
}

/**
 * WaitBlanking - Wait Vertical blanking.
 */
void WaitBlanking(void)
{
	while(old_game_time == game_time);		//	Game_time ++ In IRQ.asm
	old_game_time = game_time;
}

⌨️ 快捷键说明

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