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

📄 ppu_texture.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_Texture.h
 *  Author:     	xydeng  (eMail: xydeng@sunplus.com)
 *  Tel:        	00885-028-87848688-5884
 *  Date:       	2005-11-11
 *  Description:	Texture type define(platform relative)
 *  Reference:
 *  Version history:
 *-----------------------------------------------------------------------------
 *	Version   YYYY-MM-DD-INDEX   Modified By         Description
 *	1.0.0     2005-11-11           xydeng               Create
 *
 *****************************************************************************/
 
#include "Sys_Global.h"
#include "Sys_load.h"

typedef union
{
	struct
	{
		U8 Blend		:1;
		U8 RGB555		:1;
		U8 Vcmp 		:1;
		U8 Hcmp 		:1;
		U8 Sp_Palette	:5;
		U8 Sp_Depth		:2;
		U8 Sp_EnBlend	:1;		
	}B;
	U8 Byte;
}TX_CONTROL;
 
typedef struct aniTextHead   //The maximum of text is 2
{
	U16	    ctag[4]; 		//caption name "SANI",represent sunplus ani.
	U16 	version; 		//version information.
	U16     sReserved;		
	U16 	ucXSpeed;		//indicate x move speed(pixels/s).
	U16 	ucYSpeed;		//indicate y move speed(pixels/s).
	U16 	textnum; 		//0: no text 1: have one text 2: have two text 3: have three text
	U16     cReserved[7];	//
//	long	 textOffset[2]; //The begin position of text, -1 means that there is no text.
}ANITEXTHEAD;

typedef struct tagText
{
	U16 	bType; 			//0:character mode 1:bitmap mode 2:hi-color(15 bits)
	U16	    cName[20];
	U16	    ColorBit; 		//color mode,2: 4 colors 4:16 colors 6:64 colors 8:256 colors 15: 32768 colors
	U16 	xPos;  			//X start position
	U16 	yPos;  			//Y start position
	U16 	xSize; 			//width of text (cell number)
	U16 	ySize; 			//Hight of text (cell number)
	U16 	cxSize; 		//x character size (pixels)
	U16 	cySize; 		//y character size (pixels)
	U16 	usedcelnum;   	//the number of total used cell .
	U16 	bank;		 	//0~15 palette bank begin position
	U16 	bBlendMode;    	//0: no blending 1: 25% blend 2:50% blend 3:75% blend
	U16 	layer;		 	//0~3
	U16 	delaycount;   	//delay counter of text
	U16 	repeat;		 	//repeat times -1: always repeat		 		 		 		 		 
	U16 	XScrollData; 	//the value of X scroll 0: no scroll <0: scroll left >0: scroll right
	U16 	YScrollData; 	//The value of Y scroll 0: no scroll <0: scroll left >0: scroll right
	U16 	datasize[2];	//if bType is 0(character mode),data include index and cell data ??
	                         		//if bType is 1 or 2(bitmap mode),data only include pixel data.
}ANI_TEXT;

typedef struct tagSPRITFILEEHEAD
{
	U16	tag[4]; //the caption of sprite,"SSPR" represent sunplus sprite file		 
	U32	version;//version information.
	U32	sprnum; //sprite number, 0 means no sprite
	U32    clsize;//CELL lib block size.
}SPRITEFILEHEAD;

typedef struct tagSPrite
{
	U16		caption[20]; 	//identifier
	U16		xPos;		 	//x position of sprite on screen
	U16		yPos;		 	//y position of sprite on screen
	U16		FrmNum;
	U16		ColorBit; 		//color mode,2: 4 colors 4:16 colors 6:64 colors 8:256 colors 15: 32768 colors
	U16		bank;			//(0~15) begin position of palette bank 
	U16		layer;			//0~3
	U16		direction; 		//the direction of sprite, 0:up 1:down 2:left 3:right
	U16		MoveType;  		//the type of movement, 0: no movement 
		 		 			 			//1: easy type (like text scroll) only move x and y
		 		 			 			//2: movement by data	
	U16		moveNum;    	//Move number
}ANI_SPRITE;

extern S16			g_aTextPos_X[3];
extern S16			g_aTextPos_Y[3];
extern U8			g_aPNTPtrFlag[3];
extern bool			g_bTextScrollFlag;
extern ANITEXTHEAD	*pAniTextHead;
extern ANI_TEXT		*pAniText[3];

//====================================================================================================
// 3 text
#define TEXT1			0x00000000
#define TEXT2			0x00000001
#define TEXT3			0x00000002

//Text Mode
#define CHAR_MODE		0x0000
#define BITMAP_MODE		0x0001
#define HICOLOR_32K    	0x0002
#define HICOLOR_64K		0x0003

// Text Colors
#define TX_Color4          0x00000002
#define TX_Color16         0x00000004
#define TX_Color64         0x00000006
#define TX_Color256        0x00000008
#define TX_Color32768      0x00000010
#define TX_Color65536      0x00000020

// P_PPU_Control
#define PPUVGA			0x00000001
#define PPUVGA2CIF		0x00000002
#define PPUEN			0x00001000

// P_PPU_Tx_Attribute	
#define TXColor4		0x00000000
#define TXColor16		0x00000001
#define TXColor64		0x00000002
#define TXColor256		0x00000003
#define TX_NO_Flip		0x00000000
#define TX_H_Flip		0x00000004	
#define TX_V_Flip		0x00000008	
#define TX_ALL_Flip		0x0000000C

//Text Horizontal size	
#define TXHSize8		0x00000000
#define TXHSize16		0x00000010
#define TXHSize32		0x00000020
#define TXHSize64		0x00000030

//Text Vertical size
#define TXVSize8		0x00000000
#define TXVSize16		0x00000040
#define TXVSize32		0x00000080
#define TXVSize64		0x000000C0

//Text Palette
#define TXPalette0		0x00000000
#define TXPalette1		0x00000100
#define TXPalette2		0x00000200
#define TXPalette3		0x00000300
#define TXPalette4		0x00000400
#define TXPalette5		0x00000500
#define TXPalette6		0x00000600
#define TXPalette7		0x00000700
#define TXPalette8		0x00000800
#define TXPalette9		0x00000900
#define TXPalette10		0x00000a00
#define TXPalette11		0x00000b00
#define TXPalette12		0x00000c00
#define TXPalette13		0x00000d00
#define TXPalette14		0x00000e00
#define TXPalette15		0x00000f00
#define TXPalette16		0x00001000
#define TXPalette17		0x00001100
#define TXPalette18		0x00001200
#define TXPalette19		0x00001300
#define TXPalette20		0x00001400
#define TXPalette21		0x00001500
#define TXPalette22		0x00001600
#define TXPalette23		0x00001700
#define TXPalette24		0x00001800
#define TXPalette25		0x00001900
#define TXPalette26		0x00001a00
#define TXPalette27		0x00001b00
#define TXPalette28		0x00001c00
#define TXPalette29		0x00001d00
#define TXPalette30		0x00001e00
#define TXPalette31		0x00001f00
#define TXDepth0		0x00000000			
#define TXDepth1		0x00002000			
#define TXDepth2		0x00004000			
#define TXDepth3		0x00006000			

// P_PPU_Tx_Control
#define TXLINEAR		0x00000001
#define TXREGMODE		0x00000002
#define	TXWAPMODE		0x00000004
#define TXEN			0x00000008
#define TXMOVEN			0x00000010
#define TXHCMP			0x00000020
#define TXVCMP			0x00000040
#define TXRGB555		0x00000080
#define BLEND			0x00000100
#define TXRGB565		0x00001000

/**
 * basic function about manage and display Texture.
 */
void ClearTextRegister(void);
void PPU_InitStructure(void);
void PPU_InitCharacterText(ANI_TEXT *ptrAniText,U32 nTEXT );
void PPU_InitBitmapText(ANI_TEXT *ptrAniText,S32 eTEXT );
bool PPU_InitTexture(void);
void PPU_BitmapShow(S32 nTextLayer, S32 nXSize, S32 nYSize, S32 nColorMode, S32 nBank, S32 nDepthLayer, U32 *PatAddr, U32 *IndexAddr);
void PPU_CharacterShow(U32 nTextLayer, U32 nXSize, U32 nYSize, U32 *PatAddr, U32 *IndexAddr, U32 nColorMode, U32 nCellXSize, U32 nCellYSize, U32 nPaletteBank, U32 nDepth);

void PPU_ScrollScreen(U8 *pPtrFlag);



⌨️ 快捷键说明

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