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

📄 ppu_sprite.h

📁 凌阳32位单片机开发的小游戏
💻 H
字号:
/******************************************************************************
 *
 *     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_Sprite.h
 *  Author:     	Robin.xjliu  (eMail: xjliu@sunplus.com)
 *  Tel:        	00885-028-87848688-5884
 *  Date:       	2005-11-04
 *  Description:	sprite type define(platform relative)
 *  Reference:
 *  Version history:
 *-----------------------------------------------------------------------------
 *	Version   YYYY-MM-DD-INDEX   Modified By         Description
 *	1.0.0     2005-11-04           xjliu               Create
 *
 *****************************************************************************/
#ifndef _PPU_SPRITE_H
#define _PPU_SPRITE_H

#include "Sys_Global.h"

/**
 * Frame's attribute define
 */
typedef union
{
	struct
	{
		U16 Sp_Color	:2;
		U16 Sp_Flip		:2;
		U16 Sp_HSize	:2;
		U16 Sp_VSize	:2;
		U16 Sp_Palette	:5;
		U16 Sp_Depth	:2;
		U16 Sp_EnBlend	:1;		
	}B;
	U16 W;
}FRAME_INFO;

/**
 * Frame's cell define
 */
typedef struct{
	const U16	nPGTIndex;
	const S16	sRefX;					//cell左上角相对于Frame的stOrgPos的水平偏移
	const S16	sRefY;					//cell左上角相对于Frame的stOrgPos的垂直偏移
}FRAME_CELL;

/**
 * Blocks: Collision rectangle block
 */
typedef struct
{/* The rectangle block */
    S16	Left;
	S16	Top;
	S16	Right;
	S16	Bottom;
}FRAME_BLOCK;

/**
 * Frame define
 */
typedef struct{
	const SIZE			stSize;
	const POINT			stOrgPos;		//相对于整个Frame左上角的坐标
	const U16			nCellNum;
	const FRAME_INFO	*pFrameInfo;
	const FRAME_CELL	*pFrameCellTbl;
	//add by Robin.Lau for collision detect
	const U16			nBlockNum;
	const FRAME_BLOCK	*pFrameBlockTbl;
}FRAME;

/**
 * Sprite define
 */
typedef struct{
	LISTHEAD	SprList;
	U32			nCtrlFlag;
	POINT		stPos;				//Sprite相对于屏幕左上角(0,0)的坐标
	FRAME		*pFrame;
}SPRITE;

/**
 * cell display info define
 */
typedef union
{
	struct
	{
		S32 nChNum		:16;
		S32 sPosX		:10;
		S32 ReservedL	: 6;	
	}B;
	S32 DW;
}SP_ATTR1;

typedef union
{
	struct
	{
		S32 nAttribute	:16;
		S32 sPosY		:10;
		S32 nBlend		: 6;
	}B;
	S32 DW;
}SP_ATTR2;

typedef struct{
	SP_ATTR1	SP_Attribute1;
	SP_ATTR2	SP_Attribute2;
}PAINT_CELL;


#define List2Sprite(ptr)	list_entry(ptr,SPRITE,SprList)	//((SPRITE*)(ptr))
/**
 * Setting for sprite attribute
 */
#define		SP_DISBLEND			0
#define		SP_ENBLEND			1
	
#define		SP_DEPTH0			0
#define		SP_DEPTH1 			1
#define		SP_DEPTH2 			2
#define		SP_DEPTH3 			3

#define		SP_PALETTE0 		0
#define		SP_PALETTE1 		1
#define		SP_PALETTE2 		2
#define		SP_PALETTE3 		3
#define		SP_PALETTE4 		4
#define		SP_PALETTE5 		5
#define		SP_PALETTE6 		6
#define		SP_PALETTE7 		7
#define		SP_PALETTE8 		8
#define		SP_PALETTE9 		9
#define		SP_PALETTE10 		10
#define		SP_PALETTE11 		11
#define		SP_PALETTE12 		12
#define		SP_PALETTE13 		13
#define		SP_PALETTE14 		14
#define		SP_PALETTE15 		15
#define		SP_PALETTE16 		16
#define		SP_PALETTE17 		17
#define		SP_PALETTE18 		18
#define		SP_PALETTE19 		19
#define		SP_PALETTE20 		20
#define		SP_PALETTE21 		21
#define		SP_PALETTE22 		22
#define		SP_PALETTE23 		23
#define		SP_PALETTE24 		24
#define		SP_PALETTE25 		25
#define		SP_PALETTE26 		26
#define		SP_PALETTE27 		27
#define		SP_PALETTE28		28
#define		SP_PALETTE29		29
#define		SP_PALETTE30 		30
#define		SP_PALETTE31		31

#define		SP_VSIZE8 			0
#define		SP_VSIZE16 			1
#define		SP_VSIZE32 			2
#define		SP_VSIZE64 			3
#define		SP_HSIZE8 			0
#define		SP_HSIZE16 			1
#define		SP_HSIZE32 			2
#define		SP_HSIZE64 			3

#define		SP_NO_FLIP			0
#define		SP_H_FLIP 			1
#define		SP_V_FLIP	 		2
#define		SP_ALL_FLIP			3

#define		SP_COLOR4 			0
#define		SP_COLOR16 			1
#define		SP_COLOR64 			2
#define		SP_COLOR256 		3

extern bool g_bShowSpriteFlag;

/**
 * basic function about manage and display sprite.
 */
void PPU_InitSprite(void);
SPRITE* PPU_AllocSprite( const FRAME *pFrame, S16 x, S16 y, U16 nPri );
void PPU_FreeSprite(SPRITE *pSprite);
void PPU_PaintSprite(void);
#define PPU_ShowSprite(ptr)	g_bShowSpriteFlag = ptr

/**
 * extend function about set and get some sprite register info
 */
/**
 * PPU_SetSP_Coord - Sprite Coordinate Select.
 * @ptr: SP_CENTER - Origin on center, SP_CORNER - Origin on top/left corner
 */
#define PPU_SetSP_Coord(ptr) P_SP_Control->B.Coord_sel = ptr
#define SP_CENTER	0
#define SP_CORNER	1

/**
 * PPU_SetSP_En - Set Sprite display enable/disable.
 * @ptr: SP_ENABLE - enable sprite, SP_DISABLE - disable sprite
 */
#define PPU_SetSP_En(ptr) P_SP_Control->B.Sp_en = ptr
#define SP_DISABLE	0
#define SP_ENABLE	1

/**
 * PPU_SetSP_MaxCellNum - Set cell number.
 * @ptr: max cell number, use "CELL_NUM_MAX"
 */
#define PPU_SetSP_MaxCellNum(ptr) *P_SP_MAX = (ptr & 0x01FF)

/**
 * PPU_SetSP_BUF_SA - Set cell data start address.
 * @ptr: the start address of sprite PGT data, like "SpritePixel"
 */
#define PPU_SetSP_BUF_SA(ptr) P_SP_BUF_SA->DW = ptr


#endif	//_PPU_SPRITE_H



⌨️ 快捷键说明

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