?? ppu_control.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_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
*
*****************************************************************************/
#ifndef _PPU_CONTROL_H
#define _PPU_CONTROL_H
#include "Sys_Global.h"
//#include "..\SysLib_Extend\Include\Lcd.h"
#define QVGA_Data 0x0000
#define VGA_Data 0x0001
#define HVGA_Data 0x0002
#define PPU_SOFT 0x0000
#define PPU_P2T_HARD 0x0010
#define PPU_P2L_HARD 0x0020
#define PPU_P2L_HW4 0x0030
#define PPU_P2T_EN 0x0001
void InitPPU(void);
void PPU_Service(void);
void WaitBlanking(void);
//PPU_Sprite
/**
* 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; //Character Number
const S16 sRefX; //horizontal offset of cell's left&top corner relative to frame's left&top corner
const S16 sRefY; //vertical offset of cell's left&top corner relative to frame's left&top corner
}FRAME_CELL;
/**
* Blocks: Collision rectangle block
*/
typedef struct
{/* The rectangle block */
S16 Left;
S16 Top;
S16 Right;
S16 Bottom;
}FRAME_BLOCK;
/**
* Frame define
*/
#ifndef SPRITETAB_BIN
typedef struct{
const SIZE stSize; //the size of this frame(Unit: pixel)
const POINT stOrgPos; //center of gravity
const U16 nCellNum; //the cell number of this frame
const FRAME_INFO *pFrameInfo; //point to the attribute of frame
const FRAME_CELL *pFrameCellTbl;
//add by Robin.Lau for collision detect
const U16 nBlockNum; //collision block number of this frame
const FRAME_BLOCK *pFrameBlockTbl;
}FRAME;
#else
typedef struct{
const SIZE stSize;
const POINT stOrgPos;
const U16 nCellNum;
const U16 nBlockNum;
const FRAME_INFO *pFrameInfo;
const FRAME_CELL *pFrameCellTbl;
const FRAME_BLOCK *pFrameBlockTbl;
}FRAME;
#endif //SPRITETAB_BIN
/**
* Sprite define
*/
typedef struct{
LISTHEAD SprList;
U32 nCtrlFlag;
POINT stPos; //position of this sprite in the screen
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
//PPU_Texture
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]; //
U16 nTFT_Info;
// 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;
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];
//====================================================================================================
//display mode(resolution)
#define DISPLAY_QVGA 0x00000000 //resolution: 320 x 240
#define DISPLAY_VGA 0x00000001 //resolution: 640 x 480
#define DISPLAY_HVGA 0x00000002 //resolution: 640 x 240
#define DISPLAY_VGA2CIF 0x00000003 //resolution: 320 x 240
// 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 PPU_QVGA 0x00000000
#define PPU_VGA 0x00000001
#define PPU_HVGA 0x00000002
#define PPU_VGA2CIF 0x00000003
#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(U32 nTextLayer, U32 nXSize, U32 nYSize, U32 nColorMode, U32 nBank, U32 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);
//PPU_Effect
extern U16 nHMovementCnt;
void PPU_SetTxBlendLevel(U8 nText, U8 nBlendLevel);
U8 PPU_GetTxBlendLevel(U8 nText);
void PPU_EnableTxBlend(bool bText1, bool bText2, bool bText3);
void PPU_TxHMovement(S16 nMode, S32 nStartScanline,S32 nEndScanline,S32 nCompValue,const S8 *pScanline,U16 nNumberData);
void PPU_EnTxHMovement(bool bText1, bool bText2, bool bText3);
void PPU_TxVCompress(U16 nCmpValue, S16 nCmpStep, U16 nCmpOffset);
void PPU_EnTxVCompress(bool bText1, bool bText2, bool bText3);
void PPU_TxHCompress(U8 nMode, U16 nStartLine, U16 nEndLine, U16 nSingleValue, U16 *pHCmpValueTbl);
void PPU_EnTxHCompress(bool bText1);
//PPU_Palette
extern bool g_bInitPaletteFlag;
/**
* PPU_SP_InitPalette - initialize sprite palette.
* @SPPalAddr: sprite palette data start address
*/
void PPU_SP_InitPalette(U32 *pSPPalAddr);
/**
* PPU_BG_InitPalette - initialize texture palette.
* @BGPalAddr: texture palette data start address
*/
void PPU_BG_InitPalette(U32 *pBGPalAddr);
void FadeOut(void);
void FadeIn(void);
void PPU_SP_SetPalette(U16 col_st, U16 number, U32 *pSPPalAddr);
#endif //_PPU_CONTROL_H
?? 快捷鍵說明
復制代碼
Ctrl + C
搜索代碼
Ctrl + F
全屏模式
F11
切換主題
Ctrl + Shift + D
顯示快捷鍵
?
增大字號
Ctrl + =
減小字號
Ctrl + -